gpt4 book ai didi

com.alibaba.wasp.zookeeper.ZooKeeperWatcher.getRecoverableZooKeeper()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 11:19:42 25 4
gpt4 key购买 nike

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

ZooKeeperWatcher.getRecoverableZooKeeper介绍

[英]Get the connection to ZooKeeper.
[中]接通动物园管理员。

代码示例

代码示例来源:origin: alibaba/wasp

@Override
public void processResult(int rc, String path, Object ctx, String name) {
 if (rc == KeeperException.Code.NODEEXISTS.intValue()) {
  LOG.warn("Node for " + path + " already exists");
 } else if (rc != 0) {
  // This is result code. If non-zero, need to resubmit.
  LOG.warn("rc != 0 for " + path + " -- retryable connectionloss -- "
    + "FIX see http://wiki.apache.org/hadoop/ZooKeeper/FAQ#A2");
  this.counter.addAndGet(1);
  return;
 }
 if (LOG.isDebugEnabled()) {
  LOG.debug("rs=" + ctx + ", server=" + destination);
 }
 // Async exists to set a watcher so we'll get triggered when
 // unassigned node changes.
 ZooKeeper zk = this.zkw.getRecoverableZooKeeper().getZooKeeper();
 zk.exists(path, this.zkw, callBack, ctx);
}

代码示例来源:origin: alibaba/wasp

/**
 * Delete the specified node with the specified version. Sets no watches.
 * Throws all exceptions.
 */
public static boolean deleteNode(ZooKeeperWatcher zkw, String node,
  int version) throws KeeperException {
 try {
  zkw.getRecoverableZooKeeper().delete(node, version);
  return true;
 } catch (KeeperException.BadVersionException bve) {
  return false;
 } catch (InterruptedException ie) {
  zkw.interruptedException(ie);
  return false;
 }
}

代码示例来源:origin: alibaba/wasp

/**
 * Deletes the specified node. Fails silent if the node does not exist.
 *
 * @param zkw
 * @param node
 * @throws org.apache.zookeeper.KeeperException
 */
public static void deleteNodeFailSilent(ZooKeeperWatcher zkw, String node)
  throws KeeperException {
 try {
  zkw.getRecoverableZooKeeper().delete(node, -1);
 } catch (KeeperException.NoNodeException nne) {
 } catch (InterruptedException ie) {
  zkw.interruptedException(ie);
 }
}

代码示例来源:origin: alibaba/wasp

try {
 children = zkw.getRecoverableZooKeeper().getChildren(znode, null);
} catch (KeeperException.NoNodeException nne) {
 return null;

代码示例来源:origin: alibaba/wasp

KeeperException.NoNodeException {
try {
 return zkw.getRecoverableZooKeeper()
   .setData(znode, data, expectedVersion) != null;
} catch (InterruptedException e) {

代码示例来源:origin: alibaba/wasp

try {
 waitForZKConnectionIfAuthenticating(zkw);
 zkw.getRecoverableZooKeeper().create(znode, data, createACL(zkw, znode),
   CreateMode.EPHEMERAL);
} catch (KeeperException.NodeExistsException nee) {

代码示例来源:origin: alibaba/wasp

private static byte[] getDataInternal(ZooKeeperWatcher zkw, String znode,
  Stat stat, boolean watcherSet) throws KeeperException {
 try {
  byte[] data = zkw.getRecoverableZooKeeper().getData(znode, zkw, stat);
  logRetrievedMsg(zkw, znode, data, watcherSet);
  return data;
 } catch (KeeperException.NoNodeException e) {
  // This log can get pretty annoying when we cycle on 100ms waits.
  // Enable trace if you really want to see it.
  LOG.trace(zkw.prefix("Unable to get data of znode " + znode + " "
    + "because node does not exist (not an error)"));
  return null;
 } catch (KeeperException e) {
  LOG.warn(zkw.prefix("Unable to get data of znode " + znode), e);
  zkw.keeperException(e);
  return null;
 } catch (InterruptedException e) {
  LOG.warn(zkw.prefix("Unable to get data of znode " + znode), e);
  zkw.interruptedException(e);
  return null;
 }
}

代码示例来源:origin: alibaba/wasp

throws KeeperException {
try {
 return !zkw.getRecoverableZooKeeper().getChildren(znode, null).isEmpty();
} catch (KeeperException.NoNodeException ke) {
 LOG.debug(zkw.prefix("Unable to list children of znode " + znode + " "

代码示例来源:origin: alibaba/wasp

try {
 waitForZKConnectionIfAuthenticating(zkw);
 zkw.getRecoverableZooKeeper().create(znode, data, createACL(zkw, znode),
   CreateMode.PERSISTENT);
 return zkw.getRecoverableZooKeeper().exists(znode, zkw).getVersion();
} catch (InterruptedException e) {
 zkw.interruptedException(e);

代码示例来源:origin: alibaba/wasp

try {
 waitForZKConnectionIfAuthenticating(zkw);
 zkw.getRecoverableZooKeeper().getZooKeeper().create(znode, data,
   createACL(zkw, znode), CreateMode.PERSISTENT, cb, ctx);
} catch (InterruptedException e) {

代码示例来源:origin: alibaba/wasp

throws KeeperException {
try {
 Stat s = zkw.getRecoverableZooKeeper().exists(znode, zkw);
 boolean exists = s != null ? true : false;
 if (exists) {

代码示例来源:origin: alibaba/wasp

/**
 * Get znode data. Does not set a watcher.
 *
 * @return ZNode data, null if the node does not exist or if there is an
 *         error.
 */
public static byte[] getData(ZooKeeperWatcher zkw, String znode)
  throws KeeperException {
 try {
  byte[] data = zkw.getRecoverableZooKeeper().getData(znode, null, null);
  logRetrievedMsg(zkw, znode, data, false);
  return data;
 } catch (KeeperException.NoNodeException e) {
  LOG.debug(zkw.prefix("Unable to get data of znode " + znode + " "
    + "because node does not exist (not an error)"));
  return null;
 } catch (KeeperException e) {
  LOG.warn(zkw.prefix("Unable to get data of znode " + znode), e);
  zkw.keeperException(e);
  return null;
 } catch (InterruptedException e) {
  LOG.warn(zkw.prefix("Unable to get data of znode " + znode), e);
  zkw.interruptedException(e);
  return null;
 }
}

代码示例来源:origin: alibaba/wasp

/**
 * Delete the specified node and all of it's children.
 * <p>
 * If the node does not exist, just returns.
 * <p>
 * Sets no watches. Throws all exceptions besides dealing with deletion of
 * children.
 */
public static void deleteNodeRecursively(ZooKeeperWatcher zkw, String node)
  throws KeeperException {
 try {
  List<String> children = ZKUtil.listChildrenNoWatch(zkw, node);
  // the node is already deleted, so we just finish
  if (children == null)
   return;
  if (!children.isEmpty()) {
   for (String child : children) {
    deleteNodeRecursively(zkw, joinZNode(node, child));
   }
  }
  zkw.getRecoverableZooKeeper().delete(node, -1);
 } catch (InterruptedException ie) {
  zkw.interruptedException(ie);
 }
}

代码示例来源:origin: alibaba/wasp

/**
 * Check if the specified node exists. Sets no watches.
 *
 * @param zkw
 *          zk reference
 * @param znode
 *          path of node to watch
 * @return version of the node if it exists, -1 if does not exist
 * @throws org.apache.zookeeper.KeeperException
 *           if unexpected zookeeper exception
 */
public static int checkExists(ZooKeeperWatcher zkw, String znode)
  throws KeeperException {
 try {
  Stat s = zkw.getRecoverableZooKeeper().exists(znode, null);
  return s != null ? s.getVersion() : -1;
 } catch (KeeperException e) {
  LOG.warn(zkw.prefix("Unable to set watcher on znode (" + znode + ")"), e);
  zkw.keeperException(e);
  return -1;
 } catch (InterruptedException e) {
  LOG.warn(zkw.prefix("Unable to set watcher on znode (" + znode + ")"), e);
  zkw.interruptedException(e);
  return -1;
 }
}

代码示例来源:origin: alibaba/wasp

/**
 * Get the number of children of the specified node.
 *
 * If the node does not exist or has no children, returns 0.
 *
 * Sets no watches at all.
 *
 * @param zkw
 *          zk reference
 * @param znode
 *          path of node to count children of
 * @return number of children of specified node, 0 if none or parent does not
 *         exist
 * @throws org.apache.zookeeper.KeeperException
 *           if unexpected zookeeper exception
 */
public static int getNumberOfChildren(ZooKeeperWatcher zkw, String znode)
  throws KeeperException {
 try {
  Stat stat = zkw.getRecoverableZooKeeper().exists(znode, null);
  return stat == null ? 0 : stat.getNumChildren();
 } catch (KeeperException e) {
  LOG.warn(zkw.prefix("Unable to get children of node " + znode));
  zkw.keeperException(e);
 } catch (InterruptedException e) {
  zkw.interruptedException(e);
 }
 return 0;
}

代码示例来源:origin: alibaba/wasp

throws KeeperException {
try {
 RecoverableZooKeeper zk = zkw.getRecoverableZooKeeper();
 waitForZKConnectionIfAuthenticating(zkw);
 if (zk.exists(znode, false) == null) {
} catch (KeeperException.NoAuthException nee) {
 try {
  if (null == zkw.getRecoverableZooKeeper().exists(znode, false)) {

代码示例来源:origin: alibaba/wasp

Stat stat) throws KeeperException {
try {
 byte[] data = zkw.getRecoverableZooKeeper().getData(znode, null, stat);
 logRetrievedMsg(zkw, znode, data, false);
 return data;

代码示例来源:origin: alibaba/wasp

+ this.isa
  + ", sessionid=0x"
  + Long.toHexString(this.zooKeeper.getRecoverableZooKeeper()
    .getSessionId()));
isOnline = true;

代码示例来源:origin: alibaba/wasp

+ this.serverName
+ ", sessionid=0x"
+ Long.toHexString(this.zooKeeper.getRecoverableZooKeeper()
  .getSessionId()) + ", cluster-up flag was=" + wasUp);

代码示例来源:origin: alibaba/wasp

zkw.getRecoverableZooKeeper().create(znode, new byte[0],
   createACL(zkw, znode), CreateMode.PERSISTENT);
} catch (KeeperException.NodeExistsException nee) {

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