Search in sources :

Example 16 with RingRegion

use of com.ms.silverking.cloud.ring.RingRegion in project SilverKing by Morgan-Stanley.

the class SingleRing method releaseToNode.

/**
 * Mutates this ring to move the specified region from the oldOwner to the newOwner.
 * The specified region must be a subregion of an existing region owned by the oldOwner.
 */
@Override
public void releaseToNode(RingRegion region, Node oldOwner, Node newOwner) {
    RingEntry oldEntry;
    RingRegion otherRegion;
    RingRegion oldRegion;
    ensureMutable();
    Log.fine("region: " + region);
    oldEntry = removeOwner(region.getEnd());
    oldRegion = oldEntry.getRegion();
    Log.fine("oldRegion: " + oldRegion);
    if (region.getSize() > oldRegion.getSize()) {
        throw new RuntimeException("region.getSize() > oldRegion.getSize() " + oldRegion + " " + region);
    }
    if (oldRegion.getEnd() == region.getEnd()) {
        if (oldRegion.getStart() == region.getStart()) {
            // complete replacement
            Log.fine("complete replacement");
            addEntry(oldEntry.replacePrimaryOwner(oldOwner, newOwner));
        } else {
            // region is the end of the old region
            Log.fine("region is the end of the old region");
            addEntry(new RingEntry(oldEntry.getOwnersSetWithReplacement(oldOwner, newOwner, OwnerQueryMode.Primary), region, oldEntry.getMinPrimaryUnderFailure()));
            otherRegion = new RingRegion(oldRegion.getStart(), LongRingspace.prevPoint(region.getStart()));
            addEntry(new RingEntry(oldEntry.getPrimaryOwnersList(), otherRegion, oldEntry.getMinPrimaryUnderFailure()));
        }
    } else {
        if (oldRegion.getStart() == region.getStart()) {
            // region is the start of the old region
            Log.fine("region is the start of the old region");
            otherRegion = new RingRegion(LongRingspace.nextPoint(region.getEnd()), oldRegion.getEnd());
            addEntry(new RingEntry(oldEntry.getPrimaryOwnersList(), otherRegion, oldEntry.getMinPrimaryUnderFailure()));
            addEntry(new RingEntry(oldEntry.getOwnersSetWithReplacement(oldOwner, newOwner, OwnerQueryMode.Primary), region, oldEntry.getMinPrimaryUnderFailure()));
        } else {
            throw new RuntimeException("invalid regions: " + oldRegion + "\t" + region);
        }
    }
}
Also used : RingRegion(com.ms.silverking.cloud.ring.RingRegion)

Example 17 with RingRegion

use of com.ms.silverking.cloud.ring.RingRegion in project SilverKing by Morgan-Stanley.

the class DHTRingMaster method requestChecksumTree.

public void requestChecksumTree(Triple<Long, Long, Long> nsAndRegion, ConvergencePoint curCP, ConvergencePoint targetCP, IPAndPort owner) {
    MessageGroup mg;
    UUIDBase uuid;
    uuid = UUIDBase.random();
    mg = new ProtoChecksumTreeRequestMessageGroup(uuid, nsAndRegion.getV1(), targetCP, curCP, mgBase.getMyID(), new RingRegion(nsAndRegion.getV2(), nsAndRegion.getV3()), mgBase._getIPAndPort(), false).toMessageGroup();
    mgBase.send(mg, owner);
}
Also used : RingRegion(com.ms.silverking.cloud.ring.RingRegion) ProtoChecksumTreeRequestMessageGroup(com.ms.silverking.cloud.dht.net.ProtoChecksumTreeRequestMessageGroup) MessageGroup(com.ms.silverking.cloud.dht.net.MessageGroup) ProtoChecksumTreeMessageGroup(com.ms.silverking.cloud.dht.net.ProtoChecksumTreeMessageGroup) UUIDBase(com.ms.silverking.id.UUIDBase) ProtoChecksumTreeRequestMessageGroup(com.ms.silverking.cloud.dht.net.ProtoChecksumTreeRequestMessageGroup)

Example 18 with RingRegion

use of com.ms.silverking.cloud.ring.RingRegion 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 19 with RingRegion

use of com.ms.silverking.cloud.ring.RingRegion in project SilverKing by Morgan-Stanley.

the class ConvergenceController2 method requestRemoteChecksumTreesForPrimary.

/*
    private void requestRemoteChecksumTreesForPrimary(ConvergencePoint targetCP, ConvergencePoint curCP, RingEntry targetEntry) {
        Set<IPAndPort>  sourceOwners;
        
        sourceOwners = ringMaster.getReplicas(targetEntry.getRegion(), OwnerQueryMode.Primary);
        //sourceOwners = ImmutableUtil.remove(sourceMap.getOwners(targetEntry.getRegion(), OwnerQueryMode.Primary), 
        //                                    mgBase._getIPAndPort());
        if (!sourceOwners.isEmpty()) {
            if (true) {
                System.out.printf("target %s\towners %s\n", targetEntry.getRegion(), CollectionUtil.toString(sourceOwners));
            }
            requestRemoteChecksumTree(targetCP, curCP, targetEntry, sourceOwners);
        } else {
            Log.warning("Primary convergence. No previous non-local owners for entry: ", targetEntry);
        }
    }
    */
private void requestRemoteChecksumTreesForPrimary(RingEntry targetEntry) {
    List<RingEntry> sourceEntries;
    sourceEntries = getEntries(targetEntry.getRegion());
    if (!sourceEntries.isEmpty()) {
        Log.warningf("%x target %s\towners %s\n", ns, targetEntry.getRegion(), CollectionUtil.toString(sourceEntries));
        for (RingEntry sourceEntry : sourceEntries) {
            List<IPAndPort> nonLocalOwners;
            List<IPAndPort> _nonLocalOwners;
            // ExclusionSet    curExclusionSet;
            nonLocalOwners = new ArrayList<>(sourceEntry.getOwnersIPList(OwnerQueryMode.Primary));
            nonLocalOwners.remove(mgBase._getIPAndPort());
            // curExclusionSet = ringMaster.getCurrentExclusionSet();
            // Log.warning("Filtering exclusion set: ", curExclusionSet);
            // nonLocalOwners = curExclusionSet.filterByIP(nonLocalOwners);
            Log.info("Filtering exclusion set: ", exclusionSet);
            _nonLocalOwners = exclusionSet.filterByIP(nonLocalOwners);
            if (_nonLocalOwners.size() != nonLocalOwners.size()) {
                Log.warning("Raw nonLocalOwners:      ", nonLocalOwners);
                Log.warning("Filtered nonLocalOwners: ", _nonLocalOwners);
            }
            if (_nonLocalOwners.size() == 0) {
                Log.warningf("%x All nonLocalOwners excluded. Ignoring exclusions for this entry.", ns);
            } else {
                nonLocalOwners = _nonLocalOwners;
            }
            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.
            iResult = RingRegion.intersect(sourceEntry.getRegion(), targetEntry.getRegion());
            for (RingRegion commonSubRegion : iResult.getOverlapping()) {
                requestRemoteChecksumTree(targetCP, curCP, commonSubRegion, nonLocalOwners);
            }
        }
    } else {
        // FIXME - 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.warningf("Primary convergence %x. No previous non-local owners for entry: ", 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 20 with RingRegion

use of com.ms.silverking.cloud.ring.RingRegion in project SilverKing by Morgan-Stanley.

the class RegionTreeBuilder method createLeaves.

private static LeafChecksumNode[] createLeaves(RingRegion region, int numLeaves) {
    LeafChecksumNode[] leaves;
    long leafRegionSize;
    long lastEnd;
    leaves = new LeafChecksumNode[numLeaves];
    leafRegionSize = region.getSize() / numLeaves;
    lastEnd = LongRingspace.prevPoint(region.getStart());
    for (int i = 0; i < numLeaves; i++) {
        RingRegion leafRegion;
        long start;
        long end;
        start = LongRingspace.nextPoint(lastEnd);
        if (i < numLeaves - 1) {
            end = LongRingspace.add(start, leafRegionSize - 1);
        } else {
            end = region.getEnd();
        }
        leafRegion = new RingRegion(start, end);
        leaves[i] = new LeafChecksumNode(leafRegion);
        lastEnd = end;
    }
    return leaves;
}
Also used : RingRegion(com.ms.silverking.cloud.ring.RingRegion)

Aggregations

RingRegion (com.ms.silverking.cloud.ring.RingRegion)22 IntersectionResult (com.ms.silverking.cloud.ring.IntersectionResult)5 IPAndPort (com.ms.silverking.net.IPAndPort)4 KeyAndVersionChecksum (com.ms.silverking.cloud.dht.daemon.storage.KeyAndVersionChecksum)3 ConvergencePoint (com.ms.silverking.cloud.dht.daemon.storage.convergence.ConvergencePoint)3 RingEntry (com.ms.silverking.cloud.toporing.RingEntry)2 AbstractChecksumNode (com.ms.silverking.cloud.dht.daemon.storage.convergence.AbstractChecksumNode)1 ChecksumNode (com.ms.silverking.cloud.dht.daemon.storage.convergence.ChecksumNode)1 LeafChecksumNode (com.ms.silverking.cloud.dht.daemon.storage.convergence.LeafChecksumNode)1 NonLeafChecksumNode (com.ms.silverking.cloud.dht.daemon.storage.convergence.NonLeafChecksumNode)1 RingID (com.ms.silverking.cloud.dht.daemon.storage.convergence.RingID)1 RingIDAndVersionPair (com.ms.silverking.cloud.dht.daemon.storage.convergence.RingIDAndVersionPair)1 SKGridConfiguration (com.ms.silverking.cloud.dht.gridconfig.SKGridConfiguration)1 MessageGroup (com.ms.silverking.cloud.dht.net.MessageGroup)1 ProtoChecksumTreeMessageGroup (com.ms.silverking.cloud.dht.net.ProtoChecksumTreeMessageGroup)1 ProtoChecksumTreeRequestMessageGroup (com.ms.silverking.cloud.dht.net.ProtoChecksumTreeRequestMessageGroup)1 UUIDBase (com.ms.silverking.id.UUIDBase)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1