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

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

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

ZooKeeper.getDataWatches介绍

暂无

代码示例

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

List<String> dataWatches = zooKeeper.getDataWatches();
List<String> existWatches = zooKeeper.getExistWatches();
List<String> childWatches = zooKeeper.getChildWatches();

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

/**
 * Test verifies deletion of NodeDataChanged watches
 */
@Test(timeout = 30000)
public void testRemoveNodeDataChangedWatches() throws Exception {
  LOG.info("Adding data watcher using getData()");
  List<EventType> expectedEvents = new ArrayList<Watcher.Event.EventType>();
  expectedEvents.add(EventType.DataWatchRemoved);
  MyWatcher myWatcher = new MyWatcher("/testnode1", expectedEvents, 1);
  zk.create("/testnode1", "data".getBytes(), Ids.OPEN_ACL_UNSAFE,
      CreateMode.PERSISTENT);
  zk.getData("/testnode1", myWatcher, null);
  String cmdstring = "removewatches /testnode1 -d";
  LOG.info("Remove watchers using shell command : {}", cmdstring);
  zkMain.cl.parseCommand(cmdstring);
  Assert.assertTrue("Removewatches cmd fails to remove data watches",
      zkMain.processZKCmd(zkMain.cl));
  LOG.info("Waiting for the DataWatchRemoved event");
  myWatcher.matches();
  // verifying that other path data watches are removed
  Assert.assertEquals(
      "Data watches are not removed : " + zk.getDataWatches(), 0, zk
          .getDataWatches().size());
}

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

List<String> dataWatches = zooKeeper.getDataWatches();
List<String> existWatches = zooKeeper.getExistWatches();
List<String> childWatches = zooKeeper.getChildWatches();

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

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

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

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

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

.getDataWatches().size());
stopServer();
for (int i = 0; i < count; i++) {
    .getChildWatches().size());
Assert.assertEquals("Didn't remove watch references!", 0, zk1
    .getDataWatches().size());

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

removeWatches(zk2, "/node1", w1, WatcherType.Data, false, Code.OK);
Assert.assertEquals("Didn't find data watcher", 1,
    zk2.getDataWatches().size());
Assert.assertEquals("Didn't find data watcher", "/node2",
    zk2.getDataWatches().get(0));
removeWatches(zk2, "/node2", w2, WatcherType.Any, false, Code.OK);
Assert.assertTrue("Didn't remove data watcher", w2.matches());

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

removeWatches(zk2, "/node1", w2, WatcherType.Data, false, Code.OK);
Assert.assertEquals("Didn't find data watcher", 1,
    zk2.getDataWatches().size());
Assert.assertEquals("Didn't find data watcher", "/node1",
    zk2.getDataWatches().get(0));
removeWatches(zk2, "/node1", w1, WatcherType.Any, false, Code.OK);
Assert.assertTrue("Didn't remove data 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

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

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

(!zooKeeper.getDataWatches().isEmpty()
 || !zooKeeper.getExistWatches().isEmpty()
 || !zooKeeper.getChildWatches().isEmpty()))
  zooKeeper.getDataWatches(),
  zooKeeper.getExistWatches(),
  zooKeeper.getChildWatches());

相关文章