Search in sources :

Example 16 with ChildData

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

the class ExecutionListenerManagerTest method assertMonitorExecutionChangedJobListenerWhenIsMonitorExecutionPathAndUpdateButEnable.

@Test
public void assertMonitorExecutionChangedJobListenerWhenIsMonitorExecutionPathAndUpdateButEnable() {
    executionListenerManager.new MonitorExecutionChangedJobListener().dataChanged(null, new TreeCacheEvent(TreeCacheEvent.Type.NODE_UPDATED, new ChildData("/test_job/config", null, LiteJsonConstants.getJobJson().getBytes())), "/test_job/config");
    verify(executionService, times(0)).removeExecutionInfo();
}
Also used : ChildData(org.apache.curator.framework.recipes.cache.ChildData) TreeCacheEvent(org.apache.curator.framework.recipes.cache.TreeCacheEvent) MonitorExecutionChangedJobListener(com.dangdang.ddframe.job.lite.internal.execution.ExecutionListenerManager.MonitorExecutionChangedJobListener) Test(org.junit.Test)

Example 17 with ChildData

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

the class ExecutionListenerManagerTest method assertMonitorExecutionChangedJobListenerWhenIsMonitorExecutionPathAndUpdateButDisable.

@Test
public void assertMonitorExecutionChangedJobListenerWhenIsMonitorExecutionPathAndUpdateButDisable() {
    executionListenerManager.new MonitorExecutionChangedJobListener().dataChanged(null, new TreeCacheEvent(TreeCacheEvent.Type.NODE_UPDATED, new ChildData("/test_job/config", null, LiteJsonConstants.getJobJson(false).getBytes())), "/test_job/config");
    verify(executionService).removeExecutionInfo();
}
Also used : ChildData(org.apache.curator.framework.recipes.cache.ChildData) TreeCacheEvent(org.apache.curator.framework.recipes.cache.TreeCacheEvent) MonitorExecutionChangedJobListener(com.dangdang.ddframe.job.lite.internal.execution.ExecutionListenerManager.MonitorExecutionChangedJobListener) Test(org.junit.Test)

Example 18 with ChildData

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

the class FailoverListenerManagerTest method assertJobCrashedJobListenerWhenIsRunningItemPathAndRemoveButItemCompleted.

@Test
public void assertJobCrashedJobListenerWhenIsRunningItemPathAndRemoveButItemCompleted() {
    when(executionService.isCompleted(0)).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(failoverService, times(0)).setCrashedFailoverFlag(0);
}
Also used : ChildData(org.apache.curator.framework.recipes.cache.ChildData) TreeCacheEvent(org.apache.curator.framework.recipes.cache.TreeCacheEvent) Test(org.junit.Test)

Example 19 with ChildData

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

the class FailoverListenerManagerTest method assertFailoverSettingsChangedJobListenerWhenIsFailoverPathAndUpdateButEnableFailover.

@Test
public void assertFailoverSettingsChangedJobListenerWhenIsFailoverPathAndUpdateButEnableFailover() {
    failoverListenerManager.new FailoverSettingsChangedJobListener().dataChanged(null, new TreeCacheEvent(TreeCacheEvent.Type.NODE_UPDATED, new ChildData("/test_job/config", null, LiteJsonConstants.getJobJson().getBytes())), "/test_job/config");
    verify(failoverService, times(0)).removeFailoverInfo();
}
Also used : ChildData(org.apache.curator.framework.recipes.cache.ChildData) TreeCacheEvent(org.apache.curator.framework.recipes.cache.TreeCacheEvent) Test(org.junit.Test)

Example 20 with ChildData

use of org.apache.curator.framework.recipes.cache.ChildData 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();
}
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)

Aggregations

ChildData (org.apache.curator.framework.recipes.cache.ChildData)119 Test (org.junit.Test)75 TreeCacheEvent (org.apache.curator.framework.recipes.cache.TreeCacheEvent)70 IOException (java.io.IOException)10 PathChildrenCacheEvent (org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent)9 CuratorFramework (org.apache.curator.framework.CuratorFramework)8 LeaderElectionJobListener (com.dangdang.ddframe.job.lite.internal.election.ElectionListenerManager.LeaderElectionJobListener)7 SimpleJobConfiguration (com.dangdang.ddframe.job.config.simple.SimpleJobConfiguration)6 PathChildrenCache (org.apache.curator.framework.recipes.cache.PathChildrenCache)6 KeeperException (org.apache.zookeeper.KeeperException)6 JobPausedStatusJobListener (com.dangdang.ddframe.job.lite.internal.server.JobOperationListenerManager.JobPausedStatusJobListener)5 PathChildrenCacheListener (org.apache.curator.framework.recipes.cache.PathChildrenCacheListener)5 TreeCache (org.apache.curator.framework.recipes.cache.TreeCache)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 ServiceDTO (io.fabric8.gateway.ServiceDTO)3 ObjectInputStream (java.io.ObjectInputStream)3 URISyntaxException (java.net.URISyntaxException)3