本文整理汇总了Java中org.apache.bookkeeper.util.LocalBookKeeper.waitForServerUp方法的典型用法代码示例。如果您正苦于以下问题:Java LocalBookKeeper.waitForServerUp方法的具体用法?Java LocalBookKeeper.waitForServerUp怎么用?Java LocalBookKeeper.waitForServerUp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.bookkeeper.util.LocalBookKeeper
的用法示例。
在下文中一共展示了LocalBookKeeper.waitForServerUp方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setupZooKeeper
import org.apache.bookkeeper.util.LocalBookKeeper; //导入方法依赖的package包/类
@BeforeClass
public static void setupZooKeeper() throws Exception {
LOG.info("Starting ZK server");
zkTmpDir = File.createTempFile("zookeeper", "test");
zkTmpDir.delete();
zkTmpDir.mkdir();
try {
zks = new ZooKeeperServer(zkTmpDir, zkTmpDir, ZooKeeperDefaultPort);
serverFactory = new NIOServerCnxnFactory();
serverFactory.configure(new InetSocketAddress(ZooKeeperDefaultPort), 10);
serverFactory.startup(zks);
} catch (Exception e) {
LOG.error("Exception while instantiating ZooKeeper", e);
}
boolean b = LocalBookKeeper.waitForServerUp(HOSTPORT, CONNECTION_TIMEOUT);
LOG.debug("ZooKeeper server up: " + b);
}
示例2: setupZooKeeper
import org.apache.bookkeeper.util.LocalBookKeeper; //导入方法依赖的package包/类
@BeforeClass
public static void setupZooKeeper() throws Exception {
// create a ZooKeeper server(dataDir, dataLogDir, port)
LOG.info("Starting ZK server");
ZkTmpDir = File.createTempFile("zookeeper", "test");
ZkTmpDir.delete();
ZkTmpDir.mkdir();
try {
zks = new ZooKeeperServer(ZkTmpDir, ZkTmpDir, ZooKeeperDefaultPort);
serverFactory = new NIOServerCnxnFactory();
serverFactory.configure(new InetSocketAddress(ZooKeeperDefaultPort), 10);
serverFactory.startup(zks);
} catch (Exception e) {
LOG.error("Exception while instantiating ZooKeeper", e);
}
boolean b = LocalBookKeeper.waitForServerUp(HOSTPORT, CONNECTION_TIMEOUT);
LOG.debug("ZooKeeper server up: " + b);
}
示例3: start
import org.apache.bookkeeper.util.LocalBookKeeper; //导入方法依赖的package包/类
void start() throws Exception {
bkthread.start();
if (!LocalBookKeeper.waitForServerUp(zkEnsemble, 10000)) {
throw new Exception("Error starting zookeeper/bookkeeper");
}
assertEquals("Not all bookies started",
numBookies, checkBookiesUp(numBookies, 10));
}
示例4: start
import org.apache.bookkeeper.util.LocalBookKeeper; //导入方法依赖的package包/类
public void start() throws Exception {
bkStartupThread.start();
if (!LocalBookKeeper.waitForServerUp(zkEnsemble, zkTimeoutSec*1000)) {
throw new Exception("Error starting zookeeper/bookkeeper");
}
int bookiesUp = checkBookiesUp(numBookies, zkTimeoutSec);
assert (numBookies == bookiesUp);
// Provision "/messaging/distributedlog" namespace
DLMetadata.create(new BKDLConfig(zkEnsemble, "/ledgers")).create(uri);
}
示例5: waitForServerUp
import org.apache.bookkeeper.util.LocalBookKeeper; //导入方法依赖的package包/类
/**
* Blocks the current thread and awaits ZooKeeper to start running locally on the given port.
*
* @param zkPort The ZooKeeper Port.
* @return True if ZooKeeper started within a specified timeout, false otherwise.
*/
public static boolean waitForServerUp(int zkPort) {
val address = LOOPBACK_ADDRESS.getHostAddress() + ":" + zkPort;
return LocalBookKeeper.waitForServerUp(address, LocalBookKeeper.CONNECTION_TIMEOUT);
}