use of org.camunda.bpm.engine.impl.jobexecutor.AcquiredJobs in project camunda-bpm-platform by camunda.
the class AcquireJobCmdUnitTest method checkThatAcquiredJobsInDifferentBatches.
protected void checkThatAcquiredJobsInDifferentBatches() {
AcquiredJobs acquiredJobs = acquireJobsCmd.execute(commandContext);
List<List<String>> jobIdBatches = acquiredJobs.getJobIdBatches();
assertThat(jobIdBatches.size(), is(2));
assertThat(jobIdBatches.get(0).size(), is(1));
assertThat(jobIdBatches.get(1).size(), is(1));
}
use of org.camunda.bpm.engine.impl.jobexecutor.AcquiredJobs in project camunda-bpm-platform by camunda.
the class DeploymentAwareJobExecutorTest method testExplicitDeploymentUnregistration.
@Deployment(resources = "org/camunda/bpm/engine/test/jobexecutor/simpleAsyncProcess.bpmn20.xml")
public void testExplicitDeploymentUnregistration() {
runtimeService.startProcessInstanceByKey("simpleAsyncProcess");
processEngine.getManagementService().unregisterDeploymentForJobExecutor(deploymentId);
AcquiredJobs acquiredJobs = getExecutableJobs(processEngineConfiguration.getJobExecutor());
Assert.assertEquals(0, acquiredJobs.size());
}
use of org.camunda.bpm.engine.impl.jobexecutor.AcquiredJobs in project camunda-bpm-platform by camunda.
the class DeploymentAwareJobExecutorTest method testProcessingOfJobsWithMatchingDeployment.
@Deployment(resources = "org/camunda/bpm/engine/test/jobexecutor/simpleAsyncProcess.bpmn20.xml")
public void testProcessingOfJobsWithMatchingDeployment() {
runtimeService.startProcessInstanceByKey("simpleAsyncProcess");
Set<String> registeredDeployments = managementService.getRegisteredDeployments();
Assert.assertEquals(1, registeredDeployments.size());
Assert.assertTrue(registeredDeployments.contains(deploymentId));
Job executableJob = managementService.createJobQuery().singleResult();
String otherDeploymentId = deployAndInstantiateWithNewEngineConfiguration("org/camunda/bpm/engine/test/jobexecutor/simpleAsyncProcessVersion2.bpmn20.xml");
// assert that two jobs have been created, one for each deployment
List<Job> jobs = managementService.createJobQuery().list();
Assert.assertEquals(2, jobs.size());
Set<String> jobDeploymentIds = new HashSet<String>();
jobDeploymentIds.add(jobs.get(0).getDeploymentId());
jobDeploymentIds.add(jobs.get(1).getDeploymentId());
Assert.assertTrue(jobDeploymentIds.contains(deploymentId));
Assert.assertTrue(jobDeploymentIds.contains(otherDeploymentId));
// select executable jobs for executor of first engine
AcquiredJobs acquiredJobs = getExecutableJobs(processEngineConfiguration.getJobExecutor());
Assert.assertEquals(1, acquiredJobs.size());
Assert.assertTrue(acquiredJobs.contains(executableJob.getId()));
repositoryService.deleteDeployment(otherDeploymentId, true);
}
use of org.camunda.bpm.engine.impl.jobexecutor.AcquiredJobs in project camunda-bpm-platform by camunda.
the class DeploymentAwareJobExecutorTest method testExplicitDeploymentRegistration.
@Deployment(resources = "org/camunda/bpm/engine/test/jobexecutor/simpleAsyncProcess.bpmn20.xml")
public void testExplicitDeploymentRegistration() {
runtimeService.startProcessInstanceByKey("simpleAsyncProcess");
String otherDeploymentId = deployAndInstantiateWithNewEngineConfiguration("org/camunda/bpm/engine/test/jobexecutor/simpleAsyncProcessVersion2.bpmn20.xml");
processEngine.getManagementService().registerDeploymentForJobExecutor(otherDeploymentId);
List<Job> jobs = managementService.createJobQuery().list();
AcquiredJobs acquiredJobs = getExecutableJobs(processEngineConfiguration.getJobExecutor());
Assert.assertEquals(2, acquiredJobs.size());
for (Job job : jobs) {
Assert.assertTrue(acquiredJobs.contains(job.getId()));
}
repositoryService.deleteDeployment(otherDeploymentId, true);
}
use of org.camunda.bpm.engine.impl.jobexecutor.AcquiredJobs in project camunda-bpm-platform by camunda.
the class BackoffJobAcquisitionStrategyTest method testAcquireLessJobsOnRejection.
@Test
public void testAcquireLessJobsOnRejection() {
// given a job acquisition strategy and a job acquisition context
// with acquired jobs, some of which have been rejected for execution
JobAcquisitionContext context = new JobAcquisitionContext();
AcquiredJobs acquiredJobs = buildAcquiredJobs(NUM_JOBS_TO_ACQUIRE, NUM_JOBS_TO_ACQUIRE, 0);
context.submitAcquiredJobs(ENGINE_NAME, acquiredJobs);
// when half of the jobs are rejected
int numJobsRejected = 5;
for (int i = 0; i < numJobsRejected; i++) {
context.submitRejectedBatch(ENGINE_NAME, acquiredJobs.getJobIdBatches().get(i));
}
// then the strategy only attempts to acquire the number of jobs that were successfully submitted
strategy.reconfigure(context);
Assert.assertEquals(NUM_JOBS_TO_ACQUIRE - numJobsRejected, strategy.getNumJobsToAcquire(ENGINE_NAME));
// without a timeout
Assert.assertEquals(0, strategy.getWaitTime());
}
Aggregations