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

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

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

ZKAssign.transitionNodeOpening介绍

[英]Transitions an existing unassigned node for the specified entityGroup which is currently in the OFFLINE state to be in the OPENING 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 written as OPENING is returned.

This method can fail and return -1 for three different reasons:

  • Unassigned node for this entityGroup does not exist
  • Unassigned node for this entityGroup is not in OFFLINE state
  • After verifying OFFLINE 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 FServer when initiating an open of a entityGroup after receiving an OPEN RPC from the Master.
[中]将当前处于脱机状态的指定entityGroup的现有未分配节点转换为打开状态。
不从其他状态转换节点。如果由于某种原因无法转换节点,该方法将返回-1。如果转换成功,则返回写为打开的节点版本。
由于三种不同的原因,此方法可能会失败并返回-1:
*此entityGroup的未分配节点不存在
*此entityGroup的未分配节点未处于脱机状态
*验证脱机状态后,更新因版本错误而失败(其他人已转换该节点)
不设置任何手表。
只有当FServer在从主服务器接收到打开的RPC后启动entityGroup的打开时,才应使用此方法。

代码示例

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

return transitionNodeOpening(zkw, entityGroup, serverName,
  EventType.M_ZK_ENTITYGROUP_OFFLINE);

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

/**
 * Creates a znode with OPENED state.
 *
 * @param TEST_UTIL
 * @param entityGroup
 * @param serverName
 * @return
 * @throws java.io.IOException
 * @throws ZooKeeperConnectionException
 * @throws org.apache.zookeeper.KeeperException
 * @throws org.apache.zookeeper.KeeperException.NodeExistsException
 */
public static ZooKeeperWatcher createAndForceNodeToOpenedState(
  WaspTestingUtility TEST_UTIL, EntityGroup entityGroup,
  ServerName serverName) throws ZooKeeperConnectionException, IOException,
  KeeperException, NodeExistsException {
 ZooKeeperWatcher zkw = getZooKeeperWatcher(TEST_UTIL);
 ZKAssign.createNodeOffline(zkw, entityGroup.getEntityGroupInfo(),
   serverName);
 int version = ZKAssign.transitionNodeOpening(zkw,
   entityGroup.getEntityGroupInfo(), serverName);
 ZKAssign.transitionNodeOpened(zkw, entityGroup.getEntityGroupInfo(),
   serverName, version);
 return zkw;
}

相关文章