Search in sources :

Example 1 with ExclusionZK

use of com.ms.silverking.cloud.meta.ExclusionZK in project SilverKing by Morgan-Stanley.

the class StaticRingCreator method createStaticRing.

public static RingCreationResults createStaticRing(String ringName, ZooKeeperConfig zkConfig, Set<String> servers, int replication, UUIDBase myID) {
    try {
        MetaClient mc;
        com.ms.silverking.cloud.meta.MetaClient cloudMC;
        NamedRingConfiguration namedRingConfig;
        RingConfiguration ringConfig;
        RingTreeRecipe recipe;
        Topology topology;
        WeightSpecifications weightSpecs;
        ExclusionSet exclusionSet;
        StoragePolicyGroup storagePolicyGroup;
        HostGroupTable hostGroupTable;
        long ringConfigVersion;
        CloudConfiguration cloudConfig;
        String exclusionSpecsName;
        String hostGroupTableName;
        topology = StaticTopologyCreator.createTopology("topology." + myID, servers);
        exclusionSpecsName = "exclusionSpecs." + myID;
        hostGroupTableName = "hostGroupTable." + myID;
        cloudConfig = new CloudConfiguration(topology.getName(), exclusionSpecsName, hostGroupTableName);
        cloudMC = new com.ms.silverking.cloud.meta.MetaClient(cloudConfig, zkConfig);
        new TopologyZK(cloudMC).writeToZK(topology, null);
        new ExclusionZK(cloudMC).writeToZK(ExclusionSet.emptyExclusionSet(0));
        mc = new MetaClient(NamedRingConfiguration.emptyTemplate.ringName(ringName), zkConfig);
        ringConfig = new RingConfiguration(cloudConfig, "weightSpecsName", StaticTopologyCreator.parentID, SimpleStoragePolicyCreator.storagePolicyGroupName, SimpleStoragePolicyCreator.storagePolicyName, null);
        new RingConfigurationZK(mc).writeToZK(ringConfig, null);
        namedRingConfig = new NamedRingConfiguration(ringName, ringConfig);
        mc = new MetaClient(namedRingConfig, zkConfig);
        EmbeddedSK.setEmbeddedNamedRingConfiguration(ringName, namedRingConfig);
        Log.warning(zkConfig);
        ringConfigVersion = 0;
        weightSpecs = new WeightSpecifications(0);
        exclusionSet = ExclusionSet.emptyExclusionSet(0);
        storagePolicyGroup = SimpleStoragePolicyCreator.createStoragePolicyGroup(replication);
        new StoragePolicyZK(mc).writeToZK(storagePolicyGroup, null);
        hostGroupTable = HostGroupTable.createHostGroupTable(servers, hostGroupName);
        new HostGroupTableZK(cloudMC).writeToZK(hostGroupTable, null);
        recipe = new RingTreeRecipe(topology, StaticTopologyCreator.parentID, weightSpecs, exclusionSet, storagePolicyGroup, SimpleStoragePolicyCreator.storagePolicyName, hostGroupTable, ImmutableSet.of(hostGroupName), ringConfigVersion, DHTUtil.currentTimeMillis());
        Log.warning("Recipe.ringParent: " + recipe.ringParent);
        RingTree ringTree;
        String newInstancePath;
        ringTree = RingTreeBuilder.create(recipe, null);
        newInstancePath = mc.createConfigInstancePath(ringConfigVersion);
        SingleRingZK.writeTree(mc, topology, newInstancePath, ringTree);
        if (TopoRingConstants.verbose) {
            System.out.println(ringTree);
            System.out.println("Building complete");
        }
        return new RingCreationResults(exclusionSpecsName, hostGroupTableName, hostGroupTable, hostGroupName);
    } catch (IOException ioe) {
        Log.logErrorWarning(ioe);
        return null;
    } catch (KeeperException ke) {
        Log.logErrorWarning(ke);
        return null;
    }
}
Also used : MetaClient(com.ms.silverking.cloud.toporing.meta.MetaClient) HostGroupTable(com.ms.silverking.cloud.config.HostGroupTable) RingConfiguration(com.ms.silverking.cloud.toporing.meta.RingConfiguration) NamedRingConfiguration(com.ms.silverking.cloud.toporing.meta.NamedRingConfiguration) RingConfigurationZK(com.ms.silverking.cloud.toporing.meta.RingConfigurationZK) ExclusionZK(com.ms.silverking.cloud.meta.ExclusionZK) NamedRingConfiguration(com.ms.silverking.cloud.toporing.meta.NamedRingConfiguration) Topology(com.ms.silverking.cloud.topology.Topology) StoragePolicyZK(com.ms.silverking.cloud.storagepolicy.StoragePolicyZK) IOException(java.io.IOException) StoragePolicyGroup(com.ms.silverking.cloud.storagepolicy.StoragePolicyGroup) WeightSpecifications(com.ms.silverking.cloud.toporing.meta.WeightSpecifications) TopologyZK(com.ms.silverking.cloud.topology.TopologyZK) CloudConfiguration(com.ms.silverking.cloud.meta.CloudConfiguration) ExclusionSet(com.ms.silverking.cloud.meta.ExclusionSet) HostGroupTableZK(com.ms.silverking.cloud.meta.HostGroupTableZK) KeeperException(org.apache.zookeeper.KeeperException)

Example 2 with ExclusionZK

use of com.ms.silverking.cloud.meta.ExclusionZK 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);
}
Also used : ExclusionZK(com.ms.silverking.cloud.meta.ExclusionZK) ExclusionSet(com.ms.silverking.cloud.meta.ExclusionSet) CmdLineException(org.kohsuke.args4j.CmdLineException) KeeperException(org.apache.zookeeper.KeeperException) IOException(java.io.IOException) AlreadyBoundException(java.rmi.AlreadyBoundException) ServerSetExtensionZK(com.ms.silverking.cloud.meta.ServerSetExtensionZK)

Example 3 with ExclusionZK

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

use of com.ms.silverking.cloud.meta.ExclusionZK 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

ExclusionSet (com.ms.silverking.cloud.meta.ExclusionSet)4 ExclusionZK (com.ms.silverking.cloud.meta.ExclusionZK)4 IOException (java.io.IOException)4 KeeperException (org.apache.zookeeper.KeeperException)4 ServerSetExtensionZK (com.ms.silverking.cloud.meta.ServerSetExtensionZK)3 InvalidTransitionException (com.ms.silverking.cloud.dht.daemon.storage.convergence.InvalidTransitionException)2 InstantiatedRingTree (com.ms.silverking.cloud.toporing.InstantiatedRingTree)2 InvalidRingException (com.ms.silverking.cloud.toporing.InvalidRingException)2 ResolvedReplicaMap (com.ms.silverking.cloud.toporing.ResolvedReplicaMap)2 RingTree (com.ms.silverking.cloud.toporing.RingTree)2 HostGroupTable (com.ms.silverking.cloud.config.HostGroupTable)1 CloudConfiguration (com.ms.silverking.cloud.meta.CloudConfiguration)1 HostGroupTableZK (com.ms.silverking.cloud.meta.HostGroupTableZK)1 StoragePolicyGroup (com.ms.silverking.cloud.storagepolicy.StoragePolicyGroup)1 StoragePolicyZK (com.ms.silverking.cloud.storagepolicy.StoragePolicyZK)1 Topology (com.ms.silverking.cloud.topology.Topology)1 TopologyZK (com.ms.silverking.cloud.topology.TopologyZK)1 MetaClient (com.ms.silverking.cloud.toporing.meta.MetaClient)1 NamedRingConfiguration (com.ms.silverking.cloud.toporing.meta.NamedRingConfiguration)1 RingConfiguration (com.ms.silverking.cloud.toporing.meta.RingConfiguration)1