use of org.apache.geode.internal.cache.FixedPartitionAttributesImpl in project geode by apache.
the class CacheXmlParser method startFixedPartitionAttributes.
/**
* When a <code>fixed-partition-attributes</code> element is encountered, we create an instance of
* FixedPartitionAttributesImpl and add it to the PartitionAttributesImpl stack.
*/
private void startFixedPartitionAttributes(Attributes atts) {
FixedPartitionAttributesImpl fpai = new FixedPartitionAttributesImpl();
String partitionName = atts.getValue(PARTITION_NAME);
if (partitionName != null) {
fpai.setPartitionName(partitionName);
}
String isPrimary = atts.getValue(IS_PRIMARY);
if (isPrimary != null) {
fpai.isPrimary(parseBoolean(isPrimary));
}
String numBuckets = atts.getValue(NUM_BUCKETS);
if (numBuckets != null) {
fpai.setNumBuckets(parseInt(numBuckets));
}
Object a = stack.peek();
if (a instanceof PartitionAttributesImpl) {
((PartitionAttributesImpl) a).addFixedPartitionAttributes(fpai);
}
}
use of org.apache.geode.internal.cache.FixedPartitionAttributesImpl in project geode by apache.
the class PartitionedRegionLoadModel method makeFPRPrimaryForThisNode.
/**
* Move all primary from other to this
*/
private void makeFPRPrimaryForThisNode() {
List<FixedPartitionAttributesImpl> FPAs = this.partitionedRegion.getFixedPartitionAttributesImpl();
InternalDistributedMember targetId = this.partitionedRegion.getDistributionManager().getId();
Member target = this.members.get(targetId);
Set<Bucket> unsuccessfulAttempts = new HashSet<Bucket>();
for (Bucket bucket : this.buckets) {
if (bucket != null) {
for (FixedPartitionAttributesImpl fpa : FPAs) {
if (fpa.hasBucket(bucket.id) && fpa.isPrimary()) {
Member source = bucket.primary;
bucket.getPrimary();
if (source != target) {
// HACK: In case we don't know who is Primary at this time
// we just set source as target too for stat purposes
InternalDistributedMember srcDM = (source == null || source == INVALID_MEMBER) ? target.getDistributedMember() : source.getDistributedMember();
if (logger.isDebugEnabled()) {
logger.debug("PRLM#movePrimariesForFPR: For Bucket#{}, moving primary from source {} to target {}", bucket.getId(), bucket.primary, target);
}
boolean successfulMove = this.operator.movePrimary(srcDM, target.getDistributedMember(), bucket.getId());
unsuccessfulAttempts.add(bucket);
// We have to move the primary otherwise there is some problem!
Assert.assertTrue(successfulMove, " Fixed partitioned region not able to move the primary!");
if (successfulMove) {
if (logger.isDebugEnabled()) {
logger.debug("PRLM#movePrimariesForFPR: For Bucket#{}, moving primary source {} to target {}", bucket.getId(), source, target);
}
bucket.setPrimary(target, bucket.getPrimaryLoad());
}
}
}
}
}
}
}
use of org.apache.geode.internal.cache.FixedPartitionAttributesImpl in project geode by apache.
the class FixedPartitioningTestBase method checkFPR.
public static void checkFPR(String regionName) {
region_FPR = (PartitionedRegion) cache.getRegion(regionName);
PartitionedRegion colocatedRegion = (PartitionedRegion) cache.getRegion(region_FPR.getColocatedWith());
List<FixedPartitionAttributesImpl> childFPAs = region_FPR.getFixedPartitionAttributesImpl();
List<FixedPartitionAttributesImpl> parentFPAs = colocatedRegion.getFixedPartitionAttributesImpl();
assertEquals(parentFPAs, childFPAs);
}
Aggregations