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;
}
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);
}
}
}
}
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;
}
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();
}
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();
}
Aggregations