Search in sources :

Example 11 with RingRegion

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

the class RingTree method projectEntryList.

private List<RingEntry> projectEntryList(List<RingEntry> entryList, RingRegion parent) {
    RingRegion projectedRegion;
    List<RingEntry> projectedList;
    if (debug) {
        System.out.println("projectEntryList " + parent);
        System.out.println(RingEntry.toString(entryList));
        System.out.println();
    }
    projectedList = new ArrayList<>();
    for (RingEntry entry : entryList) {
        projectedRegion = LongRingspace.mapChildRegionToParentRegion(LongRingspace.globalRegion, entry.getRegion(), parent);
        projectedList.add(entry.replaceRegion(projectedRegion));
    }
    if (debug) {
        System.out.println("out projectEntryList " + parent);
        System.out.println(RingEntry.toString(projectedList));
        System.out.println();
    }
    return projectedList;
}
Also used : RingRegion(com.ms.silverking.cloud.ring.RingRegion)

Example 12 with RingRegion

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

the class ProtoRegionList method create.

/**
 * Create a ProtoRegionList from the given nodes weighted according to the
 * weightSpecs
 * @param nodes
 * @param weightSpecs
 * @return
 */
static ProtoRegionList create(List<Node> nodes, WeightSpecifications weightSpecs) {
    List<ProtoRegion> protoRegions;
    List<RingRegion> regions;
    protoRegions = new ArrayList<>();
    regions = RingRegion.allRingspace.divide(weightSpecs.getWeights(nodes));
    for (RingRegion region : regions) {
        protoRegions.add(new ProtoRegion(region, minPrimaryUnderFailure));
    }
    return new ProtoRegionList(protoRegions);
}
Also used : RingRegion(com.ms.silverking.cloud.ring.RingRegion)

Example 13 with RingRegion

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

the class ProtoRegionList method createIsomorphic.

static ProtoRegionList createIsomorphic(SingleRing sourceRing) {
    List<RingRegion> sourceRegions;
    List<ProtoRegion> protoRegions;
    Preconditions.checkNotNull(sourceRing);
    sourceRegions = sourceRing.getRegionsSorted();
    protoRegions = new ArrayList<>(sourceRegions.size());
    for (RingRegion sourceRegion : sourceRegions) {
        protoRegions.add(new ProtoRegion(sourceRegion, minPrimaryUnderFailure));
    }
    return new ProtoRegionList(protoRegions);
}
Also used : RingRegion(com.ms.silverking.cloud.ring.RingRegion)

Example 14 with RingRegion

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

the class ProtoRegion method intersect.

static ProtoRegion intersect(ProtoRegion r0, ProtoRegion r1) {
    RingRegion rr0;
    RingRegion rr1;
    rr0 = r0.getRegion();
    rr1 = r1.getRegion();
    if (!rr0.equals(rr1) && rr0.isContiguousWith(rr1)) {
        throw new RuntimeException("contiguous not expected");
    } else if (rr0.overlaps(rr1)) {
        RingRegion _r0;
        RingRegion _r01;
        _r0 = rr0.trimOverlappingWith(rr1);
        if (_r0 != null) {
            _r01 = rr0.trimOverlappingWith(_r0);
        } else {
            _r01 = rr0;
        }
        return new ProtoRegion(_r01, PrimarySecondaryListPair.merge(r0.getOwners(), r1.getOwners()), Math.max(r0.getMinPrimaryUnderFailure(), r1.getMinPrimaryUnderFailure()));
    } else {
        throw new RuntimeException("Invalid regions for merge");
    }
}
Also used : RingRegion(com.ms.silverking.cloud.ring.RingRegion)

Example 15 with RingRegion

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

the class ProtoRegion method merge.

static List<ProtoRegion> merge(ProtoRegion r0, ProtoRegion r1) {
    List<ProtoRegion> merged;
    merged = new ArrayList<>();
    if (r0.getRegion().isContiguousWith(r1.getRegion())) {
        RingRegion region;
        ProtoRegion protoRegion;
        PrimarySecondaryListPair owners;
        region = r0.getRegion().merge(r1.getRegion());
        owners = PrimarySecondaryListPair.merge(r0.getOwners(), r1.getOwners());
        protoRegion = new ProtoRegion(region, owners, Math.max(r0.getMinPrimaryUnderFailure(), r1.getMinPrimaryUnderFailure()));
        merged.add(protoRegion);
    } else if (r0.getRegion().overlaps(r1.getRegion())) {
        RingRegion _r0;
        RingRegion _r01;
        RingRegion _r1;
        _r0 = r0.getRegion().trimOverlappingWith(r1.getRegion());
        _r01 = r0.getRegion().trimOverlappingWith(_r0);
        _r1 = r1.getRegion().trimOverlappingWith(r0.getRegion());
        if (_r0 != null) {
            merged.add(new ProtoRegion(_r0, r0.getOwners().duplicate(), Math.max(r0.getMinPrimaryUnderFailure(), r1.getMinPrimaryUnderFailure())));
        }
        merged.add(new ProtoRegion(_r01, PrimarySecondaryListPair.merge(r0.getOwners(), r1.getOwners()), Math.max(r0.getMinPrimaryUnderFailure(), r1.getMinPrimaryUnderFailure())));
        if (_r1 != null) {
            merged.add(new ProtoRegion(_r1, r1.getOwners().duplicate(), Math.max(r0.getMinPrimaryUnderFailure(), r1.getMinPrimaryUnderFailure())));
        }
    } else {
        throw new RuntimeException("Invalid regions for merge");
    }
    return merged;
}
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