gpt4 book ai didi

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

转载 作者:知者 更新时间:2024-03-15 01:36:49 25 4
gpt4 key购买 nike

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

ZooKeeperWatcher.prefix介绍

[英]Adds this instance's identifier as a prefix to the passed str
[中]将此实例的标识符作为前缀添加到传递的str

代码示例

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

/**
 * Handles KeeperExceptions in client calls.
 * <p>
 * This may be temporary but for now this gives one place to deal with these.
 * <p>
 * TODO: Currently this method rethrows the exception to let the caller handle
 * <p>
 * @param ke
 * @throws KeeperException
 */
public void keeperException(KeeperException ke)
throws KeeperException {
 LOG.error(prefix("Received unexpected KeeperException, re-throwing exception"), ke);
 throw ke;
}

代码示例来源:origin: com.aliyun.hbase/alihbase-client

/**
 * Handles KeeperExceptions in client calls.
 * <p>
 * This may be temporary but for now this gives one place to deal with these.
 * <p>
 * TODO: Currently this method rethrows the exception to let the caller handle
 * <p>
 * @param ke
 * @throws KeeperException
 */
public void keeperException(KeeperException ke)
throws KeeperException {
 LOG.error(prefix("Received unexpected KeeperException, re-throwing exception"), ke);
 throw ke;
}

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

/**
 * Handles InterruptedExceptions in client calls.
 * <p>
 * This may be temporary but for now this gives one place to deal with these.
 * <p>
 * TODO: Currently, this method does nothing.
 *       Is this ever expected to happen?  Do we abort or can we let it run?
 *       Maybe this should be logged as WARN?  It shouldn't happen?
 * <p>
 * @param ie
 */
public void interruptedException(InterruptedException ie) {
 LOG.debug(prefix("Received InterruptedException, doing nothing here"), ie);
 // At least preserver interrupt.
 Thread.currentThread().interrupt();
 // no-op
}

代码示例来源:origin: com.aliyun.hbase/alihbase-client

/**
 * Handles InterruptedExceptions in client calls.
 * <p>
 * This may be temporary but for now this gives one place to deal with these.
 * <p>
 * TODO: Currently, this method does nothing.
 *       Is this ever expected to happen?  Do we abort or can we let it run?
 *       Maybe this should be logged as WARN?  It shouldn't happen?
 * <p>
 * @param ie
 */
public void interruptedException(InterruptedException ie) {
 LOG.debug(prefix("Received InterruptedException, doing nothing here"), ie);
 // At least preserver interrupt.
 Thread.currentThread().interrupt();
 // no-op
}

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

/**
 * Handles KeeperExceptions in client calls.
 * <p>
 * This may be temporary but for now this gives one place to deal with these.
 * <p>
 * TODO: Currently this method rethrows the exception to let the caller handle
 * <p>
 * @param ke
 * @throws KeeperException
 */
public void keeperException(KeeperException ke)
throws KeeperException {
 LOG.error(prefix("Received unexpected KeeperException, re-throwing exception"), ke);
 throw ke;
}

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

/**
 * Deletes all unassigned nodes regardless of their state.
 *
 * <p>No watchers are set.
 *
 * <p>This method is used by the Master during cluster startup to clear out
 * any existing state from other cluster runs.
 *
 * @param zkw zk reference
 * @throws KeeperException if unexpected zookeeper exception
 */
public static void deleteAllNodes(ZooKeeperWatcher zkw)
throws KeeperException {
 LOG.debug(zkw.prefix("Deleting any existing unassigned nodes"));
 ZKUtil.deleteChildrenRecursively(zkw, zkw.assignmentZNode);
}

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

/**
 * Handles InterruptedExceptions in client calls.
 * <p>
 * This may be temporary but for now this gives one place to deal with these.
 * <p>
 * TODO: Currently, this method does nothing.
 *       Is this ever expected to happen?  Do we abort or can we let it run?
 *       Maybe this should be logged as WARN?  It shouldn't happen?
 * <p>
 * @param ie
 */
public void interruptedException(InterruptedException ie) {
 LOG.debug(prefix("Received InterruptedException, doing nothing here"), ie);
 // At least preserver interrupt.
 Thread.currentThread().interrupt();
 // no-op
}

代码示例来源:origin: com.aliyun.hbase/alihbase-client

/**
  * 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, InterruptedException {
  try {
   byte [] data = zkw.getRecoverableZooKeeper2().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;
  }
 }

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

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) {
  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: co.cask.hbase/hbase

private static void logRetrievedMsg(final ZooKeeperWatcher zkw,
  final String znode, final byte [] data, final boolean watcherSet) {
 if (!LOG.isDebugEnabled()) return;
 LOG.debug(zkw.prefix("Retrieved " + ((data == null)? 0: data.length) +
  " byte(s) of data from znode " + znode +
  (watcherSet? " and set watcher; ": "; data=") +
  (data == null? "null": data.length == 0? "empty": (
    znode.startsWith(zkw.assignmentZNode) ?
      RegionTransitionData.fromBytes(data).toString()
      : StringUtils.abbreviate(Bytes.toStringBinary(data), 32)))));
}

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

/**
 * Deletes all unassigned nodes regardless of their state.
 *
 * <p>No watchers are set.
 *
 * <p>This method is used by the Master during cluster startup to clear out
 * any existing state from other cluster runs.
 *
 * @param zkw zk reference
 * @throws KeeperException if unexpected zookeeper exception
 */
public static void deleteAllNodes(ZooKeeperWatcher zkw)
throws KeeperException {
 LOG.debug(zkw.prefix("Deleting any existing unassigned nodes"));
 ZKUtil.deleteChildrenRecursively(zkw, zkw.assignmentZNode);
}

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

/**
 * 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 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: com.aliyun.hbase/alihbase-client

/**
 * 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 KeeperException if unexpected zookeeper exception
 */
public static int checkExists(ZooKeeperWatcher zkw, String znode)
throws KeeperException {
 try {
  Stat s = zkw.getRecoverableZooKeeper2().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: co.cask.hbase/hbase

public void stop() {
  try {
   // If our address is in ZK, delete it on our way out
   byte [] bytes =
    ZKUtil.getDataAndWatch(watcher, watcher.masterAddressZNode);
   // TODO: redo this to make it atomic (only added for tests)
   ServerName master = bytes == null ? null : ServerName.parseVersionedServerName(bytes);
   if (master != null &&  master.equals(this.sn)) {
    ZKUtil.deleteNode(watcher, watcher.masterAddressZNode);
   }
  } catch (KeeperException e) {
   LOG.error(this.watcher.prefix("Error deleting our own master address node"), e);
  }
 }
}

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

private static void logRetrievedMsg(final ZooKeeperWatcher zkw,
  final String znode, final byte [] data, final boolean watcherSet) {
 if (!LOG.isTraceEnabled()) return;
 LOG.trace(zkw.prefix("Retrieved " + ((data == null)? 0: data.length) +
  " byte(s) of data from znode " + znode +
  (watcherSet? " and set watcher; ": "; data=") +
  (data == null? "null": data.length == 0? "empty": (
    znode.startsWith(zkw.assignmentZNode)?
     ZKAssign.toString(data): // We should not be doing this reaching into another class
    znode.startsWith(ZooKeeperWatcher.META_ZNODE_PREFIX)?
     getServerNameOrEmptyString(data):
    znode.startsWith(zkw.backupMasterAddressesZNode)?
     getServerNameOrEmptyString(data):
    StringUtils.abbreviate(Bytes.toStringBinary(data), 32)))));
}

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

public static void createNodeOffline(ZooKeeperWatcher zkw, HRegionInfo region,
  ServerName serverName, final EventType event)
throws KeeperException, KeeperException.NodeExistsException {
 LOG.debug(zkw.prefix("Creating unassigned node for " +
  region.getEncodedName() + " in OFFLINE state"));
 RegionTransitionData data = new RegionTransitionData(event,
  region.getRegionName(), serverName);
 String node = getNodeName(zkw, region.getEncodedName());
 ZKUtil.createAndWatch(zkw, node, data.getBytes());
}

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

public static void createNodeOffline(ZooKeeperWatcher zkw, HRegionInfo region,
  ServerName serverName, final EventType event)
throws KeeperException, KeeperException.NodeExistsException {
 LOG.debug(zkw.prefix("Creating unassigned node " +
  region.getEncodedName() + " in OFFLINE state"));
 RegionTransition rt =
  RegionTransition.createRegionTransition(event, region.getRegionName(), serverName);
 String node = getNodeName(zkw, region.getEncodedName());
 ZKUtil.createAndWatch(zkw, node, rt.toByteArray());
}

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

private void createBaseZNodes() throws ZooKeeperConnectionException {
 try {
  // Create all the necessary "directories" of znodes
  ZKUtil.createWithParents(this, baseZNode);
  if (conf.getBoolean("hbase.assignment.usezk", true)) {
   ZKUtil.createAndFailSilent(this, assignmentZNode);
  }
  ZKUtil.createAndFailSilent(this, rsZNode);
  ZKUtil.createAndFailSilent(this, drainingZNode);
  ZKUtil.createAndFailSilent(this, tableZNode);
  ZKUtil.createAndFailSilent(this, splitLogZNode);
  ZKUtil.createAndFailSilent(this, backupMasterAddressesZNode);
  ZKUtil.createAndFailSilent(this, tableLockZNode);
  ZKUtil.createAndFailSilent(this, recoveringRegionsZNode);
 } catch (KeeperException e) {
  throw new ZooKeeperConnectionException(
    prefix("Unexpected KeeperException creating base node"), e);
 }
}

代码示例来源:origin: com.aliyun.hbase/alihbase-client

private void createBaseZNodes() throws ZooKeeperConnectionException {
 try {
  // Create all the necessary "directories" of znodes
  ZKUtil2.createWithParents(this, baseZNode);
  if (conf.getBoolean("hbase.assignment.usezk", true)) {
   ZKUtil2.createAndFailSilent(this, assignmentZNode);
  }
  ZKUtil2.createAndFailSilent(this, rsZNode);
  ZKUtil2.createAndFailSilent(this, drainingZNode);
  ZKUtil2.createAndFailSilent(this, tableZNode);
  ZKUtil2.createAndFailSilent(this, splitLogZNode);
  ZKUtil2.createAndFailSilent(this, backupMasterAddressesZNode);
  ZKUtil2.createAndFailSilent(this, tableLockZNode);
  ZKUtil2.createAndFailSilent(this, recoveringRegionsZNode);
 } catch (KeeperException e) {
  throw new ZooKeeperConnectionException(
    prefix("Unexpected KeeperException creating base node"), e);
 }
}

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

private void createBaseZNodes() throws ZooKeeperConnectionException {
 try {
  // Create all the necessary "directories" of znodes
  ZKUtil.createAndFailSilent(this, baseZNode);
  ZKUtil.createAndFailSilent(this, assignmentZNode);
  ZKUtil.createAndFailSilent(this, rsZNode);
  ZKUtil.createAndFailSilent(this, drainingZNode);
  ZKUtil.createAndFailSilent(this, masterTableZNode);
  ZKUtil.createAndFailSilent(this, masterTableZNode92);
  ZKUtil.createAndFailSilent(this, splitLogZNode);
  ZKUtil.createAndFailSilent(this, backupMasterAddressesZNode);
 } catch (KeeperException e) {
  throw new ZooKeeperConnectionException(
    prefix("Unexpected KeeperException creating base node"), e);
 }
}

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