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

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

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

ZKAssign.getNodeName介绍

[英]Gets the full path node name for the unassigned node for the specified region.
[中]获取指定区域的未分配节点的完整路径节点名。

代码示例

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

  1. /**
  2. * @param zkw
  3. * @param pathOrRegionName
  4. * @return Path to znode
  5. */
  6. public static String getPath(final ZooKeeperWatcher zkw, final String pathOrRegionName) {
  7. return pathOrRegionName.startsWith("/")? pathOrRegionName : getNodeName(zkw, pathOrRegionName);
  8. }

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

  1. /**
  2. * Get the version of the specified znode
  3. * @param zkw zk reference
  4. * @param region region's info
  5. * @return the version of the znode, -1 if it doesn't exist
  6. * @throws KeeperException
  7. */
  8. public static int getVersion(ZooKeeperWatcher zkw, HRegionInfo region)
  9. throws KeeperException {
  10. String znode = getNodeName(zkw, region.getEncodedName());
  11. return ZKUtil.checkExists(zkw, znode);
  12. }

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

  1. /**
  2. * Get the version of the specified znode
  3. * @param zkw zk reference
  4. * @param region region's info
  5. * @return the version of the znode, -1 if it doesn't exist
  6. * @throws KeeperException
  7. */
  8. public static int getVersion(ZooKeeperWatcher zkw, HRegionInfo region)
  9. throws KeeperException {
  10. String znode = getNodeName(zkw, region.getEncodedName());
  11. return ZKUtil.checkExists(zkw, znode);
  12. }

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

  1. /**
  2. * Delete the assignment node regardless of its current state.
  3. * <p>
  4. * Fail silent even if the node does not exist at all.
  5. * @param watcher
  6. * @param regionInfo
  7. * @throws KeeperException
  8. */
  9. public static void deleteNodeFailSilent(ZooKeeperWatcher watcher,
  10. HRegionInfo regionInfo)
  11. throws KeeperException {
  12. String node = getNodeName(watcher, regionInfo.getEncodedName());
  13. ZKUtil.deleteNodeFailSilent(watcher, node);
  14. }

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

  1. /**
  2. * Delete the assignment node regardless of its current state.
  3. * <p>
  4. * Fail silent even if the node does not exist at all.
  5. * @param watcher
  6. * @param regionInfo
  7. * @throws KeeperException
  8. */
  9. public static void deleteNodeFailSilent(ZooKeeperWatcher watcher,
  10. HRegionInfo regionInfo)
  11. throws KeeperException {
  12. String node = getNodeName(watcher, regionInfo.getEncodedName());
  13. ZKUtil.deleteNodeFailSilent(watcher, node);
  14. }

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

  1. /**
  2. * Gets the current data in the unassigned node for the specified region name
  3. * or fully-qualified path.
  4. *
  5. * <p>Returns null if the region does not currently have a node.
  6. *
  7. * <p>Does not set a watch.
  8. *
  9. * @param zkw zk reference
  10. * @param pathOrRegionName fully-specified path or region name
  11. * @param stat object to store node info into on getData call
  12. * @return data for the unassigned node or null if node does not exist
  13. * @throws KeeperException if unexpected zookeeper exception
  14. */
  15. public static RegionTransitionData getDataNoWatch(ZooKeeperWatcher zkw,
  16. String pathOrRegionName, Stat stat)
  17. throws KeeperException {
  18. String node = pathOrRegionName.startsWith("/") ?
  19. pathOrRegionName : getNodeName(zkw, pathOrRegionName);
  20. byte [] data = ZKUtil.getDataNoWatch(zkw, node, stat);
  21. if (data == null) {
  22. return null;
  23. }
  24. return RegionTransitionData.fromBytes(data);
  25. }

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

  1. /**
  2. * Gets the current data in the unassigned node for the specified region name
  3. * or fully-qualified path.
  4. *
  5. * <p>Returns null if the region does not currently have a node.
  6. *
  7. * <p>Sets a watch on the node if the node exists.
  8. *
  9. * @param zkw zk reference
  10. * @param pathOrRegionName fully-specified path or region name
  11. * @return data for the unassigned node
  12. * @throws KeeperException if unexpected zookeeper exception
  13. */
  14. public static RegionTransitionData getData(ZooKeeperWatcher zkw,
  15. String pathOrRegionName)
  16. throws KeeperException {
  17. String node = pathOrRegionName.startsWith("/") ?
  18. pathOrRegionName : getNodeName(zkw, pathOrRegionName);
  19. byte [] data = ZKUtil.getDataAndWatch(zkw, node);
  20. if(data == null) {
  21. return null;
  22. }
  23. return RegionTransitionData.fromBytes(data);
  24. }

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

  1. /**
  2. * Gets the current data in the unassigned node for the specified region name
  3. * or fully-qualified path.
  4. *
  5. * <p>Returns null if the region does not currently have a node.
  6. *
  7. * <p>Sets a watch on the node if the node exists.
  8. *
  9. * @param zkw zk reference
  10. * @param pathOrRegionName fully-specified path or region name
  11. * @param stat object to populate the version.
  12. * @return data for the unassigned node
  13. * @throws KeeperException if unexpected zookeeper exception
  14. */
  15. public static RegionTransitionData getDataAndWatch(ZooKeeperWatcher zkw,
  16. String pathOrRegionName, Stat stat)
  17. throws KeeperException {
  18. String node = pathOrRegionName.startsWith("/") ?
  19. pathOrRegionName : getNodeName(zkw, pathOrRegionName);
  20. byte [] data = ZKUtil.getDataAndWatch(zkw, node, stat);
  21. if(data == null) {
  22. return null;
  23. }
  24. return RegionTransitionData.fromBytes(data);
  25. }

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

  1. String node = ZKAssign.getNodeName(watcher, regionInfo.getEncodedName());
  2. Stat stat = new Stat();
  3. RegionTransitionData dataInZNode = ZKAssign.getDataNoWatch(watcher, node,

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

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

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

  1. /**
  2. * Creates a new ephemeral node in the SPLITTING state for the specified region.
  3. * Create it ephemeral in case regionserver dies mid-split.
  4. *
  5. * <p>Does not transition nodes from other states. If a node already exists
  6. * for this region, a {@link NodeExistsException} will be thrown.
  7. *
  8. * @param zkw zk reference
  9. * @param region region to be created as offline
  10. * @param serverName server event originates from
  11. * @return Version of znode created.
  12. * @throws KeeperException
  13. * @throws IOException
  14. */
  15. void createNodeSplitting(final ZooKeeperWatcher zkw, final HRegionInfo region,
  16. final ServerName serverName) throws KeeperException, IOException {
  17. LOG.debug(zkw.prefix("Creating ephemeral node for " +
  18. region.getEncodedName() + " in SPLITTING state"));
  19. RegionTransitionData data =
  20. new RegionTransitionData(EventType.RS_ZK_REGION_SPLITTING,
  21. region.getRegionName(), serverName);
  22. String node = ZKAssign.getNodeName(zkw, region.getEncodedName());
  23. if (!ZKUtil.createEphemeralNodeAndWatch(zkw, node, data.getBytes())) {
  24. throw new IOException("Failed create of ephemeral " + node);
  25. }
  26. }

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

  1. /**
  2. * Creates an unassigned node in the OFFLINE state for the specified region.
  3. * <p>
  4. * Runs asynchronously. Depends on no pre-existing znode.
  5. *
  6. * <p>Sets a watcher on the unassigned region node.
  7. *
  8. * @param zkw zk reference
  9. * @param region region to be created as offline
  10. * @param serverName server event originates from
  11. * @param cb
  12. * @param ctx
  13. * @throws KeeperException if unexpected zookeeper exception
  14. * @throws KeeperException.NodeExistsException if node already exists
  15. */
  16. public static void asyncCreateNodeOffline(ZooKeeperWatcher zkw,
  17. HRegionInfo region, ServerName serverName,
  18. final AsyncCallback.StringCallback cb, final Object ctx)
  19. throws KeeperException {
  20. LOG.debug(zkw.prefix("Async create of unassigned node for " +
  21. region.getEncodedName() + " with OFFLINE state"));
  22. RegionTransitionData data = new RegionTransitionData(
  23. EventType.M_ZK_REGION_OFFLINE, region.getRegionName(), serverName);
  24. String node = getNodeName(zkw, region.getEncodedName());
  25. ZKUtil.asyncCreate(zkw, node, data.getBytes(), cb, ctx);
  26. }

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

  1. /**
  2. * Forces an existing unassigned node to the OFFLINE state for the specified
  3. * region.
  4. *
  5. * <p>Does not create a new node. If a node does not already exist for this
  6. * region, a {@link NoNodeException} will be thrown.
  7. *
  8. * <p>Sets a watcher on the unassigned region node if the method is
  9. * successful.
  10. *
  11. * <p>This method should only be used during recovery of regionserver failure.
  12. *
  13. * @param zkw zk reference
  14. * @param region region to be forced as offline
  15. * @param serverName server event originates from
  16. * @throws KeeperException if unexpected zookeeper exception
  17. * @throws KeeperException.NoNodeException if node does not exist
  18. */
  19. public static void forceNodeOffline(ZooKeeperWatcher zkw, HRegionInfo region,
  20. ServerName serverName)
  21. throws KeeperException, KeeperException.NoNodeException {
  22. LOG.debug(zkw.prefix("Forcing existing unassigned node for " +
  23. region.getEncodedName() + " to OFFLINE state"));
  24. RegionTransitionData data = new RegionTransitionData(
  25. EventType.M_ZK_REGION_OFFLINE, region.getRegionName(), serverName);
  26. String node = getNodeName(zkw, region.getEncodedName());
  27. ZKUtil.setData(zkw, node, data.getBytes());
  28. }

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

  1. EventType.M_ZK_REGION_CLOSING, region.getRegionName(), serverName);
  2. String node = getNodeName(zkw, region.getEncodedName());
  3. return ZKUtil.createAndWatch(zkw, node, data.getBytes());

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

  1. /**
  2. * Creates a new ephemeral node in the PENDING_MERGE state for the merged region.
  3. * Create it ephemeral in case regionserver dies mid-merge.
  4. *
  5. * <p>
  6. * Does not transition nodes from other states. If a node already exists for
  7. * this region, a {@link org.apache.zookeeper.KeeperException.NodeExistsException} will be thrown.
  8. *
  9. * @param region region to be created as offline
  10. * @param serverName server event originates from
  11. * @throws IOException
  12. */
  13. @Override
  14. public void startRegionMergeTransaction(final HRegionInfo region, final ServerName serverName,
  15. final HRegionInfo a, final HRegionInfo b) throws IOException {
  16. LOG.debug(watcher.prefix("Creating ephemeral node for " + region.getEncodedName()
  17. + " in PENDING_MERGE state"));
  18. byte[] payload = HRegionInfo.toDelimitedByteArray(region, a, b);
  19. RegionTransition rt =
  20. RegionTransition.createRegionTransition(RS_ZK_REQUEST_REGION_MERGE, region.getRegionName(),
  21. serverName, payload);
  22. String node = ZKAssign.getNodeName(watcher, region.getEncodedName());
  23. try {
  24. if (!ZKUtil.createEphemeralNodeAndWatch(watcher, node, rt.toByteArray())) {
  25. throw new IOException("Failed create of ephemeral " + node);
  26. }
  27. } catch (KeeperException e) {
  28. throw new IOException(e);
  29. }
  30. }

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

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

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

  1. RegionTransition.createRegionTransition(RS_ZK_REQUEST_REGION_SPLIT,
  2. region.getRegionName(), serverName, payload);
  3. String node = ZKAssign.getNodeName(watcher, region.getEncodedName());
  4. if (!ZKUtil.createEphemeralNodeAndWatch(watcher, node, rt.toByteArray())) {
  5. throw new IOException("Failed create of ephemeral " + node);

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

  1. /**
  2. * Creates an unassigned node in the OFFLINE state for the specified region.
  3. * <p>
  4. * Runs asynchronously. Depends on no pre-existing znode.
  5. *
  6. * <p>Sets a watcher on the unassigned region node.
  7. *
  8. * @param zkw zk reference
  9. * @param region region to be created as offline
  10. * @param serverName server transition will happen on
  11. * @param cb
  12. * @param ctx
  13. * @throws KeeperException if unexpected zookeeper exception
  14. * @throws KeeperException.NodeExistsException if node already exists
  15. */
  16. public static void asyncCreateNodeOffline(ZooKeeperWatcher zkw,
  17. HRegionInfo region, ServerName serverName,
  18. final AsyncCallback.StringCallback cb, final Object ctx)
  19. throws KeeperException {
  20. LOG.debug(zkw.prefix("Async create of unassigned node " +
  21. region.getEncodedName() + " with OFFLINE state"));
  22. RegionTransition rt =
  23. RegionTransition.createRegionTransition(
  24. EventType.M_ZK_REGION_OFFLINE, region.getRegionName(), serverName);
  25. String node = getNodeName(zkw, region.getEncodedName());
  26. ZKUtil.asyncCreate(zkw, node, rt.toByteArray(), cb, ctx);
  27. }

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

  1. RegionTransition rt = RegionTransition.createRegionTransition(EventType.M_ZK_REGION_CLOSING,
  2. region.getRegionName(), serverName, HConstants.EMPTY_BYTE_ARRAY);
  3. String node = getNodeName(zkw, region.getEncodedName());
  4. return ZKUtil.createAndWatch(zkw, node, rt.toByteArray());

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

  1. String node = ZKAssign.getNodeName(watcher, encodedName);
  2. Stat stat = new Stat();
  3. try {

相关文章