Search in sources :

Example 96 with ChildData

use of org.apache.curator.framework.recipes.cache.ChildData 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();
}
Also used : ChildData(org.apache.curator.framework.recipes.cache.ChildData) TreeCacheEvent(org.apache.curator.framework.recipes.cache.TreeCacheEvent) LeaderElectionJobListener(com.dangdang.ddframe.job.lite.internal.election.ElectionListenerManager.LeaderElectionJobListener) Test(org.junit.Test)

Example 97 with ChildData

use of org.apache.curator.framework.recipes.cache.ChildData in project elastic-job by dangdangdotcom.

the class JobOperationListenerManagerTest method assertJobTriggerStatusJobListenerWhenRemove.

@Test
public void assertJobTriggerStatusJobListenerWhenRemove() {
    jobOperationListenerManager.new JobTriggerStatusJobListener().dataChanged(null, new TreeCacheEvent(TreeCacheEvent.Type.NODE_REMOVED, new ChildData("/test_job/servers/" + ip + "/trigger", null, "".getBytes())), "/test_job/servers/" + ip + "/trigger");
    verify(serverService, times(0)).clearJobTriggerStatus();
    verify(jobScheduleController, times(0)).triggerJob();
}
Also used : ChildData(org.apache.curator.framework.recipes.cache.ChildData) TreeCacheEvent(org.apache.curator.framework.recipes.cache.TreeCacheEvent) Test(org.junit.Test)

Example 98 with ChildData

use of org.apache.curator.framework.recipes.cache.ChildData in project elastic-job by dangdangdotcom.

the class JobOperationListenerManagerTest method assertJobTriggerStatusJobListenerWhenIsAddAndIsJobLocalHostTriggerPathButNoJobRegister.

@Test
public void assertJobTriggerStatusJobListenerWhenIsAddAndIsJobLocalHostTriggerPathButNoJobRegister() {
    jobOperationListenerManager.new JobTriggerStatusJobListener().dataChanged(null, new TreeCacheEvent(TreeCacheEvent.Type.NODE_ADDED, new ChildData("/test_job/servers/" + ip + "/trigger", null, "".getBytes())), "/test_job/servers/" + ip + "/trigger");
    verify(serverService).clearJobTriggerStatus();
    verify(jobScheduleController, times(0)).triggerJob();
}
Also used : ChildData(org.apache.curator.framework.recipes.cache.ChildData) TreeCacheEvent(org.apache.curator.framework.recipes.cache.TreeCacheEvent) Test(org.junit.Test)

Example 99 with ChildData

use of org.apache.curator.framework.recipes.cache.ChildData in project elastic-job by dangdangdotcom.

the class JobOperationListenerManagerTest method assertJobPausedStatusJobListenerWhenIsNotJobPausedPath.

@Test
public void assertJobPausedStatusJobListenerWhenIsNotJobPausedPath() {
    jobOperationListenerManager.new JobPausedStatusJobListener().dataChanged(null, new TreeCacheEvent(TreeCacheEvent.Type.NODE_UPDATED, new ChildData("/test_job/servers/" + ip + "/other", null, "".getBytes())), "/test_job/servers/" + ip + "/other");
    verify(jobScheduleController, times(0)).pauseJob();
    verify(jobScheduleController, times(0)).resumeJob();
}
Also used : JobPausedStatusJobListener(com.dangdang.ddframe.job.lite.internal.server.JobOperationListenerManager.JobPausedStatusJobListener) ChildData(org.apache.curator.framework.recipes.cache.ChildData) TreeCacheEvent(org.apache.curator.framework.recipes.cache.TreeCacheEvent) Test(org.junit.Test)

Example 100 with ChildData

use of org.apache.curator.framework.recipes.cache.ChildData in project elastic-job by dangdangdotcom.

the class JobOperationListenerManagerTest method assertJobShutdownStatusJobListenerWhenIsJobShutdownPathButJobIsNotExisted.

@Test
public void assertJobShutdownStatusJobListenerWhenIsJobShutdownPathButJobIsNotExisted() {
    jobOperationListenerManager.new JobShutdownStatusJobListener().dataChanged(null, new TreeCacheEvent(TreeCacheEvent.Type.NODE_ADDED, new ChildData("/test_job/servers/" + ip + "/shutdown", null, "".getBytes())), "/test_job/servers/" + ip + "/shutdown");
    verify(jobScheduleController, times(0)).shutdown();
}
Also used : ChildData(org.apache.curator.framework.recipes.cache.ChildData) TreeCacheEvent(org.apache.curator.framework.recipes.cache.TreeCacheEvent) Test(org.junit.Test)

Aggregations

ChildData (org.apache.curator.framework.recipes.cache.ChildData)129 Test (org.junit.Test)75 TreeCacheEvent (org.apache.curator.framework.recipes.cache.TreeCacheEvent)71 IOException (java.io.IOException)11 CuratorFramework (org.apache.curator.framework.CuratorFramework)11 PathChildrenCacheEvent (org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent)10 PathChildrenCache (org.apache.curator.framework.recipes.cache.PathChildrenCache)9 LeaderElectionJobListener (com.dangdang.ddframe.job.lite.internal.election.ElectionListenerManager.LeaderElectionJobListener)7 SimpleJobConfiguration (com.dangdang.ddframe.job.config.simple.SimpleJobConfiguration)6 PathChildrenCacheListener (org.apache.curator.framework.recipes.cache.PathChildrenCacheListener)6 TreeCache (org.apache.curator.framework.recipes.cache.TreeCache)6 KeeperException (org.apache.zookeeper.KeeperException)6 JobPausedStatusJobListener (com.dangdang.ddframe.job.lite.internal.server.JobOperationListenerManager.JobPausedStatusJobListener)5 TestSimpleJob (com.dangdang.ddframe.job.lite.fixture.TestSimpleJob)4 CronSettingAndJobEventChangedJobListener (com.dangdang.ddframe.job.lite.internal.config.ConfigurationListenerManager.CronSettingAndJobEventChangedJobListener)4 MonitorExecutionChangedJobListener (com.dangdang.ddframe.job.lite.internal.execution.ExecutionListenerManager.MonitorExecutionChangedJobListener)4 ByteArrayInputStream (java.io.ByteArrayInputStream)4 HashMap (java.util.HashMap)4 Map (java.util.Map)4 ServiceDTO (io.fabric8.gateway.ServiceDTO)3