use of com.ms.silverking.cloud.toporing.ResolvedReplicaMap 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;
}
use of com.ms.silverking.cloud.toporing.ResolvedReplicaMap in project SilverKing by Morgan-Stanley.
the class RingMapState method newExclusionSet.
// FUTURE - deprecate this
public void newExclusionSet(ExclusionSet exclusionSet, ReplicaPrioritizer replicaPrioritizer) throws InvalidRingException {
RingTree newRingTree;
ResolvedReplicaMap newResolvedReplicaMap;
newRingTree = RingTreeBuilder.removeExcludedNodes(rawRingTree, exclusionSet);
newResolvedReplicaMap = newRingTree.getResolvedMap(ringConfig.getRingParentName(), replicaPrioritizer);
ringTreeMinusExclusions = newRingTree;
resolvedReplicaMapMinusExclusions = newResolvedReplicaMap;
/*
System.out.println("\tResolved Map");
resolvedReplicaMapMinusExclusions.display();
System.out.println("\tEnd Resolved Map");
*/
}
use of com.ms.silverking.cloud.toporing.ResolvedReplicaMap in project SilverKing by Morgan-Stanley.
the class RingMapState method readInitialExclusions.
/*
private void waitForExclusionSet() {
Log.warningf("waitForExclusionSet: %s", ringIDAndVersionPair);
exclusionSetLock.lock();
try {
while (!exclusionSetInitialized) {
try {
exclusionSetCV.await();
} catch (InterruptedException e) {
}
}
} finally {
exclusionSetLock.unlock();
}
Log.warningf("out waitForExclusionSet: %s", ringIDAndVersionPair);
}
*/
private void readInitialExclusions(MetaClient mc) throws KeeperException {
ExclusionZK exclusionZK;
ExclusionSet instanceExclusionSet;
ExclusionSet exclusionSet;
RingTree newRingTree;
ResolvedReplicaMap newResolvedReplicaMap;
Log.warning("RingMapState reading initial exclusions");
exclusionZK = new ExclusionZK(mc);
try {
exclusionSet = exclusionZK.readLatestFromZK();
} catch (Exception e) {
Log.logErrorWarning(e);
Log.warning("No ExclusionSet found. Using empty set.");
exclusionSet = ExclusionSet.emptyExclusionSet(0);
}
curExclusionSet = exclusionSet;
Log.warning("curExclusionSet initialized:\n", curExclusionSet);
try {
instanceExclusionSet = new ExclusionSet(new ServerSetExtensionZK(dhtMC, dhtMC.getMetaPaths().getInstanceExclusionsPath()).readLatestFromZK());
} catch (Exception e) {
Log.logErrorWarning(e);
Log.warning("No instance ExclusionSet found. Using empty set.");
instanceExclusionSet = ExclusionSet.emptyExclusionSet(0);
}
curInstanceExclusionSet = instanceExclusionSet;
Log.warning("curInstanceExclusionSet initialized:\n", curInstanceExclusionSet);
try {
newRingTree = RingTreeBuilder.removeExcludedNodes(rawRingTree, ExclusionSet.union(curExclusionSet, curInstanceExclusionSet));
} catch (Exception e) {
Log.logErrorWarning(e);
throw new RuntimeException(e);
}
newResolvedReplicaMap = newRingTree.getResolvedMap(ringConfig.getRingParentName(), new ReplicaNaiveIPPrioritizer());
ringTreeMinusExclusions = newRingTree;
resolvedReplicaMapMinusExclusions = newResolvedReplicaMap;
System.out.println("\tResolved Map");
resolvedReplicaMapMinusExclusions.display();
Log.warning("RingMapState done reading initial exclusions");
}
use of com.ms.silverking.cloud.toporing.ResolvedReplicaMap in project SilverKing by Morgan-Stanley.
the class RingMapState2 method readInitialExclusions.
private void readInitialExclusions(MetaClient mc) throws KeeperException {
ExclusionZK exclusionZK;
ExclusionSet instanceExclusionSet;
ExclusionSet exclusionSet;
RingTree newRingTree;
ResolvedReplicaMap newResolvedReplicaMap;
Log.warning("RingMapState reading initial exclusions");
exclusionZK = new ExclusionZK(mc);
try {
exclusionSet = exclusionZK.readLatestFromZK();
} catch (Exception e) {
Log.logErrorWarning(e);
Log.warning("No ExclusionSet found. Using empty set.");
exclusionSet = ExclusionSet.emptyExclusionSet(0);
}
curExclusionSet = exclusionSet;
Log.warning("curExclusionSet initialized:\n", curExclusionSet);
try {
instanceExclusionSet = new ExclusionSet(new ServerSetExtensionZK(dhtMC, dhtMC.getMetaPaths().getInstanceExclusionsPath()).readLatestFromZK());
} catch (Exception e) {
Log.logErrorWarning(e);
Log.warning("No instance ExclusionSet found. Using empty set.");
instanceExclusionSet = ExclusionSet.emptyExclusionSet(0);
}
curInstanceExclusionSet = instanceExclusionSet;
Log.warning("curInstanceExclusionSet initialized:\n", curInstanceExclusionSet);
curUnionExclusionSet = ExclusionSet.union(curExclusionSet, curInstanceExclusionSet);
Log.warningf("curUnionExclusionSet initialized: %s", curUnionExclusionSet);
try {
newRingTree = RingTreeBuilder.removeExcludedNodes(rawRingTree, curUnionExclusionSet);
} catch (Exception e) {
Log.logErrorWarning(e);
throw new RuntimeException(e);
}
newResolvedReplicaMap = newRingTree.getResolvedMap(ringConfig.getRingParentName(), new SimpleIPDistancePrioritizer(nodeID, defaultIPDistanceMask));
ringTreeMinusExclusions = newRingTree;
resolvedReplicaMapMinusExclusions = newResolvedReplicaMap;
if (Log.levelMet(Level.INFO)) {
System.out.println("\tResolved Map");
resolvedReplicaMapMinusExclusions.display();
}
Log.warning("RingMapState done reading initial exclusions");
}
Aggregations