use of com.ms.silverking.cloud.dht.daemon.ReplicaNaiveIPPrioritizer in project SilverKing by Morgan-Stanley.
the class MasterModeDependencyWatcher method handleExclusionChange.
private void handleExclusionChange() {
synchronized (this) {
try {
Map<String, Long> curBuild;
ExclusionSet exclusionSet;
ExclusionSet instanceExclusionSet;
long exclusionVersion;
long instanceExclusionVersion;
ZooKeeperExtended zk;
ExclusionSet mergedExclusionSet;
RingTree existingRingTree;
RingTree newRingTree;
String newInstancePath;
ResolvedReplicaMap newReplicaMap;
zk = mc.getZooKeeper();
curBuild = createBuildMap(zk);
exclusionVersion = curBuild.get(mp.getExclusionsPath());
instanceExclusionVersion = curBuild.get(dhtMC.getMetaPaths().getInstanceExclusionsPath());
exclusionSet = new ExclusionSet(new ServerSetExtensionZK(mc, mc.getMetaPaths().getExclusionsPath()).readFromZK(exclusionVersion, null));
try {
instanceExclusionSet = new ExclusionSet(new ServerSetExtensionZK(mc, dhtMC.getMetaPaths().getInstanceExclusionsPath()).readFromZK(instanceExclusionVersion, null));
} catch (Exception e) {
Log.warning("No instance ExclusionSet found");
instanceExclusionSet = ExclusionSet.emptyExclusionSet(0);
}
mergedExclusionSet = ExclusionSet.union(exclusionSet, instanceExclusionSet);
newRingTree = RingTreeBuilder.removeExcludedNodes(masterRingTree, mergedExclusionSet);
newReplicaMap = newRingTree.getResolvedMap(ringConfig.getRingConfiguration().getRingParentName(), new ReplicaNaiveIPPrioritizer());
if (!existingReplicaMap.equals(newReplicaMap)) {
newInstancePath = mc.createConfigInstancePath(ringConfigVersion);
SingleRingZK.writeTree(mc, topology, newInstancePath, newRingTree);
Log.warningf("RingTree written to ZK: %s", newInstancePath);
existingReplicaMap = newReplicaMap;
} else {
Log.warning("RingTree unchanged. No ZK update.");
}
} catch (Exception e) {
e.printStackTrace();
Log.logErrorWarning(e, "handleExclusionChange() failed");
}
}
}
use of com.ms.silverking.cloud.dht.daemon.ReplicaNaiveIPPrioritizer in project SilverKing by Morgan-Stanley.
the class SKAdmin method replicaSetExcludedByExclusions.
private boolean replicaSetExcludedByExclusions(ExclusionSet es) throws KeeperException, IOException {
InstantiatedRingTree curTree;
ResolvedReplicaMap replicaMap;
List<Set<IPAndPort>> excludedReplicaSets;
curTree = readCurrentTree();
replicaMap = curTree.getResolvedMap(ringConfig.getRingParentName(), new ReplicaNaiveIPPrioritizer());
excludedReplicaSets = replicaMap.getExcludedReplicaSets(es.asIPAndPortSet(0));
if (excludedReplicaSets.size() != 0) {
Log.warning("Exclusion set excludes at least one replica set:");
for (Set<IPAndPort> s : excludedReplicaSets) {
Log.warningf("%s", s);
}
return true;
}
return false;
}
Aggregations