Search in sources :

Example 11 with AcquiredJobs

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));
}
Also used : AcquiredJobs(org.camunda.bpm.engine.impl.jobexecutor.AcquiredJobs) List(java.util.List)

Example 12 with AcquiredJobs

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());
}
Also used : AcquiredJobs(org.camunda.bpm.engine.impl.jobexecutor.AcquiredJobs) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 13 with AcquiredJobs

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);
}
Also used : AcquiredJobs(org.camunda.bpm.engine.impl.jobexecutor.AcquiredJobs) Job(org.camunda.bpm.engine.runtime.Job) HashSet(java.util.HashSet) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 14 with AcquiredJobs

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);
}
Also used : AcquiredJobs(org.camunda.bpm.engine.impl.jobexecutor.AcquiredJobs) Job(org.camunda.bpm.engine.runtime.Job) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 15 with AcquiredJobs

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());
}
Also used : AcquiredJobs(org.camunda.bpm.engine.impl.jobexecutor.AcquiredJobs) JobAcquisitionContext(org.camunda.bpm.engine.impl.jobexecutor.JobAcquisitionContext) Test(org.junit.Test)

Aggregations

AcquiredJobs (org.camunda.bpm.engine.impl.jobexecutor.AcquiredJobs)17 Job (org.camunda.bpm.engine.runtime.Job)6 Test (org.junit.Test)6 CommandExecutor (org.camunda.bpm.engine.impl.interceptor.CommandExecutor)5 Deployment (org.camunda.bpm.engine.test.Deployment)5 List (java.util.List)4 AcquireJobsCmd (org.camunda.bpm.engine.impl.cmd.AcquireJobsCmd)4 JobExecutor (org.camunda.bpm.engine.impl.jobexecutor.JobExecutor)4 ArrayList (java.util.ArrayList)3 CommandContext (org.camunda.bpm.engine.impl.interceptor.CommandContext)3 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)3 Page (org.camunda.bpm.engine.impl.Page)2 JobAcquisitionContext (org.camunda.bpm.engine.impl.jobexecutor.JobAcquisitionContext)2 JobEntity (org.camunda.bpm.engine.impl.persistence.entity.JobEntity)2 MessageEntity (org.camunda.bpm.engine.impl.persistence.entity.MessageEntity)2 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)2 AbstractFoxPlatformIntegrationTest (org.camunda.bpm.integrationtest.util.AbstractFoxPlatformIntegrationTest)2 OperateOnDeployment (org.jboss.arquillian.container.test.api.OperateOnDeployment)2 Date (java.util.Date)1 HashSet (java.util.HashSet)1