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

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

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

ZKAssign.transitionNodeOpened介绍

[英]Transitions an existing unassigned node for the specified region which is currently in the OPENING state to be in the OPENED 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 OPENING state
  • After verifying OPENING state, update fails because of wrong version (this should never actually happen since an RS only does this transition following a transition to OPENING. if two RS are conflicting, one would fail the original transition to OPENING and not this transition)

Does not set any watches.

This method should only be used by a RegionServer when completing the open of a region.
[中]将当前处于打开状态的指定区域的现有未分配节点转换为处于打开状态。
不从其他状态转换节点。如果由于某种原因无法转换节点,该方法将返回-1。如果转换成功,则返回转换后的节点版本。
由于三种不同的原因,此方法可能会失败并返回false:
*此区域的未分配节点不存在
*此区域的未分配节点未处于打开状态
*验证打开状态后,由于版本错误,更新失败(这实际上不应该发生,因为RS只会在转换到打开后进行此转换。如果两个RS冲突,则其中一个会失败到打开的原始转换,而不是此转换)
不设置任何手表。
此方法只能由RegionServer在完成区域打开时使用。

代码示例

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

  1. /**
  2. * @param r Region we're working on.
  3. * @return whether znode is successfully transitioned to OPENED state.
  4. * @throws IOException
  5. */
  6. private boolean transitionToOpened(final HRegion r) throws IOException {
  7. boolean result = false;
  8. HRegionInfo hri = r.getRegionInfo();
  9. final String name = hri.getRegionNameAsString();
  10. // Finally, Transition ZK node to OPENED
  11. try {
  12. if (ZKAssign.transitionNodeOpened(this.server.getZooKeeper(), hri,
  13. this.server.getServerName(), this.version) == -1) {
  14. LOG.warn("Completed the OPEN of region " + name +
  15. " but when transitioning from " +
  16. " OPENING to OPENED got a version mismatch, someone else clashed " +
  17. "so now unassigning -- closing region on server: " +
  18. this.server.getServerName());
  19. } else {
  20. LOG.debug("region transitioned to opened in zookeeper: " +
  21. r.getRegionInfo() + ", server: " + this.server.getServerName());
  22. result = true;
  23. }
  24. } catch (KeeperException e) {
  25. LOG.error("Failed transitioning node " + name +
  26. " from OPENING to OPENED -- closing region", e);
  27. }
  28. return result;
  29. }

代码示例来源:origin: NGDATA/lilyproject

  1. /**
  2. * Creates a znode with OPENED state.
  3. */
  4. public static ZooKeeperWatcher createAndForceNodeToOpenedState(
  5. HBaseTestingUtility TEST_UTIL, HRegion region,
  6. ServerName serverName) throws ZooKeeperConnectionException,
  7. IOException, KeeperException, NodeExistsException {
  8. ZooKeeperWatcher zkw = getZooKeeperWatcher(TEST_UTIL);
  9. ZKAssign.createNodeOffline(zkw, region.getRegionInfo(), serverName);
  10. int version = ZKAssign.transitionNodeOpening(zkw, region
  11. .getRegionInfo(), serverName);
  12. ZKAssign.transitionNodeOpened(zkw, region.getRegionInfo(), serverName,
  13. version);
  14. return zkw;
  15. }

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

  1. if (ZKAssign.transitionNodeOpened(watcher, hri,
  2. zkOrd.getServerName(), zkOrd.getVersion()) == -1) {
  3. String warnMsg = "Completed the OPEN of region " + name +

相关文章