Merge branch 'RED-10353-4.2' into 'release/4.348.x'
RED-10353: Increase rules timeout, added different error message and error... See merge request redactmanager/redaction-service!549
This commit is contained in:
commit
5ef3699648
@ -4,7 +4,7 @@ plugins {
|
||||
}
|
||||
|
||||
description = "redaction-service-api-v1"
|
||||
val persistenceServiceVersion = "2.465.79"
|
||||
val persistenceServiceVersion = "2.465.83"
|
||||
|
||||
dependencies {
|
||||
implementation("org.springframework:spring-web:6.0.12")
|
||||
|
||||
@ -16,7 +16,7 @@ val layoutParserVersion = "0.142.6"
|
||||
val jacksonVersion = "2.15.2"
|
||||
val droolsVersion = "9.44.0.Final"
|
||||
val pdfBoxVersion = "3.0.0"
|
||||
val persistenceServiceVersion = "2.465.79"
|
||||
val persistenceServiceVersion = "2.465.83"
|
||||
val springBootStarterVersion = "3.1.5"
|
||||
val springCloudVersion = "4.0.4"
|
||||
val testContainersVersion = "1.19.7"
|
||||
|
||||
@ -28,7 +28,7 @@ public class RedactionServiceSettings {
|
||||
|
||||
private int dictionaryCacheExpireAfterAccessDays = 3;
|
||||
|
||||
private int droolsExecutionTimeoutSecs = 300;
|
||||
private int droolsExecutionTimeoutSecs = 600;
|
||||
|
||||
private boolean ruleExecutionSecured = true;
|
||||
|
||||
|
||||
@ -20,6 +20,7 @@ import org.springframework.stereotype.Service;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.AnalyzeRequest;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.AnalyzeResult;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.file.ErrorCode;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.file.FileErrorInfo;
|
||||
import com.iqser.red.service.redaction.v1.server.client.FileStatusProcessingUpdateClient;
|
||||
import com.iqser.red.service.redaction.v1.server.client.RulesClient;
|
||||
@ -140,10 +141,19 @@ public class RedactionMessageReceiver {
|
||||
private void sendAnalysisFailed(AnalyzeRequest analyzeRequest, boolean priority, Exception e) {
|
||||
|
||||
log.error("Failed to process analyze request: {}", analyzeRequest, e);
|
||||
var timestamp = OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS);
|
||||
ErrorCode errorCode = null;
|
||||
|
||||
if(e instanceof DroolsTimeoutException dre){
|
||||
if (!dre.isReported()){
|
||||
errorCode = ErrorCode.RULES_EXECUTION_TIMEOUT;
|
||||
} else {
|
||||
errorCode = ErrorCode.LOCKED_RULES;
|
||||
}
|
||||
}
|
||||
|
||||
fileStatusProcessingUpdateClient.analysisFailed(analyzeRequest.getDossierId(),
|
||||
analyzeRequest.getFileId(),
|
||||
new FileErrorInfo(e.getMessage(), priority ? REDACTION_PRIORITY_QUEUE : REDACTION_QUEUE, "redaction-service", timestamp));
|
||||
new FileErrorInfo(e.getMessage(), priority ? REDACTION_PRIORITY_QUEUE : REDACTION_QUEUE, "redaction-service", errorCode));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -155,7 +155,7 @@ public class AnalyzeService {
|
||||
log.info("Finished Dictionary Search for file {} in dossier {}", analyzeRequest.getFileId(), analyzeRequest.getDossierId());
|
||||
|
||||
// we could add the imported redactions similar to the manual redactions here as well for additional processing
|
||||
List<FileAttribute> allFileAttributes = entityDroolsExecutionService.executeRules(kieWrapperEntityRules.container(),
|
||||
List<FileAttribute> allFileAttributes = entityDroolsExecutionService.executeRules(analyzeRequest.getFileId(), kieWrapperEntityRules.container(),
|
||||
document,
|
||||
sectionsToReAnalyse,
|
||||
dictionary,
|
||||
@ -221,7 +221,7 @@ public class AnalyzeService {
|
||||
log.info("Finished Dictionary Search for file {} in dossier {}", analyzeRequest.getFileId(), analyzeRequest.getDossierId());
|
||||
|
||||
// we could add the imported redactions similar to the manual redactions here as well for additional processing
|
||||
List<FileAttribute> allFileAttributes = entityDroolsExecutionService.executeRules(kieWrapperEntityRules.container(),
|
||||
List<FileAttribute> allFileAttributes = entityDroolsExecutionService.executeRules(analyzeRequest.getFileId(), kieWrapperEntityRules.container(),
|
||||
document,
|
||||
dictionary,
|
||||
analyzeRequest.getFileAttributes(),
|
||||
@ -350,7 +350,7 @@ public class AnalyzeService {
|
||||
// We need the latest EntityLog entries for components rules execution
|
||||
entityLog.setEntityLogEntry(redactionStorageService.getEntityLog(analyzeRequest.getDossierId(), analyzeRequest.getFileId()).getEntityLogEntry());
|
||||
|
||||
List<Component> components = componentDroolsExecutionService.executeRules(kieWrapperComponentRules.container(),
|
||||
List<Component> components = componentDroolsExecutionService.executeRules(analyzeRequest.getFileId(), kieWrapperComponentRules.container(),
|
||||
entityLog,
|
||||
document,
|
||||
addedFileAttributes,
|
||||
|
||||
@ -49,7 +49,7 @@ public class ComponentDroolsExecutionService {
|
||||
ComponentMappingMemoryCache componentMappingMemoryCache;
|
||||
|
||||
|
||||
public List<Component> executeRules(KieContainer kieContainer,
|
||||
public List<Component> executeRules(String fileId, KieContainer kieContainer,
|
||||
EntityLog entityLog,
|
||||
Document document,
|
||||
Set<FileAttribute> fileAttributes,
|
||||
@ -99,14 +99,14 @@ public class ComponentDroolsExecutionService {
|
||||
} catch (ExecutionException e) {
|
||||
kieSession.dispose();
|
||||
if (e.getCause() instanceof TimeoutException) {
|
||||
throw new DroolsTimeoutException(e, false, RuleFileType.COMPONENT);
|
||||
throw new DroolsTimeoutException(String.format("The file %s caused a timeout", fileId), e, false, RuleFileType.COMPONENT);
|
||||
}
|
||||
throw new RuntimeException(e);
|
||||
} catch (InterruptedException e) {
|
||||
kieSession.dispose();
|
||||
throw new RuntimeException(e);
|
||||
} catch (TimeoutException e) {
|
||||
throw new DroolsTimeoutException(e, false, RuleFileType.COMPONENT);
|
||||
throw new DroolsTimeoutException(String.format("The file %s caused a timeout", fileId), e, false, RuleFileType.COMPONENT);
|
||||
}
|
||||
|
||||
List<FileAttribute> resultingFileAttributes = getFileAttributes(kieSession);
|
||||
|
||||
@ -52,14 +52,14 @@ public class EntityDroolsExecutionService {
|
||||
|
||||
@Timed("redactmanager_executeRules")
|
||||
@Observed(name = "EntityDroolsExecutionService", contextualName = "execute-entity-rules")
|
||||
public List<FileAttribute> executeRules(KieContainer kieContainer,
|
||||
public List<FileAttribute> executeRules(String fileId, KieContainer kieContainer,
|
||||
Document document,
|
||||
Dictionary dictionary,
|
||||
List<FileAttribute> fileAttributes,
|
||||
ManualRedactions manualRedactions,
|
||||
NerEntities nerEntities) {
|
||||
|
||||
return executeRules(kieContainer,
|
||||
return executeRules(fileId, kieContainer,
|
||||
document,
|
||||
document.streamChildren()
|
||||
.toList(),
|
||||
@ -72,7 +72,7 @@ public class EntityDroolsExecutionService {
|
||||
|
||||
@Timed("redactmanager_executeRules")
|
||||
@Observed(name = "EntityDroolsExecutionService", contextualName = "execute-entity-rules")
|
||||
public List<FileAttribute> executeRules(KieContainer kieContainer,
|
||||
public List<FileAttribute> executeRules(String fileId, KieContainer kieContainer,
|
||||
Document document,
|
||||
List<SemanticNode> sectionsToAnalyze,
|
||||
Dictionary dictionary,
|
||||
@ -133,14 +133,14 @@ public class EntityDroolsExecutionService {
|
||||
} catch (ExecutionException e) {
|
||||
kieSession.dispose();
|
||||
if (e.getCause() instanceof TimeoutException) {
|
||||
throw new DroolsTimeoutException(e, false, RuleFileType.ENTITY);
|
||||
throw new DroolsTimeoutException(String.format("The file %s caused a timeout",fileId), e, false, RuleFileType.ENTITY);
|
||||
}
|
||||
throw new RuntimeException(e);
|
||||
} catch (InterruptedException e) {
|
||||
kieSession.dispose();
|
||||
throw new RuntimeException(e);
|
||||
} catch (TimeoutException e) {
|
||||
throw new DroolsTimeoutException(e, false, RuleFileType.ENTITY);
|
||||
throw new DroolsTimeoutException(String.format("The file %s caused a timeout",fileId), e, false, RuleFileType.ENTITY);
|
||||
}
|
||||
|
||||
List<FileAttribute> resultingFileAttributes = getFileAttributes(kieSession);
|
||||
|
||||
@ -22,6 +22,15 @@ public class DroolsTimeoutException extends RuntimeException {
|
||||
}
|
||||
|
||||
|
||||
public DroolsTimeoutException(String message, Throwable cause, boolean reported, RuleFileType ruleFileType) {
|
||||
|
||||
super(message, cause);
|
||||
this.reported = reported;
|
||||
this.ruleFileType = ruleFileType;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public DroolsTimeoutException(boolean reported, RuleFileType ruleFileType) {
|
||||
|
||||
super(DROOLS_TIMEOUT_MESSAGE);
|
||||
|
||||
@ -154,7 +154,7 @@ public class DocumentPerformanceIntegrationTest extends BuildDocumentIntegration
|
||||
System.out.printf("Inserting entities into the graph took %d ms\n", System.currentTimeMillis() - graphInsertionStart);
|
||||
|
||||
long droolsStart = System.currentTimeMillis();
|
||||
List<FileAttribute> fileAttributes = entityDroolsExecutionService.executeRules(kieContainer,
|
||||
List<FileAttribute> fileAttributes = entityDroolsExecutionService.executeRules(TEST_FILE_ID, kieContainer,
|
||||
document,
|
||||
dictionary,
|
||||
Collections.emptyList(),
|
||||
|
||||
@ -1 +1 @@
|
||||
Subproject commit 5705cc0782605fdca5dfff134b436f7143c9e421
|
||||
Subproject commit 57e6e0dd3c08a3a65ec59b5dfb70f0f77ebcc7c7
|
||||
Loading…
x
Reference in New Issue
Block a user