Search in sources :

Example 51 with ChildData

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

the class ShardingListenerManagerTest method assertShardingTotalCountChangedJobListenerWhenIsNotConfigPath.

@Test
public void assertShardingTotalCountChangedJobListenerWhenIsNotConfigPath() {
    shardingListenerManager.new ShardingTotalCountChangedJobListener().dataChanged(null, new TreeCacheEvent(TreeCacheEvent.Type.NODE_ADDED, new ChildData("/test_job/config/other", null, "".getBytes())), "/test_job/config/other");
    verify(shardingService, times(0)).setReshardingFlag();
}
Also used : ChildData(org.apache.curator.framework.recipes.cache.ChildData) TreeCacheEvent(org.apache.curator.framework.recipes.cache.TreeCacheEvent) Test(org.junit.Test)

Example 52 with ChildData

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

the class ShardingListenerManagerTest method assertListenServersChangedJobListenerWhenIsNotServerStatusPath.

@Test
public void assertListenServersChangedJobListenerWhenIsNotServerStatusPath() {
    shardingListenerManager.new ListenServersChangedJobListener().dataChanged(null, new TreeCacheEvent(TreeCacheEvent.Type.NODE_ADDED, new ChildData("/test_job/servers/" + ip + "/other", null, "".getBytes())), "/test_job/servers/" + ip + "/other");
    verify(shardingService, times(0)).setReshardingFlag();
}
Also used : ChildData(org.apache.curator.framework.recipes.cache.ChildData) TreeCacheEvent(org.apache.curator.framework.recipes.cache.TreeCacheEvent) Test(org.junit.Test)

Example 53 with ChildData

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

the class ShardingListenerManagerTest method assertListenServersChangedJobListenerWhenIsServerStatusPathAndAdd.

@Test
public void assertListenServersChangedJobListenerWhenIsServerStatusPathAndAdd() {
    shardingListenerManager.new ListenServersChangedJobListener().dataChanged(null, new TreeCacheEvent(TreeCacheEvent.Type.NODE_ADDED, new ChildData("/test_job/servers/" + ip + "/status", null, "".getBytes())), "/test_job/servers/" + ip + "/status");
    verify(shardingService).setReshardingFlag();
}
Also used : ChildData(org.apache.curator.framework.recipes.cache.ChildData) TreeCacheEvent(org.apache.curator.framework.recipes.cache.TreeCacheEvent) Test(org.junit.Test)

Example 54 with ChildData

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

the class ShardingListenerManagerTest method assertListenServersChangedJobListenerWhenIsServerStatusPathButUpdateAndIsServerDisabledPath.

@Test
public void assertListenServersChangedJobListenerWhenIsServerStatusPathButUpdateAndIsServerDisabledPath() {
    shardingListenerManager.new ListenServersChangedJobListener().dataChanged(null, new TreeCacheEvent(TreeCacheEvent.Type.NODE_UPDATED, new ChildData("/test_job/servers/" + ip + "/disabled", null, "".getBytes())), "/test_job/servers/" + ip + "/disabled");
    verify(shardingService).setReshardingFlag();
}
Also used : ChildData(org.apache.curator.framework.recipes.cache.ChildData) TreeCacheEvent(org.apache.curator.framework.recipes.cache.TreeCacheEvent) Test(org.junit.Test)

Example 55 with ChildData

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

the class ShardingListenerManagerTest method assertShardingTotalCountChangedJobListenerWhenIsConfigPathAndCurrentShardingTotalCountIsEqualToNewShardingTotalCount.

@Test
public void assertShardingTotalCountChangedJobListenerWhenIsConfigPathAndCurrentShardingTotalCountIsEqualToNewShardingTotalCount() {
    shardingListenerManager.setCurrentShardingTotalCount(3);
    shardingListenerManager.new ShardingTotalCountChangedJobListener().dataChanged(null, new TreeCacheEvent(TreeCacheEvent.Type.NODE_ADDED, new ChildData("/test_job/config", null, LiteJsonConstants.getJobJson().getBytes())), "/test_job/config");
    verify(shardingService, times(0)).setReshardingFlag();
    verify(executionService, times(0)).setNeedFixExecutionInfoFlag();
}
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