use of com.ms.silverking.cloud.meta.ExclusionSet in project SilverKing by Morgan-Stanley.
the class DHTRingMaster method readExclusions.
private ExclusionSet readExclusions(String ringName, long ringVersion) throws KeeperException, IOException {
ExclusionZK exclusionZK;
ExclusionSet instanceExclusionSet;
ExclusionSet exclusionSet;
com.ms.silverking.cloud.meta.MetaClient cloudMC;
com.ms.silverking.cloud.toporing.meta.MetaClient ringMC;
ringMC = com.ms.silverking.cloud.toporing.meta.MetaClient.createMetaClient(ringName, ringVersion, zkConfig);
cloudMC = ringMC.createCloudMC();
exclusionZK = new ExclusionZK(cloudMC);
try {
exclusionSet = exclusionZK.readLatestFromZK();
} catch (Exception e) {
Log.logErrorWarning(e);
Log.warningAsync("No ExclusionSet found. Using empty set.");
exclusionSet = ExclusionSet.emptyExclusionSet(0);
}
try {
instanceExclusionSet = new ExclusionSet(new ServerSetExtensionZK(mc, mc.getMetaPaths().getInstanceExclusionsPath()).readLatestFromZK());
} catch (Exception e) {
Log.logErrorWarning(e);
Log.warningAsync("No instance ExclusionSet found. Using empty set.");
instanceExclusionSet = ExclusionSet.emptyExclusionSet(0);
}
return ExclusionSet.union(exclusionSet, instanceExclusionSet);
}
use of com.ms.silverking.cloud.meta.ExclusionSet in project SilverKing by Morgan-Stanley.
the class NodeRingMaster2 method getAllCurrentAndTargetNonExcludedNonLocalReplicaServers.
public Set<IPAndPort> getAllCurrentAndTargetNonExcludedNonLocalReplicaServers() {
Set<IPAndPort> allReplicas;
ExclusionSet curExclusionSet;
Set<IPAndPort> nonExcludedReplicas;
allReplicas = getAllCurrentAndTargetReplicaServers();
curExclusionSet = latestExclusionSet;
nonExcludedReplicas = new HashSet<>(curExclusionSet.filterByIP(allReplicas));
nonExcludedReplicas.remove(nodeID);
return ImmutableSet.copyOf(nonExcludedReplicas);
}
use of com.ms.silverking.cloud.meta.ExclusionSet 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.meta.ExclusionSet 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