use of org.apache.geode.internal.cache.PartitionedRegionDataStore in project geode by apache.
the class DestroyMessage 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) throws EntryExistsException, DataLocationException {
InternalDistributedMember eventSender = originalSender;
if (eventSender == null) {
eventSender = getSender();
}
@Released EntryEventImpl event = null;
try {
if (this.bridgeContext != null) {
event = EntryEventImpl.create(r, getOperation(), this.key, null, /* newValue */
getCallbackArg(), false, /* originRemote */
eventSender, true);
event.setContext(this.bridgeContext);
} else // bridgeContext != null
{
event = EntryEventImpl.create(r, getOperation(), this.key, null, /* newValue */
getCallbackArg(), false, /* originRemote - false to force distribution in buckets */
eventSender, true, /* generateCallbacks */
false);
}
if (this.versionTag != null) {
this.versionTag.replaceNullIDs(getSender());
event.setVersionTag(this.versionTag);
}
event.setInvokePRCallbacks(!notificationOnly);
Assert.assertTrue(eventId != null);
event.setEventId(eventId);
event.setPossibleDuplicate(this.posDup);
PartitionedRegionDataStore ds = r.getDataStore();
boolean sendReply = true;
if (!notificationOnly) {
Assert.assertTrue(ds != null, "This process should have storage for an item in " + this.toString());
try {
Integer bucket = Integer.valueOf(PartitionedRegionHelper.getHashKey(r, null, this.key, null, this.cbArg));
// try {
// // the event must show its true origin for cachewriter invocation
// event.setOriginRemote(true);
// event.setPartitionMessage(this);
// r.doCacheWriteBeforeDestroy(event);
// }
// finally {
// event.setOriginRemote(false);
// }
event.setCausedByMessage(this);
r.getDataView().destroyOnRemote(event, true, /* cacheWrite */
this.expectedOldValue);
if (logger.isTraceEnabled(LogMarker.DM)) {
logger.trace(LogMarker.DM, "{} updated bucket: {} with key: {}", getClass().getName(), bucket, this.key);
}
} catch (CacheWriterException cwe) {
sendReply(getSender(), this.processorId, dm, new ReplyException(cwe), r, startTime);
return false;
} catch (EntryNotFoundException eee) {
logger.trace(LogMarker.DM, "{}: operateOnRegion caught EntryNotFoundException", getClass().getName());
ReplyMessage.send(getSender(), getProcessorId(), new ReplyException(eee), getReplySender(dm), r.isInternalRegion());
// this prevents us from acking later
sendReply = false;
} catch (PrimaryBucketException pbe) {
sendReply(getSender(), getProcessorId(), dm, new ReplyException(pbe), r, startTime);
sendReply = false;
} finally {
this.versionTag = event.getVersionTag();
}
} else {
@Released EntryEventImpl e2 = createListenerEvent(event, r, dm.getDistributionManagerId());
try {
r.invokeDestroyCallbacks(EnumListenerEvent.AFTER_DESTROY, e2, r.isInitialized(), true);
} finally {
// if e2 == ev then no need to free it here. The outer finally block will get it.
if (e2 != event) {
e2.release();
}
}
}
return sendReply;
} finally {
if (event != null) {
event.release();
}
}
}
use of org.apache.geode.internal.cache.PartitionedRegionDataStore in project geode by apache.
the class FetchEntriesMessage method operateOnPartitionedRegion.
@Override
protected boolean operateOnPartitionedRegion(DistributionManager dm, PartitionedRegion pr, long startTime) throws CacheException, ForceReattemptException {
if (logger.isTraceEnabled(LogMarker.DM)) {
logger.trace(LogMarker.DM, "FetchEntriesMessage operateOnRegion: {}", pr.getFullPath());
}
PartitionedRegionDataStore ds = pr.getDataStore();
BucketRegion entries = null;
if (ds != null) {
entries = ds.handleRemoteGetEntries(this.bucketId);
if (logger.isTraceEnabled(LogMarker.DM)) {
logger.trace(LogMarker.DM, "FetchKeysMessage send keys back using processorId: {}", getProcessorId());
}
} else {
logger.warn(LocalizedMessage.create(LocalizedStrings.FetchEntriesMessage_FETCHKEYSMESSAGE_DATA_STORE_NOT_CONFIGURED_FOR_THIS_MEMBER));
}
pr.getPrStats().endPartitionMessagesProcessing(startTime);
FetchEntriesReplyMessage.send(getSender(), getProcessorId(), dm, this.bucketId, entries);
return false;
}
use of org.apache.geode.internal.cache.PartitionedRegionDataStore in project geode by apache.
the class FetchEntryMessage method operateOnPartitionedRegion.
@Override
protected boolean operateOnPartitionedRegion(DistributionManager dm, PartitionedRegion r, long startTime) throws ForceReattemptException {
// FetchEntryMessage is used in refreshing client caches during interest list recovery,
// so don't be too verbose or hydra tasks may time out
PartitionedRegionDataStore ds = r.getDataStore();
EntrySnapshot val;
if (ds != null) {
try {
KeyInfo keyInfo = r.getKeyInfo(key);
val = (EntrySnapshot) r.getDataView().getEntryOnRemote(keyInfo, r, true);
r.getPrStats().endPartitionMessagesProcessing(startTime);
FetchEntryReplyMessage.send(getSender(), getProcessorId(), val, dm, null);
} catch (TransactionException tex) {
FetchEntryReplyMessage.send(getSender(), getProcessorId(), null, dm, new ReplyException(tex));
} catch (PRLocallyDestroyedException pde) {
FetchEntryReplyMessage.send(getSender(), getProcessorId(), null, dm, new ReplyException(new ForceReattemptException(LocalizedStrings.FetchEntryMessage_ENCOUNTERED_PRLOCALLYDESTROYED.toLocalizedString(), pde)));
} catch (EntryNotFoundException enfe) {
FetchEntryReplyMessage.send(getSender(), getProcessorId(), null, dm, new ReplyException(LocalizedStrings.FetchEntryMessage_ENTRY_NOT_FOUND.toLocalizedString(), enfe));
} catch (PrimaryBucketException pbe) {
FetchEntryReplyMessage.send(getSender(), getProcessorId(), null, dm, new ReplyException(pbe));
} catch (ForceReattemptException pbe) {
pbe.checkKey(key);
// Slightly odd -- we're marshalling the retry to the peer on another host...
FetchEntryReplyMessage.send(getSender(), getProcessorId(), null, dm, new ReplyException(pbe));
} catch (DataLocationException e) {
FetchEntryReplyMessage.send(getSender(), getProcessorId(), null, dm, new ReplyException(e));
}
} else {
throw new InternalGemFireError(LocalizedStrings.FetchEntryMessage_FETCHENTRYMESSAGE_MESSAGE_SENT_TO_WRONG_MEMBER.toLocalizedString());
}
// response
return false;
}
use of org.apache.geode.internal.cache.PartitionedRegionDataStore in project geode by apache.
the class FetchKeysMessage method operateOnPartitionedRegion.
@Override
protected boolean operateOnPartitionedRegion(DistributionManager dm, PartitionedRegion r, long startTime) throws CacheException, ForceReattemptException {
if (logger.isDebugEnabled()) {
logger.debug("FetchKeysMessage operateOnRegion: {} bucketId: {} type: {} {}", r.getFullPath(), this.bucketId, InterestType.getString(interestType), (allowTombstones ? " with tombstones" : " without tombstones"));
}
PartitionedRegionDataStore ds = r.getDataStore();
if (ds != null) {
try {
Set keys = ds.handleRemoteGetKeys(this.bucketId, interestType, interestArg, allowTombstones);
if (logger.isTraceEnabled(LogMarker.DM)) {
logger.debug("FetchKeysMessage sending {} keys back using processorId: : {}", keys.size(), getProcessorId(), keys);
}
r.getPrStats().endPartitionMessagesProcessing(startTime);
FetchKeysReplyMessage.send(getSender(), getProcessorId(), dm, keys);
} catch (PRLocallyDestroyedException pde) {
if (logger.isDebugEnabled()) {
logger.debug("FetchKeysMessage Encountered PRLocallyDestroyedException");
}
throw new ForceReattemptException(LocalizedStrings.FetchKeysMessage_ENCOUNTERED_PRLOCALLYDESTROYEDEXCEPTION.toLocalizedString(), pde);
}
} else {
logger.warn(LocalizedMessage.create(LocalizedStrings.FetchKeysMessage_FETCHKEYSMESSAGE_DATA_STORE_NOT_CONFIGURED_FOR_THIS_MEMBER));
}
// Unless there was an exception thrown, this message handles sending the response
return false;
}
use of org.apache.geode.internal.cache.PartitionedRegionDataStore in project geode by apache.
the class InvalidateMessage 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
*
* @throws EntryExistsException
* @throws DataLocationException
*/
@Override
protected boolean operateOnPartitionedRegion(DistributionManager dm, PartitionedRegion r, long startTime) throws EntryExistsException, DataLocationException {
InternalDistributedMember eventSender = originalSender;
if (eventSender == null) {
eventSender = getSender();
}
final Object key = getKey();
@Released final EntryEventImpl event = EntryEventImpl.create(r, getOperation(), key, null, /* newValue */
getCallbackArg(), false, /* originRemote - false to force distribution in buckets */
eventSender, true, /* generateCallbacks */
false);
try {
if (this.versionTag != null) {
this.versionTag.replaceNullIDs(getSender());
event.setVersionTag(this.versionTag);
}
if (this.bridgeContext != null) {
event.setContext(this.bridgeContext);
}
// Assert.assertTrue(eventId != null); bug #47235: region invalidation doesn't send event ids
event.setEventId(eventId);
event.setPossibleDuplicate(this.posDup);
PartitionedRegionDataStore ds = r.getDataStore();
boolean sendReply = true;
// boolean failed = false;
event.setInvokePRCallbacks(!notificationOnly);
if (!notificationOnly) {
Assert.assertTrue(ds != null, "This process should have storage for an item in " + this.toString());
try {
Integer bucket = Integer.valueOf(PartitionedRegionHelper.getHashKey(event));
event.setCausedByMessage(this);
r.getDataView().invalidateOnRemote(event, true, /* invokeCallbacks */
false);
this.versionTag = event.getVersionTag();
if (logger.isTraceEnabled(LogMarker.DM)) {
logger.trace(LogMarker.DM, "{} invalidateLocally in bucket: {}, key: {}", getClass().getName(), bucket, key);
}
} catch (DataLocationException e) {
((ForceReattemptException) e).checkKey(event.getKey());
throw e;
} catch (EntryNotFoundException eee) {
// failed = true;
if (logger.isDebugEnabled()) {
logger.debug("{}: operateOnRegion caught EntryNotFoundException {}", getClass().getName(), eee.getMessage(), eee);
}
sendReply(getSender(), getProcessorId(), dm, new ReplyException(eee), r, startTime);
// this prevents us from acking later
sendReply = false;
} catch (PrimaryBucketException pbe) {
sendReply(getSender(), getProcessorId(), dm, new ReplyException(pbe), r, startTime);
return false;
}
} else {
event.setRegion(r);
event.setOriginRemote(true);
if (this.versionTag != null) {
this.versionTag.replaceNullIDs(getSender());
event.setVersionTag(this.versionTag);
}
if (this.filterInfo != null) {
event.setLocalFilterInfo(this.filterInfo.getFilterInfo(dm.getDistributionManagerId()));
}
r.invokeInvalidateCallbacks(EnumListenerEvent.AFTER_INVALIDATE, event, r.isInitialized());
}
return sendReply;
} finally {
event.release();
}
}
Aggregations