summaryrefslogtreecommitdiffstats
path: root/bpmn/mso-infrastructure-bpmn
diff options
context:
space:
mode:
authorJozsef Csongvai <jozsef.csongvai@bell.ca>2021-09-15 16:08:06 -0400
committerJozsef Csongvai <jozsef.csongvai@bell.ca>2021-09-29 09:49:18 -0400
commit35078e2cade2baeef29f3965437582510befec26 (patch)
treee4d8661ab2376917e79713e5bca918075caf990c /bpmn/mso-infrastructure-bpmn
parentdc088aed68ac9aa4677590806d8fef34e35d0abf (diff)
Add history ttl to all bpmn's programatically
This enables camunda to set REMOVAL_TIME_ to entries written to the camundabpmn database, which can then be cleaned up after ttl has expired. Regular clean-up will improve database performance and prevent locking timeouts. Change-Id: I0803a0ebda9220daba7d505797c94ba47ade5921 Issue-ID: SO-3770 Signed-off-by: Jozsef Csongvai <jozsef.csongvai@bell.ca>
Diffstat (limited to 'bpmn/mso-infrastructure-bpmn')
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/MSOInfrastructureApplication.java24
1 files changed, 23 insertions, 1 deletions
diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/MSOInfrastructureApplication.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/MSOInfrastructureApplication.java
index 8d6e133a1c..24c9b0f85d 100644
--- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/MSOInfrastructureApplication.java
+++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/MSOInfrastructureApplication.java
@@ -28,7 +28,10 @@ import javax.annotation.PostConstruct;
import org.camunda.bpm.application.PreUndeploy;
import org.camunda.bpm.application.ProcessApplicationInfo;
import org.camunda.bpm.engine.ProcessEngine;
+import org.camunda.bpm.engine.RepositoryService;
+import org.camunda.bpm.engine.repository.Deployment;
import org.camunda.bpm.engine.repository.DeploymentBuilder;
+import org.camunda.bpm.engine.repository.ProcessDefinition;
import org.onap.logging.filter.spring.MDCTaskDecorator;
import org.onap.so.bpmn.common.DefaultToShortClassNameBeanNameGenerator;
import org.onap.so.db.catalog.beans.Workflow;
@@ -76,6 +79,9 @@ public class MSOInfrastructureApplication {
@Value("${mso.async.queue-capacity}")
private int queueCapacity;
+ @Value("${mso.bpmn-history-ttl:14}")
+ private Integer bpmnHistoryTtl;
+
private static final String LOGS_DIR = "logs_dir";
private static final String BPMN_SUFFIX = ".bpmn";
private static final String SDC_SOURCE = "sdc";
@@ -102,8 +108,10 @@ public class MSOInfrastructureApplication {
@PostConstruct
public void postConstruct() {
try {
- DeploymentBuilder deploymentBuilder = processEngine.getRepositoryService().createDeployment();
+ RepositoryService repositoryService = processEngine.getRepositoryService();
+ DeploymentBuilder deploymentBuilder = repositoryService.createDeployment();
deployCustomWorkflows(deploymentBuilder);
+ setBpmnTTL(repositoryService, bpmnHistoryTtl);
} catch (Exception e) {
logger.warn("Unable to invoke deploymentBuilder ", e);
}
@@ -149,4 +157,18 @@ public class MSOInfrastructureApplication {
logger.warn("Unable to deploy custom workflows ", e);
}
}
+
+ private void setBpmnTTL(RepositoryService repositoryService, Integer ttl) {
+ List<Deployment> deployments = repositoryService.createDeploymentQuery().list();
+ for (Deployment deployment : deployments) {
+ List<ProcessDefinition> processDefinitions =
+ repositoryService.createProcessDefinitionQuery().deploymentId(deployment.getId()).list();
+ for (ProcessDefinition processDefinition : processDefinitions) {
+ if (!ttl.equals(processDefinition.getHistoryTimeToLive())) {
+ logger.info("Setting ttl {} for processdefinition {}", ttl, processDefinition.getName());
+ repositoryService.updateProcessDefinitionHistoryTimeToLive(processDefinition.getId(), ttl);
+ }
+ }
+ }
+ }
}