congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
AcquiredJobs.getJobIdBatches
Code IndexAdd Tabnine to your IDE (free)

How to use
getJobIdBatches
method
in
org.camunda.bpm.engine.impl.jobexecutor.AcquiredJobs

Best Java code snippets using org.camunda.bpm.engine.impl.jobexecutor.AcquiredJobs.getJobIdBatches (Showing top 20 results out of 315)

origin: camunda/camunda-bpm-platform

/**
 * @return true, if for all engines there were less jobs acquired than requested
 */
public boolean areAllEnginesIdle() {
 for (AcquiredJobs acquiredJobs : acquiredJobsByEngine.values()) {
  int jobsAcquired = acquiredJobs.getJobIdBatches().size() + acquiredJobs.getNumberOfJobsFailedToLock();
  if (jobsAcquired >= acquiredJobs.getNumberOfJobsAttemptedToAcquire()) {
   return false;
  }
 }
 return true;
}
origin: camunda/camunda-bpm-platform

/**
 * @return true, if for all engines there were less jobs acquired than requested
 */
public boolean areAllEnginesIdle() {
 for (AcquiredJobs acquiredJobs : acquiredJobsByEngine.values()) {
  int jobsAcquired = acquiredJobs.getJobIdBatches().size() + acquiredJobs.getNumberOfJobsFailedToLock();
  if (jobsAcquired >= acquiredJobs.getNumberOfJobsAttemptedToAcquire()) {
   return false;
  }
 }
 return true;
}
origin: camunda/camunda-bpm-platform

public void acquiredJobs(String processEngine, AcquiredJobs acquiredJobs) {
 logDebug(
   "022",
   "Acquired {} jobs for process engine '{}': {}", acquiredJobs.size(), processEngine, acquiredJobs.getJobIdBatches());
}
origin: camunda/camunda-bpm-platform

public void acquiredJobs(String processEngine, AcquiredJobs acquiredJobs) {
 logDebug(
   "022",
   "Acquired {} jobs for process engine '{}': {}", acquiredJobs.size(), processEngine, acquiredJobs.getJobIdBatches());
}
origin: camunda/camunda-bpm-platform

/**
 * @return true, if all acquired jobs (spanning all engines) were rejected for execution
 */
protected boolean allSubmittedJobsRejected(JobAcquisitionContext context) {
 for (Map.Entry<String, AcquiredJobs> acquiredJobsForEngine : context.getAcquiredJobsByEngine().entrySet()) {
  String engineName = acquiredJobsForEngine.getKey();
  List<List<String>> acquiredJobBatches = acquiredJobsForEngine.getValue().getJobIdBatches();
  List<List<String>> resubmittedJobBatches = context.getAdditionalJobsByEngine().get(engineName);
  List<List<String>> rejectedJobBatches = context.getRejectedJobsByEngine().get(engineName);
  int numJobsSubmittedForExecution = acquiredJobBatches.size();
  if (resubmittedJobBatches != null) {
   numJobsSubmittedForExecution += resubmittedJobBatches.size();
  }
  int numJobsRejected = 0;
  if (rejectedJobBatches != null) {
   numJobsRejected += rejectedJobBatches.size();
  }
  // if not all jobs scheduled for execution have been rejected
  if (numJobsRejected == 0 || numJobsSubmittedForExecution > numJobsRejected) {
   return false;
  }
 }
 return true;
}
origin: camunda/camunda-bpm-platform

/**
 * @return true, if all acquired jobs (spanning all engines) were rejected for execution
 */
protected boolean allSubmittedJobsRejected(JobAcquisitionContext context) {
 for (Map.Entry<String, AcquiredJobs> acquiredJobsForEngine : context.getAcquiredJobsByEngine().entrySet()) {
  String engineName = acquiredJobsForEngine.getKey();
  List<List<String>> acquiredJobBatches = acquiredJobsForEngine.getValue().getJobIdBatches();
  List<List<String>> resubmittedJobBatches = context.getAdditionalJobsByEngine().get(engineName);
  List<List<String>> rejectedJobBatches = context.getRejectedJobsByEngine().get(engineName);
  int numJobsSubmittedForExecution = acquiredJobBatches.size();
  if (resubmittedJobBatches != null) {
   numJobsSubmittedForExecution += resubmittedJobBatches.size();
  }
  int numJobsRejected = 0;
  if (rejectedJobBatches != null) {
   numJobsRejected += rejectedJobBatches.size();
  }
  // if not all jobs scheduled for execution have been rejected
  if (numJobsRejected == 0 || numJobsSubmittedForExecution > numJobsRejected) {
   return false;
  }
 }
 return true;
}
origin: camunda/camunda-bpm-platform

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));
}
origin: camunda/camunda-bpm-platform

 public void testAcquiredJobs() {
  List<String> firstBatch = new ArrayList<String>(Arrays.asList("a", "b", "c"));
  List<String> secondBatch = new ArrayList<String>(Arrays.asList("d", "e", "f"));
  List<String> thirdBatch = new ArrayList<String>(Arrays.asList("g"));

  AcquiredJobs acquiredJobs = new AcquiredJobs(0);
  acquiredJobs.addJobIdBatch(firstBatch);
  acquiredJobs.addJobIdBatch(secondBatch);
  acquiredJobs.addJobIdBatch(thirdBatch);

  assertEquals(firstBatch, acquiredJobs.getJobIdBatches().get(0));
  assertEquals(secondBatch, acquiredJobs.getJobIdBatches().get(1));
  assertEquals(thirdBatch, acquiredJobs.getJobIdBatches().get(2));

  acquiredJobs.removeJobId("a");
  assertEquals(Arrays.asList("b", "c"), acquiredJobs.getJobIdBatches().get(0));
  assertEquals(secondBatch, acquiredJobs.getJobIdBatches().get(1));
  assertEquals(thirdBatch, acquiredJobs.getJobIdBatches().get(2));

  assertEquals(3, acquiredJobs.getJobIdBatches().size());
  acquiredJobs.removeJobId("g");
  assertEquals(2, acquiredJobs.getJobIdBatches().size());
 }
}
origin: camunda/camunda-bpm-platform

@Test
public void exclusiveJobsSameInstance() {
 // given: two exclusive jobs for the same process instance
 JobEntity job1 = createExclusiveJob(JOB_ID_1, PROCESS_INSTANCE_ID_1);
 JobEntity job2 = createExclusiveJob(JOB_ID_2, PROCESS_INSTANCE_ID_1);
 // when the job executor acquire new jobs
 when(jobManager.findNextJobsToExecute(any(Page.class))).thenReturn(Arrays.asList(job1, job2));
 // then the job executor should acquire job1 and job 2 in one batch
 AcquiredJobs acquiredJobs = acquireJobsCmd.execute(commandContext);
 List<List<String>> jobIdBatches = acquiredJobs.getJobIdBatches();
 assertThat(jobIdBatches.size(), is(1));
 assertThat(jobIdBatches.get(0).size(), is(2));
 assertThat(jobIdBatches.get(0), hasItems(JOB_ID_1, JOB_ID_2));
}
origin: camunda/camunda-bpm-platform

protected void executeJobs(JobAcquisitionContext context, ProcessEngineImpl currentProcessEngine, AcquiredJobs acquiredJobs) {
 // submit those jobs that were acquired in previous cycles but could not be scheduled for execution
 List<List<String>> additionalJobs = context.getAdditionalJobsByEngine().get(currentProcessEngine.getName());
 if (additionalJobs != null) {
  for (List<String> jobBatch : additionalJobs) {
   LOG.executeJobs(currentProcessEngine.getName(), jobBatch);
   jobExecutor.executeJobs(jobBatch, currentProcessEngine);
  }
 }
 // submit those jobs that were acquired in the current cycle
 for (List<String> jobIds : acquiredJobs.getJobIdBatches()) {
  LOG.executeJobs(currentProcessEngine.getName(), jobIds);
  jobExecutor.executeJobs(jobIds, currentProcessEngine);
 }
}
origin: camunda/camunda-bpm-platform

protected void executeJobs(JobAcquisitionContext context, ProcessEngineImpl currentProcessEngine, AcquiredJobs acquiredJobs) {
 // submit those jobs that were acquired in previous cycles but could not be scheduled for execution
 List<List<String>> additionalJobs = context.getAdditionalJobsByEngine().get(currentProcessEngine.getName());
 if (additionalJobs != null) {
  for (List<String> jobBatch : additionalJobs) {
   LOG.executeJobs(currentProcessEngine.getName(), jobBatch);
   jobExecutor.executeJobs(jobBatch, currentProcessEngine);
  }
 }
 // submit those jobs that were acquired in the current cycle
 for (List<String> jobIds : acquiredJobs.getJobIdBatches()) {
  LOG.executeJobs(currentProcessEngine.getName(), jobIds);
  jobExecutor.executeJobs(jobIds, currentProcessEngine);
 }
}
origin: camunda/camunda-bpm-platform

public void testJobCommandsWithTimer() {
 // clock gets automatically reset in LogTestCase.runTest
 ClockUtil.setCurrentTime(new Date(SOME_TIME));
 CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
 JobExecutor jobExecutor = processEngineConfiguration.getJobExecutor();
 String jobId = commandExecutor.execute(new Command<String>() {
  public String execute(CommandContext commandContext) {
   TimerEntity timer = createTweetTimer("i'm coding a test", new Date(SOME_TIME + (10 * SECOND)));
   commandContext.getJobManager().schedule(timer);
   return timer.getId();
  }
 });
 AcquiredJobs acquiredJobs = commandExecutor.execute(new AcquireJobsCmd(jobExecutor));
 List<List<String>> jobIdsList = acquiredJobs.getJobIdBatches();
 assertEquals(0, jobIdsList.size());
 List<String> expectedJobIds = new ArrayList<String>();
 ClockUtil.setCurrentTime(new Date(SOME_TIME + (20 * SECOND)));
 acquiredJobs = commandExecutor.execute(new AcquireJobsCmd(jobExecutor, jobExecutor.getMaxJobsPerAcquisition()));
 jobIdsList = acquiredJobs.getJobIdBatches();
 assertEquals(1, jobIdsList.size());
 List<String> jobIds = jobIdsList.get(0);
 expectedJobIds.add(jobId);
 assertEquals(expectedJobIds, new ArrayList<String>(jobIds));
 assertEquals(0, tweetHandler.getMessages().size());
 ExecuteJobHelper.executeJob(jobId, commandExecutor);
 assertEquals("i'm coding a test", tweetHandler.getMessages().get(0));
 assertEquals(1, tweetHandler.getMessages().size());
 clearDatabase();
}
origin: camunda/camunda-bpm-platform

public void testJobCommandsWithMessage() {
 CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
 JobExecutor jobExecutor = processEngineConfiguration.getJobExecutor();
 String jobId = commandExecutor.execute(new Command<String>() {
  public String execute(CommandContext commandContext) {
   MessageEntity message = createTweetMessage("i'm coding a test");
   commandContext.getJobManager().send(message);
   return message.getId();
  }
 });
 AcquiredJobs acquiredJobs = commandExecutor.execute(new AcquireJobsCmd(jobExecutor));
 List<List<String>> jobIdsList = acquiredJobs.getJobIdBatches();
 assertEquals(1, jobIdsList.size());
 List<String> jobIds = jobIdsList.get(0);
 List<String> expectedJobIds = new ArrayList<String>();
 expectedJobIds.add(jobId);
 assertEquals(expectedJobIds, new ArrayList<String>(jobIds));
 assertEquals(0, tweetHandler.getMessages().size());
 ExecuteJobHelper.executeJob(jobId, commandExecutor);
 assertEquals("i'm coding a test", tweetHandler.getMessages().get(0));
 assertEquals(1, tweetHandler.getMessages().size());
 clearDatabase();
}
origin: camunda/camunda-bpm-platform

@Test
public void testWaitTimeOnFullRejection() {
 // given a job acquisition strategy and a job acquisition context
 // with acquired jobs all 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);
 for (int i = 0; i < NUM_JOBS_TO_ACQUIRE; i++) {
  context.submitRejectedBatch(ENGINE_NAME, acquiredJobs.getJobIdBatches().get(i));
 }
 // when reconfiguring the strategy
 strategy.reconfigure(context);
 // then there is a slight wait time to avoid constant spinning while
 // no execution resources are available
 Assert.assertEquals(BackoffJobAcquisitionStrategy.DEFAULT_EXECUTION_SATURATION_WAIT_TIME, strategy.getWaitTime());
}
origin: camunda/camunda-bpm-platform

@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());
}
origin: org.camunda.bpm/camunda-engine

/**
 * @return true, if for all engines there were less jobs acquired than requested
 */
public boolean areAllEnginesIdle() {
 for (AcquiredJobs acquiredJobs : acquiredJobsByEngine.values()) {
  int jobsAcquired = acquiredJobs.getJobIdBatches().size() + acquiredJobs.getNumberOfJobsFailedToLock();
  if (jobsAcquired >= acquiredJobs.getNumberOfJobsAttemptedToAcquire()) {
   return false;
  }
 }
 return true;
}
origin: org.camunda.bpm/camunda-engine

public void acquiredJobs(String processEngine, AcquiredJobs acquiredJobs) {
 logDebug(
   "022",
   "Acquired {} jobs for process engine '{}': {}", acquiredJobs.size(), processEngine, acquiredJobs.getJobIdBatches());
}
origin: org.camunda.bpm/camunda-engine

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));
}
origin: org.camunda.bpm/camunda-engine

protected void executeJobs(JobAcquisitionContext context, ProcessEngineImpl currentProcessEngine, AcquiredJobs acquiredJobs) {
 // submit those jobs that were acquired in previous cycles but could not be scheduled for execution
 List<List<String>> additionalJobs = context.getAdditionalJobsByEngine().get(currentProcessEngine.getName());
 if (additionalJobs != null) {
  for (List<String> jobBatch : additionalJobs) {
   LOG.executeJobs(currentProcessEngine.getName(), jobBatch);
   jobExecutor.executeJobs(jobBatch, currentProcessEngine);
  }
 }
 // submit those jobs that were acquired in the current cycle
 for (List<String> jobIds : acquiredJobs.getJobIdBatches()) {
  LOG.executeJobs(currentProcessEngine.getName(), jobIds);
  jobExecutor.executeJobs(jobIds, currentProcessEngine);
 }
}
origin: org.camunda.bpm/camunda-engine

@Test
public void exclusiveJobsSameInstance() {
 // given: two exclusive jobs for the same process instance
 JobEntity job1 = createExclusiveJob(JOB_ID_1, PROCESS_INSTANCE_ID_1);
 JobEntity job2 = createExclusiveJob(JOB_ID_2, PROCESS_INSTANCE_ID_1);
 // when the job executor acquire new jobs
 when(jobManager.findNextJobsToExecute(any(Page.class))).thenReturn(Arrays.asList(job1, job2));
 // then the job executor should acquire job1 and job 2 in one batch
 AcquiredJobs acquiredJobs = acquireJobsCmd.execute(commandContext);
 List<List<String>> jobIdBatches = acquiredJobs.getJobIdBatches();
 assertThat(jobIdBatches.size(), is(1));
 assertThat(jobIdBatches.get(0).size(), is(2));
 assertThat(jobIdBatches.get(0), hasItems(JOB_ID_1, JOB_ID_2));
}
org.camunda.bpm.engine.impl.jobexecutorAcquiredJobsgetJobIdBatches

Popular methods of AcquiredJobs

  • size
  • <init>
  • addJobIdBatch
  • removeJobId
  • contains
  • getNumberOfJobsAttemptedToAcquire
  • getNumberOfJobsFailedToLock

Popular in Java

  • Making http requests using okhttp
  • getSupportFragmentManager (FragmentActivity)
  • startActivity (Activity)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • Calendar (java.util)
    Calendar is an abstract base class for converting between a Date object and a set of integer fields
  • LinkedHashMap (java.util)
    LinkedHashMap is an implementation of Map that guarantees iteration order. All optional operations a
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • DataSource (javax.sql)
    An interface for the creation of Connection objects which represent a connection to a database. This
  • JList (javax.swing)
  • Project (org.apache.tools.ant)
    Central representation of an Ant project. This class defines an Ant project with all of its targets,
  • Sublime Text for Python
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now