use of org.apache.geode.internal.cache.FixedPartitionAttributesImpl in project geode by apache.
the class PartitionRegionHelper method getNumberOfBuckets.
private static int getNumberOfBuckets(PartitionedRegion pr) {
if (pr.isFixedPartitionedRegion()) {
int numBuckets = 0;
Set<FixedPartitionAttributesImpl> fpaSet = new HashSet<FixedPartitionAttributesImpl>(pr.getRegionAdvisor().adviseAllFixedPartitionAttributes());
if (pr.getFixedPartitionAttributesImpl() != null) {
fpaSet.addAll(pr.getFixedPartitionAttributesImpl());
}
for (FixedPartitionAttributesImpl fpa : fpaSet) {
numBuckets = numBuckets + fpa.getNumBuckets();
}
return numBuckets;
}
return pr.getTotalNumberOfBuckets();
}
use of org.apache.geode.internal.cache.FixedPartitionAttributesImpl in project geode by apache.
the class CacheXml66DUnitTest method validateAttributes.
private void validateAttributes(Region region, List<FixedPartitionAttributes> fpattrsList, QuarterPartitionResolver resolver, boolean isColocated) {
RegionAttributes regionAttrs = region.getAttributes();
PartitionAttributes pa = regionAttrs.getPartitionAttributes();
assertEquals(pa.getRedundantCopies(), 1);
assertNotNull(pa.getPartitionResolver().getClass());
assertEquals(pa.getPartitionResolver(), resolver);
List<FixedPartitionAttributesImpl> fixedPartitionsList = pa.getFixedPartitionAttributes();
if (isColocated) {
assertNull(fixedPartitionsList);
assertNotNull(pa.getColocatedWith());
} else {
assertNull(pa.getColocatedWith());
assertEquals(fixedPartitionsList.size(), 4);
assertEquals(fixedPartitionsList.containsAll(fpattrsList), true);
for (FixedPartitionAttributes fpa : fixedPartitionsList) {
if (fpa.getPartitionName().equals("Q1")) {
assertEquals(fpa.getNumBuckets(), 1);
assertEquals(fpa.isPrimary(), false);
}
if (fpa.getPartitionName().equals("Q2")) {
assertEquals(fpa.getNumBuckets(), 1);
assertEquals(fpa.isPrimary(), true);
}
if (fpa.getPartitionName().equals("Q3")) {
assertEquals(fpa.getNumBuckets(), 3);
assertEquals(fpa.isPrimary(), false);
}
if (fpa.getPartitionName().equals("Q4")) {
assertEquals(fpa.getNumBuckets(), 3);
assertEquals(fpa.isPrimary(), false);
}
}
}
}
use of org.apache.geode.internal.cache.FixedPartitionAttributesImpl in project geode by apache.
the class MovePrimariesFPR method makeFPRPrimaryForThisNode.
/**
* Move all primary from other to this
*/
private void makeFPRPrimaryForThisNode() {
PartitionedRegion partitionedRegion = model.getPartitionedRegion();
List<FixedPartitionAttributesImpl> FPAs = partitionedRegion.getFixedPartitionAttributesImpl();
InternalDistributedMember targetId = partitionedRegion.getDistributionManager().getId();
Member target = model.getMember(targetId);
for (Bucket bucket : model.getBuckets()) {
if (bucket != null) {
for (FixedPartitionAttributesImpl fpa : FPAs) {
if (fpa.hasBucket(bucket.getId()) && fpa.isPrimary()) {
Member source = 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
source = (source == null || source == model.INVALID_MEMBER) ? target : source;
if (logger.isDebugEnabled()) {
logger.debug("PRLM#movePrimariesForFPR: For Bucket#{}, moving primary from source {} to target {}", bucket.getId(), bucket.getPrimary(), target);
}
boolean successfulMove = model.movePrimary(new Move(source, target, 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#{}, moved primary from source {} to target {}", bucket.getId(), bucket.getPrimary(), target);
}
bucket.setPrimary(target, bucket.getPrimaryLoad());
}
}
}
}
}
}
}
use of org.apache.geode.internal.cache.FixedPartitionAttributesImpl in project geode by apache.
the class PartitionedRegionLoadModel method findBestTargetForFPR.
public Move findBestTargetForFPR(Bucket bucket, boolean checkIPAddress) {
Move noMove = null;
InternalDistributedMember targetMemberID = null;
Member targetMember = null;
List<FixedPartitionAttributesImpl> fpas = this.partitionedRegion.getFixedPartitionAttributesImpl();
if (fpas != null) {
for (FixedPartitionAttributesImpl fpaImpl : fpas) {
if (fpaImpl.hasBucket(bucket.getId())) {
targetMemberID = this.partitionedRegion.getDistributionManager().getDistributionManagerId();
if (this.members.containsKey(targetMemberID)) {
targetMember = this.members.get(targetMemberID);
if (targetMember.willAcceptBucket(bucket, null, checkIPAddress).willAccept()) {
// all the buckets for a FPR on this node.
return new Move(null, targetMember, bucket);
}
}
}
}
}
return noMove;
}
use of org.apache.geode.internal.cache.FixedPartitionAttributesImpl in project geode by apache.
the class CreateBucketMessage method operateOnPartitionedRegion.
/**
* This method is called upon receipt and make the desired changes to the PartitionedRegion Note:
* It is very important that this message does NOT cause any deadlocks as the sender will wait
* indefinitely for the acknowledgement
*/
@Override
protected boolean operateOnPartitionedRegion(DistributionManager dm, PartitionedRegion r, long startTime) {
if (logger.isTraceEnabled(LogMarker.DM)) {
logger.trace(LogMarker.DM, "CreateBucketMessage operateOnRegion: {}", r.getFullPath());
}
// serviced. BUGFIX for 35888
if (!r.isInitialized()) {
// This VM is NOT ready to manage a new bucket, refuse operation
CreateBucketReplyMessage.sendResponse(getSender(), getProcessorId(), dm, null);
return false;
}
// For FPR, for given bucket id find out the partition to which this bucket
// belongs
String partitionName = null;
if (r.isFixedPartitionedRegion()) {
FixedPartitionAttributesImpl fpa = PartitionedRegionHelper.getFixedPartitionAttributesForBucket(r, bucketId);
partitionName = fpa.getPartitionName();
}
r.checkReadiness();
InternalDistributedMember primary = r.getRedundancyProvider().createBucketAtomically(bucketId, bucketSize, startTime, false, partitionName);
r.getPrStats().endPartitionMessagesProcessing(startTime);
CreateBucketReplyMessage.sendResponse(getSender(), getProcessorId(), dm, primary);
return false;
}
Aggregations