Search in sources :

Example 1 with RingEntry

use of com.ms.silverking.cloud.toporing.RingEntry in project SilverKing by Morgan-Stanley.

the class RingInfo method getAllocationMap.

private Map<IPAndPort, Long> getAllocationMap(ResolvedReplicaMap map) {
    Map<IPAndPort, Long> am;
    am = new HashMap<>();
    for (RingEntry entry : map.getEntries()) {
        for (IPAndPort replica : entry.getOwnersIPList(OwnerQueryMode.Primary)) {
            Long curAllocation;
            curAllocation = am.get(replica);
            if (curAllocation == null) {
                curAllocation = new Long(0);
            }
            curAllocation += entry.getRegion().getSize();
            am.put(replica, curAllocation);
        }
    }
    return am;
}
Also used : IPAndPort(com.ms.silverking.net.IPAndPort) RingEntry(com.ms.silverking.cloud.toporing.RingEntry)

Example 2 with RingEntry

use of com.ms.silverking.cloud.toporing.RingEntry in project SilverKing by Morgan-Stanley.

the class ConvergenceController2 method startPrimaryConvergence.

private void startPrimaryConvergence() {
    List<RingEntry> myPrimaryEntries;
    myPrimaryEntries = getTargetMapReplicaEntries(mgBase._getIPAndPort(), OwnerQueryMode.Primary);
    if (myPrimaryEntries != null) {
        for (RingEntry entry : myPrimaryEntries) {
            requestRemoteChecksumTreesForPrimary(entry);
        }
    }
}
Also used : RingEntry(com.ms.silverking.cloud.toporing.RingEntry)

Example 3 with RingEntry

use of com.ms.silverking.cloud.toporing.RingEntry in project SilverKing by Morgan-Stanley.

the class CentralConvergenceController method syncNamespace.

private Action syncNamespace(long ns, SyncTargets syncTargets, Action upstreamDependency) throws ConvergenceException {
    Set<RingEntry> entries;
    SynchronizationPoint syncPoint;
    List<ReplicaSyncRequest> srList;
    Log.warningAsyncf("Synchronizing %x", ns);
    srList = new ArrayList<>();
    entries = targetReplicaMap.getEntries();
    for (RingEntry entry : entries) {
        syncRegion(ns, entry, syncTargets, upstreamDependency, srList);
    }
    Log.warningAsyncf("Done synchronizing %x", ns);
    syncPoint = SynchronizationPoint.of(Long.toHexString(ns), srList.toArray(new Action[0]));
    // Note: downstream computed from upstream later
    if (serializeNamespaces) {
        syncController.addAction(syncPoint);
    } else {
        syncController.addCompleteAction(syncPoint);
    }
    return syncPoint;
}
Also used : RingEntry(com.ms.silverking.cloud.toporing.RingEntry)

Example 4 with RingEntry

use of com.ms.silverking.cloud.toporing.RingEntry in project SilverKing by Morgan-Stanley.

the class CentralConvergenceController method syncRegion.

// ////////////////////////////////////////////////////////////////
private void syncRegion(long ns, RingEntry targetEntry, SyncTargets syncTargets, Action upstreamDependency, List<ReplicaSyncRequest> srList) throws ConvergenceException {
    List<RingEntry> sourceEntries;
    // Log.warningAsyncf("syncRegion %x %s", ns, targetEntry);
    sourceEntries = curMap.getEntries(targetEntry.getRegion());
    if (!sourceEntries.isEmpty()) {
        // Log.warningAsyncf("%x target %s\towners %s\n", ns, targetEntry.getRegion(), CollectionUtil.toString(sourceEntries));
        for (RingEntry sourceEntry : sourceEntries) {
            List<IPAndPort> sourceOwners;
            List<IPAndPort> nonExcludedSourceOwners;
            sourceOwners = new ArrayList<>(sourceEntry.getOwnersIPList(OwnerQueryMode.Primary));
            Log.info("Filtering exclusion set: ", exclusionSet);
            nonExcludedSourceOwners = exclusionSet.filterByIP(sourceOwners);
            if (nonExcludedSourceOwners.size() != sourceOwners.size()) {
                Log.warningAsync("Raw sourceOwners:      ", sourceOwners);
                Log.warningAsync("Filtered nonExcludedSourceOwners: ", nonExcludedSourceOwners);
            }
            if (nonExcludedSourceOwners.size() == 0) {
                Log.warningAsyncf("%x All nonLocalOwners excluded. Ignoring exclusions for this entry.", ns);
            } else {
                sourceOwners = nonExcludedSourceOwners;
            }
            IntersectionResult iResult;
            // We don't want to request the entire source region.
            // We're only interested in the portion(s) of the source region that cover(s) the target region.
            // Log.warningAsyncf("Intersection %s %s", sourceEntry.getRegion(), targetEntry.getRegion());
            iResult = RingRegion.intersect(sourceEntry.getRegion(), targetEntry.getRegion());
            for (RingRegion commonSubRegion : iResult.getOverlapping()) {
                List<IPAndPort> targetOwners;
                List<IPAndPort> nonExcludedTargetOwners;
                targetOwners = new ArrayList<>(targetEntry.getOwnersIPList(syncTargets.getOwnerQueryMode()));
                nonExcludedTargetOwners = exclusionSet.filterByIP(targetOwners);
                for (IPAndPort newOwner : nonExcludedTargetOwners) {
                    if (sourceOwners.contains(newOwner) && !syncUnchangedOwners) {
                        Log.warningAsyncf("Skipping unchanged owner: %s", newOwner);
                    } else {
                        Action prev;
                        prev = upstreamDependency;
                        for (IPAndPort sourceOwner : nonExcludedSourceOwners) {
                            prev = syncReplica(ns, commonSubRegion, newOwner.port(dhtConfig.getPort()), sourceOwner.port(dhtConfig.getPort()), prev, srList);
                        }
                    }
                }
            }
        }
    } else {
        // This should actually never occur as the getEntries() call above
        // has no notion of local/non-local. It just returns the owners, and there
        // should always be owners.
        Log.warningAsyncf("Primary convergence %x. No previous non-local owners for entry: ", ns, targetEntry);
        throw new ConvergenceException("Unexpected no previous non-local owners for entry");
    }
// Log.warningAsyncf("Done syncRegion %x %s", ns, targetEntry);
}
Also used : IPAndPort(com.ms.silverking.net.IPAndPort) RingRegion(com.ms.silverking.cloud.ring.RingRegion) IntersectionResult(com.ms.silverking.cloud.ring.IntersectionResult) RingEntry(com.ms.silverking.cloud.toporing.RingEntry)

Example 5 with RingEntry

use of com.ms.silverking.cloud.toporing.RingEntry in project SilverKing by Morgan-Stanley.

the class RecoverDataController method recoverNamespace.

private Action recoverNamespace(long ns, Action upstreamDependency) throws ConvergenceException {
    Set<RingEntry> entries;
    SynchronizationPoint syncPoint;
    List<ReplicaSyncRequest> srList;
    Log.warningAsyncf("Recovering %x", ns);
    srList = new ArrayList<>();
    entries = targetReplicaMap.getEntries();
    for (RingEntry entry : entries) {
        recoverRegion(ns, entry, upstreamDependency, srList);
    }
    syncPoint = SynchronizationPoint.of(Long.toHexString(ns), srList.toArray(new Action[0]));
    // Note: downstream computed from upstream later
    if (serializeNamespaces) {
        syncController.addAction(syncPoint);
    } else {
        syncController.addCompleteAction(syncPoint);
    }
    Log.warningAsyncf("Done synchronizing %x", ns);
    return syncPoint;
}
Also used : RingEntry(com.ms.silverking.cloud.toporing.RingEntry)

Aggregations

RingEntry (com.ms.silverking.cloud.toporing.RingEntry)7 IPAndPort (com.ms.silverking.net.IPAndPort)3 IntersectionResult (com.ms.silverking.cloud.ring.IntersectionResult)2 RingRegion (com.ms.silverking.cloud.ring.RingRegion)2