use of org.apache.geode.internal.cache.PartitionedRegionDataStore in project geode by apache.
the class InterestEventMessage method operateOnPartitionedRegion.
@Override
protected boolean operateOnPartitionedRegion(final DistributionManager dm, PartitionedRegion r, long startTime) throws ForceReattemptException {
if (logger.isTraceEnabled(LogMarker.DM)) {
logger.debug("InterestEventMessage operateOnPartitionedRegion: {}", r.getFullPath());
}
PartitionedRegionDataStore ds = r.getDataStore();
if (ds != null) {
try {
ds.handleInterestEvent(this.event);
r.getPrStats().endPartitionMessagesProcessing(startTime);
InterestEventReplyMessage.send(getSender(), getProcessorId(), dm);
} catch (Exception e) {
sendReply(getSender(), getProcessorId(), dm, new ReplyException(new ForceReattemptException("Caught exception during interest registration processing:", e)), r, startTime);
return false;
}
} else {
throw new InternalError("InterestEvent message was sent to a member with no storage.");
}
// response
return false;
}
use of org.apache.geode.internal.cache.PartitionedRegionDataStore in project geode by apache.
the class ManageBackupBucketMessage 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, "ManageBucketMessage operateOnRegion: {}", r.getFullPath());
}
// serviced. BUGFIX for 35888
if (!r.isInitialized()) {
// This VM is NOT ready to manage a new bucket, refuse operation
ManageBackupBucketReplyMessage.sendStillInitializing(getSender(), getProcessorId(), dm);
return false;
}
// Don't allow closed PartitionedRegions that have datastores to host
r.checkReadiness();
// buckets
PartitionedRegionDataStore prDs = r.getDataStore();
boolean managingBucket = prDs.grabBucket(this.bucketId, this.moveSource, this.forceCreation, replaceOfflineData, this.isRebalance, null, false) == CreateBucketResult.CREATED;
r.getPrStats().endPartitionMessagesProcessing(startTime);
if (managingBucket) {
ManageBackupBucketReplyMessage.sendAcceptance(getSender(), getProcessorId(), dm);
} else {
ManageBackupBucketReplyMessage.sendRefusal(getSender(), getProcessorId(), dm);
}
return false;
}
use of org.apache.geode.internal.cache.PartitionedRegionDataStore in project geode by apache.
the class RemoveBucketMessage method operateOnPartitionedRegion.
@Override
protected boolean operateOnPartitionedRegion(DistributionManager dm, PartitionedRegion region, long startTime) throws ForceReattemptException {
PartitionedRegionDataStore dataStore = region.getDataStore();
boolean removed = dataStore.removeBucket(this.bucketId, this.forceRemovePrimary);
region.getPrStats().endPartitionMessagesProcessing(startTime);
RemoveBucketReplyMessage.send(getSender(), getProcessorId(), dm, null, removed);
return false;
}
use of org.apache.geode.internal.cache.PartitionedRegionDataStore in project geode by apache.
the class SizedBasedLoadProbe method getLoad.
public PRLoad getLoad(PartitionedRegion pr) {
PartitionedRegionDataStore ds = pr.getDataStore();
int configuredBucketCount = pr.getTotalNumberOfBuckets();
PRLoad prLoad = new PRLoad(configuredBucketCount, pr.getLocalMaxMemory());
// key: bid, value: size
for (Integer bidInt : ds.getAllLocalBucketIds()) {
int bid = bidInt.intValue();
long bucketSize = ds.getBucketSize(bid);
if (bucketSize < MIN_BUCKET_SIZE) {
bucketSize = MIN_BUCKET_SIZE;
}
BucketAdvisor bucketAdvisor = pr.getRegionAdvisor().getBucket(bid).getBucketAdvisor();
// Wait for a primary to exist for this bucket, because
// it might be this member.
bucketAdvisor.getPrimary();
boolean isPrimary = pr.getRegionAdvisor().getBucket(bid).getBucketAdvisor().isPrimary();
prLoad.addBucket(bid, bucketSize, isPrimary ? 1 : 0);
}
return prLoad;
}
use of org.apache.geode.internal.cache.PartitionedRegionDataStore in project geode by apache.
the class Bug39356DUnitTest method testMoveBucketToHostThatHasTheBucketAlready.
/**
* A test to make sure that we cannot move a bucket to a member which already hosts the bucket,
* thereby reducing our redundancy.
*/
@Test
public void testMoveBucketToHostThatHasTheBucketAlready() {
Host host = Host.getHost(0);
VM vm0 = host.getVM(0);
VM vm1 = host.getVM(1);
SerializableRunnable createPrRegion = new SerializableRunnable("createRegion") {
public void run() {
Cache cache = getCache();
AttributesFactory attr = new AttributesFactory();
PartitionAttributesFactory paf = new PartitionAttributesFactory();
paf.setRedundantCopies(1);
paf.setRecoveryDelay(-1);
paf.setStartupRecoveryDelay(-1);
PartitionAttributes prAttr = paf.create();
attr.setPartitionAttributes(prAttr);
cache.createRegion("region1", attr.create());
}
};
vm0.invoke(createPrRegion);
vm1.invoke(createPrRegion);
// Create a bucket
vm0.invoke(new SerializableRunnable("createSomeBuckets") {
public void run() {
Cache cache = getCache();
Region region = cache.getRegion("region1");
region.put(Integer.valueOf(0), "A");
}
});
final InternalDistributedMember vm1MemberId = (InternalDistributedMember) vm1.invoke(new SerializableCallable() {
public Object call() throws Exception {
return InternalDistributedSystem.getAnyInstance().getDistributedMember();
}
});
// Move the bucket
vm0.invoke(new SerializableRunnable("moveBucket") {
public void run() {
Cache cache = getCache();
PartitionedRegion region = (PartitionedRegion) cache.getRegion("region1");
Set<InternalDistributedMember> owners = region.getRegionAdvisor().getBucketOwners(0);
assertEquals(2, owners.size());
PartitionedRegionDataStore ds = region.getDataStore();
assertTrue(ds.isManagingBucket(0));
// try to move the bucket from the other member to this one. This should
// fail because we already have the bucket
assertFalse(ds.moveBucket(0, vm1MemberId, true));
assertEquals(owners, region.getRegionAdvisor().getBucketOwners(0));
}
});
}
Aggregations