use of com.dangdang.ddframe.job.config.simple.SimpleJobConfiguration in project elastic-job by dangdangdotcom.
the class JobSchedulerTest method mockInit.
private void mockInit(final boolean isMisfire) {
when(schedulerFacade.newJobTriggerListener()).thenReturn(new JobTriggerListener(null, null));
when(schedulerFacade.loadJobConfiguration()).thenReturn(LiteJobConfiguration.newBuilder(new SimpleJobConfiguration(JobCoreConfiguration.newBuilder("test_job", "* * 0/10 * * ? 2050", 3).misfire(isMisfire).build(), TestSimpleJob.class.getCanonicalName())).build());
}
use of com.dangdang.ddframe.job.config.simple.SimpleJobConfiguration in project elastic-job by dangdangdotcom.
the class ExecutionServiceTest method assertRegisterJobCompletedWhenNotMonitorExecution.
@Test
public void assertRegisterJobCompletedWhenNotMonitorExecution() {
when(configService.load(true)).thenReturn(LiteJobConfiguration.newBuilder(new SimpleJobConfiguration(JobCoreConfiguration.newBuilder("test_job", "0/1 * * * * ?", 3).build(), TestSimpleJob.class.getCanonicalName())).monitorExecution(false).build());
executionService.registerJobCompleted(new ShardingContexts("fake_task_id", "test_job", 10, "", Collections.<Integer, String>emptyMap()));
verify(configService).load(true);
verify(serverService, times(0)).updateServerStatus(ServerStatus.READY);
}
use of com.dangdang.ddframe.job.config.simple.SimpleJobConfiguration in project elastic-job by dangdangdotcom.
the class ExecutionServiceTest method assertCleanPreviousExecutionInfoWhenNeedFixExecutionInfoForNewValuesLess.
@Test
public void assertCleanPreviousExecutionInfoWhenNeedFixExecutionInfoForNewValuesLess() {
when(jobNodeStorage.isJobNodeExisted("execution")).thenReturn(true);
when(leaderElectionService.isLeader()).thenReturn(true);
when(jobNodeStorage.getJobNodeChildrenKeys("execution")).thenReturn(Arrays.asList("0", "1", "2"));
when(jobNodeStorage.isJobNodeExisted("leader/execution/necessary")).thenReturn(true);
when(configService.load(false)).thenReturn(LiteJobConfiguration.newBuilder(new SimpleJobConfiguration(JobCoreConfiguration.newBuilder("test_job", "0/1 * * * * ?", 2).build(), TestSimpleJob.class.getCanonicalName())).build());
executionService.cleanPreviousExecutionInfo();
verify(jobNodeStorage).isJobNodeExisted("execution");
verify(leaderElectionService).isLeader();
verify(jobNodeStorage).fillEphemeralJobNode("leader/execution/cleaning", "");
verify(jobNodeStorage).getJobNodeChildrenKeys("execution");
verify(jobNodeStorage).removeJobNodeIfExisted("execution/0/completed");
verify(jobNodeStorage).removeJobNodeIfExisted("execution/1/completed");
verify(jobNodeStorage).removeJobNodeIfExisted("execution/2/completed");
verify(jobNodeStorage).isJobNodeExisted("leader/execution/necessary");
verify(configService).load(false);
verify(jobNodeStorage).removeJobNodeIfExisted("execution/2");
verify(jobNodeStorage).removeJobNodeIfExisted("leader/execution/necessary");
verify(jobNodeStorage).removeJobNodeIfExisted("leader/execution/cleaning");
verify(jobNodeStorage).isJobNodeExisted("leader/execution/cleaning");
}
use of com.dangdang.ddframe.job.config.simple.SimpleJobConfiguration in project elastic-job by dangdangdotcom.
the class ExecutionServiceTest method assertRegisterJobBeginWithNextFireTime.
@Test
public void assertRegisterJobBeginWithNextFireTime() {
when(configService.load(true)).thenReturn(LiteJobConfiguration.newBuilder(new SimpleJobConfiguration(JobCoreConfiguration.newBuilder("test_job", "0/1 * * * * ?", 3).build(), TestSimpleJob.class.getCanonicalName())).monitorExecution(true).build());
when(jobScheduleController.getNextFireTime()).thenReturn(new Date(0L));
JobRegistry.getInstance().addJobScheduleController("test_job", jobScheduleController);
executionService.registerJobBegin(getShardingContext());
verify(configService).load(true);
verify(serverService).updateServerStatus(ServerStatus.RUNNING);
verify(jobNodeStorage).fillEphemeralJobNode("execution/0/running", "");
verify(jobNodeStorage).fillEphemeralJobNode("execution/1/running", "");
verify(jobNodeStorage).fillEphemeralJobNode("execution/2/running", "");
verify(jobNodeStorage).replaceJobNode(eq("execution/0/lastBeginTime"), anyLong());
verify(jobNodeStorage).replaceJobNode(eq("execution/1/lastBeginTime"), anyLong());
verify(jobNodeStorage).replaceJobNode(eq("execution/2/lastBeginTime"), anyLong());
verify(jobNodeStorage).replaceJobNode("execution/0/nextFireTime", 0L);
verify(jobNodeStorage).replaceJobNode("execution/1/nextFireTime", 0L);
verify(jobNodeStorage).replaceJobNode("execution/2/nextFireTime", 0L);
}
use of com.dangdang.ddframe.job.config.simple.SimpleJobConfiguration in project elastic-job by dangdangdotcom.
the class LiteJobConfigurationGsonFactoryTest method assertToJsonForSimpleJob.
@Test
public void assertToJsonForSimpleJob() {
LiteJobConfiguration actual = LiteJobConfiguration.newBuilder(new SimpleJobConfiguration(JobCoreConfiguration.newBuilder("test_job", "0/1 * * * * ?", 3).failover(true).misfire(false).build(), TestSimpleJob.class.getCanonicalName())).monitorExecution(false).maxTimeDiffSeconds(1000).monitorPort(8888).jobShardingStrategyClass("testClass").disabled(true).overwrite(true).reconcileIntervalMinutes(15).build();
assertThat(LiteJobConfigurationGsonFactory.toJson(actual), is(simpleJobJson));
}
Aggregations