本文整理了Java中org.I0Itec.zkclient.ZkServer
类的一些代码示例,展示了ZkServer
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZkServer
类的具体详情如下:
包路径:org.I0Itec.zkclient.ZkServer
类名称:ZkServer
暂无
代码示例来源:origin: apache/incubator-pinot
public boolean start(int zkPort) {
IDefaultNameSpace defaultNameSpace = new IDefaultNameSpace() {
@Override
public void createDefaultNameSpace(org.I0Itec.zkclient.ZkClient zkClient) {
// init any zk paths if needed
}
};
LOGGER.info("Starting zookeeper at localhost:{} in thread: {}", zkPort, Thread.currentThread().getName());
_zkServer = new ZkServer(_dataDir, _logDir, defaultNameSpace, zkPort, 30000, 60000);
_zkServer.start();
return true;
}
代码示例来源:origin: apache/incubator-pinot
public boolean stop() {
_zkServer.shutdown();
return _tempDir.delete();
}
代码示例来源:origin: apache/helix
final ZkClient zkClient = builder.build();
zkServer.shutdown();
zkClient.waitForKeeperState(KeeperState.Disconnected, 5000, TimeUnit.MILLISECONDS);
Assert.assertFalse(zkClient.waitUntilConnected(0, TimeUnit.MILLISECONDS));
zkServer.start();
Assert.assertTrue(zkClient.waitUntilConnected(5000, TimeUnit.MILLISECONDS));
Assert.assertTrue(TestHelper.verify(new TestHelper.Verifier() {
zkClient.close();
} finally {
zkServer.shutdown();
代码示例来源:origin: org.apache.helix/helix-core
public static void stopZkServer(ZkServer zkServer) {
if (zkServer != null) {
zkServer.shutdown();
System.out.println("Shut down zookeeper at port " + zkServer.getPort() + " in thread "
+ Thread.currentThread().getName());
}
}
}
代码示例来源:origin: com.101tec/zkclient
@PostConstruct
public void start() {
final String[] localHostNames = NetworkUtil.getLocalHostNames();
String names = "";
for (int i = 0; i < localHostNames.length; i++) {
final String name = localHostNames[i];
names += " " + name;
if (i + 1 != localHostNames.length) {
names += ",";
}
}
LOG.info("Starting ZkServer on: [" + names + "] port " + _port + "...");
try {
startZooKeeperServer();
_zkClient = new ZkClient("localhost:" + _port, 10000);
_defaultNameSpace.createDefaultNameSpace(_zkClient);
} catch (RuntimeException e) {
shutdown();
throw e;
}
}
代码示例来源:origin: ezbz/projectx
@Test
@Ignore
public void test_createServer() throws Exception {
ZkServer zkServer = null;
try {
classUnderTest.afterPropertiesSet();
zkServer = classUnderTest.getObject();
assertNotNull("target object is null", zkServer);
assertNotNull("client is null", zkServer.getZkClient());
assertEquals("incorrect port", port, zkServer.getPort());
} finally {
final ZkClient zkClient = classUnderTest.getObject().getZkClient();
if (null != zkClient) {
classUnderTest.destroy();
}
}
}
}
代码示例来源:origin: com.101tec/zkclient
LOG.info("data log dir: " + dataLogDir.getAbsolutePath());
LOG.info("JAAS login file: " + System.getProperty("java.security.auth.login.config", "none"));
startSingleZkServer(_tickTime, dataDir, dataLogDir, port);
} else {
throw new IllegalStateException("Zookeeper port " + port + " was already in use. Running in single machine mode?");
代码示例来源:origin: com.github.sgroschupf/zkclient
@PostConstruct
public void start() {
final String[] localHostNames = NetworkUtil.getLocalHostNames();
String names = "";
for (int i = 0; i < localHostNames.length; i++) {
final String name = localHostNames[i];
names += " " + name;
if (i + 1 != localHostNames.length) {
names += ",";
}
}
LOG.info("Starting ZkServer on: [" + names + "] port " + _port + "...");
startZooKeeperServer();
_zkClient = new ZkClient("localhost:" + _port, 10000);
_defaultNameSpace.createDefaultNameSpace(_zkClient);
}
代码示例来源:origin: apache/helix
public static void main(String[] args) throws Exception {
setup();
zkServer.getZkClient().setZkSerializer(new ZNRecordSerializer());
ZNRecord record = zkServer.getZkClient().readData(PropertyPathBuilder.idealState(clusterName, "TestDB"));
String externalViewPath = PropertyPathBuilder.externalView(clusterName, "TestDB");
MockSpectatorProcess process = new MockSpectatorProcess();
process.start();
// try to route, there is no master or slave available
process.routeRequest("TestDB", "TestDB_1");
// update the externalview on zookeeper
zkServer.getZkClient().createPersistent(externalViewPath, record);
// sleep for sometime so that the ZK Callback is received.
Thread.sleep(1000);
process.routeRequest("TestDB", "TestDB_1");
System.exit(1);
}
代码示例来源:origin: apache/helix
zkServer.shutdown();
zkServer.start();
Assert.assertTrue(controller._zkclient
.waitUntilConnected(HelixZkClient.DEFAULT_CONNECTION_TIMEOUT, TimeUnit.MILLISECONDS));
zkServer.shutdown();
System.clearProperty(SystemPropertyKeys.ZK_CONNECTION_TIMEOUT);
代码示例来源:origin: apache/helix
public static void stopZkServer(ZkServer zkServer) {
if (zkServer != null) {
zkServer.shutdown();
System.out.println("Shut down zookeeper at port " + zkServer.getPort() + " in thread "
+ Thread.currentThread().getName());
}
}
}
代码示例来源:origin: com.github.sgroschupf/zkclient
LOG.info("data dir: " + dataDir.getAbsolutePath());
LOG.info("data log dir: " + dataLogDir.getAbsolutePath());
startSingleZkServer(_tickTime, dataDir, dataLogDir, port);
} else {
throw new IllegalStateException("Zookeeper port " + port + " was already in use. Running in single machine mode?");
代码示例来源:origin: ezbz/projectx
@Override
public void afterPropertiesSet() throws Exception {
zkServer = new ZkServer(dataDirectory, logDirectory, defaultNameSpace, port, tickTime,
minSessionTimeout);
zkServer.start();
}
代码示例来源:origin: apache/helix
static public void stopZkServer(ZkServer zkServer) {
if (zkServer != null) {
zkServer.shutdown();
System.out.println("Shut down zookeeper at port " + zkServer.getPort() + " in thread "
+ Thread.currentThread().getName());
}
}
代码示例来源:origin: ezbz/projectx
@Override
public void destroy() throws Exception {
zkServer.shutdown();
}
}
代码示例来源:origin: org.apache.helix/helix-core
public void start(int port, String dataDir, String logDir) throws Exception {
IDefaultNameSpace defaultNameSpace = new IDefaultNameSpace() {
@Override
public void createDefaultNameSpace(ZkClient zkClient) {
}
};
ZkServer server = new ZkServer(dataDir, logDir, defaultNameSpace, port);
server.start();
Thread.currentThread().join();
}
代码示例来源:origin: apache/helix
public void start(int port, String dataDir, String logDir) throws Exception {
IDefaultNameSpace defaultNameSpace = new IDefaultNameSpace() {
@Override
public void createDefaultNameSpace(ZkClient zkClient) {
}
};
ZkServer server = new ZkServer(dataDir, logDir, defaultNameSpace, port);
server.start();
Thread.currentThread().join();
}
代码示例来源:origin: apache/helix
private static void startLocalZookeeper(int port) throws Exception {
ZkServer server = null;
String baseDir = "/tmp/IntegrationTest/";
final String dataDir = baseDir + "zk/dataDir";
final String logDir = baseDir + "/tmp/logDir";
FileUtils.deleteDirectory(new File(dataDir));
FileUtils.deleteDirectory(new File(logDir));
IDefaultNameSpace defaultNameSpace = new IDefaultNameSpace() {
@Override
public void createDefaultNameSpace(ZkClient zkClient) {
}
};
int zkPort = 2199;
final String zkAddress = "localhost:" + zkPort;
server = new ZkServer(dataDir, logDir, defaultNameSpace, zkPort);
server.start();
}
代码示例来源:origin: apache/helix
public static void startZookeeper() {
echo("STARTING Zookeeper at " + ZK_ADDRESS);
IDefaultNameSpace defaultNameSpace = new IDefaultNameSpace() {
@Override
public void createDefaultNameSpace(ZkClient zkClient) {
}
};
new File("/tmp/helix-quickstart").mkdirs();
// start zookeeper
ZkServer server =
new ZkServer("/tmp/helix-quickstart/dataDir", "/tmp/helix-quickstart/logDir",
defaultNameSpace, 2199);
server.start();
}
代码示例来源:origin: org.apache.helix/helix-core
public static void startZookeeper() {
echo("STARTING Zookeeper at " + ZK_ADDRESS);
IDefaultNameSpace defaultNameSpace = new IDefaultNameSpace() {
@Override
public void createDefaultNameSpace(ZkClient zkClient) {
}
};
new File("/tmp/helix-quickstart").mkdirs();
// start zookeeper
ZkServer server =
new ZkServer("/tmp/helix-quickstart/dataDir", "/tmp/helix-quickstart/logDir",
defaultNameSpace, 2199);
server.start();
}
内容来源于网络,如有侵权,请联系作者删除!