org.apache.zookeeper.ZooKeeper.getChildWatches()方法的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(5.1k)|赞(0)|评价(0)|浏览(140)

本文整理了Java中org.apache.zookeeper.ZooKeeper.getChildWatches()方法的一些代码示例,展示了ZooKeeper.getChildWatches()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZooKeeper.getChildWatches()方法的具体详情如下:
包路径:org.apache.zookeeper.ZooKeeper
类名称:ZooKeeper
方法名:getChildWatches

ZooKeeper.getChildWatches介绍

暂无

代码示例

代码示例来源:origin: apache/zookeeper

List<String> dataWatches = zooKeeper.getDataWatches();
List<String> existWatches = zooKeeper.getExistWatches();
List<String> childWatches = zooKeeper.getChildWatches();
if (!dataWatches.isEmpty()
    || !existWatches.isEmpty() || !childWatches.isEmpty()) {

代码示例来源:origin: apache/zookeeper

/**
 * Test verifies deletion of NodeChildrenChanged watches
 */
@Test(timeout = 30000)
public void testRemoveNodeChildrenChangedWatches() throws Exception {
  List<EventType> expectedEvents = new ArrayList<Watcher.Event.EventType>();
  expectedEvents.add(EventType.ChildWatchRemoved);
  MyWatcher myWatcher = new MyWatcher("/testnode1", expectedEvents, 1);
  zk.create("/testnode1", "data".getBytes(), Ids.OPEN_ACL_UNSAFE,
      CreateMode.PERSISTENT);
  LOG.info("Adding child changed watcher");
  zk.getChildren("/testnode1", myWatcher);
  String cmdstring = "removewatches /testnode1 -c";
  LOG.info("Remove watchers using shell command : {}", cmdstring);
  zkMain.cl.parseCommand(cmdstring);
  Assert.assertTrue("Removewatches cmd fails to remove child watches",
      zkMain.processZKCmd(zkMain.cl));
  myWatcher.matches();
  Assert.assertEquals(
      "Failed to remove child watches : " + zk.getChildWatches(), 0,
      zk.getChildWatches().size());
}

代码示例来源:origin: apache/zookeeper

myWatcher.matches();
Assert.assertEquals(
    "Failed to remove child watches : " + zk.getChildWatches(), 1,
    zk.getChildWatches().size());
    "Failed to remove child watches :" + zk.getChildWatches(), zk
        .getChildWatches().contains("/testnode1/testnode2"));

代码示例来源:origin: org.apache.zookeeper/zookeeper

List<String> dataWatches = zooKeeper.getDataWatches();
List<String> existWatches = zooKeeper.getExistWatches();
List<String> childWatches = zooKeeper.getChildWatches();
if (!dataWatches.isEmpty()
      || !existWatches.isEmpty() || !childWatches.isEmpty()) {

代码示例来源:origin: apache/zookeeper

.getChildWatches().contains("/testnode2"));
Assert.assertTrue("Failed to find data watches for the path testnode2",
    zk.getDataWatches().contains("/testnode2"));

代码示例来源:origin: apache/zookeeper

.getChildWatches().size());
for (int i = 0; i < count; i++) {
  final MyWatcher watcher = wList.get(i);
    .getChildWatches().size());

代码示例来源:origin: apache/zookeeper

.getChildWatches().size());
    .getChildWatches().size());
Assert.assertEquals("Didn't remove watch references!", 0, zk1
    .getDataWatches().size());

代码示例来源:origin: apache/zookeeper

Assert.assertTrue("Didn't remove child watcher", w1.matches());
Assert.assertEquals("Didn't find child watcher", 1, zk2
    .getChildWatches().size());
removeWatches(zk2, "/node1", w2, WatcherType.Any, false, Code.OK);
Assert.assertTrue("Didn't remove child watcher", w2.matches());

代码示例来源:origin: apache/zookeeper

/**
 * Test verifies WatcherType.Any - removes only the configured child watcher
 * function
 */
@Test(timeout = 90000)
public void testRemoveAnyChildWatcher() throws Exception {
  zk1.create("/node1", null, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
  MyWatcher w1 = new MyWatcher("/node1", 2);
  MyWatcher w2 = new MyWatcher("/node1", 1);
  LOG.info("Adding data watcher {} on path {}", new Object[] { w1,
      "/node1" });
  Assert.assertNotNull("Didn't set data watches",
      zk2.exists("/node1", w1));
  // Add multiple child watches
  LOG.info("Adding child watcher {} on path {}", new Object[] { w1,
      "/node1" });
  zk2.getChildren("/node1", w2);
  LOG.info("Adding child watcher {} on path {}", new Object[] { w2,
      "/node1" });
  zk2.getChildren("/node1", w1);
  removeWatches(zk2, "/node1", w2, WatcherType.Any, false, Code.OK);
  Assert.assertTrue("Didn't remove child watcher", w2.matches());
  Assert.assertEquals("Didn't find child watcher", 1, zk2
      .getChildWatches().size());
  Assert.assertEquals("Didn't find data watcher", 1, zk2
      .getDataWatches().size());
  removeWatches(zk2, "/node1", w1, WatcherType.Any, false, Code.OK);
  Assert.assertTrue("Didn't remove watchers", w1.matches());
}

代码示例来源:origin: apache/zookeeper

Assert.assertTrue("Didn't remove data watcher", w1.matches());
Assert.assertEquals("Didn't find child watcher", 1, zk2
    .getChildWatches().size());
Assert.assertEquals("Didn't find data watcher", 1, zk2
    .getDataWatches().size());

代码示例来源:origin: apache/zookeeper

Assert.assertTrue("Didn't remove child watcher", w2.matches());
Assert.assertEquals("Didn't find child watcher", 1, zk2
    .getChildWatches().size());
removeWatches(zk2, "/node1", w1, WatcherType.Any, false, Code.OK);
Assert.assertTrue("Didn't remove child watcher", w1.matches());

代码示例来源:origin: org.apache.hadoop/zookeeper

(!zooKeeper.getDataWatches().isEmpty()
   || !zooKeeper.getExistWatches().isEmpty()
   || !zooKeeper.getChildWatches().isEmpty()))
    zooKeeper.getChildWatches());
RequestHeader h = new RequestHeader();
h.setType(ZooDefs.OpCode.setWatches);

相关文章