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

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

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

ZKClusterId.readClusterIdZNode介绍

暂无

代码示例

代码示例来源:origin: apache/hbase

/**
  * Get the UUID for the provided ZK watcher. Doesn't handle any ZK exceptions
  * @param zkw watcher connected to an ensemble
  * @return the UUID read from zookeeper
  * @throws KeeperException if a ZooKeeper operation fails
  */
 public static UUID getUUIDForCluster(ZKWatcher zkw) throws KeeperException {
  String uuid = readClusterIdZNode(zkw);
  return uuid == null ? null : UUID.fromString(uuid);
 }
}

代码示例来源:origin: apache/hbase

public String getId() {
 try {
  if (id == null) {
   id = readClusterIdZNode(watcher);
  }
 } catch (KeeperException ke) {
  abortable.abort("Unexpected exception from ZooKeeper reading cluster ID",
    ke);
 }
 return id;
}

代码示例来源:origin: apache/hbase

/**
 * Get the authentication token of the user for the cluster specified in the configuration
 * @return null if the user does not have the token, otherwise the auth token for the cluster.
 */
private static Token<AuthenticationTokenIdentifier> getAuthToken(Configuration conf, User user)
  throws IOException, InterruptedException {
 ZKWatcher zkw = new ZKWatcher(conf, "TokenUtil-getAuthToken", null);
 try {
  String clusterId = ZKClusterId.readClusterIdZNode(zkw);
  if (clusterId == null) {
   throw new IOException("Failed to get cluster ID");
  }
  return new AuthenticationTokenSelector().selectToken(new Text(clusterId), user.getTokens());
 } catch (KeeperException e) {
  throw new IOException(e);
 } finally {
  zkw.close();
 }
}

代码示例来源:origin: apache/hbase

clusterId = ZKClusterId.readClusterIdZNode(this.zooKeeper);
if (clusterId == null) {
 this.abort("Cluster ID has not been set");

代码示例来源:origin: apache/hbase

@Test
public void testClusterId() throws Exception  {
 TEST_UTIL.startMiniZKCluster();
 TEST_UTIL.startMiniDFSCluster(1);
 Configuration conf = new Configuration(TEST_UTIL.getConfiguration());
 //start region server, needs to be separate
 //so we get an unset clusterId
 rst = JVMClusterUtil.createRegionServerThread(conf, HRegionServer.class, 0);
 rst.start();
 //Make sure RS is in blocking state
 Thread.sleep(10000);
 StartMiniClusterOption option = StartMiniClusterOption.builder()
   .numMasters(1).numRegionServers(0).build();
 TEST_UTIL.startMiniHBaseCluster(option);
 rst.waitForServerOnline();
 String clusterId = ZKClusterId.readClusterIdZNode(TEST_UTIL.getZooKeeperWatcher());
 assertNotNull(clusterId);
 assertEquals(clusterId, rst.getRegionServer().getClusterId());
}

代码示例来源:origin: org.apache.hbase/hbase-zookeeper

/**
  * Get the UUID for the provided ZK watcher. Doesn't handle any ZK exceptions
  * @param zkw watcher connected to an ensemble
  * @return the UUID read from zookeeper
  * @throws KeeperException if a ZooKeeper operation fails
  */
 public static UUID getUUIDForCluster(ZKWatcher zkw) throws KeeperException {
  String uuid = readClusterIdZNode(zkw);
  return uuid == null ? null : UUID.fromString(uuid);
 }
}

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

/**
  * Get the UUID for the provided ZK watcher. Doesn't handle any ZK exceptions
  * @param zkw watcher connected to an ensemble
  * @return the UUID read from zookeeper
  * @throws KeeperException
  */
 public static UUID getUUIDForCluster(ZooKeeperWatcher zkw) throws KeeperException {
  String uuid = readClusterIdZNode(zkw);
  return uuid == null ? null : UUID.fromString(uuid);
 }
}

代码示例来源:origin: org.apache.hbase/hbase-zookeeper

public String getId() {
 try {
  if (id == null) {
   id = readClusterIdZNode(watcher);
  }
 } catch (KeeperException ke) {
  abortable.abort("Unexpected exception from ZooKeeper reading cluster ID",
    ke);
 }
 return id;
}

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

public String getId() {
 try {
  if (id == null) {
   id = readClusterIdZNode(watcher);
  }
 } catch (KeeperException ke) {
  abortable.abort("Unexpected exception from ZooKeeper reading cluster ID",
    ke);
 }
 return id;
}

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

/**
  * Get the authentication token of the user for the cluster specified in the configuration
  * @return null if the user does not have the token, otherwise the auth token for the cluster.
  */
 private static Token<AuthenticationTokenIdentifier> getAuthToken(Configuration conf, User user)
   throws IOException, InterruptedException {
  ZooKeeperWatcher zkw = new ZooKeeperWatcher(conf, "TokenUtil-getAuthToken", null);
  try {
   String clusterId = ZKClusterId.readClusterIdZNode(zkw);
   if (clusterId == null) {
    throw new IOException("Failed to get cluster ID");
   }
   return new AuthenticationTokenSelector().selectToken(new Text(clusterId), user.getTokens());
  } catch (KeeperException e) {
   throw new IOException(e);
  } finally {
   zkw.close();
  }
 }
}

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

@Override
public String getClusterId() {
 if (this.clusterId != null) return this.clusterId;
 // No synchronized here, worse case we will retrieve it twice, that's
 //  not an issue.
 ZooKeeperKeepAliveConnection zkw = null;
 try {
  zkw = hci.getKeepAliveZooKeeperWatcher();
  this.clusterId = ZKClusterId.readClusterIdZNode(zkw);
  if (this.clusterId == null) {
   LOG.info("ClusterId read in ZooKeeper is null");
  }
 } catch (KeeperException e) {
  LOG.warn("Can't retrieve clusterId from Zookeeper", e);
 } catch (IOException e) {
  LOG.warn("Can't retrieve clusterId from Zookeeper", e);
 } finally {
  if (zkw != null) zkw.close();
 }
 return this.clusterId;
}

代码示例来源:origin: org.apache.hbase/hbase-server

@Test
public void testClusterId() throws Exception  {
 TEST_UTIL.startMiniZKCluster();
 TEST_UTIL.startMiniDFSCluster(1);
 Configuration conf = new Configuration(TEST_UTIL.getConfiguration());
 //start region server, needs to be separate
 //so we get an unset clusterId
 rst = JVMClusterUtil.createRegionServerThread(conf, HRegionServer.class, 0);
 rst.start();
 //Make sure RS is in blocking state
 Thread.sleep(10000);
 TEST_UTIL.startMiniHBaseCluster(1, 0);
 rst.waitForServerOnline();
 String clusterId = ZKClusterId.readClusterIdZNode(TEST_UTIL.getZooKeeperWatcher());
 assertNotNull(clusterId);
 assertEquals(clusterId, rst.getRegionServer().getClusterId());
}

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

clusterId = ZKClusterId.readClusterIdZNode(this.zooKeeper);
if (clusterId == null) {
 this.abort("Cluster ID has not been set");

相关文章