Search in sources :

Example 1 with StoragePolicy

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;
}
Also used : DHTNode(com.ms.silverking.cloud.dht.daemon.DHTNode) Node(com.ms.silverking.cloud.topology.Node) ArrayList(java.util.ArrayList) StoragePolicy(com.ms.silverking.cloud.storagepolicy.StoragePolicy)

Aggregations

DHTNode (com.ms.silverking.cloud.dht.daemon.DHTNode)1 StoragePolicy (com.ms.silverking.cloud.storagepolicy.StoragePolicy)1 Node (com.ms.silverking.cloud.topology.Node)1 ArrayList (java.util.ArrayList)1