use of org.apache.flink.shaded.curator5.org.apache.curator.framework.CuratorFramework in project elastic-job by dangdangdotcom.
the class ZookeeperRegistryCenterModifyTest method assertPersistSequential.
@Test
public void assertPersistSequential() throws Exception {
assertThat(zkRegCenter.persistSequential("/sequential/test_sequential", "test_value"), startsWith("/sequential/test_sequential"));
assertThat(zkRegCenter.persistSequential("/sequential/test_sequential", "test_value"), startsWith("/sequential/test_sequential"));
CuratorFramework client = CuratorFrameworkFactory.newClient(EmbedTestingServer.getConnectionString(), new RetryOneTime(2000));
client.start();
client.blockUntilConnected();
List<String> actual = client.getChildren().forPath("/" + ZookeeperRegistryCenterModifyTest.class.getName() + "/sequential");
assertThat(actual.size(), is(2));
for (String each : actual) {
assertThat(each, startsWith("test_sequential"));
assertThat(zkRegCenter.get("/sequential/" + each), startsWith("test_value"));
}
}
use of org.apache.flink.shaded.curator5.org.apache.curator.framework.CuratorFramework in project storm by apache.
the class Zookeeper method zkLeaderElectorImpl.
protected ILeaderElector zkLeaderElectorImpl(Map conf, BlobStore blobStore) throws UnknownHostException {
List<String> servers = (List<String>) conf.get(Config.STORM_ZOOKEEPER_SERVERS);
Object port = conf.get(Config.STORM_ZOOKEEPER_PORT);
CuratorFramework zk = mkClientImpl(conf, servers, port, "", conf);
String leaderLockPath = conf.get(Config.STORM_ZOOKEEPER_ROOT) + "/leader-lock";
String id = NimbusInfo.fromConf(conf).toHostPortString();
AtomicReference<LeaderLatch> leaderLatchAtomicReference = new AtomicReference<>(new LeaderLatch(zk, leaderLockPath, id));
AtomicReference<LeaderLatchListener> leaderLatchListenerAtomicReference = new AtomicReference<>(leaderLatchListenerImpl(conf, zk, blobStore, leaderLatchAtomicReference.get()));
return new LeaderElectorImp(conf, servers, zk, leaderLockPath, id, leaderLatchAtomicReference, leaderLatchListenerAtomicReference, blobStore);
}
use of org.apache.flink.shaded.curator5.org.apache.curator.framework.CuratorFramework in project storm by apache.
the class Utils method newCuratorStarted.
public static CuratorFramework newCuratorStarted(Map conf, List<String> servers, Object port, ZookeeperAuthInfo auth) {
CuratorFramework ret = newCurator(conf, servers, port, auth);
LOG.info("Starting Utils Curator (2)...");
ret.start();
return ret;
}
use of org.apache.flink.shaded.curator5.org.apache.curator.framework.CuratorFramework in project storm by apache.
the class KafkaOffsetLagUtil method getOldConsumerOffsetsFromZk.
private static Map<String, Map<Integer, Long>> getOldConsumerOffsetsFromZk(Map<String, List<Integer>> topicPartitions, OldKafkaSpoutOffsetQuery oldKafkaSpoutOffsetQuery) throws Exception {
Map<String, Map<Integer, Long>> result = new HashMap<>();
CuratorFramework curatorFramework = CuratorFrameworkFactory.newClient(oldKafkaSpoutOffsetQuery.getZkServers(), 20000, 15000, new RetryOneTime(1000));
curatorFramework.start();
String partitionPrefix = "partition_";
String zkPath = oldKafkaSpoutOffsetQuery.getZkPath();
if (zkPath.endsWith("/")) {
zkPath = zkPath.substring(0, zkPath.length() - 1);
}
if (curatorFramework.checkExists().forPath(zkPath) == null) {
throw new IllegalArgumentException(OPTION_ZK_COMMITTED_NODE_LONG + " '" + zkPath + "' dose not exists.");
}
byte[] zkData;
try {
if (topicPartitions != null) {
for (Map.Entry<String, List<Integer>> topicEntry : topicPartitions.entrySet()) {
Map<Integer, Long> partitionOffsets = new HashMap<>();
for (Integer partition : topicEntry.getValue()) {
String path = zkPath + "/" + (oldKafkaSpoutOffsetQuery.isWildCardTopic() ? topicEntry.getKey() + "/" : "") + partitionPrefix + partition;
if (curatorFramework.checkExists().forPath(path) != null) {
zkData = curatorFramework.getData().forPath(path);
Map<Object, Object> offsetData = (Map<Object, Object>) JSONValue.parseWithException(new String(zkData, "UTF-8"));
partitionOffsets.put(partition, (Long) offsetData.get("offset"));
}
}
result.put(topicEntry.getKey(), partitionOffsets);
}
}
} finally {
if (curatorFramework != null) {
curatorFramework.close();
}
}
return result;
}
use of org.apache.flink.shaded.curator5.org.apache.curator.framework.CuratorFramework in project storm by apache.
the class BlobStoreUtils method createZKClient.
public static CuratorFramework createZKClient(Map<String, Object> conf) {
@SuppressWarnings("unchecked") List<String> zkServers = (List<String>) conf.get(Config.STORM_ZOOKEEPER_SERVERS);
Object port = conf.get(Config.STORM_ZOOKEEPER_PORT);
ZookeeperAuthInfo zkAuthInfo = new ZookeeperAuthInfo(conf);
CuratorFramework zkClient = Utils.newCurator(conf, zkServers, port, (String) conf.get(Config.STORM_ZOOKEEPER_ROOT), zkAuthInfo);
zkClient.start();
return zkClient;
}
Aggregations