use of org.apache.curator.framework.recipes.cache.TreeCacheEvent in project elastic-job by dangdangdotcom.
the class ElectionListenerManagerTest method assertLeaderElectionJobListenerWhenIsLeaderHostPathAndIsRemoveAndIsLeader.
@Test
public void assertLeaderElectionJobListenerWhenIsLeaderHostPathAndIsRemoveAndIsLeader() {
when(leaderElectionService.hasLeader()).thenReturn(true);
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(leaderElectionService, times(0)).leaderElection();
}
use of org.apache.curator.framework.recipes.cache.TreeCacheEvent in project elastic-job by dangdangdotcom.
the class ElectionListenerManagerTest method assertLeaderElectionJobListenerWhenIsLeaderHostPathAndIsRemoveAndIsNotLeaderWithAvailableServers.
@Test
public void assertLeaderElectionJobListenerWhenIsLeaderHostPathAndIsRemoveAndIsNotLeaderWithAvailableServers() {
when(leaderElectionService.hasLeader()).thenReturn(false);
when(serverService.getAvailableServers()).thenReturn(Collections.singletonList("localhost"));
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).leaderElection();
}
use of org.apache.curator.framework.recipes.cache.TreeCacheEvent in project elastic-job by dangdangdotcom.
the class ElectionListenerManagerTest method assertLeaderElectionJobListenerWhenIsNotLeaderHostPath.
@Test
public void assertLeaderElectionJobListenerWhenIsNotLeaderHostPath() {
electionListenerManager.new LeaderElectionJobListener().dataChanged(null, new TreeCacheEvent(TreeCacheEvent.Type.NODE_ADDED, new ChildData("/test_job/leader/election/other", null, "localhost".getBytes())), "/test_job/leader/election/other");
verify(leaderElectionService, times(0)).leaderElection();
}
use of org.apache.curator.framework.recipes.cache.TreeCacheEvent in project elastic-job by dangdangdotcom.
the class ElectionListenerManagerTest method assertLeaderElectionJobListenerWhenIsLeaderHostPathButNotRemove.
@Test
public void assertLeaderElectionJobListenerWhenIsLeaderHostPathButNotRemove() {
electionListenerManager.new LeaderElectionJobListener().dataChanged(null, new TreeCacheEvent(TreeCacheEvent.Type.NODE_ADDED, new ChildData("/test_job/leader/election/host", null, "localhost".getBytes())), "/test_job/leader/election/host");
verify(leaderElectionService, times(0)).leaderElection();
}
use of org.apache.curator.framework.recipes.cache.TreeCacheEvent in project elastic-job by dangdangdotcom.
the class FailoverListenerManagerTest method assertJobCrashedJobListenerWhenIsRunningItemPathButNotRemove.
@Test
public void assertJobCrashedJobListenerWhenIsRunningItemPathButNotRemove() {
failoverListenerManager.new JobCrashedJobListener().dataChanged(null, new TreeCacheEvent(TreeCacheEvent.Type.NODE_ADDED, new ChildData("/test_job/execution/0/running", null, "".getBytes())), "/test_job/execution/0/running");
verify(failoverService, times(0)).setCrashedFailoverFlag(0);
}
Aggregations