Search in sources :

Example 6 with ResolvedReplicaMap

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;
}
Also used : IPAndPort(com.ms.silverking.net.IPAndPort) ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) HashSet(java.util.HashSet) ExclusionSet(com.ms.silverking.cloud.meta.ExclusionSet) ReplicaNaiveIPPrioritizer(com.ms.silverking.cloud.dht.daemon.ReplicaNaiveIPPrioritizer) InstantiatedRingTree(com.ms.silverking.cloud.toporing.InstantiatedRingTree) ResolvedReplicaMap(com.ms.silverking.cloud.toporing.ResolvedReplicaMap)

Example 7 with ResolvedReplicaMap

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");
        */
}
Also used : RingTree(com.ms.silverking.cloud.toporing.RingTree) InstantiatedRingTree(com.ms.silverking.cloud.toporing.InstantiatedRingTree) ResolvedReplicaMap(com.ms.silverking.cloud.toporing.ResolvedReplicaMap)

Example 8 with ResolvedReplicaMap

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");
}
Also used : ExclusionZK(com.ms.silverking.cloud.meta.ExclusionZK) ExclusionSet(com.ms.silverking.cloud.meta.ExclusionSet) RingTree(com.ms.silverking.cloud.toporing.RingTree) InstantiatedRingTree(com.ms.silverking.cloud.toporing.InstantiatedRingTree) ResolvedReplicaMap(com.ms.silverking.cloud.toporing.ResolvedReplicaMap) InvalidRingException(com.ms.silverking.cloud.toporing.InvalidRingException) KeeperException(org.apache.zookeeper.KeeperException) IOException(java.io.IOException) InvalidTransitionException(com.ms.silverking.cloud.dht.daemon.storage.convergence.InvalidTransitionException) ServerSetExtensionZK(com.ms.silverking.cloud.meta.ServerSetExtensionZK)

Example 9 with ResolvedReplicaMap

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");
}
Also used : ExclusionZK(com.ms.silverking.cloud.meta.ExclusionZK) ExclusionSet(com.ms.silverking.cloud.meta.ExclusionSet) RingTree(com.ms.silverking.cloud.toporing.RingTree) InstantiatedRingTree(com.ms.silverking.cloud.toporing.InstantiatedRingTree) ResolvedReplicaMap(com.ms.silverking.cloud.toporing.ResolvedReplicaMap) InvalidRingException(com.ms.silverking.cloud.toporing.InvalidRingException) KeeperException(org.apache.zookeeper.KeeperException) IOException(java.io.IOException) InvalidTransitionException(com.ms.silverking.cloud.dht.daemon.storage.convergence.InvalidTransitionException) ServerSetExtensionZK(com.ms.silverking.cloud.meta.ServerSetExtensionZK)

Aggregations

ResolvedReplicaMap (com.ms.silverking.cloud.toporing.ResolvedReplicaMap)9 InstantiatedRingTree (com.ms.silverking.cloud.toporing.InstantiatedRingTree)6 RingTree (com.ms.silverking.cloud.toporing.RingTree)5 ExclusionSet (com.ms.silverking.cloud.meta.ExclusionSet)3 InvalidRingException (com.ms.silverking.cloud.toporing.InvalidRingException)3 IOException (java.io.IOException)3 KeeperException (org.apache.zookeeper.KeeperException)3 InvalidTransitionException (com.ms.silverking.cloud.dht.daemon.storage.convergence.InvalidTransitionException)2 ExclusionZK (com.ms.silverking.cloud.meta.ExclusionZK)2 ServerSetExtensionZK (com.ms.silverking.cloud.meta.ServerSetExtensionZK)2 IPAndPort (com.ms.silverking.net.IPAndPort)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 DHTKey (com.ms.silverking.cloud.dht.common.DHTKey)1 ReplicaNaiveIPPrioritizer (com.ms.silverking.cloud.dht.daemon.ReplicaNaiveIPPrioritizer)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Set (java.util.Set)1 CmdLineException (org.kohsuke.args4j.CmdLineException)1