本文整理汇总了Java中org.apache.hadoop.hbase.zookeeper.ZKClusterId类的典型用法代码示例。如果您正苦于以下问题:Java ZKClusterId类的具体用法?Java ZKClusterId怎么用?Java ZKClusterId使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ZKClusterId类属于org.apache.hadoop.hbase.zookeeper包,在下文中一共展示了ZKClusterId类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: setUp
import org.apache.hadoop.hbase.zookeeper.ZKClusterId; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
zkw = HBaseTestingUtility.getZooKeeperWatcher(utility);
String fakeRs1 = ZKUtil.joinZNode(zkw.rsZNode, "hostname1.example.org:1234");
try {
ZKClusterId.setClusterId(zkw, new ClusterId());
rp = ReplicationFactory.getReplicationPeers(zkw, conf, zkw);
rp.init();
rt = ReplicationFactory.getReplicationTracker(zkw, rp, conf, zkw, new DummyServer(fakeRs1));
} catch (Exception e) {
fail("Exception during test setup: " + e);
}
rsRemovedCount = new AtomicInteger(0);
rsRemovedData = "";
plChangedCount = new AtomicInteger(0);
plChangedData = new ArrayList<String>();
peerRemovedCount = new AtomicInteger(0);
peerRemovedData = "";
}
开发者ID:fengchen8086,项目名称:ditb,代码行数:20,代码来源:TestReplicationTrackerZKImpl.java
示例2: 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());
}
开发者ID:fengchen8086,项目名称:ditb,代码行数:24,代码来源:TestClusterId.java
示例3: 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();
}
}
开发者ID:fengchen8086,项目名称:ditb,代码行数:20,代码来源:TokenUtil.java
示例4: 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());
}
开发者ID:tenggyut,项目名称:HIndex,代码行数:23,代码来源:TestClusterId.java
示例5: 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();
}
}
开发者ID:apache,项目名称:hbase,代码行数:20,代码来源:TokenUtil.java
示例6: setUp
import org.apache.hadoop.hbase.zookeeper.ZKClusterId; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
zkw = HBaseTestingUtility.getZooKeeperWatcher(utility);
String fakeRs1 = ZNodePaths.joinZNode(zkw.znodePaths.rsZNode, "hostname1.example.org:1234");
try {
ZKClusterId.setClusterId(zkw, new ClusterId());
rp = ReplicationFactory.getReplicationPeers(zkw, conf);
rp.init();
rt = ReplicationFactory.getReplicationTracker(zkw, new DummyServer(fakeRs1),
new DummyServer(fakeRs1));
} catch (Exception e) {
fail("Exception during test setup: " + e);
}
rsRemovedCount = new AtomicInteger(0);
rsRemovedData = "";
}
开发者ID:apache,项目名称:hbase,代码行数:17,代码来源:TestReplicationTrackerZKImpl.java
示例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().getClusterId());
}
开发者ID:apache,项目名称:hbase,代码行数:22,代码来源:TestClusterId.java
示例8: 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());
}
开发者ID:shenli-uiuc,项目名称:PyroDB,代码行数:24,代码来源:TestClusterId.java
示例9: setupBeforeClass
import org.apache.hadoop.hbase.zookeeper.ZKClusterId; //导入依赖的package包/类
@BeforeClass
public static void setupBeforeClass() throws Exception {
TEST_UTIL = new HBaseTestingUtility();
TEST_UTIL.startMiniZKCluster();
// security settings only added after startup so that ZK does not require SASL
Configuration conf = TEST_UTIL.getConfiguration();
conf.set("hadoop.security.authentication", "kerberos");
conf.set("hbase.security.authentication", "kerberos");
server = new TokenServer(conf);
serverThread = new Thread(server);
Threads.setDaemonThreadRunning(serverThread,
"TokenServer:"+server.getServerName().toString());
// wait for startup
while (!server.isStarted() && !server.isStopped()) {
Thread.sleep(10);
}
ZKClusterId.setClusterId(server.getZooKeeper(), clusterId);
secretManager = (AuthenticationTokenSecretManager)server.getSecretManager();
while(secretManager.getCurrentKey() == null) {
Thread.sleep(1);
}
}
开发者ID:daidong,项目名称:DominoHBase,代码行数:24,代码来源:TestTokenAuthentication.java
示例10: 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));
}
开发者ID:daidong,项目名称:DominoHBase,代码行数:23,代码来源:TestClusterId.java
示例11: getPeerUUID
import org.apache.hadoop.hbase.zookeeper.ZKClusterId; //导入依赖的package包/类
@Override
// Synchronize peer cluster connection attempts to avoid races and rate
// limit connections when multiple replication sources try to connect to
// the peer cluster. If the peer cluster is down we can get out of control
// over time.
public synchronized UUID getPeerUUID() {
UUID peerUUID = null;
try {
peerUUID = ZKClusterId.getUUIDForCluster(zkw);
} catch (KeeperException ke) {
reconnect(ke);
}
return peerUUID;
}
开发者ID:fengchen8086,项目名称:ditb,代码行数:15,代码来源:HBaseReplicationEndpoint.java
示例12: AuthenticationTokenSecretManager
import org.apache.hadoop.hbase.zookeeper.ZKClusterId; //导入依赖的package包/类
/**
* Create a new secret manager instance for generating keys.
* @param conf Configuration to use
* @param zk Connection to zookeeper for handling leader elections
* @param keyUpdateInterval Time (in milliseconds) between rolling a new master key for token signing
* @param tokenMaxLifetime Maximum age (in milliseconds) before a token expires and is no longer valid
*/
/* TODO: Restrict access to this constructor to make rogues instances more difficult.
* For the moment this class is instantiated from
* org.apache.hadoop.hbase.ipc.SecureServer so public access is needed.
*/
public AuthenticationTokenSecretManager(Configuration conf,
ZooKeeperWatcher zk, String serverName,
long keyUpdateInterval, long tokenMaxLifetime) {
this.zkWatcher = new ZKSecretWatcher(conf, zk, this);
this.keyUpdateInterval = keyUpdateInterval;
this.tokenMaxLifetime = tokenMaxLifetime;
this.leaderElector = new LeaderElector(zk, serverName);
this.name = NAME_PREFIX+serverName;
this.clusterId = new ZKClusterId(zk, zk);
}
开发者ID:fengchen8086,项目名称:ditb,代码行数:22,代码来源:AuthenticationTokenSecretManager.java
示例13: initPeerClusterState
import org.apache.hadoop.hbase.zookeeper.ZKClusterId; //导入依赖的package包/类
private static String initPeerClusterState(String baseZKNode)
throws IOException, KeeperException {
// Add a dummy region server and set up the cluster id
Configuration testConf = new Configuration(conf);
testConf.set(HConstants.ZOOKEEPER_ZNODE_PARENT, baseZKNode);
ZooKeeperWatcher zkw1 = new ZooKeeperWatcher(testConf, "test1", null);
String fakeRs = ZKUtil.joinZNode(zkw1.rsZNode, "hostname1.example.org:1234");
ZKUtil.createWithParents(zkw1, fakeRs);
ZKClusterId.setClusterId(zkw1, new ClusterId());
return ZKConfig.getZooKeeperClusterKey(testConf);
}
开发者ID:fengchen8086,项目名称:ditb,代码行数:12,代码来源:TestReplicationStateZKImpl.java
示例14: setupBeforeClass
import org.apache.hadoop.hbase.zookeeper.ZKClusterId; //导入依赖的package包/类
@BeforeClass
public static void setupBeforeClass() throws Exception {
TEST_UTIL = new HBaseTestingUtility();
TEST_UTIL.startMiniZKCluster();
// register token type for protocol
SecurityInfo.addInfo(AuthenticationProtos.AuthenticationService.getDescriptor().getName(),
new SecurityInfo("hbase.test.kerberos.principal",
AuthenticationProtos.TokenIdentifier.Kind.HBASE_AUTH_TOKEN));
// security settings only added after startup so that ZK does not require SASL
Configuration conf = TEST_UTIL.getConfiguration();
conf.set("hadoop.security.authentication", "kerberos");
conf.set("hbase.security.authentication", "kerberos");
conf.setBoolean(HADOOP_SECURITY_AUTHORIZATION, true);
server = new TokenServer(conf);
serverThread = new Thread(server);
Threads.setDaemonThreadRunning(serverThread, "TokenServer:"+server.getServerName().toString());
// wait for startup
while (!server.isStarted() && !server.isStopped()) {
Thread.sleep(10);
}
server.rpcServer.refreshAuthManager(new PolicyProvider() {
@Override
public Service[] getServices() {
return new Service [] {
new Service("security.client.protocol.acl",
AuthenticationProtos.AuthenticationService.BlockingInterface.class)};
}
});
ZKClusterId.setClusterId(server.getZooKeeper(), clusterId);
secretManager = (AuthenticationTokenSecretManager)server.getSecretManager();
while(secretManager.getCurrentKey() == null) {
Thread.sleep(1);
}
}
开发者ID:fengchen8086,项目名称:ditb,代码行数:35,代码来源:TestTokenAuthentication.java
示例15: initPeerClusterState
import org.apache.hadoop.hbase.zookeeper.ZKClusterId; //导入依赖的package包/类
private static String initPeerClusterState(String baseZKNode)
throws IOException, KeeperException {
// Add a dummy region server and set up the cluster id
Configuration testConf = new Configuration(conf);
testConf.set(HConstants.ZOOKEEPER_ZNODE_PARENT, baseZKNode);
ZooKeeperWatcher zkw1 = new ZooKeeperWatcher(testConf, "test1", null);
String fakeRs = ZKUtil.joinZNode(zkw1.rsZNode, "hostname1.example.org:1234");
ZKUtil.createWithParents(zkw1, fakeRs);
ZKClusterId.setClusterId(zkw1, new ClusterId());
return ZKUtil.getZooKeeperClusterKey(testConf);
}
开发者ID:grokcoder,项目名称:pbase,代码行数:12,代码来源:TestReplicationStateZKImpl.java
示例16: 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();
}
}
开发者ID:tenggyut,项目名称:HIndex,代码行数:17,代码来源:TableMapReduceUtil.java
示例17: getPeerUUID
import org.apache.hadoop.hbase.zookeeper.ZKClusterId; //导入依赖的package包/类
@Override
public UUID getPeerUUID(String peerId) {
ReplicationPeer peer = this.peerClusters.get(peerId);
if (peer == null) {
return null;
}
UUID peerUUID = null;
try {
peerUUID = ZKClusterId.getUUIDForCluster(peer.getZkw());
} catch (KeeperException ke) {
reconnectPeer(ke, peer);
}
return peerUUID;
}
开发者ID:tenggyut,项目名称:HIndex,代码行数:15,代码来源:ReplicationPeersZKImpl.java
示例18: initPeerClusterState
import org.apache.hadoop.hbase.zookeeper.ZKClusterId; //导入依赖的package包/类
private static String initPeerClusterState(String baseZKNode)
throws IOException, KeeperException {
// Add a dummy region server and set up the cluster id
Configuration testConf = new Configuration(conf);
testConf.set(HConstants.ZOOKEEPER_ZNODE_PARENT, baseZKNode);
ZKWatcher zkw1 = new ZKWatcher(testConf, "test1", null);
String fakeRs = ZNodePaths.joinZNode(zkw1.znodePaths.rsZNode, "hostname1.example.org:1234");
ZKUtil.createWithParents(zkw1, fakeRs);
ZKClusterId.setClusterId(zkw1, new ClusterId());
return ZKConfig.getZooKeeperClusterKey(testConf);
}
开发者ID:apache,项目名称:hbase,代码行数:12,代码来源:TestReplicationStateZKImpl.java
示例19: AuthenticationTokenSecretManager
import org.apache.hadoop.hbase.zookeeper.ZKClusterId; //导入依赖的package包/类
/**
* Create a new secret manager instance for generating keys.
* @param conf Configuration to use
* @param zk Connection to zookeeper for handling leader elections
* @param keyUpdateInterval Time (in milliseconds) between rolling a new master key for token signing
* @param tokenMaxLifetime Maximum age (in milliseconds) before a token expires and is no longer valid
*/
/* TODO: Restrict access to this constructor to make rogues instances more difficult.
* For the moment this class is instantiated from
* org.apache.hadoop.hbase.ipc.SecureServer so public access is needed.
*/
public AuthenticationTokenSecretManager(Configuration conf,
ZKWatcher zk, String serverName,
long keyUpdateInterval, long tokenMaxLifetime) {
this.zkWatcher = new ZKSecretWatcher(conf, zk, this);
this.keyUpdateInterval = keyUpdateInterval;
this.tokenMaxLifetime = tokenMaxLifetime;
this.leaderElector = new LeaderElector(zk, serverName);
this.name = NAME_PREFIX+serverName;
this.clusterId = new ZKClusterId(zk, zk);
}
开发者ID:apache,项目名称:hbase,代码行数:22,代码来源:AuthenticationTokenSecretManager.java
示例20: setUp
import org.apache.hadoop.hbase.zookeeper.ZKClusterId; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
TEST_UTIL = new HBaseTestingUtility();
TEST_UTIL.startMiniZKCluster();
// register token type for protocol
SecurityInfo.addInfo(AuthenticationProtos.AuthenticationService.getDescriptor().getName(),
new SecurityInfo("hbase.test.kerberos.principal",
AuthenticationProtos.TokenIdentifier.Kind.HBASE_AUTH_TOKEN));
// security settings only added after startup so that ZK does not require SASL
Configuration conf = TEST_UTIL.getConfiguration();
conf.set("hadoop.security.authentication", "kerberos");
conf.set("hbase.security.authentication", "kerberos");
conf.setBoolean(HADOOP_SECURITY_AUTHORIZATION, true);
conf.set(RpcServerFactory.CUSTOM_RPC_SERVER_IMPL_CONF_KEY, rpcServerImpl);
server = new TokenServer(conf, TEST_UTIL);
serverThread = new Thread(server);
Threads.setDaemonThreadRunning(serverThread, "TokenServer:"+server.getServerName().toString());
// wait for startup
while (!server.isStarted() && !server.isStopped()) {
Thread.sleep(10);
}
server.rpcServer.refreshAuthManager(new PolicyProvider() {
@Override
public Service[] getServices() {
return new Service [] {
new Service("security.client.protocol.acl",
AuthenticationProtos.AuthenticationService.BlockingInterface.class)};
}
});
ZKClusterId.setClusterId(server.getZooKeeper(), clusterId);
secretManager = (AuthenticationTokenSecretManager)server.getSecretManager();
while(secretManager.getCurrentKey() == null) {
Thread.sleep(1);
}
}
开发者ID:apache,项目名称:hbase,代码行数:36,代码来源:TestTokenAuthentication.java
注:本文中的org.apache.hadoop.hbase.zookeeper.ZKClusterId类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论