Search in sources :

Example 1 with MetaClient

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

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

the class RingInfo method readTree.

private InstantiatedRingTree readTree(Triple<String, Long, Long> ring) throws IOException, KeeperException {
    MetaClient ringMC;
    long ringConfigVersion;
    long configInstanceVersion;
    InstantiatedRingTree ringTree;
    ringConfigVersion = ring.getTail().getV1();
    configInstanceVersion = ring.getTail().getV2();
    ringMC = metaUtil.getRingMC();
    ringTree = SingleRingZK.readTree(ringMC, ringConfigVersion, configInstanceVersion);
    return ringTree;
}
Also used : MetaClient(com.ms.silverking.cloud.toporing.meta.MetaClient) InstantiatedRingTree(com.ms.silverking.cloud.toporing.InstantiatedRingTree)

Example 3 with MetaClient

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

the class MetaTool method doWork.

@Override
protected void doWork(MetaToolOptions options) throws IOException, KeeperException {
    MetaClient mc;
    Tool tool;
    tool = Tool.valueOf(options.tool);
    mc = new MetaClient(namedRingConfigurationFor(tool, options.name), new ZooKeeperConfig(options.zkConfig));
    doWork(options, new MetaToolWorker(getModule(tool, mc)));
}
Also used : ZooKeeperConfig(com.ms.silverking.cloud.zookeeper.ZooKeeperConfig) MetaClient(com.ms.silverking.cloud.toporing.meta.MetaClient)

Example 4 with MetaClient

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

the class DebugKey method readTree.

private InstantiatedRingTree readTree(Triple<String, Long, Long> ring) throws IOException, KeeperException {
    MetaClient ringMC;
    long ringConfigVersion;
    long configInstanceVersion;
    InstantiatedRingTree ringTree;
    ringConfigVersion = ring.getTail().getV1();
    configInstanceVersion = ring.getTail().getV2();
    ringMC = metaUtil.getRingMC();
    ringTree = SingleRingZK.readTree(ringMC, ringConfigVersion, configInstanceVersion);
    return ringTree;
}
Also used : MetaClient(com.ms.silverking.cloud.toporing.meta.MetaClient) InstantiatedRingTree(com.ms.silverking.cloud.toporing.InstantiatedRingTree)

Example 5 with MetaClient

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

the class ComputeRingStats method readTree.

private InstantiatedRingTree readTree(Triple<String, Long, Long> ring) throws IOException, KeeperException {
    MetaClient ringMC;
    long ringConfigVersion;
    long configInstanceVersion;
    InstantiatedRingTree ringTree;
    ringConfigVersion = ring.getTail().getV1();
    configInstanceVersion = ring.getTail().getV2();
    ringMC = metaUtil.getRingMC();
    ringTree = SingleRingZK.readTree(ringMC, ringConfigVersion, configInstanceVersion);
    return ringTree;
}
Also used : MetaClient(com.ms.silverking.cloud.toporing.meta.MetaClient) InstantiatedRingTree(com.ms.silverking.cloud.toporing.InstantiatedRingTree)

Aggregations

MetaClient (com.ms.silverking.cloud.toporing.meta.MetaClient)6 InstantiatedRingTree (com.ms.silverking.cloud.toporing.InstantiatedRingTree)3 HostGroupTable (com.ms.silverking.cloud.config.HostGroupTable)1 CloudConfiguration (com.ms.silverking.cloud.meta.CloudConfiguration)1 ExclusionSet (com.ms.silverking.cloud.meta.ExclusionSet)1 ExclusionZK (com.ms.silverking.cloud.meta.ExclusionZK)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 MetaPaths (com.ms.silverking.cloud.toporing.meta.MetaPaths)1 NamedRingConfiguration (com.ms.silverking.cloud.toporing.meta.NamedRingConfiguration)1 RingConfiguration (com.ms.silverking.cloud.toporing.meta.RingConfiguration)1 RingConfigurationZK (com.ms.silverking.cloud.toporing.meta.RingConfigurationZK)1 WeightSpecifications (com.ms.silverking.cloud.toporing.meta.WeightSpecifications)1 ZooKeeperConfig (com.ms.silverking.cloud.zookeeper.ZooKeeperConfig)1 Triple (com.ms.silverking.collection.Triple)1 IOException (java.io.IOException)1 KeeperException (org.apache.zookeeper.KeeperException)1