Search in sources :

Example 1 with RingTree

use of com.ms.silverking.cloud.toporing.RingTree in project SilverKing by Morgan-Stanley.

the class ConvergenceControllerBase method getResolvedReplicaMap.

protected ResolvedReplicaMap getResolvedReplicaMap(DHTMetaUpdate metaUpdate, RingConfiguration ringConfig) {
    RingTree ringTreeMinusExclusions;
    ResolvedReplicaMap resolvedReplicaMapMinusExclusions;
    try {
        ringTreeMinusExclusions = RingTreeBuilder.removeExcludedNodes(metaUpdate.getRingTree(), exclusionSet);
    } catch (InvalidRingException ire) {
        throw new RuntimeException("Unexpected InvalidRingException", ire);
    }
    resolvedReplicaMapMinusExclusions = ringTreeMinusExclusions.getResolvedMap(ringConfig.getRingParentName(), null);
    return resolvedReplicaMapMinusExclusions;
}
Also used : InvalidRingException(com.ms.silverking.cloud.toporing.InvalidRingException) RingTree(com.ms.silverking.cloud.toporing.RingTree) ResolvedReplicaMap(com.ms.silverking.cloud.toporing.ResolvedReplicaMap)

Example 2 with RingTree

use of com.ms.silverking.cloud.toporing.RingTree in project SilverKing by Morgan-Stanley.

the class RingMapState2 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 3 with RingTree

use of com.ms.silverking.cloud.toporing.RingTree 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 4 with RingTree

use of com.ms.silverking.cloud.toporing.RingTree 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 5 with RingTree

use of com.ms.silverking.cloud.toporing.RingTree 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)5 RingTree (com.ms.silverking.cloud.toporing.RingTree)5 InstantiatedRingTree (com.ms.silverking.cloud.toporing.InstantiatedRingTree)4 InvalidRingException (com.ms.silverking.cloud.toporing.InvalidRingException)3 InvalidTransitionException (com.ms.silverking.cloud.dht.daemon.storage.convergence.InvalidTransitionException)2 ExclusionSet (com.ms.silverking.cloud.meta.ExclusionSet)2 ExclusionZK (com.ms.silverking.cloud.meta.ExclusionZK)2 ServerSetExtensionZK (com.ms.silverking.cloud.meta.ServerSetExtensionZK)2 IOException (java.io.IOException)2 KeeperException (org.apache.zookeeper.KeeperException)2