gpt4 book ai didi

org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher.sync()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-15 00:06:49 27 4
gpt4 key购买 nike

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

ZooKeeperWatcher.sync介绍

[英]Forces a synchronization of this ZooKeeper client connection.

Executing this method before running other methods will ensure that the subsequent operations are up-to-date and consistent as of the time that the sync is complete.

This is used for compareAndSwap type operations where we need to read the data of an existing node and delete or transition that node, utilizing the previously read version and data. We want to ensure that the version read is up-to-date from when we begin the operation.
[中]强制同步此ZooKeeper客户端连接。
在运行其他方法之前执行此方法将确保后续操作在同步完成时是最新且一致的。
这用于比较DSWAP类型的操作,我们需要读取现有节点的数据,并使用以前读取的版本和数据删除或转换该节点。我们希望确保从开始操作时读取的版本是最新的。

代码示例

代码示例来源:origin: harbby/presto-connectors

/**
 * Disable all archiving of files for a given table
 * <p>
 * Inherently an <b>asynchronous operation</b>.
 * @param zooKeeper watcher for the ZK cluster
 * @param table name of the table to disable
 * @throws KeeperException if an unexpected ZK connection issues occurs
 */
private void disable(ZooKeeperWatcher zooKeeper, byte[] table) throws KeeperException {
 // ensure the latest state of the archive node is found
 zooKeeper.sync(archiveZnode);
 // if the top-level archive node is gone, then we are done
 if (ZKUtil.checkExists(zooKeeper, archiveZnode) < 0) {
  return;
 }
 // delete the table node, from the archive
 String tableNode = this.getTableNode(table);
 // make sure the table is the latest version so the delete takes
 zooKeeper.sync(tableNode);
 LOG.debug("Attempting to delete table node:" + tableNode);
 ZKUtil.deleteNodeRecursively(zooKeeper, tableNode);
}

代码示例来源:origin: harbby/presto-connectors

@Override
public void nodeDataChanged(String path) {
 if (path.equals(labelZnode) || path.equals(userAuthsZnode)) {
  try {
   watcher.sync(path);
   byte[] data = ZKUtil.getDataAndWatch(watcher, path);
   if (path.equals(labelZnode)) {
    refreshVisibilityLabelsCache(data);
   } else {
    refreshUserAuthsCache(data);
   }
  } catch (KeeperException ke) {
   LOG.error("Error reading data from zookeeper for node " + path, ke);
   // only option is to abort
   watcher.abort("Zookeeper error getting data for node " + path, ke);
  }
 }
}

代码示例来源:origin: co.cask.hbase/hbase

"node for " + regionName + " that is in expected state " + expectedState));
String node = getNodeName(zkw, regionName);
zkw.sync(node);
Stat stat = new Stat();
byte [] bytes = ZKUtil.getDataNoWatch(zkw, node, stat);

代码示例来源:origin: co.cask.hbase/hbase

zkw.sync(node);

代码示例来源:origin: co.cask.hbase/hbase

zkw.sync(node);

代码示例来源:origin: harbby/presto-connectors

zkw.sync(encoded);

代码示例来源:origin: harbby/presto-connectors

zkw.sync(node);

代码示例来源:origin: co.cask.hbase/hbase

String node = getNodeName(zkw, region.getEncodedName());
Stat stat = new Stat();
zkw.sync(node);
int version = ZKUtil.checkExists(zkw, node);
if (version == -1) {

代码示例来源:origin: harbby/presto-connectors

byte [] data = rt.toByteArray();
String node = getNodeName(zkw, region.getEncodedName());
zkw.sync(node);
int version = ZKUtil.checkExists(zkw, node);
if (version == -1) {

代码示例来源:origin: harbby/presto-connectors

zkw.sync(node);
Stat stat = new Stat();
byte [] bytes = ZKUtil.getDataNoWatch(zkw, node, stat);

代码示例来源:origin: harbby/presto-connectors

zkw.sync(node);

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com