use of org.apache.geode.internal.offheap.annotations.Released in project geode by apache.
the class LocalRegion method basicImportPutAll.
// TODO: return value is never used
public VersionedObjectList basicImportPutAll(Map map, boolean skipCallbacks) {
long startPut = CachePerfStats.getStatTime();
@Released EntryEventImpl event = EntryEventImpl.create(this, Operation.PUTALL_CREATE, null, null, null, true, getMyId(), !skipCallbacks);
try {
DistributedPutAllOperation putAllOp = new DistributedPutAllOperation(event, map.size(), false);
try {
VersionedObjectList result = basicPutAll(map, putAllOp, null);
getCachePerfStats().endPutAll(startPut);
return result;
} finally {
putAllOp.freeOffHeapResources();
}
} finally {
event.release();
}
}
use of org.apache.geode.internal.offheap.annotations.Released in project geode by apache.
the class LocalRegion method basicBridgeRemoveAll.
/**
* Called on a bridge server when it has a received a removeAll command from a client.
*
* @param keys a collection of the keys we are putting
* @param retryVersions a collection of version tags. If the client is retrying a key then that
* keys slot will be non-null in this collection. Note that keys and retryVersions are
* parallel lists.
* @param callbackArg callback argument from client
*/
public VersionedObjectList basicBridgeRemoveAll(List<Object> keys, ArrayList<VersionTag> retryVersions, ClientProxyMembershipID memberId, EventID eventId, Object callbackArg) throws TimeoutException, CacheWriterException {
long startOp = CachePerfStats.getStatTime();
if (isGatewaySenderEnabled()) {
callbackArg = new GatewaySenderEventCallbackArgument(callbackArg);
}
@Released final EntryEventImpl event = EntryEventImpl.create(this, Operation.REMOVEALL_DESTROY, null, null, /* new value */
callbackArg, false, /* origin remote */
memberId.getDistributedMember(), true, /* generateCallbacks */
eventId);
try {
event.setContext(memberId);
DistributedRemoveAllOperation removeAllOp = new DistributedRemoveAllOperation(event, keys.size(), true);
try {
VersionedObjectList result = basicRemoveAll(keys, removeAllOp, retryVersions);
getCachePerfStats().endRemoveAll(startOp);
return result;
} finally {
removeAllOp.freeOffHeapResources();
}
} finally {
event.release();
}
}
use of org.apache.geode.internal.offheap.annotations.Released in project geode by apache.
the class RemoteInvalidateMessage method operateOnRegion.
/**
* 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
*/
@Override
protected boolean operateOnRegion(DistributionManager dm, LocalRegion r, long startTime) throws EntryExistsException, RemoteOperationException {
InternalDistributedMember eventSender = originalSender;
if (eventSender == null) {
eventSender = getSender();
}
final Object key = getKey();
@Released final EntryEventImpl event = EntryEventImpl.create(r, getOperation(), key, null, /* newValue */
getCallbackArg(), this.useOriginRemote, /* originRemote - false to force distribution in buckets */
eventSender, true, /* generateCallbacks */
false);
try {
if (this.bridgeContext != null) {
event.setContext(this.bridgeContext);
}
event.setCausedByMessage(this);
if (this.versionTag != null) {
this.versionTag.replaceNullIDs(getSender());
event.setVersionTag(this.versionTag);
}
Assert.assertTrue(eventId != null);
event.setEventId(eventId);
event.setPossibleDuplicate(this.possibleDuplicate);
// for cqs, which needs old value based on old value being sent on wire.
boolean eventShouldHaveOldValue = getHasOldValue();
if (eventShouldHaveOldValue) {
if (getOldValueIsSerialized()) {
event.setSerializedOldValue(getOldValueBytes());
} else {
event.setOldValue(getOldValueBytes());
}
}
boolean sendReply = true;
try {
r.checkReadiness();
r.checkForLimitedOrNoAccess();
r.basicInvalidate(event);
if (logger.isTraceEnabled(LogMarker.DM)) {
logger.trace(LogMarker.DM, "remoteInvalidated key: {}", key);
}
sendReply(getSender(), this.processorId, dm, /* ex */
null, event.getRegion(), event.getVersionTag(), startTime);
sendReply = false;
} catch (EntryNotFoundException eee) {
// failed = true;
if (logger.isDebugEnabled()) {
logger.debug("operateOnRegion caught EntryNotFoundException");
}
sendReply(getSender(), getProcessorId(), dm, new ReplyException(eee), r, null, startTime);
// this prevents us from acking later
sendReply = false;
} catch (PrimaryBucketException pbe) {
sendReply(getSender(), getProcessorId(), dm, new ReplyException(pbe), r, startTime);
return false;
}
return sendReply;
} finally {
event.release();
}
}
use of org.apache.geode.internal.offheap.annotations.Released in project geode by apache.
the class RemotePutAllMessage method doLocalPutAll.
/* we need a event with content for waitForNodeOrCreateBucket() */
/**
* This method is called by both operateOnLocalRegion() when processing a remote msg or by
* sendMsgByBucket() when processing a msg targeted to local Jvm. LocalRegion Note: It is very
* important that this message does NOT cause any deadlocks as the sender will wait indefinitely
* for the acknowledgment
*
* @param r partitioned region eventSender the endpoint server who received request from client
* lastModified timestamp for last modification
* @return If succeeds, return true, otherwise, throw exception
*/
public boolean doLocalPutAll(final LocalRegion r, final InternalDistributedMember eventSender, long lastModified) throws EntryExistsException, RemoteOperationException {
final DistributedRegion dr = (DistributedRegion) r;
// create a base event and a DPAO for PutAllMessage distributed btw redundant buckets
@Released EntryEventImpl baseEvent = EntryEventImpl.create(r, Operation.PUTALL_CREATE, null, null, this.callbackArg, false, eventSender, !skipCallbacks);
try {
baseEvent.setCausedByMessage(this);
// set baseEventId to the first entry's event id. We need the thread id for DACE
baseEvent.setEventId(this.eventId);
if (this.bridgeContext != null) {
baseEvent.setContext(this.bridgeContext);
}
baseEvent.setPossibleDuplicate(this.posDup);
if (logger.isDebugEnabled()) {
logger.debug("RemotePutAllMessage.doLocalPutAll: eventSender is {}, baseEvent is {}, msg is {}", eventSender, baseEvent, this);
}
final DistributedPutAllOperation dpao = new DistributedPutAllOperation(baseEvent, putAllDataCount, false);
try {
final VersionedObjectList versions = new VersionedObjectList(putAllDataCount, true, dr.concurrencyChecksEnabled);
dr.syncBulkOp(new Runnable() {
@SuppressWarnings("synthetic-access")
public void run() {
// final boolean requiresRegionContext = dr.keyRequiresRegionContext();
InternalDistributedMember myId = r.getDistributionManager().getDistributionManagerId();
for (int i = 0; i < putAllDataCount; ++i) {
@Released EntryEventImpl ev = PutAllPRMessage.getEventFromEntry(r, myId, eventSender, i, putAllData, false, bridgeContext, posDup, !skipCallbacks);
try {
ev.setPutAllOperation(dpao);
if (logger.isDebugEnabled()) {
logger.debug("invoking basicPut with {}", ev);
}
if (dr.basicPut(ev, false, false, null, false)) {
putAllData[i].versionTag = ev.getVersionTag();
versions.addKeyAndVersion(putAllData[i].key, ev.getVersionTag());
}
} finally {
ev.release();
}
}
}
}, baseEvent.getEventId());
if (getTXUniqId() != TXManagerImpl.NOTX || dr.getConcurrencyChecksEnabled()) {
dr.getDataView().postPutAll(dpao, versions, dr);
}
PutAllReplyMessage.send(getSender(), this.processorId, getReplySender(r.getDistributionManager()), versions, this.putAllData, this.putAllDataCount);
return false;
} finally {
dpao.freeOffHeapResources();
}
} finally {
baseEvent.release();
}
}
use of org.apache.geode.internal.offheap.annotations.Released in project geode by apache.
the class RemoteDestroyMessage method operateOnRegion.
/**
* 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 operateOnRegion(DistributionManager dm, LocalRegion r, long startTime) throws EntryExistsException, RemoteOperationException {
InternalDistributedMember eventSender = originalSender;
if (eventSender == null) {
eventSender = getSender();
}
@Released EntryEventImpl event = null;
try {
if (this.bridgeContext != null) {
event = EntryEventImpl.create(r, getOperation(), getKey(), null, /* newValue */
getCallbackArg(), false, /* originRemote */
eventSender, true);
event.setContext(this.bridgeContext);
// for cq processing and client notification by BS.
if (this.hasOldValue) {
if (this.oldValueIsSerialized) {
event.setSerializedOldValue(getOldValueBytes());
} else {
event.setOldValue(getOldValueBytes());
}
}
} else // bridgeContext != null
{
event = EntryEventImpl.create(r, getOperation(), getKey(), null, /* newValue */
getCallbackArg(), this.useOriginRemote, eventSender, true, /* generateCallbacks */
false);
}
event.setCausedByMessage(this);
if (this.versionTag != null) {
this.versionTag.replaceNullIDs(getSender());
event.setVersionTag(this.versionTag);
}
// for cq processing and client notification by BS.
if (this.hasOldValue) {
if (this.oldValueIsSerialized) {
event.setSerializedOldValue(getOldValueBytes());
} else {
event.setOldValue(getOldValueBytes());
}
}
Assert.assertTrue(eventId != null);
event.setEventId(eventId);
event.setPossibleDuplicate(this.possibleDuplicate);
try {
r.getDataView().destroyOnRemote(event, true, this.expectedOldValue);
sendReply(dm, event.getVersionTag());
} catch (CacheWriterException cwe) {
sendReply(getSender(), this.processorId, dm, new ReplyException(cwe), r, startTime);
return false;
} catch (EntryNotFoundException eee) {
if (logger.isDebugEnabled()) {
logger.debug("operateOnRegion caught EntryNotFoundException", eee);
}
ReplyMessage.send(getSender(), getProcessorId(), new ReplyException(eee), getReplySender(dm), r.isInternalRegion());
} catch (DataLocationException e) {
if (logger.isDebugEnabled()) {
logger.debug("operateOnRegion caught DataLocationException");
}
ReplyMessage.send(getSender(), getProcessorId(), new ReplyException(e), getReplySender(dm), r.isInternalRegion());
}
return false;
} finally {
if (event != null) {
event.release();
}
}
}
Aggregations