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

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

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

ZKAssign.transitionNodeClosed介绍

[英]Transitions an existing unassigned node for the specified region which is currently in the CLOSING state to be in the CLOSED state.

Does not transition nodes from other states. If for some reason the node could not be transitioned, the method returns -1. If the transition is successful, the version of the node after transition is returned.

This method can fail and return false for three different reasons:

  • Unassigned node for this region does not exist
  • Unassigned node for this region is not in CLOSING state
  • After verifying CLOSING state, update fails because of wrong version (someone else already transitioned the node)

Does not set any watches.

This method should only be used by a RegionServer when initiating a close of a region after receiving a CLOSE RPC from the Master.
[中]将当前处于关闭状态的指定区域的现有未分配节点转换为关闭状态。
不从其他状态转换节点。如果由于某种原因无法转换节点,该方法将返回-1。如果转换成功,则返回转换后的节点版本。
由于三种不同的原因,此方法可能会失败并返回false:
*此区域的未分配节点不存在
*此区域的未分配节点未处于关闭状态
*验证关闭状态后,更新因版本错误而失败(其他人已转换该节点)
不设置任何手表。
只有RegionServer在从主服务器接收到关闭RPC后启动区域关闭时,才应使用此方法。

代码示例

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

/**
 * Transition ZK node to CLOSED
 * @param expectedVersion
 * @return If the state is set successfully
 */
private boolean setClosedState(final int expectedVersion, final HRegion region) {
 try {
  if (ZKAssign.transitionNodeClosed(server.getZooKeeper(), regionInfo,
    server.getServerName(), expectedVersion) == FAILED) {
   LOG.warn("Completed the CLOSE of a region but when transitioning from " +
     " CLOSING to CLOSED got a version mismatch, someone else clashed " +
     "so now unassigning");
   region.close();
   return false;
  }
 } catch (NullPointerException e) {
  // I've seen NPE when table was deleted while close was running in unit tests.
  LOG.warn("NPE during close -- catching and continuing...", e);
  return false;
 } catch (KeeperException e) {
  LOG.error("Failed transitioning node from CLOSING to CLOSED", e);
  return false;
 } catch (IOException e) {
  LOG.error("Failed to close region after failing to transition", e);
  return false;
 }
 return true;
}

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

if (ZKAssign.transitionNodeClosed(watcher, region.getRegionInfo(),
 sn, expectedVersion) == FAILED_VERSION) {
 LOG.warn("Completed the CLOSE of a region but when transitioning from " +

相关文章