Search in sources :

Example 1 with TopologyRingCreator

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

the class TestTopoRingCreator method main.

public static void main(String[] args) {
    try {
        if (args.length != 8) {
            System.out.println("<topologyFile> <weightSpecsFile> <exclusionList> <nodeID> <storagePolicyGroup1,...> <policyID> <HostGroupTableFile> <HostGroup,...>");
        } else {
            TopologyRingCreator topologyRingCreator;
            Topology topology;
            File topologyFile;
            File weightSpecsFile;
            File exclusionFile;
            String nodeID;
            String policyID;
            // Replication         replication;
            StoragePolicyGroup[] storagePolicyGroups;
            TopologyRing lastRing;
            HostGroupTable hostGroupTable;
            Set<String> hostGroups;
            // Log.setLevelAll();
            topologyFile = new File(args[0]);
            weightSpecsFile = new File(args[1]);
            exclusionFile = new File(args[2]);
            nodeID = args[3];
            storagePolicyGroups = parseStoragePolicyGroups(args[4]);
            policyID = args[5];
            topology = TopologyParser.parse(topologyFile);
            topologyRingCreator = new TopologyRingCreator();
            hostGroupTable = HostGroupTable.parse(args[6], VersionedDefinition.NO_VERSION);
            hostGroups = ImmutableSet.copyOf(args[7].split(","));
            lastRing = null;
            for (StoragePolicyGroup spGroup : storagePolicyGroups) {
                RingTreeRecipe recipe;
                TopologyRing topologyRing;
                recipe = new RingTreeRecipe(topology, topology.getNodeByID(nodeID), new WeightSpecifications(VersionedDefinition.NO_VERSION).parse(weightSpecsFile), ExclusionSet.parse(exclusionFile), spGroup, policyID, hostGroupTable, hostGroups, 0L, DHTUtil.currentTimeMillis());
                System.out.println("********************************");
                System.out.println("RingTreeRecipe: " + recipe);
                topologyRing = topologyRingCreator.create(recipe, nodeID);
                System.out.println("\n\nTopologyRing:\n");
                System.out.println(topologyRing);
                System.out.println("\n\n");
                if (lastRing != null) {
                    topologyRing = topologyRingCreator.reduceDataMovement(lastRing, topologyRing, recipe);
                    System.out.println(topologyRing);
                }
                lastRing = topologyRing;
            }
        }
    } catch (Exception e) {
        Log.logErrorWarning(e);
    }
}
Also used : WeightSpecifications(com.ms.silverking.cloud.toporing.meta.WeightSpecifications) TopologyRingCreator(com.ms.silverking.cloud.toporing.TopologyRingCreator) RingTreeRecipe(com.ms.silverking.cloud.toporing.RingTreeRecipe) TopologyRing(com.ms.silverking.cloud.toporing.TopologyRing) HostGroupTable(com.ms.silverking.cloud.config.HostGroupTable) Topology(com.ms.silverking.cloud.topology.Topology) File(java.io.File) StoragePolicyGroup(com.ms.silverking.cloud.storagepolicy.StoragePolicyGroup) PolicyParseException(com.ms.silverking.cloud.storagepolicy.PolicyParseException)

Aggregations

HostGroupTable (com.ms.silverking.cloud.config.HostGroupTable)1 PolicyParseException (com.ms.silverking.cloud.storagepolicy.PolicyParseException)1 StoragePolicyGroup (com.ms.silverking.cloud.storagepolicy.StoragePolicyGroup)1 Topology (com.ms.silverking.cloud.topology.Topology)1 RingTreeRecipe (com.ms.silverking.cloud.toporing.RingTreeRecipe)1 TopologyRing (com.ms.silverking.cloud.toporing.TopologyRing)1 TopologyRingCreator (com.ms.silverking.cloud.toporing.TopologyRingCreator)1 WeightSpecifications (com.ms.silverking.cloud.toporing.meta.WeightSpecifications)1 File (java.io.File)1