当前位置: 首页>>代码示例>>Java>>正文


Java Type类代码示例

本文整理汇总了Java中org.apache.curator.framework.recipes.cache.TreeCacheEvent.Type的典型用法代码示例。如果您正苦于以下问题:Java Type类的具体用法?Java Type怎么用?Java Type使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Type类属于org.apache.curator.framework.recipes.cache.TreeCacheEvent包,在下文中一共展示了Type类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的org.apache.curator.framework.recipes.cache.TreeCacheEvent.Type类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。