本文整理汇总了Java中org.apache.curator.framework.recipes.cache.TreeCacheEvent.Type类的典型用法代码示例。如果您正苦于以下问题:Java Type类的具体用法?Java Type怎么用?Java Type使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Type类属于org.apache.curator.framework.recipes.cache.TreeCacheEvent包,在下文中一共展示了Type类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: dataChanged
import org.apache.curator.framework.recipes.cache.TreeCacheEvent.Type; //导入依赖的package包/类
@Override
protected void dataChanged(final CuratorFramework client, final TreeCacheEvent event, final String path) {
if (!serverNode.isLocalJobPausedPath(path)) {
return;
}
JobScheduleController jobScheduleController = JobRegistry.getInstance().getJobScheduleController(jobName);
if (null == jobScheduleController) {
return;
}
if (Type.NODE_ADDED == event.getType()) {
jobScheduleController.pauseJob();
}
if (Type.NODE_REMOVED == event.getType()) {
jobScheduleController.resumeJob();
serverService.clearJobPausedStatus();
}
}
开发者ID:artoderk,项目名称:elastic-jobx,代码行数:18,代码来源:JobOperationListenerManager.java
示例2: testStartup
import org.apache.curator.framework.recipes.cache.TreeCacheEvent.Type; //导入依赖的package包/类
@Test
public void testStartup() throws Exception
{
client.create().forPath("/test");
client.create().forPath("/test/1", "one".getBytes());
client.create().forPath("/test/2", "two".getBytes());
client.create().forPath("/test/3", "three".getBytes());
client.create().forPath("/test/2/sub", "two-sub".getBytes());
cache = newTreeCacheWithListeners(client, "/test");
cache.start();
assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test");
assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test/1", "one".getBytes());
assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test/2", "two".getBytes());
assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test/3", "three".getBytes());
assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test/2/sub", "two-sub".getBytes());
assertEvent(TreeCacheEvent.Type.INITIALIZED);
assertNoMoreEvents();
Assert.assertEquals(cache.getCurrentChildren("/test").keySet(), ImmutableSet.of("1", "2", "3"));
Assert.assertEquals(cache.getCurrentChildren("/test/1").keySet(), ImmutableSet.of());
Assert.assertEquals(cache.getCurrentChildren("/test/2").keySet(), ImmutableSet.of("sub"));
Assert.assertNull(cache.getCurrentChildren("/test/non_exist"));
}
开发者ID:apache,项目名称:curator,代码行数:25,代码来源:TestTreeCache.java
示例3: testCreateParents
import org.apache.curator.framework.recipes.cache.TreeCacheEvent.Type; //导入依赖的package包/类
@Test
public void testCreateParents() throws Exception
{
cache = newTreeCacheWithListeners(client, "/one/two/three");
cache.start();
assertEvent(TreeCacheEvent.Type.INITIALIZED);
assertNoMoreEvents();
Assert.assertNull(client.checkExists().forPath("/one/two/three"));
cache.close();
cache = buildWithListeners(TreeCache.newBuilder(client, "/one/two/three").setCreateParentNodes(true));
cache.start();
assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/one/two/three");
assertEvent(TreeCacheEvent.Type.INITIALIZED);
assertNoMoreEvents();
Assert.assertNotNull(client.checkExists().forPath("/one/two/three"));
}
开发者ID:apache,项目名称:curator,代码行数:18,代码来源:TestTreeCache.java
示例4: testDepth0
import org.apache.curator.framework.recipes.cache.TreeCacheEvent.Type; //导入依赖的package包/类
@Test
public void testDepth0() throws Exception
{
client.create().forPath("/test");
client.create().forPath("/test/1", "one".getBytes());
client.create().forPath("/test/2", "two".getBytes());
client.create().forPath("/test/3", "three".getBytes());
client.create().forPath("/test/2/sub", "two-sub".getBytes());
cache = buildWithListeners(TreeCache.newBuilder(client, "/test").setMaxDepth(0));
cache.start();
assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test");
assertEvent(TreeCacheEvent.Type.INITIALIZED);
assertNoMoreEvents();
Assert.assertEquals(cache.getCurrentChildren("/test").keySet(), ImmutableSet.of());
Assert.assertNull(cache.getCurrentData("/test/1"));
Assert.assertNull(cache.getCurrentChildren("/test/1"));
Assert.assertNull(cache.getCurrentData("/test/non_exist"));
}
开发者ID:apache,项目名称:curator,代码行数:21,代码来源:TestTreeCache.java
示例5: testDepth1
import org.apache.curator.framework.recipes.cache.TreeCacheEvent.Type; //导入依赖的package包/类
@Test
public void testDepth1() throws Exception
{
client.create().forPath("/test");
client.create().forPath("/test/1", "one".getBytes());
client.create().forPath("/test/2", "two".getBytes());
client.create().forPath("/test/3", "three".getBytes());
client.create().forPath("/test/2/sub", "two-sub".getBytes());
cache = buildWithListeners(TreeCache.newBuilder(client, "/test").setMaxDepth(1));
cache.start();
assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test");
assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test/1", "one".getBytes());
assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test/2", "two".getBytes());
assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test/3", "three".getBytes());
assertEvent(TreeCacheEvent.Type.INITIALIZED);
assertNoMoreEvents();
Assert.assertEquals(cache.getCurrentChildren("/test").keySet(), ImmutableSet.of("1", "2", "3"));
Assert.assertEquals(cache.getCurrentChildren("/test/1").keySet(), ImmutableSet.of());
Assert.assertEquals(cache.getCurrentChildren("/test/2").keySet(), ImmutableSet.of());
Assert.assertNull(cache.getCurrentData("/test/2/sub"));
Assert.assertNull(cache.getCurrentChildren("/test/2/sub"));
Assert.assertNull(cache.getCurrentChildren("/test/non_exist"));
}
开发者ID:apache,项目名称:curator,代码行数:26,代码来源:TestTreeCache.java
示例6: testDepth1Deeper
import org.apache.curator.framework.recipes.cache.TreeCacheEvent.Type; //导入依赖的package包/类
@Test
public void testDepth1Deeper() throws Exception
{
client.create().forPath("/test");
client.create().forPath("/test/foo");
client.create().forPath("/test/foo/bar");
client.create().forPath("/test/foo/bar/1", "one".getBytes());
client.create().forPath("/test/foo/bar/2", "two".getBytes());
client.create().forPath("/test/foo/bar/3", "three".getBytes());
client.create().forPath("/test/foo/bar/2/sub", "two-sub".getBytes());
cache = buildWithListeners(TreeCache.newBuilder(client, "/test/foo/bar").setMaxDepth(1));
cache.start();
assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test/foo/bar");
assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test/foo/bar/1", "one".getBytes());
assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test/foo/bar/2", "two".getBytes());
assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test/foo/bar/3", "three".getBytes());
assertEvent(TreeCacheEvent.Type.INITIALIZED);
assertNoMoreEvents();
}
开发者ID:apache,项目名称:curator,代码行数:21,代码来源:TestTreeCache.java
示例7: testFromRoot
import org.apache.curator.framework.recipes.cache.TreeCacheEvent.Type; //导入依赖的package包/类
@Test
public void testFromRoot() throws Exception
{
client.create().forPath("/test");
client.create().forPath("/test/one", "hey there".getBytes());
cache = newTreeCacheWithListeners(client, "/");
cache.start();
assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/");
assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test");
assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test/one");
assertEvent(TreeCacheEvent.Type.INITIALIZED);
assertNoMoreEvents();
Assert.assertTrue(cache.getCurrentChildren("/").keySet().contains("test"));
Assert.assertEquals(cache.getCurrentChildren("/test").keySet(), ImmutableSet.of("one"));
Assert.assertEquals(cache.getCurrentChildren("/test/one").keySet(), ImmutableSet.of());
Assert.assertEquals(new String(cache.getCurrentData("/test/one").getData()), "hey there");
}
开发者ID:apache,项目名称:curator,代码行数:20,代码来源:TestTreeCache.java
示例8: testFromRootWithDepth
import org.apache.curator.framework.recipes.cache.TreeCacheEvent.Type; //导入依赖的package包/类
@Test
public void testFromRootWithDepth() throws Exception
{
client.create().forPath("/test");
client.create().forPath("/test/one", "hey there".getBytes());
cache = buildWithListeners(TreeCache.newBuilder(client, "/").setMaxDepth(1));
cache.start();
assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/");
assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test");
assertEvent(TreeCacheEvent.Type.INITIALIZED);
assertNoMoreEvents();
Assert.assertTrue(cache.getCurrentChildren("/").keySet().contains("test"));
Assert.assertEquals(cache.getCurrentChildren("/test").keySet(), ImmutableSet.of());
Assert.assertNull(cache.getCurrentData("/test/one"));
Assert.assertNull(cache.getCurrentChildren("/test/one"));
}
开发者ID:apache,项目名称:curator,代码行数:19,代码来源:TestTreeCache.java
示例9: testWithNamespace
import org.apache.curator.framework.recipes.cache.TreeCacheEvent.Type; //导入依赖的package包/类
@Test
public void testWithNamespace() throws Exception
{
client.create().forPath("/outer");
client.create().forPath("/outer/foo");
client.create().forPath("/outer/test");
client.create().forPath("/outer/test/one", "hey there".getBytes());
cache = newTreeCacheWithListeners(client.usingNamespace("outer"), "/test");
cache.start();
assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test");
assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test/one");
assertEvent(TreeCacheEvent.Type.INITIALIZED);
assertNoMoreEvents();
Assert.assertEquals(cache.getCurrentChildren("/test").keySet(), ImmutableSet.of("one"));
Assert.assertEquals(cache.getCurrentChildren("/test/one").keySet(), ImmutableSet.of());
Assert.assertEquals(new String(cache.getCurrentData("/test/one").getData()), "hey there");
}
开发者ID:apache,项目名称:curator,代码行数:20,代码来源:TestTreeCache.java
示例10: testWithNamespaceAtRoot
import org.apache.curator.framework.recipes.cache.TreeCacheEvent.Type; //导入依赖的package包/类
@Test
public void testWithNamespaceAtRoot() throws Exception
{
client.create().forPath("/outer");
client.create().forPath("/outer/foo");
client.create().forPath("/outer/test");
client.create().forPath("/outer/test/one", "hey there".getBytes());
cache = newTreeCacheWithListeners(client.usingNamespace("outer"), "/");
cache.start();
assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/");
assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/foo");
assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test");
assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test/one");
assertEvent(TreeCacheEvent.Type.INITIALIZED);
assertNoMoreEvents();
Assert.assertEquals(cache.getCurrentChildren("/").keySet(), ImmutableSet.of("foo", "test"));
Assert.assertEquals(cache.getCurrentChildren("/foo").keySet(), ImmutableSet.of());
Assert.assertEquals(cache.getCurrentChildren("/test").keySet(), ImmutableSet.of("one"));
Assert.assertEquals(cache.getCurrentChildren("/test/one").keySet(), ImmutableSet.of());
Assert.assertEquals(new String(cache.getCurrentData("/test/one").getData()), "hey there");
}
开发者ID:apache,项目名称:curator,代码行数:23,代码来源:TestTreeCache.java
示例11: testChildrenInitialized
import org.apache.curator.framework.recipes.cache.TreeCacheEvent.Type; //导入依赖的package包/类
@Test
public void testChildrenInitialized() throws Exception
{
client.create().forPath("/test", "".getBytes());
client.create().forPath("/test/1", "1".getBytes());
client.create().forPath("/test/2", "2".getBytes());
client.create().forPath("/test/3", "3".getBytes());
cache = newTreeCacheWithListeners(client, "/test");
cache.start();
assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test");
assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test/1");
assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test/2");
assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test/3");
assertEvent(TreeCacheEvent.Type.INITIALIZED);
assertNoMoreEvents();
}
开发者ID:apache,项目名称:curator,代码行数:18,代码来源:TestTreeCache.java
示例12: testUpdateWhenNotCachingData
import org.apache.curator.framework.recipes.cache.TreeCacheEvent.Type; //导入依赖的package包/类
@Test
public void testUpdateWhenNotCachingData() throws Exception
{
client.create().forPath("/test");
cache = buildWithListeners(TreeCache.newBuilder(client, "/test").setCacheData(false));
cache.start();
assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test");
assertEvent(TreeCacheEvent.Type.INITIALIZED);
client.create().forPath("/test/foo", "first".getBytes());
assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test/foo");
client.setData().forPath("/test/foo", "something new".getBytes());
assertEvent(TreeCacheEvent.Type.NODE_UPDATED, "/test/foo");
assertNoMoreEvents();
Assert.assertNotNull(cache.getCurrentData("/test/foo"));
// No byte data querying the tree because we're not caching data.
Assert.assertNull(cache.getCurrentData("/test/foo").getData());
}
开发者ID:apache,项目名称:curator,代码行数:22,代码来源:TestTreeCache.java
示例13: testDeleteThenCreate
import org.apache.curator.framework.recipes.cache.TreeCacheEvent.Type; //导入依赖的package包/类
@Test
public void testDeleteThenCreate() throws Exception
{
client.create().forPath("/test");
client.create().forPath("/test/foo", "one".getBytes());
cache = newTreeCacheWithListeners(client, "/test");
cache.start();
assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test");
assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test/foo");
assertEvent(TreeCacheEvent.Type.INITIALIZED);
client.delete().forPath("/test/foo");
assertEvent(TreeCacheEvent.Type.NODE_REMOVED, "/test/foo", "one".getBytes());
client.create().forPath("/test/foo", "two".getBytes());
assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test/foo");
client.delete().forPath("/test/foo");
assertEvent(TreeCacheEvent.Type.NODE_REMOVED, "/test/foo", "two".getBytes());
client.create().forPath("/test/foo", "two".getBytes());
assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test/foo");
assertNoMoreEvents();
}
开发者ID:apache,项目名称:curator,代码行数:25,代码来源:TestTreeCache.java
示例14: testDeleteThenCreateRoot
import org.apache.curator.framework.recipes.cache.TreeCacheEvent.Type; //导入依赖的package包/类
@Test
public void testDeleteThenCreateRoot() throws Exception
{
client.create().forPath("/test");
client.create().forPath("/test/foo", "one".getBytes());
cache = newTreeCacheWithListeners(client, "/test/foo");
cache.start();
assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test/foo");
assertEvent(TreeCacheEvent.Type.INITIALIZED);
client.delete().forPath("/test/foo");
assertEvent(TreeCacheEvent.Type.NODE_REMOVED, "/test/foo");
client.create().forPath("/test/foo", "two".getBytes());
assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test/foo");
client.delete().forPath("/test/foo");
assertEvent(TreeCacheEvent.Type.NODE_REMOVED, "/test/foo");
client.create().forPath("/test/foo", "two".getBytes());
assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test/foo");
assertNoMoreEvents();
}
开发者ID:apache,项目名称:curator,代码行数:24,代码来源:TestTreeCache.java
示例15: testKilledSession
import org.apache.curator.framework.recipes.cache.TreeCacheEvent.Type; //导入依赖的package包/类
@Test
public void testKilledSession() throws Exception
{
client.create().forPath("/test");
cache = newTreeCacheWithListeners(client, "/test");
cache.start();
assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test");
assertEvent(TreeCacheEvent.Type.INITIALIZED);
client.create().forPath("/test/foo", "foo".getBytes());
assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test/foo");
client.create().withMode(CreateMode.EPHEMERAL).forPath("/test/me", "data".getBytes());
assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test/me");
KillSession2.kill(client.getZookeeperClient().getZooKeeper());
assertEvent(TreeCacheEvent.Type.CONNECTION_LOST);
assertEvent(TreeCacheEvent.Type.CONNECTION_RECONNECTED);
assertEvent(TreeCacheEvent.Type.INITIALIZED);
assertEvent(TreeCacheEvent.Type.NODE_REMOVED, "/test/me", "data".getBytes());
assertNoMoreEvents();
}
开发者ID:apache,项目名称:curator,代码行数:24,代码来源:TestTreeCache.java
示例16: testDeleteNodeAfterCloseDoesntCallExecutor
import org.apache.curator.framework.recipes.cache.TreeCacheEvent.Type; //导入依赖的package包/类
@Test
public void testDeleteNodeAfterCloseDoesntCallExecutor() throws Exception
{
client.create().forPath("/test");
cache = newTreeCacheWithListeners(client, "/test");
cache.start();
assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test");
assertEvent(TreeCacheEvent.Type.INITIALIZED);
client.create().forPath("/test/one", "hey there".getBytes());
assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test/one");
Assert.assertEquals(new String(cache.getCurrentData("/test/one").getData()), "hey there");
cache.close();
assertNoMoreEvents();
client.delete().forPath("/test/one");
assertNoMoreEvents();
}
开发者ID:apache,项目名称:curator,代码行数:21,代码来源:TestTreeCache.java
示例17: testServerNotStartedYet
import org.apache.curator.framework.recipes.cache.TreeCacheEvent.Type; //导入依赖的package包/类
/**
* Make sure TreeCache gets to a sane state when we can't initially connect to server.
*/
@Test
public void testServerNotStartedYet() throws Exception
{
// Stop the existing server.
server.stop();
// Shutdown the existing client and re-create it started.
client.close();
initCuratorFramework();
// Start the client disconnected.
cache = newTreeCacheWithListeners(client, "/test");
cache.start();
assertNoMoreEvents();
// Now restart the server.
server.restart();
assertEvent(TreeCacheEvent.Type.INITIALIZED);
client.create().forPath("/test");
assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test");
assertNoMoreEvents();
}
开发者ID:apache,项目名称:curator,代码行数:28,代码来源:TestTreeCache.java
示例18: childEvent
import org.apache.curator.framework.recipes.cache.TreeCacheEvent.Type; //导入依赖的package包/类
@Override
public void childEvent(CuratorFramework client, TreeCacheEvent event) throws Exception {
ChildData eventData = event.getData();
if (event.getType() == Type.CONNECTION_RECONNECTED) {
LOGGER.traceMarker("ZK-Event", "========= Reconnect =========");
registerZkNodeAndWatch();
return;
}
if (event.getType() == Type.CONNECTION_LOST) {
LOGGER.traceMarker("ZK-Event", "========= Lost =========");
return;
}
if (event.getType() == Type.INITIALIZED) {
LOGGER.traceMarker("ZK-Event", "========= Initialized =========");
return;
}
if (event.getType() == Type.NODE_ADDED) {
LOGGER.traceMarker("ZK-Event", "========= Node Added: %s =========", eventData.getPath());
return;
}
if (event.getType() == Type.NODE_UPDATED) {
LOGGER.traceMarker("ZK-Event", "========= Node Updated: %s =========", eventData.getPath());
onDataChanged(eventData.getPath());
return;
}
if (event.getType() == Type.NODE_REMOVED) {
LOGGER.traceMarker("ZK-Event", "========= Node Removed: %s =========", eventData.getPath());
close();
return;
}
}
开发者ID:FlowCI,项目名称:flow-platform,代码行数:38,代码来源:AgentManager.java
示例19: dataChanged
import org.apache.curator.framework.recipes.cache.TreeCacheEvent.Type; //导入依赖的package包/类
@Override
protected void dataChanged(final CuratorFramework client, final TreeCacheEvent event, final String path) {
if (Type.NODE_REMOVED == event.getType() && guaranteeNode.isStartedRootNode(path)) {
for (ElasticJobListener each : elasticJobListeners) {
if (each instanceof AbstractDistributeOnceElasticJobListener) {
((AbstractDistributeOnceElasticJobListener) each).notifyWaitingTaskStart();
}
}
}
}
开发者ID:artoderk,项目名称:elastic-jobx,代码行数:11,代码来源:GuaranteeListenerManager.java
示例20: dataChanged
import org.apache.curator.framework.recipes.cache.TreeCacheEvent.Type; //导入依赖的package包/类
@Override
protected void dataChanged(final CuratorFramework client, final TreeCacheEvent event, final String path) {
if (configNode.isMonitorExecutionPath(path) && Type.NODE_UPDATED == event.getType()) {
if (!Boolean.valueOf(new String(event.getData().getData()))) {
executionService.removeExecutionInfo();
}
}
}
开发者ID:artoderk,项目名称:elastic-jobx,代码行数:9,代码来源:ExecutionListenerManager.java
注:本文中的org.apache.curator.framework.recipes.cache.TreeCacheEvent.Type类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论