use of com.ms.silverking.cloud.topology.Node in project SilverKing by Morgan-Stanley.
the class RingMapState method getTargetsByAncestorClass.
private Set<IPAndPort> getTargetsByAncestorClass(String nodeClassName) {
Node ancestor;
ancestor = rawRingTree.getTopology().getAncestor(nodeID.getIPAsString(), NodeClass.forName(nodeClassName));
return nodeListToIPAndPortSet(ancestor.getAllDescendants(NodeClass.server));
}
use of com.ms.silverking.cloud.topology.Node in project SilverKing by Morgan-Stanley.
the class RingMapState method nodeListToIPAndPortSet.
// /////////////
private Set<IPAndPort> nodeListToIPAndPortSet(List<Node> replicaNodes) {
ImmutableSet.Builder<IPAndPort> replicaSet;
replicaSet = ImmutableSet.builder();
for (Node replicaNode : replicaNodes) {
if (!replicaNode.getNodeClass().equals(NodeClass.server)) {
throw new RuntimeException("Unexpected non-server node class: " + replicaNode);
}
replicaSet.add(new IPAndPort(replicaNode.getIDString(), nodeID.getPort()));
}
return replicaSet.build();
}
use of com.ms.silverking.cloud.topology.Node in project SilverKing by Morgan-Stanley.
the class RingTree method getStorageReplicas.
public Set<IPAndPort> getStorageReplicas(long coordinate) {
Set<Node> nodes;
Set<IPAndPort> replicas;
if (debug) {
System.out.println("getStorageReplicas");
}
nodes = getStorageNodes(coordinate);
if (debug) {
System.out.println("nodes.size()" + nodes.size());
}
replicas = new HashSet<>();
for (Node node : nodes) {
if (debug) {
System.out.println(node);
}
replicas.add(new IPAndPort(node.getIDString() + ":" + DHTNode.getServerPort()));
}
return ImmutableSet.copyOf(replicas);
}
use of com.ms.silverking.cloud.topology.Node in project SilverKing by Morgan-Stanley.
the class RingTree method getStorageNodes.
// Slow/proof-of-concept implementation
// replace, possibly pre-compute when concept is
// decided on
// (Precomputation is now in place)
private Set<Node> getStorageNodes(Node parent, long coordinate) {
TopologyRing ring;
RingEntry ringEntry;
Set<Node> children;
Set<Node> storageNodes;
long normalizedCoordinate;
ring = getNodeRing(parent);
ringEntry = ring.getOwner(coordinate);
normalizedCoordinate = LongRingspace.mapRegionPointToRingspace(ringEntry.getRegion(), coordinate);
children = ringEntry.getPrimaryOwnersSet();
storageNodes = new HashSet<>();
for (Node child : children) {
if (child.hasChildren()) {
storageNodes.addAll(getStorageNodes(child, normalizedCoordinate));
} else {
storageNodes.add(child);
}
}
return storageNodes;
}
use of com.ms.silverking.cloud.topology.Node in project SilverKing by Morgan-Stanley.
the class RingTreeRecipe method nonExcludedChildren.
public Set<Node> nonExcludedChildren(String nodeID) {
ImmutableSet.Builder<Node> builder;
Node node;
node = topology.getNodeByID(nodeID);
builder = ImmutableSet.builder();
for (Node child : node.getChildren()) {
if (!exclusionList.contains(child.getIDString())) {
if (hasDescendantInHostGroups(child)) {
builder.add(child);
}
}
}
return builder.build();
}
Aggregations