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;
}
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);
}
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);
}
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");
}
}
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;
}
Aggregations