use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.data.Stat in project lucene-solr by apache.
the class ZkStateReader method fetchCollectionState.
private DocCollection fetchCollectionState(String coll, Watcher watcher) throws KeeperException, InterruptedException {
String collectionPath = getCollectionPath(coll);
while (true) {
try {
Stat stat = new Stat();
byte[] data = zkClient.getData(collectionPath, watcher, stat, true);
ClusterState state = ClusterState.load(stat.getVersion(), data, Collections.<String>emptySet(), collectionPath);
ClusterState.CollectionRef collectionRef = state.getCollectionStates().get(coll);
return collectionRef == null ? null : collectionRef.get();
} catch (KeeperException.NoNodeException e) {
if (watcher != null) {
// Leave an exists watch in place in case a state.json is created later.
Stat exists = zkClient.exists(collectionPath, watcher, true);
if (exists != null) {
// Loop and try again.
continue;
}
}
return null;
}
}
}
use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.data.Stat in project phoenix by apache.
the class PhoenixMRJobUtil method getActiveResourceManagerHost.
public static String getActiveResourceManagerHost(Configuration config, String zkQuorum) throws IOException, InterruptedException, JSONException, KeeperException, InvalidProtocolBufferException, ZooKeeperConnectionException {
ZooKeeperWatcher zkw = null;
ZooKeeper zk = null;
String activeRMHost = null;
try {
zkw = new ZooKeeperWatcher(config, "get-active-yarnmanager", null);
zk = new ZooKeeper(zkQuorum, 30000, zkw, false);
List<String> children = zk.getChildren(YARN_LEADER_ELECTION, zkw);
for (String subEntry : children) {
List<String> subChildern = zk.getChildren(YARN_LEADER_ELECTION + "/" + subEntry, zkw);
for (String eachEntry : subChildern) {
if (eachEntry.contains(ACTIVE_STANDBY_ELECTOR_LOCK)) {
String path = YARN_LEADER_ELECTION + "/" + subEntry + "/" + ACTIVE_STANDBY_ELECTOR_LOCK;
byte[] data = zk.getData(path, zkw, new Stat());
ActiveRMInfoProto proto = ActiveRMInfoProto.parseFrom(data);
proto.getRmId();
LOG.info("Active RmId : " + proto.getRmId());
activeRMHost = config.get(YarnConfiguration.RM_HOSTNAME + "." + proto.getRmId());
LOG.info("activeResourceManagerHostname = " + activeRMHost);
}
}
}
} finally {
if (zkw != null)
zkw.close();
if (zk != null)
zk.close();
}
return activeRMHost;
}
use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.data.Stat in project asterixdb by apache.
the class ZookeeperUtil method getAsterixInstances.
@Override
public List<AsterixInstance> getAsterixInstances() throws Exception {
List<String> instanceNames = zk.getChildren(ASTERIX_INSTANCE_BASE_PATH, false);
List<AsterixInstance> asterixInstances = new ArrayList<AsterixInstance>();
String path;
for (String instanceName : instanceNames) {
path = ASTERIX_INSTANCE_BASE_PATH + File.separator + instanceName;
byte[] asterixInstanceBytes = zk.getData(path, false, new Stat());
asterixInstances.add(readAsterixInstanceObject(asterixInstanceBytes));
}
return asterixInstances;
}
use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.data.Stat in project camel by apache.
the class ZooKeeperGroup method getDataAndStat.
void getDataAndStat(final String fullPath) throws Exception {
Stat stat = new Stat();
byte[] data = client.getData().storingStatIn(stat).usingWatcher(dataWatcher).forPath(fullPath);
applyNewData(fullPath, KeeperException.Code.OK.intValue(), stat, data);
}
use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.data.Stat in project camel by apache.
the class ExistenceChangedOperation method getResult.
@Override
public OperationResult<String> getResult() {
try {
String path = getNode();
Stat statistics = connection.exists(path, true);
return new OperationResult<String>(path, statistics);
} catch (Exception e) {
return new OperationResult<String>(e);
}
}
Aggregations