use of com.ms.silverking.cloud.dht.meta.DHTRingCurTargetZK in project SilverKing by Morgan-Stanley.
the class SKAdmin method readCurrentTree.
public InstantiatedRingTree readCurrentTree() throws KeeperException, IOException {
DHTRingCurTargetZK curTargetZK;
Triple<String, Long, Long> curRingAndVersionPair;
InstantiatedRingTree ringTree;
curTargetZK = new DHTRingCurTargetZK(dhtMC, dhtConfig);
curRingAndVersionPair = curTargetZK.getCurRingAndVersionPair();
ringTree = SingleRingZK.readTree(new com.ms.silverking.cloud.toporing.meta.MetaClient(new NamedRingConfiguration(dhtConfig.getRingName(), ringConfig), dhtMC.getZooKeeper().getZKConfig()), curRingAndVersionPair.getTail());
return ringTree;
}
use of com.ms.silverking.cloud.dht.meta.DHTRingCurTargetZK in project SilverKing by Morgan-Stanley.
the class NodeRingMaster2 method initializeMap.
public void initializeMap(DHTConfiguration dhtConfig) throws IOException, KeeperException {
Triple<String, Long, Long> curRingAndVersionPair;
ConvergencePoint currentCP;
long creationTime;
int attemptIndex;
String ringName;
Pair<Long, Long> configAndInstance;
curRingAndVersionPair = new DHTRingCurTargetZK(dhtMetaReader.getMetaClient(), dhtMetaReader.getDHTConfig()).getCurRingAndVersionPair();
ringName = curRingAndVersionPair.getHead();
configAndInstance = curRingAndVersionPair.getTail();
creationTime = Long.MIN_VALUE;
attemptIndex = 0;
do {
String instanceBase;
instanceBase = MetaPaths.getRingConfigInstancePath(ringName, configAndInstance.getV1());
try {
creationTime = dhtMetaReader.getMetaClient().getZooKeeper().getCreationTime(ZooKeeperExtended.padVersionPath(instanceBase, configAndInstance.getV2()));
} catch (KeeperException e) {
Log.logErrorWarning(e);
}
if (creationTime < 0) {
ThreadUtil.sleep(zkReadRetryIntervalMillis);
}
++attemptIndex;
} while (creationTime < 0 && attemptIndex < zkReadAttempts);
if (creationTime < 0) {
throw new RuntimeException("Unable to initialize map: " + curRingAndVersionPair);
}
currentCP = new ConvergencePoint(dhtConfig.getVersion(), RingIDAndVersionPair.fromRingNameAndVersionPair(curRingAndVersionPair), creationTime);
setCurMapState(newMapState(currentCP));
}
use of com.ms.silverking.cloud.dht.meta.DHTRingCurTargetZK in project SilverKing by Morgan-Stanley.
the class NodeRingMaster2 method getRingNameFromCP.
// /////////////////////////////////////////////////////////////////////////
private String getRingNameFromCP(ConvergencePoint cp) throws KeeperException {
Triple<String, Long, Long> t;
DHTRingCurTargetZK ctZK;
ctZK = new DHTRingCurTargetZK(dhtMetaReader.getMetaClient(), dhtMetaReader.getDHTConfig());
t = ctZK.getCurRingAndVersionPair();
if (!t.getTail().equals(cp.getRingIDAndVersionPair().getRingVersionPair())) {
t = ctZK.getTargetRingAndVersionPair();
if (!t.getTail().equals(cp.getRingIDAndVersionPair().getRingVersionPair())) {
Log.warning(t.getTail());
Log.warning(cp.getRingIDAndVersionPair().getRingVersionPair());
throw new RuntimeException("cp version mismatch");
} else {
return t.getV1();
}
} else {
return t.getV1();
}
}
Aggregations