use of com.dangdang.ddframe.job.config.simple.SimpleJobConfiguration in project elastic-job by dangdangdotcom.
the class GuaranteeServiceTest method assertIsAllStarted.
@Test
public void assertIsAllStarted() {
when(jobNodeStorage.isJobNodeExisted("guarantee/started")).thenReturn(true);
when(configService.load(false)).thenReturn(LiteJobConfiguration.newBuilder(new SimpleJobConfiguration(JobCoreConfiguration.newBuilder("test_job", "0/1 * * * * ?", 3).build(), TestSimpleJob.class.getCanonicalName())).build());
when(jobNodeStorage.getJobNodeChildrenKeys("guarantee/started")).thenReturn(Arrays.asList("0", "1", "2"));
assertTrue(guaranteeService.isAllStarted());
}
use of com.dangdang.ddframe.job.config.simple.SimpleJobConfiguration in project elastic-job by dangdangdotcom.
the class JobScheduleControllerTest method assertRescheduleJobSuccess.
@Test
public void assertRescheduleJobSuccess() throws NoSuchFieldException, SchedulerException {
when(schedulerFacade.loadJobConfiguration()).thenReturn(LiteJobConfiguration.newBuilder(new SimpleJobConfiguration(JobCoreConfiguration.newBuilder("test_job", "0/1 * * * * ?", 3).build(), TestSimpleJob.class.getCanonicalName())).build());
when(scheduler.getTrigger(TriggerKey.triggerKey("test_job_Trigger"))).thenReturn(new CronTriggerImpl());
ReflectionUtils.setFieldValue(jobScheduleController, "scheduler", scheduler);
when(scheduler.isShutdown()).thenReturn(false);
jobScheduleController.rescheduleJob("0/1 * * * * ?");
verify(scheduler).rescheduleJob(eq(TriggerKey.triggerKey("test_job_Trigger")), Matchers.<Trigger>any());
}
use of com.dangdang.ddframe.job.config.simple.SimpleJobConfiguration in project elastic-job by dangdangdotcom.
the class FailoverListenerManagerTest method assertFailoverJobCrashedJobListenerWhenIsRunningItemPathAndRemoveAndItemNotCompletedButDisableFailover.
@Test
public void assertFailoverJobCrashedJobListenerWhenIsRunningItemPathAndRemoveAndItemNotCompletedButDisableFailover() {
when(executionService.isCompleted(0)).thenReturn(false);
when(configService.load(true)).thenReturn(LiteJobConfiguration.newBuilder(new SimpleJobConfiguration(JobCoreConfiguration.newBuilder("test_job", "0/1 * * * * ?", 3).failover(false).build(), TestSimpleJob.class.getCanonicalName())).build());
failoverListenerManager.new FailoverJobCrashedJobListener().dataChanged(null, new TreeCacheEvent(TreeCacheEvent.Type.NODE_REMOVED, new ChildData("/test_job/execution/0/failover", null, "".getBytes())), "/test_job/execution/0/failover");
verify(executionService).isCompleted(0);
verify(configService).load(true);
verify(failoverService, times(0)).setCrashedFailoverFlag(0);
}
use of com.dangdang.ddframe.job.config.simple.SimpleJobConfiguration in project elastic-job by dangdangdotcom.
the class FailoverListenerManagerTest method assertFailoverJobCrashedJobListenerWhenIsRunningItemPathAndRemoveAndItemNotCompletedAndEnableFailoverButHasRunningItems.
@Test
public void assertFailoverJobCrashedJobListenerWhenIsRunningItemPathAndRemoveAndItemNotCompletedAndEnableFailoverButHasRunningItems() {
when(executionService.isCompleted(0)).thenReturn(false);
when(configService.load(true)).thenReturn(LiteJobConfiguration.newBuilder(new SimpleJobConfiguration(JobCoreConfiguration.newBuilder("test_job", "0/1 * * * * ?", 3).failover(true).build(), TestSimpleJob.class.getCanonicalName())).monitorExecution(true).build());
when(shardingService.getLocalHostShardingItems()).thenReturn(Arrays.asList(1, 2));
when(executionService.hasRunningItems(Arrays.asList(1, 2))).thenReturn(true);
failoverListenerManager.new FailoverJobCrashedJobListener().dataChanged(null, new TreeCacheEvent(TreeCacheEvent.Type.NODE_REMOVED, new ChildData("/test_job/execution/0/failover", null, "".getBytes())), "/test_job/execution/0/failover");
verify(executionService).isCompleted(0);
verify(configService).load(true);
verify(failoverService).setCrashedFailoverFlag(0);
verify(shardingService).getLocalHostShardingItems();
verify(executionService).hasRunningItems(Arrays.asList(1, 2));
verify(failoverService, times(0)).failoverIfNecessary();
}
use of com.dangdang.ddframe.job.config.simple.SimpleJobConfiguration in project elastic-job by dangdangdotcom.
the class FailoverListenerManagerTest method assertFailoverJobCrashedJobListenerWhenIsRunningItemPathAndRemoveAndItemNotCompletedAndEnableFailoverAndHasNotRunningItems.
@Test
public void assertFailoverJobCrashedJobListenerWhenIsRunningItemPathAndRemoveAndItemNotCompletedAndEnableFailoverAndHasNotRunningItems() {
when(executionService.isCompleted(0)).thenReturn(false);
when(configService.load(true)).thenReturn(LiteJobConfiguration.newBuilder(new SimpleJobConfiguration(JobCoreConfiguration.newBuilder("test_job", "0/1 * * * * ?", 3).failover(true).build(), TestSimpleJob.class.getCanonicalName())).monitorExecution(true).build());
when(shardingService.getLocalHostShardingItems()).thenReturn(Arrays.asList(1, 2));
when(executionService.hasRunningItems(Arrays.asList(1, 2))).thenReturn(false);
failoverListenerManager.new FailoverJobCrashedJobListener().dataChanged(null, new TreeCacheEvent(TreeCacheEvent.Type.NODE_REMOVED, new ChildData("/test_job/execution/0/failover", null, "".getBytes())), "/test_job/execution/0/failover");
verify(executionService).isCompleted(0);
verify(configService).load(true);
verify(failoverService).setCrashedFailoverFlag(0);
verify(shardingService).getLocalHostShardingItems();
verify(executionService).hasRunningItems(Arrays.asList(1, 2));
verify(failoverService).failoverIfNecessary();
}
Aggregations