Search in sources :

Example 36 with Node

use of com.ms.silverking.cloud.topology.Node in project SilverKing by Morgan-Stanley.

the class TopologyRingCreator method createNodeAllocationStates.

private List<NodeAllocationState> createNodeAllocationStates(SubPolicyMember member, RingTreeRecipe recipe, Node parent, int replicas) {
    List<NodeAllocationState> nodeAllocationStates;
    List<Node> nodes;
    NodeClass nodeClass;
    List<Long> nodeRegionSizes;
    nodeClass = parent.getChildNodeClass();
    if (nodeClass == null) {
        System.err.println("parent.getChildren().size(): " + parent.getChildren().size());
        throw new RuntimeException("No nodes for parent " + parent);
    }
    nodes = member.getNodesList(parent, recipe);
    if (debug) {
        System.out.println("nodes.size() " + nodes.size());
    }
    nodeRegionSizes = RingRegion.allRingspace.dividedRegionSizes(recipe.weightSpecs.getWeights(nodes));
    if (debug) {
        System.out.println(CollectionUtil.toString(nodeRegionSizes, '\n'));
    }
    nodeAllocationStates = new ArrayList<>(nodes.size());
    for (int i = 0; i < nodes.size(); i++) {
        nodeAllocationStates.add(new NodeAllocationState(nodes.get(i), replicas, nodeRegionSizes.get(i)));
    }
    return nodeAllocationStates;
}
Also used : NodeClass(com.ms.silverking.cloud.topology.NodeClass) Node(com.ms.silverking.cloud.topology.Node) GenericNode(com.ms.silverking.cloud.topology.GenericNode)

Example 37 with Node

use of com.ms.silverking.cloud.topology.Node in project SilverKing by Morgan-Stanley.

the class TopologyRingCreator method sanityCheckAllocations.

private void sanityCheckAllocations(ProtoRegionList prList, List<Node> nodes, List<Long> nodeRegionSizes, int replicaIndex, int nodeIndex, long ringspaceToAllocate, List<Integer> shuffle) {
    Map<String, Long> allocations;
    allocations = prList.getAllocations();
    if (ringspaceToAllocate < -magnitudeTolerance) {
        long regionSize;
        Node n;
        Long allocation;
        int i;
        i = shuffle.get(nodeIndex);
        n = nodes.get(i);
        regionSize = nodeRegionSizes.get(i);
        allocation = allocations.get(n.getIDString());
        if (allocation == null) {
            allocation = new Long(0);
        }
        System.out.printf("%s\t%d\t%d\t%d\t%d\t%d\t***FAILED1\n", n.getIDString(), regionSize, regionSize * (replicaIndex + 1), allocation, regionSize * (replicaIndex + 1) - allocation, ringspaceToAllocate);
        // throw new RuntimeException("Fatal: sanityCheckAllocations failed@1");
        System.exit(-1);
    }
    for (int _i = 0; _i < nodes.size(); _i++) {
        long regionSize;
        Node n;
        Long allocation;
        int i;
        i = shuffle.get(_i);
        n = nodes.get(i);
        regionSize = nodeRegionSizes.get(i);
        allocation = allocations.get(n.getIDString());
        if (allocation != null) {
            long _ringspaceToAllocate;
            _ringspaceToAllocate = i == nodeIndex ? ringspaceToAllocate : 0;
            // System.out.printf("%s\t%d\t%d\t%d\t%d\t%d\n", n.getIDString(), regionSize, regionSize * (replicaIndex + 1), allocation, regionSize * (replicaIndex + 1) - allocation, _ringspaceToAllocate);
            if (_ringspaceToAllocate + allocation > regionSize * (replicaIndex + 1) + magnitudeTolerance) {
                System.out.printf("%s\t%d\t%d\t%d\t%d\t%d\t***FAILED\n", n.getIDString(), regionSize, regionSize * (replicaIndex + 1), allocation, regionSize * (replicaIndex + 1) - allocation, _ringspaceToAllocate);
                // throw new RuntimeException("Fatal: sanityCheckAllocations failed");
                System.exit(-1);
            }
        }
    }
}
Also used : Node(com.ms.silverking.cloud.topology.Node) GenericNode(com.ms.silverking.cloud.topology.GenericNode)

Example 38 with Node

use of com.ms.silverking.cloud.topology.Node in project SilverKing by Morgan-Stanley.

the class ExclusionSet method filter.

public List<Node> filter(List<Node> raw) {
    List<Node> filtered;
    filtered = new ArrayList<>(raw.size());
    for (Node node : raw) {
        if (!getServers().contains(node.getIDString())) {
            filtered.add(node);
        }
    }
    return filtered;
}
Also used : Node(com.ms.silverking.cloud.topology.Node)

Example 39 with Node

use of com.ms.silverking.cloud.topology.Node in project SilverKing by Morgan-Stanley.

the class PrimarySecondaryListPair method toString.

@Override
public String toString() {
    StringBuilder sb;
    sb = new StringBuilder();
    sb.append("p ");
    for (Node owner : primaryOwners) {
        sb.append(owner);
        sb.append(' ');
    }
    sb.append("s ");
    for (Node owner : secondaryOwners) {
        sb.append(owner);
        sb.append(' ');
    }
    return sb.toString();
}
Also used : Node(com.ms.silverking.cloud.topology.Node)

Example 40 with Node

use of com.ms.silverking.cloud.topology.Node in project SilverKing by Morgan-Stanley.

the class RingEntry method removeOwnersNotInSet.

private static List<Node> removeOwnersNotInSet(List<Node> old, Set<Node> includeNodes) {
    ImmutableList.Builder<Node> builder;
    builder = ImmutableList.builder();
    for (Node node : old) {
        if (includeNodes.contains(node)) {
            builder.add(node);
        }
    }
    return builder.build();
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) DHTNode(com.ms.silverking.cloud.dht.daemon.DHTNode) Node(com.ms.silverking.cloud.topology.Node)

Aggregations

Node (com.ms.silverking.cloud.topology.Node)50 GenericNode (com.ms.silverking.cloud.topology.GenericNode)17 DHTNode (com.ms.silverking.cloud.dht.daemon.DHTNode)10 ImmutableSet (com.google.common.collect.ImmutableSet)6 IPAndPort (com.ms.silverking.net.IPAndPort)5 NodeClass (com.ms.silverking.cloud.topology.NodeClass)4 SubPolicy (com.ms.silverking.cloud.storagepolicy.SubPolicy)2 SubPolicyMember (com.ms.silverking.cloud.storagepolicy.SubPolicyMember)2 RingInteger (com.ms.silverking.numeric.RingInteger)2 ImmutableList (com.google.common.collect.ImmutableList)1 HostGroupTable (com.ms.silverking.cloud.config.HostGroupTable)1 PolicyParser (com.ms.silverking.cloud.storagepolicy.PolicyParser)1 StoragePolicy (com.ms.silverking.cloud.storagepolicy.StoragePolicy)1 StoragePolicyGroup (com.ms.silverking.cloud.storagepolicy.StoragePolicyGroup)1 Topology (com.ms.silverking.cloud.topology.Topology)1 WeightSpecifications (com.ms.silverking.cloud.toporing.meta.WeightSpecifications)1 SimpleStopwatch (com.ms.silverking.time.SimpleStopwatch)1 Stopwatch (com.ms.silverking.time.Stopwatch)1 File (java.io.File)1 BigDecimal (java.math.BigDecimal)1