use of com.ms.silverking.cloud.zookeeper.ZooKeeperExtended in project SilverKing by Morgan-Stanley.
the class SingleRingZK method isValidRing.
// private static boolean isValidRing(MetaClient mc, String configInstancePath, String parentID, String policyName, long version) throws KeeperException {
// ZooKeeperExtended zk;
//
// zk = mc.getZooKeeper();
// return zk.getString(getBase(configInstancePath, parentID, policyName)).equals(validString);
// }
private static boolean isValidRing(MetaClient mc, String configInstancePath, String parentID, long version) throws KeeperException {
ZooKeeperExtended zk;
zk = mc.getZooKeeper();
return zk.getString(getBase(configInstancePath, parentID)).equals(validString);
}
use of com.ms.silverking.cloud.zookeeper.ZooKeeperExtended in project SilverKing by Morgan-Stanley.
the class ExclusionZKBase method getStartOfCurrentExclusion.
public Map<String, Long> getStartOfCurrentExclusion(Set<String> servers) throws KeeperException {
Map<String, Long> esStarts;
long latestExclusionSetVersion;
Map<String, Set<String>> exclusionSets;
ZooKeeperExtended _zk;
_zk = mc.getZooKeeper();
esStarts = new HashMap<>();
exclusionSets = new HashMap<>();
latestExclusionSetVersion = _zk.getLatestVersion(exclusionsPath);
for (String server : servers) {
esStarts.put(server, getStartOfCurrentExclusion(server, latestExclusionSetVersion, exclusionSets));
}
return esStarts;
}
use of com.ms.silverking.cloud.zookeeper.ZooKeeperExtended in project SilverKing by Morgan-Stanley.
the class MetaClientCore method handleSessionExpiration.
private void handleSessionExpiration() {
Lock lock;
lock = acquireLockIfShared(zkConfig);
try {
boolean established;
established = false;
while (!established) {
ZooKeeperExtended _zk;
ThreadUtil.sleepSeconds(connectionLossSleepSeconds);
_zk = zkMap.get(zkConfig);
if (_zk != null && _zk.getState() != States.CLOSED) {
established = true;
} else {
zkMap.remove(zkConfig);
try {
Log.warning(String.format("Attempting to reestablish session %s\n", zkConfig));
zk = ZooKeeperExtended.getZooKeeperWithRetries(zkConfig, sessionTimeout, this, connectAttempts);
Log.warning(String.format("Session restablished %s\n", zkConfig));
established = true;
if (shareZK) {
zkMap.put(zkConfig, zk);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
} finally {
releaseLockIfShared(lock);
}
}
use of com.ms.silverking.cloud.zookeeper.ZooKeeperExtended in project SilverKing by Morgan-Stanley.
the class MetaClientCore method process.
@Override
public void process(WatchedEvent event) {
ZooKeeperExtended _zk;
_zk = _getZooKeeper();
if (_zk == null || _zk.getState() == States.CLOSED) {
handleSessionExpiration();
}
// Log.warning(event.toString());
synchronized (this) {
this.notifyAll();
}
if (watcher != null) {
watcher.process(event);
}
}
use of com.ms.silverking.cloud.zookeeper.ZooKeeperExtended in project SilverKing by Morgan-Stanley.
the class ValueWatcher method _doCheck.
protected void _doCheck() throws KeeperException {
try {
ZooKeeperExtended _zk;
byte[] value;
Stat stat;
if (verbose) {
Log.warning("ValueCheck start: ", basePath);
}
_zk = metaClientCore.getZooKeeper();
stat = new Stat();
try {
value = _zk.getData(basePath, this, stat);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
if (stat.getMzxid() > lastNotifiedZXID) {
listener.newValue(basePath, value, stat);
lastNotifiedZXID = stat.getMzxid();
}
if (verbose) {
Log.warning("ValueCheck complete: ", basePath);
}
} catch (KeeperException ke) {
System.out.println("*** ZooKeeper state: " + metaClientCore.getZooKeeper().getState());
throw ke;
}
}
Aggregations