Search in sources :

Example 66 with ChildData

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

the class FailoverListenerManagerTest method assertFailoverJobCrashedJobListenerWhenIsNotRunningItemPath.

@Test
public void assertFailoverJobCrashedJobListenerWhenIsNotRunningItemPath() {
    failoverListenerManager.new FailoverJobCrashedJobListener().dataChanged(null, new TreeCacheEvent(TreeCacheEvent.Type.NODE_ADDED, new ChildData("/test_job/execution/0/other", null, "".getBytes())), "/test_job/execution/0/other");
    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 67 with ChildData

use of org.apache.curator.framework.recipes.cache.ChildData 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();
}
Also used : TestSimpleJob(com.dangdang.ddframe.job.lite.fixture.TestSimpleJob) ChildData(org.apache.curator.framework.recipes.cache.ChildData) SimpleJobConfiguration(com.dangdang.ddframe.job.config.simple.SimpleJobConfiguration) TreeCacheEvent(org.apache.curator.framework.recipes.cache.TreeCacheEvent) Test(org.junit.Test)

Example 68 with ChildData

use of org.apache.curator.framework.recipes.cache.ChildData 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();
}
Also used : ChildData(org.apache.curator.framework.recipes.cache.ChildData) TreeCacheEvent(org.apache.curator.framework.recipes.cache.TreeCacheEvent) Test(org.junit.Test)

Example 69 with ChildData

use of org.apache.curator.framework.recipes.cache.ChildData 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();
}
Also used : ChildData(org.apache.curator.framework.recipes.cache.ChildData) TreeCacheEvent(org.apache.curator.framework.recipes.cache.TreeCacheEvent) Test(org.junit.Test)

Example 70 with ChildData

use of org.apache.curator.framework.recipes.cache.ChildData 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();
}
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)88 Test (org.junit.Test)71 TreeCacheEvent (org.apache.curator.framework.recipes.cache.TreeCacheEvent)67 LeaderElectionJobListener (com.dangdang.ddframe.job.lite.internal.election.ElectionListenerManager.LeaderElectionJobListener)7 SimpleJobConfiguration (com.dangdang.ddframe.job.config.simple.SimpleJobConfiguration)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 IOException (java.io.IOException)4 CuratorFramework (org.apache.curator.framework.CuratorFramework)4 KeeperException (org.apache.zookeeper.KeeperException)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3 HashMap (java.util.HashMap)3 PathChildrenCache (org.apache.curator.framework.recipes.cache.PathChildrenCache)3 PathChildrenCacheEvent (org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent)3 PathChildrenCacheListener (org.apache.curator.framework.recipes.cache.PathChildrenCacheListener)3 TreeCache (org.apache.curator.framework.recipes.cache.TreeCache)3 ReliableMessageRegisterDto (com.paascloud.core.registry.base.ReliableMessageRegisterDto)2 ObjectInputStream (java.io.ObjectInputStream)2