本文整理汇总了Java中org.apache.hadoop.hbase.zookeeper.ZKClusterId.readClusterIdZNode方法的典型用法代码示例。如果您正苦于以下问题:Java ZKClusterId.readClusterIdZNode方法的具体用法?Java ZKClusterId.readClusterIdZNode怎么用?Java ZKClusterId.readClusterIdZNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.hbase.zookeeper.ZKClusterId
的用法示例。
在下文中一共展示了ZKClusterId.readClusterIdZNode方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testClusterId
import org.apache.hadoop.hbase.zookeeper.ZKClusterId; //导入方法依赖的package包/类
@Test
public void testClusterId() throws Exception {
TEST_UTIL.startMiniZKCluster();
TEST_UTIL.startMiniDFSCluster(1);
Configuration conf = new Configuration(TEST_UTIL.getConfiguration());
CoordinatedStateManager cp = CoordinatedStateManagerFactory.getCoordinatedStateManager(conf);
//start region server, needs to be separate
//so we get an unset clusterId
rst = JVMClusterUtil.createRegionServerThread(conf,cp,
HRegionServer.class, 0);
rst.start();
//Make sure RS is in blocking state
Thread.sleep(10000);
TEST_UTIL.startMiniHBaseCluster(1, 1);
rst.waitForServerOnline();
String clusterId = ZKClusterId.readClusterIdZNode(TEST_UTIL.getZooKeeperWatcher());
assertNotNull(clusterId);
assertEquals(clusterId, rst.getRegionServer().getClusterId());
}
示例2: getAuthToken
import org.apache.hadoop.hbase.zookeeper.ZKClusterId; //导入方法依赖的package包/类
/**
* 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();
}
}
示例3: testClusterId
import org.apache.hadoop.hbase.zookeeper.ZKClusterId; //导入方法依赖的package包/类
@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());
}
示例4: getAuthToken
import org.apache.hadoop.hbase.zookeeper.ZKClusterId; //导入方法依赖的package包/类
/**
* 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();
}
}
示例5: testClusterId
import org.apache.hadoop.hbase.zookeeper.ZKClusterId; //导入方法依赖的package包/类
@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());
}
示例6: testClusterId
import org.apache.hadoop.hbase.zookeeper.ZKClusterId; //导入方法依赖的package包/类
@Test
public void testClusterId() throws Exception {
TEST_UTIL.startMiniZKCluster();
TEST_UTIL.startMiniDFSCluster(1);
Configuration conf = new Configuration(TEST_UTIL.getConfiguration());
CoordinatedStateManager cp = CoordinatedStateManagerFactory.getCoordinatedStateManager(conf);
//start region server, needs to be separate
//so we get an unset clusterId
rst = JVMClusterUtil.createRegionServerThread(conf,cp,
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());
}
示例7: testClusterId
import org.apache.hadoop.hbase.zookeeper.ZKClusterId; //导入方法依赖的package包/类
@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().getConfiguration().get(HConstants.CLUSTER_ID));
}
示例8: getAuthToken
import org.apache.hadoop.hbase.zookeeper.ZKClusterId; //导入方法依赖的package包/类
/**
* 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, "mr-init-credentials", null);
try {
String clusterId = ZKClusterId.readClusterIdZNode(zkw);
return new AuthenticationTokenSelector().selectToken(new Text(clusterId), user.getUGI().getTokens());
} catch (KeeperException e) {
throw new IOException(e);
} finally {
zkw.close();
}
}
示例9: initializeZooKeeper
import org.apache.hadoop.hbase.zookeeper.ZKClusterId; //导入方法依赖的package包/类
/**
* Bring up connection to zk ensemble and then wait until a master for this
* cluster and then after that, wait until cluster 'up' flag has been set.
* This is the order in which master does things.
* Finally put up a catalog tracker.
* @throws IOException
* @throws InterruptedException
*/
private void initializeZooKeeper() throws IOException, InterruptedException {
// Open connection to zookeeper and set primary watcher
this.zooKeeper = new ZooKeeperWatcher(conf, REGIONSERVER + ":" +
this.isa.getPort(), this);
// Create the master address manager, register with zk, and start it. Then
// block until a master is available. No point in starting up if no master
// running.
this.masterAddressManager = new MasterAddressTracker(this.zooKeeper, this);
this.masterAddressManager.start();
blockAndCheckIfStopped(this.masterAddressManager);
// Wait on cluster being up. Master will set this flag up in zookeeper
// when ready.
this.clusterStatusTracker = new ClusterStatusTracker(this.zooKeeper, this);
this.clusterStatusTracker.start();
blockAndCheckIfStopped(this.clusterStatusTracker);
// Create the catalog tracker and start it;
this.catalogTracker = new CatalogTracker(this.zooKeeper, this.conf,
this, this.conf.getInt("hbase.regionserver.catalog.timeout", 600000));
catalogTracker.start();
// Retrieve clusterId
// Since cluster status is now up
// ID should have already been set by HMaster
try {
String clusterId = ZKClusterId.readClusterIdZNode(this.zooKeeper);
if (clusterId == null) {
this.abort("Cluster ID has not been set");
}
this.conf.set(HConstants.CLUSTER_ID, clusterId);
LOG.info("ClusterId : "+clusterId);
} catch (KeeperException e) {
this.abort("Failed to retrieve Cluster ID",e);
}
}