Search in sources :

Example 1 with PolicyParser

use of com.ms.silverking.cloud.storagepolicy.PolicyParser in project SilverKing by Morgan-Stanley.

the class RingTreeBuilder method main.

public static void main(String[] args) {
    try {
        if (args.length != 8) {
            System.out.println("<topology> <weights> <exclusionList> <ringParentID> <storagePolicyGroup> <storagePolicyName> <HostGroupTableFile> <HostGroup,...>");
        } else {
            File topoFile;
            File weightsFile;
            File exclusionFile;
            String ringParentID;
            File storagePolicyGroupFile;
            String storagePolicyName;
            RingTree ringTree;
            Topology topology;
            StoragePolicyGroup storagePolicyGroup;
            HostGroupTable hostGroupTable;
            Set<String> hostGroups;
            topoFile = new File(args[0]);
            weightsFile = new File(args[1]);
            exclusionFile = new File(args[2]);
            ringParentID = args[3];
            storagePolicyGroupFile = new File(args[4]);
            storagePolicyName = args[5];
            topology = TopologyParser.parse(topoFile);
            storagePolicyGroup = new PolicyParser().parsePolicyGroup(storagePolicyGroupFile, VersionedDefinition.NO_VERSION);
            hostGroupTable = HostGroupTable.parse(args[6], VersionedDefinition.NO_VERSION);
            hostGroups = ImmutableSet.copyOf(args[7].split(","));
            ringTree = create(new RingTreeRecipe(topology, (Node) topology.getNodeByID(ringParentID), new WeightSpecifications(VersionedDefinition.NO_VERSION).parse(weightsFile), ExclusionSet.parse(exclusionFile), storagePolicyGroup, storagePolicyName, hostGroupTable, hostGroups, 0L, System.currentTimeMillis()));
            // TopoReplicationSpecification.parse(replicationFile)));
            System.out.println(ringTree);
            ringTree.test("10.188.1.1");
            ringTree.testDistance("10.188.1.1", "10.188.1.1");
            ringTree.testDistance("10.188.1.1", "10.188.1.2");
            ringTree.testDistance("10.188.1.1", "10.188.2.2");
            ringTree.testDistance("10.188.2.1", "10.188.2.2");
            ringTree.testDistance("10.188.2.2", "10.188.2.2");
            ringTree.testDistance("10.188.1.1", "blah");
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : PolicyParser(com.ms.silverking.cloud.storagepolicy.PolicyParser) WeightSpecifications(com.ms.silverking.cloud.toporing.meta.WeightSpecifications) 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)

Example 2 with PolicyParser

use of com.ms.silverking.cloud.storagepolicy.PolicyParser in project SilverKing by Morgan-Stanley.

the class TopologyRingCreator method main.

// //////////////////////////////////////////////////
/**
 * @param args
 */
public static void main(String[] args) {
    try {
        if (args.length != 8) {
            System.out.println("<topologyFile> <weightSpecsFile> <exclusionList> <nodeID> <storagePolicyGroup> <policyID> <HostGroupTableFile> <HostGroup,...>");
        } else {
            TopologyRingCreator topologyRingCreator;
            Topology topology;
            File topologyFile;
            File weightSpecsFile;
            File exclusionFile;
            File storagePolicyGroupFile;
            String nodeID;
            String policyID;
            // Replication replication;
            StoragePolicyGroup storagePolicyGroup;
            TopologyRing topologyRing;
            Node node;
            RingTreeRecipe recipe;
            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];
            storagePolicyGroupFile = new File(args[4]);
            policyID = args[5];
            storagePolicyGroup = new PolicyParser().parsePolicyGroup(storagePolicyGroupFile, VersionedDefinition.NO_VERSION);
            topology = TopologyParser.parse(topologyFile);
            topologyRingCreator = new TopologyRingCreator();
            hostGroupTable = HostGroupTable.parse(args[6], VersionedDefinition.NO_VERSION);
            hostGroups = ImmutableSet.copyOf(args[7].split(","));
            recipe = new RingTreeRecipe(topology, topology.getNodeByID(nodeID), new WeightSpecifications(VersionedDefinition.NO_VERSION).parse(weightSpecsFile), ExclusionSet.parse(exclusionFile), storagePolicyGroup, policyID, hostGroupTable, hostGroups, // version not
            0L, // this tree
            DHTUtil.currentTimeMillis());
            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");
            topologyRing = topologyRingCreator.reduceDataMovement(topologyRing, topologyRing, recipe);
            System.out.println(topologyRing);
        }
    } catch (Exception e) {
        Log.logErrorWarning(e);
    }
}
Also used : PolicyParser(com.ms.silverking.cloud.storagepolicy.PolicyParser) Node(com.ms.silverking.cloud.topology.Node) GenericNode(com.ms.silverking.cloud.topology.GenericNode) HostGroupTable(com.ms.silverking.cloud.config.HostGroupTable) Topology(com.ms.silverking.cloud.topology.Topology) StoragePolicyGroup(com.ms.silverking.cloud.storagepolicy.StoragePolicyGroup) WeightSpecifications(com.ms.silverking.cloud.toporing.meta.WeightSpecifications) File(java.io.File)

Aggregations

HostGroupTable (com.ms.silverking.cloud.config.HostGroupTable)2 PolicyParser (com.ms.silverking.cloud.storagepolicy.PolicyParser)2 StoragePolicyGroup (com.ms.silverking.cloud.storagepolicy.StoragePolicyGroup)2 Topology (com.ms.silverking.cloud.topology.Topology)2 WeightSpecifications (com.ms.silverking.cloud.toporing.meta.WeightSpecifications)2 File (java.io.File)2 GenericNode (com.ms.silverking.cloud.topology.GenericNode)1 Node (com.ms.silverking.cloud.topology.Node)1