Search in sources :

Example 6 with StandaloneProcessEngineConfiguration

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

the class SequentialJobAcquisitionTest method testExecuteJobsForTwoEnginesSameAcquisition.

@Test
public void testExecuteJobsForTwoEnginesSameAcquisition() {
    // configure and build a process engine
    StandaloneProcessEngineConfiguration engineConfiguration1 = new StandaloneInMemProcessEngineConfiguration();
    engineConfiguration1.setProcessEngineName(getClass().getName() + "-engine1");
    engineConfiguration1.setJdbcUrl("jdbc:h2:mem:activiti1");
    engineConfiguration1.setJobExecutorActivate(false);
    engineConfiguration1.setJobExecutor(jobExecutor);
    engineConfiguration1.setDbMetricsReporterActivate(false);
    ProcessEngine engine1 = engineConfiguration1.buildProcessEngine();
    createdProcessEngines.add(engine1);
    // and a second one
    StandaloneProcessEngineConfiguration engineConfiguration2 = new StandaloneInMemProcessEngineConfiguration();
    engineConfiguration2.setProcessEngineName(getClass().getName() + "engine2");
    engineConfiguration2.setJdbcUrl("jdbc:h2:mem:activiti2");
    engineConfiguration2.setJobExecutorActivate(false);
    engineConfiguration2.setJobExecutor(jobExecutor);
    engineConfiguration2.setDbMetricsReporterActivate(false);
    ProcessEngine engine2 = engineConfiguration2.buildProcessEngine();
    createdProcessEngines.add(engine2);
    // stop the acquisition
    jobExecutor.shutdown();
    // deploy the processes
    engine1.getRepositoryService().createDeployment().addClasspathResource(PROCESS_RESOURCE).deploy();
    engine2.getRepositoryService().createDeployment().addClasspathResource(PROCESS_RESOURCE).deploy();
    // start one instance for each engine:
    engine1.getRuntimeService().startProcessInstanceByKey("intermediateTimerEventExample");
    engine2.getRuntimeService().startProcessInstanceByKey("intermediateTimerEventExample");
    Assert.assertEquals(1, engine1.getManagementService().createJobQuery().count());
    Assert.assertEquals(1, engine2.getManagementService().createJobQuery().count());
    Calendar calendar = Calendar.getInstance();
    calendar.add(Field.DAY_OF_YEAR.getCalendarField(), 6);
    ClockUtil.setCurrentTime(calendar.getTime());
    jobExecutor.start();
    // assert task completed for the first engine
    waitForJobExecutorToProcessAllJobs(10000, 100, jobExecutor, engine1.getManagementService(), true);
    jobExecutor.start();
    // assert task completed for the second engine
    waitForJobExecutorToProcessAllJobs(10000, 100, jobExecutor, engine2.getManagementService(), true);
    Assert.assertEquals(0, engine1.getManagementService().createJobQuery().count());
    Assert.assertEquals(0, engine2.getManagementService().createJobQuery().count());
}
Also used : StandaloneProcessEngineConfiguration(org.camunda.bpm.engine.impl.cfg.StandaloneProcessEngineConfiguration) Calendar(java.util.Calendar) StandaloneInMemProcessEngineConfiguration(org.camunda.bpm.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration) ProcessEngine(org.camunda.bpm.engine.ProcessEngine) Test(org.junit.Test)

Example 7 with StandaloneProcessEngineConfiguration

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

the class SequentialJobAcquisitionTest method testJobAddedGuardForTwoEnginesSameAcquisition.

@Test
public void testJobAddedGuardForTwoEnginesSameAcquisition() throws InterruptedException {
    // configure and build a process engine
    StandaloneProcessEngineConfiguration engineConfiguration1 = new StandaloneInMemProcessEngineConfiguration();
    engineConfiguration1.setProcessEngineName(getClass().getName() + "-engine1");
    engineConfiguration1.setJdbcUrl("jdbc:h2:mem:activiti1");
    engineConfiguration1.setJobExecutorActivate(false);
    engineConfiguration1.setJobExecutor(jobExecutor);
    engineConfiguration1.setDbMetricsReporterActivate(false);
    ProcessEngine engine1 = engineConfiguration1.buildProcessEngine();
    createdProcessEngines.add(engine1);
    // and a second one
    StandaloneProcessEngineConfiguration engineConfiguration2 = new StandaloneInMemProcessEngineConfiguration();
    engineConfiguration2.setProcessEngineName(getClass().getName() + "engine2");
    engineConfiguration2.setJdbcUrl("jdbc:h2:mem:activiti2");
    engineConfiguration2.setJobExecutorActivate(false);
    engineConfiguration2.setJobExecutor(jobExecutor);
    engineConfiguration2.setDbMetricsReporterActivate(false);
    ProcessEngine engine2 = engineConfiguration2.buildProcessEngine();
    createdProcessEngines.add(engine2);
    // stop the acquisition
    jobExecutor.shutdown();
    // deploy the processes
    engine1.getRepositoryService().createDeployment().addClasspathResource(PROCESS_RESOURCE).deploy();
    engine2.getRepositoryService().createDeployment().addClasspathResource(PROCESS_RESOURCE).deploy();
    // start one instance for each engine:
    engine1.getRuntimeService().startProcessInstanceByKey("intermediateTimerEventExample");
    engine2.getRuntimeService().startProcessInstanceByKey("intermediateTimerEventExample");
    Calendar calendar = Calendar.getInstance();
    calendar.add(Field.DAY_OF_YEAR.getCalendarField(), 6);
    ClockUtil.setCurrentTime(calendar.getTime());
    Assert.assertEquals(1, engine1.getManagementService().createJobQuery().count());
    Assert.assertEquals(1, engine2.getManagementService().createJobQuery().count());
    // assert task completed for the first engine
    jobExecutor.start();
    waitForJobExecutorToProcessAllJobs(10000, 100, jobExecutor, engine1.getManagementService(), false);
    // assert task completed for the second engine
    jobExecutor.start();
    waitForJobExecutorToProcessAllJobs(10000, 100, jobExecutor, engine2.getManagementService(), false);
    Thread.sleep(2000);
    Assert.assertFalse(((SequentialJobAcquisitionRunnable) jobExecutor.getAcquireJobsRunnable()).isJobAdded());
    Assert.assertEquals(0, engine1.getManagementService().createJobQuery().count());
    Assert.assertEquals(0, engine2.getManagementService().createJobQuery().count());
}
Also used : StandaloneProcessEngineConfiguration(org.camunda.bpm.engine.impl.cfg.StandaloneProcessEngineConfiguration) Calendar(java.util.Calendar) StandaloneInMemProcessEngineConfiguration(org.camunda.bpm.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration) ProcessEngine(org.camunda.bpm.engine.ProcessEngine) Test(org.junit.Test)

Example 8 with StandaloneProcessEngineConfiguration

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

the class SequentialJobAcquisitionTest method testExecuteJobsForSingleEngine.

@Test
public void testExecuteJobsForSingleEngine() {
    // configure and build a process engine
    StandaloneProcessEngineConfiguration standaloneProcessEngineConfiguration = new StandaloneInMemProcessEngineConfiguration();
    standaloneProcessEngineConfiguration.setProcessEngineName(getClass().getName() + "-engine1");
    standaloneProcessEngineConfiguration.setJdbcUrl("jdbc:h2:mem:jobexecutor-test-engine");
    standaloneProcessEngineConfiguration.setJobExecutorActivate(false);
    standaloneProcessEngineConfiguration.setJobExecutor(jobExecutor);
    standaloneProcessEngineConfiguration.setDbMetricsReporterActivate(false);
    ProcessEngine engine = standaloneProcessEngineConfiguration.buildProcessEngine();
    createdProcessEngines.add(engine);
    engine.getRepositoryService().createDeployment().addClasspathResource(PROCESS_RESOURCE).deploy();
    jobExecutor.shutdown();
    engine.getRuntimeService().startProcessInstanceByKey("intermediateTimerEventExample");
    Assert.assertEquals(1, engine.getManagementService().createJobQuery().count());
    Calendar calendar = Calendar.getInstance();
    calendar.add(Field.DAY_OF_YEAR.getCalendarField(), 6);
    ClockUtil.setCurrentTime(calendar.getTime());
    jobExecutor.start();
    waitForJobExecutorToProcessAllJobs(10000, 100, jobExecutor, engine.getManagementService(), true);
    Assert.assertEquals(0, engine.getManagementService().createJobQuery().count());
}
Also used : StandaloneProcessEngineConfiguration(org.camunda.bpm.engine.impl.cfg.StandaloneProcessEngineConfiguration) Calendar(java.util.Calendar) StandaloneInMemProcessEngineConfiguration(org.camunda.bpm.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration) ProcessEngine(org.camunda.bpm.engine.ProcessEngine) Test(org.junit.Test)

Example 9 with StandaloneProcessEngineConfiguration

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

the class PerfTestProcessEngine method createProcessEngine.

protected static ProcessEngine createProcessEngine(javax.sql.DataSource datasource, Properties properties) {
    ProcessEngineConfigurationImpl processEngineConfiguration = new StandaloneProcessEngineConfiguration();
    processEngineConfiguration.setDataSource(datasource);
    processEngineConfiguration.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE);
    processEngineConfiguration.setHistory(properties.getProperty("historyLevel"));
    processEngineConfiguration.setJdbcBatchProcessing(Boolean.valueOf(properties.getProperty("jdbcBatchProcessing")));
    // load plugins
    String processEnginePlugins = properties.getProperty("processEnginePlugins", "");
    for (String pluginName : processEnginePlugins.split(",")) {
        if (pluginName.length() > 1) {
            Object pluginInstance = ReflectUtil.instantiate(pluginName);
            if (!(pluginInstance instanceof ProcessEnginePlugin)) {
                throw new PerfTestException("Plugin " + pluginName + " is not an instance of ProcessEnginePlugin");
            } else {
                List<ProcessEnginePlugin> plugins = processEngineConfiguration.getProcessEnginePlugins();
                if (plugins == null) {
                    plugins = new ArrayList<ProcessEnginePlugin>();
                    processEngineConfiguration.setProcessEnginePlugins(plugins);
                }
                plugins.add((ProcessEnginePlugin) pluginInstance);
            }
        }
    }
    return processEngineConfiguration.buildProcessEngine();
}
Also used : StandaloneProcessEngineConfiguration(org.camunda.bpm.engine.impl.cfg.StandaloneProcessEngineConfiguration) PerfTestException(org.camunda.bpm.qa.performance.engine.framework.PerfTestException) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl) ProcessEnginePlugin(org.camunda.bpm.engine.impl.cfg.ProcessEnginePlugin)

Aggregations

StandaloneProcessEngineConfiguration (org.camunda.bpm.engine.impl.cfg.StandaloneProcessEngineConfiguration)9 ProcessEngine (org.camunda.bpm.engine.ProcessEngine)5 StandaloneInMemProcessEngineConfiguration (org.camunda.bpm.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration)4 Test (org.junit.Test)4 Calendar (java.util.Calendar)3 HashMap (java.util.HashMap)3 ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)3 ProcessEngineConfiguration (org.camunda.bpm.engine.ProcessEngineConfiguration)2 TaskService (org.camunda.bpm.engine.TaskService)2 Task (org.camunda.bpm.engine.task.Task)2 RepositoryService (org.camunda.bpm.engine.RepositoryService)1 RuntimeService (org.camunda.bpm.engine.RuntimeService)1 ProcessEnginePlugin (org.camunda.bpm.engine.impl.cfg.ProcessEnginePlugin)1 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)1 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)1 PerfTestException (org.camunda.bpm.qa.performance.engine.framework.PerfTestException)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1