Resolve RED-7384

This commit is contained in:
Kilian Schüttler 2024-04-24 11:50:13 +02:00 committed by Dominique Eifländer
parent b01288d85e
commit 8961abc4fe
7 changed files with 20 additions and 7 deletions

View File

@ -30,4 +30,10 @@ public class RedactionServiceSettings {
private int droolsExecutionTimeoutSecs = 300; private int droolsExecutionTimeoutSecs = 300;
public int getDroolsExecutionTimeoutSecs(int numberOfPages) {
return (int) Math.max(getDroolsExecutionTimeoutSecs(), getDroolsExecutionTimeoutSecs() * ((float) numberOfPages / 1000));
}
} }

View File

@ -17,7 +17,7 @@ public class MessageReceiver {
@RabbitHandler @RabbitHandler
@RabbitListener(queues = REDACTION_QUEUE) @RabbitListener(queues = REDACTION_QUEUE, concurrency = "1")
public void receiveAnalyzeRequest(Message message) { public void receiveAnalyzeRequest(Message message) {
redactionMessageReceiver.receiveAnalyzeRequest(message, false); redactionMessageReceiver.receiveAnalyzeRequest(message, false);

View File

@ -17,7 +17,7 @@ public class PriorityMessageReceiver {
@RabbitHandler @RabbitHandler
@RabbitListener(queues = REDACTION_PRIORITY_QUEUE) @RabbitListener(queues = REDACTION_PRIORITY_QUEUE, concurrency = "1")
public void receiveAnalyzeRequest(Message message) { public void receiveAnalyzeRequest(Message message) {
redactionMessageReceiver.receiveAnalyzeRequest(message, true); redactionMessageReceiver.receiveAnalyzeRequest(message, true);

View File

@ -50,7 +50,9 @@ public class ComponentDroolsExecutionService {
.filter(entityLogEntry -> entityLogEntry.getState().equals(EntryState.APPLIED)) .filter(entityLogEntry -> entityLogEntry.getState().equals(EntryState.APPLIED))
.map(entry -> Entity.fromEntityLogEntry(entry, document)) .map(entry -> Entity.fromEntityLogEntry(entry, document))
.forEach(kieSession::insert); .forEach(kieSession::insert);
fileAttributes.stream().filter(f -> f.getValue() != null).forEach(kieSession::insert); fileAttributes.stream()
.filter(f -> f.getValue() != null)
.forEach(kieSession::insert);
CompletableFuture<Void> completableFuture = CompletableFuture.supplyAsync(() -> { CompletableFuture<Void> completableFuture = CompletableFuture.supplyAsync(() -> {
kieSession.fireAllRules(); kieSession.fireAllRules();
@ -58,7 +60,8 @@ public class ComponentDroolsExecutionService {
}); });
try { try {
completableFuture.orTimeout(settings.getDroolsExecutionTimeoutSecs(), TimeUnit.SECONDS).get(); completableFuture.orTimeout(settings.getDroolsExecutionTimeoutSecs(document.getNumberOfPages()), TimeUnit.SECONDS)
.get();
} catch (ExecutionException e) { } catch (ExecutionException e) {
kieSession.dispose(); kieSession.dispose();
if (e.getCause() instanceof TimeoutException) { if (e.getCause() instanceof TimeoutException) {
@ -71,7 +74,9 @@ public class ComponentDroolsExecutionService {
} }
List<FileAttribute> resultingFileAttributes = getFileAttributes(kieSession); List<FileAttribute> resultingFileAttributes = getFileAttributes(kieSession);
List<Component> components = getComponents(kieSession).stream().sorted(ComponentComparator.first()).toList(); List<Component> components = getComponents(kieSession).stream()
.sorted(ComponentComparator.first())
.toList();
kieSession.dispose(); kieSession.dispose();
return components; return components;
} }

View File

@ -122,7 +122,7 @@ public class EntityDroolsExecutionService {
}); });
try { try {
completableFuture.orTimeout(settings.getDroolsExecutionTimeoutSecs(), TimeUnit.SECONDS) completableFuture.orTimeout(settings.getDroolsExecutionTimeoutSecs(document.getNumberOfPages()), TimeUnit.SECONDS)
.get(); .get();
} catch (ExecutionException e) { } catch (ExecutionException e) {
kieSession.dispose(); kieSession.dispose();

View File

@ -104,7 +104,7 @@ import lombok.extern.slf4j.Slf4j;
@SneakyThrows @SneakyThrows
public void runAnalysisEnd2End() { public void runAnalysisEnd2End() {
String folder = "files/end2end/file0"; // Should contain all files from minio directly, still zipped. Can contain multiple files. String folder = "files/end2end/file0"; // Should contain all files from minio directly, still zipped. Can contain multiple fileIds.
Path absoluteFolderPath; Path absoluteFolderPath;
if (folder.startsWith("files")) { // if it starts with "files" it is most likely in the resources folder, else it should be an absolute path if (folder.startsWith("files")) { // if it starts with "files" it is most likely in the resources folder, else it should be an absolute path

View File

@ -25,6 +25,8 @@ redaction-service:
application: application:
type: "RedactManager" type: "RedactManager"
logging.type: "CONSOLE"
storage: storage:
backend: 's3' backend: 's3'