use of com.ms.silverking.cloud.storagepolicy.StoragePolicy 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;
}
Aggregations