use of 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.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.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();
}
use of org.apache.curator.framework.recipes.cache.TreeCacheEvent in project elastic-job by dangdangdotcom.
the class ElectionListenerManagerTest method assertLeaderElectionJobListenerWhenIsLeaderHostPathAndIsRemoveAndIsNotLeaderWithoutAvailableServers.
@Test
public void assertLeaderElectionJobListenerWhenIsLeaderHostPathAndIsRemoveAndIsNotLeaderWithoutAvailableServers() {
when(leaderElectionService.hasLeader()).thenReturn(false);
when(serverService.getAvailableServers()).thenReturn(Collections.<String>emptyList());
electionListenerManager.new LeaderElectionJobListener().dataChanged(null, new TreeCacheEvent(TreeCacheEvent.Type.NODE_REMOVED, new ChildData("/test_job/leader/election/host", null, "localhost".getBytes())), "/test_job/leader/election/host");
verify(leaderElectionService).hasLeader();
verify(serverService).getAvailableServers();
verify(leaderElectionService, times(0)).leaderElection();
}
use of org.apache.curator.framework.recipes.cache.TreeCacheEvent in project elastic-job by dangdangdotcom.
the class ElectionListenerManagerTest method assertLeaderElectionJobListenerWhenJobDisabledAndIsNotLeader.
@Test
public void assertLeaderElectionJobListenerWhenJobDisabledAndIsNotLeader() {
when(leaderElectionService.isLeader()).thenReturn(false);
when(serverNode.isLocalJobPausedPath("/test_job/server/mockedIP/disabled")).thenReturn(true);
electionListenerManager.new LeaderElectionJobListener().dataChanged(null, new TreeCacheEvent(TreeCacheEvent.Type.NODE_ADDED, new ChildData("/test_job/server/mockedIP/disabled", null, "localhost".getBytes())), "/test_job/server/mockedIP/disabled");
verify(leaderElectionService, times(0)).removeLeader();
}
Aggregations