use of com.ms.silverking.cloud.zookeeper.ZooKeeperExtended in project SilverKing by Morgan-Stanley.
the class SuspectsZK method clearAllZK.
public void clearAllZK() throws IOException, KeeperException {
String basePath;
ZooKeeperExtended _zk;
basePath = mc.getMetaPaths().getInstanceSuspectsPath();
_zk = mc.getZooKeeper();
for (String child : zk.getChildren(basePath)) {
_zk.delete(basePath + "/" + child);
}
}
use of com.ms.silverking.cloud.zookeeper.ZooKeeperExtended in project SilverKing by Morgan-Stanley.
the class DHTMetaReader method readRing.
public DHTMetaUpdate readRing(String ringName, long ringConfigVersion, long configInstanceVersion) throws KeeperException, IOException {
com.ms.silverking.cloud.toporing.meta.MetaClient ringMC;
NamedRingConfiguration namedRingConfig;
RingConfiguration ringConfig;
InstantiatedRingTree ringTree;
// long ringConfigVersion;
// long configInstanceVersion;
int readAttemptIndex;
int ringReadAttempts = 20;
int ringReadRetryInvervalSeconds = 2;
ZooKeeperExtended zk;
zk = mc.getZooKeeper();
if (EmbeddedSK.embedded()) {
namedRingConfig = EmbeddedSK.getEmbeddedNamedRingConfiguration(ringName);
} else {
// unresolved
namedRingConfig = new NamedRingConfiguration(ringName, RingConfiguration.emptyTemplate);
ringMC = new com.ms.silverking.cloud.toporing.meta.MetaClient(namedRingConfig, zkConfig);
// ringConfigVersion = zk.getVersionPriorTo(ringMC.getMetaPaths().getConfigPath(), zkidLimit);
try {
ringConfig = new RingConfigurationZK(ringMC).readFromZK(ringConfigVersion, null);
} catch (Exception e) {
Log.warning("Ignoring: ", e);
ringConfig = new RingConfiguration(new CloudConfiguration(null, null, null), null, null, null, null, null);
}
// resolved
namedRingConfig = new NamedRingConfiguration(ringName, ringConfig);
if (enableLogging) {
Log.warning("ringConfig\t", ringConfig);
}
}
ringMC = new com.ms.silverking.cloud.toporing.meta.MetaClient(namedRingConfig, zkConfig);
// configInstanceVersion = zk.getVersionPriorTo(ringMC.getMetaPaths().getConfigInstancePath(ringConfigVersion), zkidLimit);
if (enableLogging) {
Log.warning("configInstanceVersion: " + configInstanceVersion);
}
if (configInstanceVersion < 0) {
throw new RuntimeException("Invalid configInstanceVersion: " + configInstanceVersion);
}
// if (configInstanceVersion == -1) {
// configInstanceVersion = 0;
// }
// FUTURE - we shouldn't get here unless it's valid. Think about error messages if invalid, instead of waiting.
Log.warning("Waiting until valid " + ringMC.getMetaPaths().getConfigInstancePath(ringConfigVersion) + " " + configInstanceVersion);
SingleRingZK.waitUntilValid(ringMC, ringMC.getMetaPaths().getConfigInstancePath(ringConfigVersion), configInstanceVersion);
Log.warning("Valid");
ringTree = null;
readAttemptIndex = 0;
while (ringTree == null) {
try {
// , weightsVersion);
ringTree = SingleRingZK.readTree(ringMC, ringConfigVersion, configInstanceVersion);
} catch (Exception e) {
if (++readAttemptIndex >= ringReadAttempts) {
throw new RuntimeException("Ring read failed", e);
} else {
ThreadUtil.sleepSeconds(ringReadRetryInvervalSeconds);
}
}
}
if (enableLogging) {
Log.warning("\t\t###\t" + ringConfigVersion + "\t" + configInstanceVersion);
}
return new DHTMetaUpdate(dhtConfig, namedRingConfig, ringTree, mc);
}
use of com.ms.silverking.cloud.zookeeper.ZooKeeperExtended in project SilverKing by Morgan-Stanley.
the class ExclusionZKBase method writeToZK.
@Override
public String writeToZK(ExclusionSet exclusionSet, MetaToolOptions options) throws IOException, KeeperException {
String vBase;
String zkVal;
ZooKeeperExtended _zk;
_zk = mc.getZooKeeper();
zkVal = CollectionUtil.toString(exclusionSet.getServers(), "", "", delimiterChar, "");
vBase = _zk.createString(base + "/", zkVal, CreateMode.PERSISTENT_SEQUENTIAL);
/*
vBase = zk.createString(base +"/" , "", CreateMode.PERSISTENT_SEQUENTIAL);
for (String entity : exclusionList.getServers()) {
//System.out.println(vBase +"/"+ entity);
zk.createString(vBase +"/"+ entity, entity);
}
*/
return null;
}
use of com.ms.silverking.cloud.zookeeper.ZooKeeperExtended in project SilverKing by Morgan-Stanley.
the class ExclusionZKBase method getVersionMzxid.
public long getVersionMzxid(long version) throws KeeperException {
Stat stat;
ZooKeeperExtended _zk;
_zk = mc.getZooKeeper();
stat = new Stat();
_zk.getString(getVBase(version), null, stat);
return stat.getMzxid();
}
use of com.ms.silverking.cloud.zookeeper.ZooKeeperExtended in project SilverKing by Morgan-Stanley.
the class ExclusionZKBase method readLatestFromZK.
public ExclusionSet readLatestFromZK(MetaToolOptions options) throws KeeperException {
String vBase;
long version;
Stat stat;
ZooKeeperExtended _zk;
_zk = mc.getZooKeeper();
version = _zk.getLatestVersion(exclusionsPath);
if (version >= 0) {
vBase = getVBase(version);
stat = new Stat();
return new ExclusionSet(readNodesAsSet(vBase, stat), version, stat.getMzxid());
} else {
return ExclusionSet.emptyExclusionSet(0);
}
}
Aggregations