Search in sources :

Example 1 with ManagementServiceImpl

use of org.camunda.bpm.engine.impl.ManagementServiceImpl in project camunda-bpm-platform by camunda.

the class PurgeDatabaseTest method testPurgeDatabase.

@Test
public void testPurgeDatabase() {
    Assert.assertNotNull(processEngine);
    VariableMap variableMap = Variables.putValue("var", "value");
    runtimeService.startProcessInstanceByKey("testDeployProcessArchive", variableMap);
    runtimeService.startProcessInstanceByKey("testDeployProcessArchive", variableMap);
    ManagementServiceImpl managementServiceImpl = (ManagementServiceImpl) managementService;
    managementServiceImpl.purge();
    assertAndEnsureCleanDb(processEngine);
}
Also used : ManagementServiceImpl(org.camunda.bpm.engine.impl.ManagementServiceImpl) VariableMap(org.camunda.bpm.engine.variable.VariableMap) Test(org.junit.Test) AbstractFoxPlatformIntegrationTest(org.camunda.bpm.integrationtest.util.AbstractFoxPlatformIntegrationTest)

Example 2 with ManagementServiceImpl

use of org.camunda.bpm.engine.impl.ManagementServiceImpl in project camunda-bpm-platform by camunda.

the class EnsureCleanDbPlugin method postProcessApplicationUndeploy.

@SuppressWarnings("resource")
@Override
public void postProcessApplicationUndeploy(ProcessApplicationInterface processApplication) {
    // best example is TestWarDeploymentWithBrokenBpmnXml in integration-test-engine test suite
    if (counter.get() == 0 || counter.decrementAndGet() == 0) {
        final ProcessEngine defaultProcessEngine = BpmPlatform.getDefaultProcessEngine();
        try {
            logger.log(Level.INFO, "=== Ensure Clean Database ===");
            ManagementServiceImpl managementService = (ManagementServiceImpl) defaultProcessEngine.getManagementService();
            PurgeReport report = managementService.purge();
            if (report.isEmpty()) {
                logger.log(Level.INFO, "Clean DB and cache.");
            } else {
                StringBuilder builder = new StringBuilder();
                DatabasePurgeReport databasePurgeReport = report.getDatabasePurgeReport();
                if (!databasePurgeReport.isEmpty()) {
                    builder.append(DATABASE_NOT_CLEAN).append(databasePurgeReport.getPurgeReportAsString());
                }
                CachePurgeReport cachePurgeReport = report.getCachePurgeReport();
                if (!cachePurgeReport.isEmpty()) {
                    builder.append(CACHE_IS_NOT_CLEAN).append(cachePurgeReport.getPurgeReportAsString());
                }
                logger.log(Level.INFO, builder.toString());
            }
        } catch (Throwable e) {
            logger.log(Level.SEVERE, "Could not clean DB:", e);
        }
    }
}
Also used : ManagementServiceImpl(org.camunda.bpm.engine.impl.ManagementServiceImpl) DatabasePurgeReport(org.camunda.bpm.engine.impl.management.DatabasePurgeReport) CachePurgeReport(org.camunda.bpm.engine.impl.persistence.deploy.cache.CachePurgeReport) CachePurgeReport(org.camunda.bpm.engine.impl.persistence.deploy.cache.CachePurgeReport) DatabasePurgeReport(org.camunda.bpm.engine.impl.management.DatabasePurgeReport) PurgeReport(org.camunda.bpm.engine.impl.management.PurgeReport) ProcessEngine(org.camunda.bpm.engine.ProcessEngine)

Example 3 with ManagementServiceImpl

use of org.camunda.bpm.engine.impl.ManagementServiceImpl in project camunda-bpm-platform by camunda.

the class PurgeDatabaseTest method testPurgeCmmnProcess.

// CMMN //////////////////////////////////////////////////////////////////////////////////////////////////////////////
@Test
public void testPurgeCmmnProcess() {
    // given cmmn process which is not managed by process engine rule
    engineRule.getRepositoryService().createDeployment().addClasspathResource("org/camunda/bpm/engine/test/standalone/db/entitymanager/PurgeDatabaseTest.testPurgeCmmnProcess.cmmn").deploy();
    VariableMap variables = Variables.createVariables();
    variables.put("key", "value");
    engineRule.getCaseService().createCaseInstanceByKey(PROCESS_DEF_KEY, variables);
    // when purge is executed
    ManagementServiceImpl managementService = (ManagementServiceImpl) engineRule.getManagementService();
    PurgeReport purge = managementService.purge();
    // then database and cache is cleaned
    assertAndEnsureCleanDbAndCache(engineRule.getProcessEngine(), true);
    // and report contains deleted entities
    assertFalse(purge.isEmpty());
    CachePurgeReport cachePurgeReport = purge.getCachePurgeReport();
    assertEquals(1, cachePurgeReport.getReportValue(CachePurgeReport.CASE_DEF_CACHE).size());
    DatabasePurgeReport databasePurgeReport = purge.getDatabasePurgeReport();
    assertEquals(1, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_RE_DEPLOYMENT"));
    assertEquals(1, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_RU_TASK"));
    assertEquals(1, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_GE_BYTEARRAY"));
    assertEquals(1, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_RE_CASE_DEF"));
    assertEquals(3, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_RU_CASE_EXECUTION"));
    assertEquals(1, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_RU_VARIABLE"));
    assertEquals(2, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_RU_CASE_SENTRY_PART"));
    if (processEngineConfiguration.getHistoryLevel().equals(HistoryLevel.HISTORY_LEVEL_FULL)) {
        assertEquals(1, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_HI_DETAIL"));
        assertEquals(1, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_HI_TASKINST"));
        assertEquals(1, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_HI_VARINST"));
        assertEquals(1, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_HI_CASEINST"));
        assertEquals(2, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_HI_CASEACTINST"));
    }
}
Also used : ManagementServiceImpl(org.camunda.bpm.engine.impl.ManagementServiceImpl) VariableMap(org.camunda.bpm.engine.variable.VariableMap) DatabasePurgeReport(org.camunda.bpm.engine.impl.management.DatabasePurgeReport) CachePurgeReport(org.camunda.bpm.engine.impl.persistence.deploy.cache.CachePurgeReport) PurgeReport(org.camunda.bpm.engine.impl.management.PurgeReport) CachePurgeReport(org.camunda.bpm.engine.impl.persistence.deploy.cache.CachePurgeReport) DatabasePurgeReport(org.camunda.bpm.engine.impl.management.DatabasePurgeReport) Test(org.junit.Test)

Example 4 with ManagementServiceImpl

use of org.camunda.bpm.engine.impl.ManagementServiceImpl in project camunda-bpm-platform by camunda.

the class PurgeDatabaseTest method testPurge.

@Test
public void testPurge() {
    // given data
    BpmnModelInstance test = Bpmn.createExecutableProcess(PROCESS_DEF_KEY).startEvent().endEvent().done();
    engineRule.getRepositoryService().createDeployment().addModelInstance(PROCESS_MODEL_NAME, test).deploy();
    engineRule.getRuntimeService().startProcessInstanceByKey(PROCESS_DEF_KEY);
    // when purge is executed
    ManagementServiceImpl managementService = (ManagementServiceImpl) engineRule.getManagementService();
    managementService.purge();
    // then no more data exist
    assertAndEnsureCleanDbAndCache(engineRule.getProcessEngine(), true);
}
Also used : ManagementServiceImpl(org.camunda.bpm.engine.impl.ManagementServiceImpl) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) Test(org.junit.Test)

Example 5 with ManagementServiceImpl

use of org.camunda.bpm.engine.impl.ManagementServiceImpl in project camunda-bpm-platform by camunda.

the class PurgeDatabaseTest method testPurgeDmnProcess.

// DMN ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
@Test
public void testPurgeDmnProcess() {
    // given dmn process which is not managed by process engine rule
    engineRule.getRepositoryService().createDeployment().addClasspathResource("org/camunda/bpm/engine/test/standalone/db/entitymanager/PurgeDatabaseTest.testPurgeDmnProcess.dmn").deploy();
    VariableMap variables = Variables.createVariables().putValue("key", "value").putValue("season", "Test");
    engineRule.getDecisionService().evaluateDecisionByKey("decisionId").variables(variables).evaluate();
    // when purge is executed
    ManagementServiceImpl managementService = (ManagementServiceImpl) engineRule.getManagementService();
    PurgeReport purge = managementService.purge();
    // then database and cache is cleaned
    assertAndEnsureCleanDbAndCache(engineRule.getProcessEngine(), true);
    // and report contains deleted entities
    assertFalse(purge.isEmpty());
    CachePurgeReport cachePurgeReport = purge.getCachePurgeReport();
    assertEquals(2, cachePurgeReport.getReportValue(CachePurgeReport.DMN_DEF_CACHE).size());
    assertEquals(1, cachePurgeReport.getReportValue(CachePurgeReport.DMN_REQ_DEF_CACHE).size());
    DatabasePurgeReport databasePurgeReport = purge.getDatabasePurgeReport();
    assertEquals(1, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_RE_DEPLOYMENT"));
    assertEquals(1, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_GE_BYTEARRAY"));
    assertEquals(1, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_RE_DECISION_REQ_DEF"));
    assertEquals(2, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_RE_DECISION_DEF"));
    if (processEngineConfiguration.getHistoryLevel().equals(HistoryLevel.HISTORY_LEVEL_FULL)) {
        assertEquals(1, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_HI_DECINST"));
        assertEquals(1, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_HI_DEC_IN"));
        assertEquals(1, (long) databasePurgeReport.getReportValue(databaseTablePrefix + "ACT_HI_DEC_OUT"));
    }
}
Also used : ManagementServiceImpl(org.camunda.bpm.engine.impl.ManagementServiceImpl) VariableMap(org.camunda.bpm.engine.variable.VariableMap) DatabasePurgeReport(org.camunda.bpm.engine.impl.management.DatabasePurgeReport) CachePurgeReport(org.camunda.bpm.engine.impl.persistence.deploy.cache.CachePurgeReport) PurgeReport(org.camunda.bpm.engine.impl.management.PurgeReport) CachePurgeReport(org.camunda.bpm.engine.impl.persistence.deploy.cache.CachePurgeReport) DatabasePurgeReport(org.camunda.bpm.engine.impl.management.DatabasePurgeReport) Test(org.junit.Test)

Aggregations

ManagementServiceImpl (org.camunda.bpm.engine.impl.ManagementServiceImpl)9 Test (org.junit.Test)7 DatabasePurgeReport (org.camunda.bpm.engine.impl.management.DatabasePurgeReport)5 PurgeReport (org.camunda.bpm.engine.impl.management.PurgeReport)5 CachePurgeReport (org.camunda.bpm.engine.impl.persistence.deploy.cache.CachePurgeReport)5 VariableMap (org.camunda.bpm.engine.variable.VariableMap)5 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)4 LockedExternalTask (org.camunda.bpm.engine.externaltask.LockedExternalTask)2 Task (org.camunda.bpm.engine.task.Task)2 ProcessEngine (org.camunda.bpm.engine.ProcessEngine)1 ProcessEngineImpl (org.camunda.bpm.engine.impl.ProcessEngineImpl)1 ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)1 Job (org.camunda.bpm.engine.runtime.Job)1 AbstractFoxPlatformIntegrationTest (org.camunda.bpm.integrationtest.util.AbstractFoxPlatformIntegrationTest)1