use of com.ms.silverking.cloud.topology.Node in project SilverKing by Morgan-Stanley.
the class SubPolicyMember method getNodesBound.
private Set<Node> getNodesBound(Node parent, RingTreeRecipe recipe) {
Set<Node> members;
members = new HashSet<>(boundIDs.size());
for (String id : boundIDs) {
Node member;
member = parent.getChildByID(id);
if (member == null) {
throw new RuntimeException("Couldn't find bound member: " + id + " in " + parent);
}
if (recipe.exclusionList.contains(id)) {
throw new RuntimeException("Bound member is excluded: " + id + " in " + parent);
}
members.add(member);
}
return members;
}
use of com.ms.silverking.cloud.topology.Node in project SilverKing by Morgan-Stanley.
the class RingTree method testCoordinate.
public void testCoordinate(long coordinate, String pov) {
System.out.print(coordinate + "\t");
for (Node node : getStorageNodesOrdered(coordinate, pov)) {
System.out.print(node + " ");
}
System.out.println();
}
use of com.ms.silverking.cloud.topology.Node in project SilverKing by Morgan-Stanley.
the class RingTree method project.
private List<RingEntry> project(Node node, RingRegion parentRegion) {
List<RingEntry> entryList;
List<RingEntry> projectedEntryList;
List<RingEntry> cleanedEntryList;
if (debug) {
System.out.println("project " + node + " " + parentRegion);
}
if (node.childNodeClassMatches(NodeClass.server)) {
entryList = getRawEntryList(node);
} else {
if (!node.hasChildren()) {
return new ArrayList<>();
} else {
TopologyRing ring;
StoragePolicy storagePolicy;
entryList = new ArrayList<>();
ring = getNodeRing(node);
if (ring == null) {
throw new RuntimeException("Can't find ring for node: " + node);
} else {
List<RingEntry> allChildList;
allChildList = new ArrayList<>();
for (RingEntry entry : ring.getMembers()) {
// all subentries to this entry
if (debug) {
System.out.println("primary");
}
for (Node childNode : entry.getPrimaryOwnersList()) {
List<RingEntry> childList;
childList = project(childNode, entry.getRegion());
if (debug) {
System.out.println("back to " + node + " from " + childNode);
}
allChildList.addAll(childList);
// merge(entryList, childList);
}
if (debug) {
System.out.println("secondary");
}
for (Node childNode : entry.getSecondaryOwnersList()) {
List<RingEntry> childList;
childList = convertPrimaryToSecondary(project(childNode, entry.getRegion()));
if (debug) {
System.out.println("back to " + node + " from " + childNode);
}
allChildList.addAll(childList);
// merge(entryList, childList);
}
}
merge(entryList, allChildList);
}
}
}
displayForDebug(entryList, "entryList");
RingEntry.ensureEntryRegionsDisjoint(entryList);
projectedEntryList = projectEntryList(entryList, parentRegion);
displayForDebug(projectedEntryList, "projectedEntryList");
cleanedEntryList = cleanupList(parentRegion, projectedEntryList);
displayForDebug(cleanedEntryList, "cleanedEntryList");
RingEntry.ensureMinPrimaryUnderFailureMet(entryList);
return cleanedEntryList;
}
use of com.ms.silverking.cloud.topology.Node in project SilverKing by Morgan-Stanley.
the class RingTree method getResolvedMap.
// ///////////////////////////////
public ResolvedReplicaMap getResolvedMap(String ringParentName, ReplicaPrioritizer replicaPrioritizer) {
try {
ResolvedReplicaMap resolvedMap;
List<RingEntry> entryList;
Node node;
Stopwatch sw;
Log.warningf("getResolvedMap: %s", ringParentName);
sw = new SimpleStopwatch();
resolvedMap = new ResolvedReplicaMap(replicaPrioritizer);
if (debug) {
System.out.println("getResolvedMap: " + topology.getRoot());
}
node = topology.getNodeByID(ringParentName);
if (node == null) {
throw new RuntimeException("Unable to getNodeByID " + ringParentName);
}
entryList = project(node, LongRingspace.globalRegion);
for (RingEntry entry : entryList) {
resolvedMap.addEntry(entry);
}
resolvedMap.computeReplicaSet();
sw.stop();
Log.warningf("getResolvedMap: %s complete %f", ringParentName, sw.getElapsedSeconds());
return resolvedMap;
} catch (RuntimeException re) {
re.printStackTrace();
throw re;
}
}
use of com.ms.silverking.cloud.topology.Node in project SilverKing by Morgan-Stanley.
the class RingTree method getMemberNodes.
public Set<Node> getMemberNodes(OwnerQueryMode oqm, NodeClass nodeClass) {
ImmutableSet.Builder<Node> replicas;
replicas = ImmutableSet.builder();
for (Node node : getMemberNodes(oqm)) {
if (node.getNodeClass() == nodeClass) {
replicas.add(node);
}
}
return replicas.build();
}
Aggregations