Search in sources :

Example 6 with WeightSpecifications

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

the class SingleRingZK method readFromZK.

/*
    private static String topologyNodeNameAndStoragePolicyNameToMapName(String topologyNodeName, String policyName) {
        return topologyNodeName + mapNameDelimiter + policyName;
    }

    private static Pair<String,String> mapNameToTopologyNodeNameAndStoragePolicyName(String mapName) {
        String[]    names;
        
        names = mapName.split(mapNameDelimiter);
        return new Pair<>(names[0], names[1]);
    }
    */
@Override
public TopologyRing readFromZK(long version, MetaToolOptions options) throws KeeperException {
    List<String> nodes;
    SingleRing singleRing;
    String storagePolicyName;
    Map<String, String> defs;
    Set<String> paths;
    nodes = zk.getChildren(base);
    storagePolicyName = nodes.get(nodes.indexOf(storagePolicyNameNode));
    nodes.remove(versionNode);
    nodes.remove(storagePolicyNameNode);
    singleRing = new SingleRing(nodeClass, version, storagePolicyName);
    paths = new HashSet<>();
    for (String node : nodes) {
        paths.add(base + "/" + node);
    }
    defs = zk.getStrings(paths);
    for (String node : nodes) {
        String def;
        RingEntry entry;
        def = defs.get(base + "/" + node);
        if (TopoRingConstants.verbose) {
            System.out.println("base: " + base);
            System.out.println("def: " + def);
        }
        entry = RingEntry.parseZKDefs(topology, node, def);
        singleRing.addEntry(entry);
    }
    // pass empty weight specifications since only the reallocator
    // needs them
    // FIXME - think about whether re-allocator will use this code
    singleRing.freeze(new WeightSpecifications(0));
    return singleRing;
}
Also used : WeightSpecifications(com.ms.silverking.cloud.toporing.meta.WeightSpecifications)

Aggregations

WeightSpecifications (com.ms.silverking.cloud.toporing.meta.WeightSpecifications)6 HostGroupTable (com.ms.silverking.cloud.config.HostGroupTable)5 StoragePolicyGroup (com.ms.silverking.cloud.storagepolicy.StoragePolicyGroup)5 Topology (com.ms.silverking.cloud.topology.Topology)5 File (java.io.File)3 ExclusionSet (com.ms.silverking.cloud.meta.ExclusionSet)2 HostGroupTableZK (com.ms.silverking.cloud.meta.HostGroupTableZK)2 PolicyParser (com.ms.silverking.cloud.storagepolicy.PolicyParser)2 TopologyZK (com.ms.silverking.cloud.topology.TopologyZK)2 NamedRingConfiguration (com.ms.silverking.cloud.toporing.meta.NamedRingConfiguration)2 RingConfiguration (com.ms.silverking.cloud.toporing.meta.RingConfiguration)2 RingConfigurationZK (com.ms.silverking.cloud.toporing.meta.RingConfigurationZK)2 IOException (java.io.IOException)2 KeeperException (org.apache.zookeeper.KeeperException)2 CloudConfiguration (com.ms.silverking.cloud.meta.CloudConfiguration)1 ExclusionZK (com.ms.silverking.cloud.meta.ExclusionZK)1 ServerSetExtensionZK (com.ms.silverking.cloud.meta.ServerSetExtensionZK)1 PolicyParseException (com.ms.silverking.cloud.storagepolicy.PolicyParseException)1 StoragePolicyZK (com.ms.silverking.cloud.storagepolicy.StoragePolicyZK)1 GenericNode (com.ms.silverking.cloud.topology.GenericNode)1