本文整理了Java中org.apache.hadoop.hbase.zookeeper.ZooKeeperHelper
类的一些代码示例,展示了ZooKeeperHelper
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZooKeeperHelper
类的具体详情如下:
包路径:org.apache.hadoop.hbase.zookeeper.ZooKeeperHelper
类名称:ZooKeeperHelper
[英]Methods that help working with ZooKeeper
[中]帮助与ZooKeeper合作的方法
代码示例来源:origin: apache/hbase
public HACK_UNTIL_ZOOKEEPER_1897_ZooKeeperMain(String[] args)
throws IOException, InterruptedException {
super(args);
// Make sure we are connected before we proceed. Can take a while on some systems. If we
// run the command without being connected, we get ConnectionLoss KeeperErrorConnection...
// Make it 30seconds. We dont' have a config in this context and zk doesn't have
// a timeout until after connection. 30000ms is default for zk.
ZooKeeperHelper.ensureConnectedZooKeeper(this.zk, 30000);
}
代码示例来源:origin: apache/hbase
@BeforeClass
public static void setUp() throws Exception {
PORT = UTIL.startMiniZKCluster().getClientPort();
ZooKeeper zk = ZooKeeperHelper.getConnectedZooKeeper("localhost:" + PORT, 10000);
DATA = new byte[10];
ThreadLocalRandom.current().nextBytes(DATA);
zk.create(PATH, DATA, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
for (int i = 0; i < CHILDREN; i++) {
zk.create(PATH + "/c" + i, new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
}
zk.close();
Configuration conf = UTIL.getConfiguration();
conf.set(HConstants.ZOOKEEPER_QUORUM, "localhost:" + PORT);
conf.setInt(ReadOnlyZKClient.RECOVERY_RETRY, 3);
conf.setInt(ReadOnlyZKClient.RECOVERY_RETRY_INTERVAL_MILLIS, 100);
conf.setInt(ReadOnlyZKClient.KEEPALIVE_MILLIS, 3000);
RO_ZK = new ReadOnlyZKClient(conf);
// only connect when necessary
assertNull(RO_ZK.zookeeper);
}
代码示例来源:origin: apache/hbase
getConnectedZooKeeper(ZKConfig.getZKQuorumServersString(TEST_UTIL.getConfiguration()),
60000);
代码示例来源:origin: apache/hbase
/**
* Get a ZooKeeper instance and wait until it connected before returning.
* @param sessionTimeoutMs Used as session timeout passed to the created ZooKeeper AND as the
* timeout to wait on connection establishment.
*/
public static ZooKeeper getConnectedZooKeeper(String connectString, int sessionTimeoutMs)
throws IOException {
ZooKeeper zookeeper = new ZooKeeper(connectString, sessionTimeoutMs, e -> {});
return ensureConnectedZooKeeper(zookeeper, sessionTimeoutMs);
}
代码示例来源:origin: com.aliyun.hbase/alihbase-zookeeper
@BeforeClass
public static void setUp() throws Exception {
PORT = UTIL.startMiniZKCluster().getClientPort();
ZooKeeper zk = ZooKeeperHelper.getConnectedZooKeeper("localhost:" + PORT, 10000);
DATA = new byte[10];
ThreadLocalRandom.current().nextBytes(DATA);
zk.create(PATH, DATA, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
for (int i = 0; i < CHILDREN; i++) {
zk.create(PATH + "/c" + i, new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
}
zk.close();
Configuration conf = UTIL.getConfiguration();
conf.set(HConstants.ZOOKEEPER_QUORUM, "localhost:" + PORT);
conf.setInt(ReadOnlyZKClient.RECOVERY_RETRY, 3);
conf.setInt(ReadOnlyZKClient.RECOVERY_RETRY_INTERVAL_MILLIS, 100);
conf.setInt(ReadOnlyZKClient.KEEPALIVE_MILLIS, 3000);
RO_ZK = new ReadOnlyZKClient(conf);
// only connect when necessary
assertNull(RO_ZK.zookeeper);
}
代码示例来源:origin: org.apache.hbase/hbase-client
/**
* Get a ZooKeeper instance and wait until it connected before returning.
* @param sessionTimeoutMs Used as session timeout passed to the created ZooKeeper AND as the
* timeout to wait on connection establishment.
*/
public static ZooKeeper getConnectedZooKeeper(String connectString, int sessionTimeoutMs)
throws IOException {
ZooKeeper zookeeper = new ZooKeeper(connectString, sessionTimeoutMs, e -> {});
return ensureConnectedZooKeeper(zookeeper, sessionTimeoutMs);
}
代码示例来源:origin: org.apache.hbase/hbase-zookeeper
@BeforeClass
public static void setUp() throws Exception {
PORT = UTIL.startMiniZKCluster().getClientPort();
ZooKeeper zk = ZooKeeperHelper.getConnectedZooKeeper("localhost:" + PORT, 10000);
DATA = new byte[10];
ThreadLocalRandom.current().nextBytes(DATA);
zk.create(PATH, DATA, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
for (int i = 0; i < CHILDREN; i++) {
zk.create(PATH + "/c" + i, new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
}
zk.close();
Configuration conf = UTIL.getConfiguration();
conf.set(HConstants.ZOOKEEPER_QUORUM, "localhost:" + PORT);
conf.setInt(ReadOnlyZKClient.RECOVERY_RETRY, 3);
conf.setInt(ReadOnlyZKClient.RECOVERY_RETRY_INTERVAL_MILLIS, 100);
conf.setInt(ReadOnlyZKClient.KEEPALIVE_MILLIS, 3000);
RO_ZK = new ReadOnlyZKClient(conf);
// only connect when necessary
assertNull(RO_ZK.zookeeper);
}
代码示例来源:origin: org.apache.hbase/hbase-zookeeper
public HACK_UNTIL_ZOOKEEPER_1897_ZooKeeperMain(String[] args)
throws IOException, InterruptedException {
super(args);
// Make sure we are connected before we proceed. Can take a while on some systems. If we
// run the command without being connected, we get ConnectionLoss KeeperErrorConnection...
// Make it 30seconds. We dont' have a config in this context and zk doesn't have
// a timeout until after connection. 30000ms is default for zk.
ZooKeeperHelper.ensureConnectedZooKeeper(this.zk, 30000);
}
代码示例来源:origin: org.apache.hbase/hbase-zookeeper
getConnectedZooKeeper(ZKConfig.getZKQuorumServersString(TEST_UTIL.getConfiguration()),
60000);
代码示例来源:origin: com.aliyun.hbase/alihbase-client
/**
* Get a ZooKeeper instance and wait until it connected before returning.
* @param sessionTimeoutMs Used as session timeout passed to the created ZooKeeper AND as the
* timeout to wait on connection establishment.
*/
public static ZooKeeper getConnectedZooKeeper(String connectString, int sessionTimeoutMs)
throws IOException {
ZooKeeper zookeeper = new ZooKeeper(connectString, sessionTimeoutMs, e -> {});
return ensureConnectedZooKeeper(zookeeper, sessionTimeoutMs);
}
代码示例来源:origin: com.aliyun.hbase/alihbase-zookeeper
getConnectedZooKeeper(ZKConfig.getZKQuorumServersString(TEST_UTIL.getConfiguration()),
60000);
内容来源于网络,如有侵权,请联系作者删除!