use of org.apache.flink.shaded.curator5.org.apache.curator.framework.recipes.cache.TreeCacheEvent 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();
}
use of org.apache.flink.shaded.curator5.org.apache.curator.framework.recipes.cache.TreeCacheEvent in project elastic-job by dangdangdotcom.
the class FailoverListenerManagerTest method assertFailoverSettingsChangedJobListenerWhenIsFailoverPathAndUpdateButDisableFailover.
@Test
public void assertFailoverSettingsChangedJobListenerWhenIsFailoverPathAndUpdateButDisableFailover() {
failoverListenerManager.new FailoverSettingsChangedJobListener().dataChanged(null, new TreeCacheEvent(TreeCacheEvent.Type.NODE_UPDATED, new ChildData("/test_job/config", null, LiteJsonConstants.getJobJson(false).getBytes())), "/test_job/config");
verify(failoverService).removeFailoverInfo();
}
use of org.apache.flink.shaded.curator5.org.apache.curator.framework.recipes.cache.TreeCacheEvent in project elastic-job by dangdangdotcom.
the class GuaranteeListenerManagerTest method assertCompletedNodeRemovedJobListenerWhenIsRemovedAndCompletedNode.
@Test
public void assertCompletedNodeRemovedJobListenerWhenIsRemovedAndCompletedNode() {
guaranteeListenerManager.new CompletedNodeRemovedJobListener().dataChanged(null, new TreeCacheEvent(TreeCacheEvent.Type.NODE_REMOVED, new ChildData("/test_job/guarantee/completed", null, "".getBytes())), "/test_job/guarantee/completed");
verify(distributeOnceElasticJobListener).notifyWaitingTaskComplete();
}
use of org.apache.flink.shaded.curator5.org.apache.curator.framework.recipes.cache.TreeCacheEvent in project elastic-job by dangdangdotcom.
the class GuaranteeListenerManagerTest method assertCompletedNodeRemovedJobListenerWhenIsNotCompletedNode.
@Test
public void assertCompletedNodeRemovedJobListenerWhenIsNotCompletedNode() {
guaranteeListenerManager.new CompletedNodeRemovedJobListener().dataChanged(null, new TreeCacheEvent(TreeCacheEvent.Type.NODE_REMOVED, new ChildData("/other_job/guarantee/completed", null, "".getBytes())), "/other_job/guarantee/completed");
verify(distributeOnceElasticJobListener, times(0)).notifyWaitingTaskStart();
}
use of org.apache.flink.shaded.curator5.org.apache.curator.framework.recipes.cache.TreeCacheEvent in project elastic-job by dangdangdotcom.
the class ElectionListenerManagerTest method assertLeaderElectionJobListenerWhenJobShutdownAndIsLeader.
@Test
public void assertLeaderElectionJobListenerWhenJobShutdownAndIsLeader() {
when(leaderElectionService.isLeader()).thenReturn(true);
when(serverNode.isLocalJobPausedPath("/test_job/server/mockedIP/shutdown")).thenReturn(true);
electionListenerManager.new LeaderElectionJobListener().dataChanged(null, new TreeCacheEvent(TreeCacheEvent.Type.NODE_ADDED, new ChildData("/test_job/server/mockedIP/shutdown", null, "localhost".getBytes())), "/test_job/server/mockedIP/shutdown");
verify(leaderElectionService).removeLeader();
}
Aggregations