client.create(path, null, CreateMode.PERSISTENT), KeeperException.NodeExistsException.class, path).get();
client.create(path, null, CreateMode.PERSISTENT), KeeperException.NodeExistsException.class, path).get();
@Override public void start() throws Exception { logAppenderInitializer.initialize(); resetShutdownTime(); createDirectory("twill"); createSystemHBaseNamespace(); updateConfigurationTable(); Services.startAndWait(zkClient, cConf.getLong(Constants.Zookeeper.CLIENT_STARTUP_TIMEOUT_MILLIS), TimeUnit.MILLISECONDS, String.format("Connection timed out while trying to start ZooKeeper client. Please " + "verify that the ZooKeeper quorum settings are correct in cdap-site.xml. " + "Currently configured as: %s", cConf.get(Constants.Zookeeper.QUORUM))); // Tries to create the ZK root node (which can be namespaced through the zk connection string) Futures.getUnchecked(ZKOperations.ignoreError(zkClient.create("/", null, CreateMode.PERSISTENT), KeeperException.NodeExistsException.class, null)); electionInfoService.startAndWait(); leaderElection.startAndWait(); }
ZKOperations.ignoreError(zkClientService.create("/", null, CreateMode.PERSISTENT), KeeperException.NodeExistsException.class, null).get();
ZKOperations.ignoreError(zkClientService.create("/", null, CreateMode.PERSISTENT), KeeperException.NodeExistsException.class, null).get();
@Before public void beforeTest() throws Exception { zkServer = InMemoryZKServer.builder().setDataDir(TEMP_FOLDER.newFolder()).build(); zkServer.startAndWait(); CConfiguration cConf = CConfiguration.create(); String kafkaZKNamespace = cConf.get(KafkaConstants.ConfigKeys.ZOOKEEPER_NAMESPACE_CONFIG); kafkaZKConnect = zkServer.getConnectionStr(); if (kafkaZKNamespace != null) { ZKClientService zkClient = new DefaultZKClientService(zkServer.getConnectionStr(), 2000, null, ImmutableMultimap.<String, byte[]>of()); zkClient.startAndWait(); zkClient.create("/" + kafkaZKNamespace, null, CreateMode.PERSISTENT); zkClient.stopAndWait(); kafkaZKConnect += "/" + kafkaZKNamespace; } kafkaServer = createKafkaServer(kafkaZKConnect, TEMP_FOLDER.newFolder()); kafkaServer.startAndWait(); }