public int getMaxJobsPerAcquisition() { return jobExecutor.getMaxJobsPerAcquisition(); }
public AcquireJobsCmd(JobExecutor jobExecutor) { this(jobExecutor, jobExecutor.getMaxJobsPerAcquisition()); }
public AcquireJobsCmd(JobExecutor jobExecutor) { this(jobExecutor, jobExecutor.getMaxJobsPerAcquisition()); }
public int getMaxJobsPerAcquisition() { return jobExecutor.getMaxJobsPerAcquisition(); }
@Before public void initCommand() { JobExecutor jobExecutor = mock(JobExecutor.class); when(jobExecutor.getMaxJobsPerAcquisition()).thenReturn(3); when(jobExecutor.getLockOwner()).thenReturn("test"); when(jobExecutor.getLockTimeInMillis()).thenReturn(5 * 60 * 1000); acquireJobsCmd = new AcquireJobsCmd(jobExecutor); commandContext = mock(CommandContext.class); DbEntityManager dbEntityManager = mock(DbEntityManager.class); when(commandContext.getDbEntityManager()).thenReturn(dbEntityManager); jobManager = mock(JobManager.class); when(commandContext.getJobManager()).thenReturn(jobManager); }
public void testJobExecutorConfigurationProperties() { // given JobExecutor jobExecutor = new DefaultJobExecutor(); Map<String, String> propertiesToSet = new HashMap<String, String>(); propertiesToSet.put(MAX_JOBS_PER_ACQUISITION, Integer.toString(Integer.MAX_VALUE)); propertiesToSet.put(MAX_WAIT, Long.toString(Long.MAX_VALUE)); propertiesToSet.put(WAIT_INCREASE_FACTOR, Float.toString(Float.MAX_VALUE)); propertiesToSet.put(BACKOFF_TIME_IN_MILLIS, Integer.toString(Integer.MAX_VALUE)); // when PropertyHelper.applyProperties(jobExecutor, propertiesToSet); // then Assert.assertEquals(Integer.MAX_VALUE, jobExecutor.getMaxJobsPerAcquisition()); Assert.assertEquals(Long.MAX_VALUE, jobExecutor.getMaxWait()); Assert.assertEquals(Float.MAX_VALUE, jobExecutor.getWaitIncreaseFactor(), 0.0001d); Assert.assertEquals(Integer.MAX_VALUE, jobExecutor.getBackoffTimeInMillis()); }
public BackoffJobAcquisitionStrategy(JobExecutor jobExecutor) { this(jobExecutor.getWaitTimeInMillis(), jobExecutor.getWaitIncreaseFactor(), jobExecutor.getMaxWait(), jobExecutor.getBackoffTimeInMillis(), jobExecutor.getWaitIncreaseFactor(), jobExecutor.getMaxBackoff(), jobExecutor.getBackoffDecreaseThreshold(), jobExecutor.getMaxJobsPerAcquisition()); }
public BackoffJobAcquisitionStrategy(JobExecutor jobExecutor) { this(jobExecutor.getWaitTimeInMillis(), jobExecutor.getWaitIncreaseFactor(), jobExecutor.getMaxWait(), jobExecutor.getBackoffTimeInMillis(), jobExecutor.getWaitIncreaseFactor(), jobExecutor.getMaxBackoff(), jobExecutor.getBackoffDecreaseThreshold(), jobExecutor.getMaxJobsPerAcquisition()); }
public AcquireJobsCmd(JobExecutor jobExecutor) { this(jobExecutor, jobExecutor.getMaxJobsPerAcquisition()); }
public int getMaxJobsPerAcquisition() { return jobExecutor.getMaxJobsPerAcquisition(); }
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(); }
@Before public void initCommand() { JobExecutor jobExecutor = mock(JobExecutor.class); when(jobExecutor.getMaxJobsPerAcquisition()).thenReturn(3); when(jobExecutor.getLockOwner()).thenReturn("test"); when(jobExecutor.getLockTimeInMillis()).thenReturn(5 * 60 * 1000); acquireJobsCmd = new AcquireJobsCmd(jobExecutor); commandContext = mock(CommandContext.class); DbEntityManager dbEntityManager = mock(DbEntityManager.class); when(commandContext.getDbEntityManager()).thenReturn(dbEntityManager); jobManager = mock(JobManager.class); when(commandContext.getJobManager()).thenReturn(jobManager); }
public BackoffJobAcquisitionStrategy(JobExecutor jobExecutor) { this(jobExecutor.getWaitTimeInMillis(), jobExecutor.getWaitIncreaseFactor(), jobExecutor.getMaxWait(), jobExecutor.getBackoffTimeInMillis(), jobExecutor.getWaitIncreaseFactor(), jobExecutor.getMaxBackoff(), jobExecutor.getBackoffDecreaseThreshold(), jobExecutor.getMaxJobsPerAcquisition()); }
public void testJobExecutorConfigurationProperties() { // given JobExecutor jobExecutor = new DefaultJobExecutor(); Map<String, String> propertiesToSet = new HashMap<String, String>(); propertiesToSet.put(MAX_JOBS_PER_ACQUISITION, Integer.toString(Integer.MAX_VALUE)); propertiesToSet.put(MAX_WAIT, Long.toString(Long.MAX_VALUE)); propertiesToSet.put(WAIT_INCREASE_FACTOR, Float.toString(Float.MAX_VALUE)); propertiesToSet.put(BACKOFF_TIME_IN_MILLIS, Integer.toString(Integer.MAX_VALUE)); // when PropertyHelper.applyProperties(jobExecutor, propertiesToSet); // then Assert.assertEquals(Integer.MAX_VALUE, jobExecutor.getMaxJobsPerAcquisition()); Assert.assertEquals(Long.MAX_VALUE, jobExecutor.getMaxWait()); Assert.assertEquals(Float.MAX_VALUE, jobExecutor.getWaitIncreaseFactor(), 0.0001d); Assert.assertEquals(Integer.MAX_VALUE, jobExecutor.getBackoffTimeInMillis()); }
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(); }
private static Details from(JobExecutor jobExecutor) { final DetailsBuilder builder = Details.builder() .name(jobExecutor.getName()) .lockOwner(jobExecutor.getLockOwner()) .lockTimeInMillis(jobExecutor.getLockTimeInMillis()) .maxJobsPerAcquisition(jobExecutor.getMaxJobsPerAcquisition()) .waitTimeInMillis(jobExecutor.getWaitTimeInMillis()); for (ProcessEngineImpl processEngineImpl : jobExecutor.getProcessEngines()) { builder.processEngineName(processEngineImpl.getName()); } return builder.build(); }
private static Details from(JobExecutor jobExecutor) { final DetailsBuilder builder = Details.builder() .name(jobExecutor.getName()) .lockOwner(jobExecutor.getLockOwner()) .lockTimeInMillis(jobExecutor.getLockTimeInMillis()) .maxJobsPerAcquisition(jobExecutor.getMaxJobsPerAcquisition()) .waitTimeInMillis(jobExecutor.getWaitTimeInMillis()); for (ProcessEngineImpl processEngineImpl : jobExecutor.getProcessEngines()) { builder.processEngineName(processEngineImpl.getName()); } return builder.build(); }