use of org.apache.curator.framework.recipes.cache.ChildData in project elastic-job by dangdangdotcom.
the class FailoverListenerManagerTest method assertJobCrashedJobListenerWhenIsRunningItemPathAndRemoveAndItemNotCompletedButDisableFailover.
@Test
public void assertJobCrashedJobListenerWhenIsRunningItemPathAndRemoveAndItemNotCompletedButDisableFailover() {
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 JobCrashedJobListener().dataChanged(null, new TreeCacheEvent(TreeCacheEvent.Type.NODE_REMOVED, new ChildData("/test_job/execution/0/running", null, "".getBytes())), "/test_job/execution/0/running");
verify(executionService).isCompleted(0);
verify(configService).load(true);
verify(failoverService, times(0)).setCrashedFailoverFlag(0);
}
use of org.apache.curator.framework.recipes.cache.ChildData in project elastic-job by dangdangdotcom.
the class FailoverListenerManagerTest method assertJobCrashedJobListenerWhenIsRunningItemPathAndRemoveAndItemNotCompletedAndEnableFailoverButHasRunningItems.
@Test
public void assertJobCrashedJobListenerWhenIsRunningItemPathAndRemoveAndItemNotCompletedAndEnableFailoverButHasRunningItems() {
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 JobCrashedJobListener().dataChanged(null, new TreeCacheEvent(TreeCacheEvent.Type.NODE_REMOVED, new ChildData("/test_job/execution/0/running", null, "".getBytes())), "/test_job/execution/0/running");
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 org.apache.curator.framework.recipes.cache.ChildData in project elastic-job by dangdangdotcom.
the class GuaranteeListenerManagerTest method assertStartedNodeRemovedJobListenerWhenIsNotStartedNode.
@Test
public void assertStartedNodeRemovedJobListenerWhenIsNotStartedNode() {
guaranteeListenerManager.new StartedNodeRemovedJobListener().dataChanged(null, new TreeCacheEvent(TreeCacheEvent.Type.NODE_REMOVED, new ChildData("/other_job/guarantee/started", null, "".getBytes())), "/other_job/guarantee/started");
verify(distributeOnceElasticJobListener, times(0)).notifyWaitingTaskStart();
}
use of org.apache.curator.framework.recipes.cache.ChildData in project elastic-job by dangdangdotcom.
the class CloudJobConfigurationListenerTest method assertChildEventWhenStateIsAddAndIsConfigPath.
@Test
public void assertChildEventWhenStateIsAddAndIsConfigPath() throws Exception {
cloudJobConfigurationListener.childEvent(null, new TreeCacheEvent(TreeCacheEvent.Type.NODE_ADDED, new ChildData("/config/job/test_job", null, CloudJsonConstants.getJobJson().getBytes())));
verify(producerManager).schedule(Matchers.<CloudJobConfiguration>any());
}
use of org.apache.curator.framework.recipes.cache.ChildData in project elastic-job by dangdangdotcom.
the class CloudJobConfigurationListenerTest method assertChildEventWhenStateIsRemovedAndIsJobConfigPath.
@Test
public void assertChildEventWhenStateIsRemovedAndIsJobConfigPath() throws Exception {
cloudJobConfigurationListener.childEvent(null, new TreeCacheEvent(TreeCacheEvent.Type.NODE_REMOVED, new ChildData("/config/job/test_job", null, "".getBytes())));
verify(producerManager).unschedule("test_job");
}
Aggregations