Search in sources :

Example 21 with Retained

use of org.apache.geode.internal.offheap.annotations.Retained in project geode by apache.

the class RemoveAllPRMessage method getEventFromEntry.

@Retained
public static EntryEventImpl getEventFromEntry(LocalRegion r, InternalDistributedMember myId, InternalDistributedMember eventSender, int idx, DistributedRemoveAllOperation.RemoveAllEntryData[] data, boolean notificationOnly, ClientProxyMembershipID bridgeContext, boolean posDup, boolean skipCallbacks) {
    RemoveAllEntryData dataItem = data[idx];
    @Retained EntryEventImpl ev = EntryEventImpl.create(r, dataItem.getOp(), dataItem.getKey(), null, null, false, eventSender, !skipCallbacks, dataItem.getEventID());
    boolean evReturned = false;
    try {
        ev.setOldValue(dataItem.getOldValue());
        if (bridgeContext != null) {
            ev.setContext(bridgeContext);
        }
        ev.setInvokePRCallbacks(!notificationOnly);
        ev.setPossibleDuplicate(posDup);
        if (dataItem.filterRouting != null) {
            ev.setLocalFilterInfo(dataItem.filterRouting.getFilterInfo(myId));
        }
        if (dataItem.versionTag != null) {
            dataItem.versionTag.replaceNullIDs(eventSender);
            ev.setVersionTag(dataItem.versionTag);
        }
        if (notificationOnly) {
            ev.setTailKey(-1L);
        } else {
            ev.setTailKey(dataItem.getTailKey());
        }
        evReturned = true;
        return ev;
    } finally {
        if (!evReturned) {
            ev.release();
        }
    }
}
Also used : Retained(org.apache.geode.internal.offheap.annotations.Retained) EntryEventImpl(org.apache.geode.internal.cache.EntryEventImpl) RemoveAllEntryData(org.apache.geode.internal.cache.DistributedRemoveAllOperation.RemoveAllEntryData) Retained(org.apache.geode.internal.offheap.annotations.Retained)

Example 22 with Retained

use of org.apache.geode.internal.offheap.annotations.Retained in project geode by apache.

the class DistributedPutAllOperation method getEventForPosition.

@Unretained
public EntryEventImpl getEventForPosition(int position) {
    PutAllEntryData entry = this.putAllData[position];
    if (entry == null) {
        return null;
    }
    if (entry.event != null) {
        return entry.event;
    }
    LocalRegion region = (LocalRegion) this.event.getRegion();
    @Retained EntryEventImpl ev = EntryEventImpl.create(region, entry.getOp(), entry.getKey(), null, /* value */
    this.event.getCallbackArgument(), false, /* originRemote */
    this.event.getDistributedMember(), this.event.isGenerateCallbacks(), entry.getEventID());
    boolean returnedEv = false;
    try {
        ev.setPossibleDuplicate(entry.isPossibleDuplicate());
        if (entry.versionTag != null && region.concurrencyChecksEnabled) {
            VersionSource id = entry.versionTag.getMemberID();
            if (id != null) {
                entry.versionTag.setMemberID(ev.getRegion().getVersionVector().getCanonicalId(id));
            }
            ev.setVersionTag(entry.versionTag);
        }
        entry.event = ev;
        returnedEv = true;
        if (entry.getValue() == null && ev.getRegion().getAttributes().getDataPolicy() == DataPolicy.NORMAL) {
            ev.setLocalInvalid(true);
        }
        ev.setNewValue(entry.getValue());
        ev.setOldValue(entry.getOldValue());
        CqService cqService = region.getCache().getCqService();
        if (cqService.isRunning() && !entry.getOp().isCreate() && !ev.hasOldValue()) {
            ev.setOldValueForQueryProcessing();
        }
        ev.setInvokePRCallbacks(!entry.isNotifyOnly());
        if (getBaseEvent().getContext() != null) {
            ev.setContext(getBaseEvent().getContext());
        }
        ev.callbacksInvoked(entry.isCallbacksInvoked());
        ev.setTailKey(entry.getTailKey());
        return ev;
    } finally {
        if (!returnedEv) {
            ev.release();
        }
    }
}
Also used : Retained(org.apache.geode.internal.offheap.annotations.Retained) VersionSource(org.apache.geode.internal.cache.versions.VersionSource) CqService(org.apache.geode.cache.query.internal.cq.CqService) Unretained(org.apache.geode.internal.offheap.annotations.Unretained)

Example 23 with Retained

use of org.apache.geode.internal.offheap.annotations.Retained in project geode by apache.

the class EntryEventImpl method setNewValueInRegion.

@Retained(ENTRY_EVENT_NEW_VALUE)
private void setNewValueInRegion(final LocalRegion owner, final RegionEntry reentry, Object oldValueForDelta) throws RegionClearedException {
    boolean wasTombstone = reentry.isTombstone();
    // not be applied. This is possible if the event originated locally.
    if (this.deltaBytes != null && this.newValue == null) {
        processDeltaBytes(oldValueForDelta);
    }
    if (owner != null) {
        owner.generateAndSetVersionTag(this, reentry);
    } else {
        this.region.generateAndSetVersionTag(this, reentry);
    }
    Object v = this.newValue;
    if (v == null) {
        v = isLocalInvalid() ? Token.LOCAL_INVALID : Token.INVALID;
    } else {
        this.region.regionInvalid = false;
    }
    reentry.setValueResultOfSearch(this.op.isNetSearch());
    // in the primary.
    if (v instanceof org.apache.geode.Delta && region.isUsedForPartitionedRegionBucket()) {
        int vSize;
        Object ov = basicGetOldValue();
        if (ov instanceof CachedDeserializable && !GemFireCacheImpl.DELTAS_RECALCULATE_SIZE) {
            vSize = ((CachedDeserializable) ov).getValueSizeInBytes();
        } else {
            vSize = CachedDeserializableFactory.calcMemSize(v, region.getObjectSizer(), false);
        }
        v = CachedDeserializableFactory.create(v, vSize);
        basicSetNewValue(v);
    }
    Object preparedV = reentry.prepareValueForCache(this.region, v, this, false);
    if (preparedV != v) {
        v = preparedV;
        if (v instanceof StoredObject) {
            if (!((StoredObject) v).isCompressed()) {
                // fix bug 52109
                // If we put it off heap and it is not compressed then remember that value.
                // Otherwise we want to remember the decompressed value in the event.
                basicSetNewValue(v);
            }
        }
    }
    boolean isTombstone = (v == Token.TOMBSTONE);
    boolean success = false;
    boolean calledSetValue = false;
    try {
        setNewValueBucketSize(owner, v);
        if ((this.op.isUpdate() && !reentry.isInvalid()) || this.op.isInvalidate()) {
            IndexManager idxManager = IndexUtils.getIndexManager(this.region, false);
            if (idxManager != null) {
                try {
                    idxManager.updateIndexes(reentry, IndexManager.REMOVE_ENTRY, this.op.isUpdate() ? IndexProtocol.BEFORE_UPDATE_OP : IndexProtocol.OTHER_OP);
                } catch (QueryException e) {
                    throw new IndexMaintenanceException(e);
                }
            }
        }
        calledSetValue = true;
        // already called prepareValueForCache
        reentry.setValueWithTombstoneCheck(v, this);
        success = true;
    } finally {
        if (!success && reentry instanceof OffHeapRegionEntry && v instanceof StoredObject) {
            OffHeapRegionEntryHelper.releaseEntry((OffHeapRegionEntry) reentry, (StoredObject) v);
        }
    }
    if (logger.isTraceEnabled()) {
        if (v instanceof CachedDeserializable) {
            logger.trace("EntryEventImpl.setNewValueInRegion: put CachedDeserializable({},{})", this.getKey(), ((CachedDeserializable) v).getStringForm());
        } else {
            logger.trace("EntryEventImpl.setNewValueInRegion: put({},{})", this.getKey(), StringUtils.forceToString(v));
        }
    }
    if (!isTombstone && wasTombstone) {
        owner.unscheduleTombstone(reentry);
    }
}
Also used : IndexManager(org.apache.geode.cache.query.internal.index.IndexManager) QueryException(org.apache.geode.cache.query.QueryException) StoredObject(org.apache.geode.internal.offheap.StoredObject) StoredObject(org.apache.geode.internal.offheap.StoredObject) IndexMaintenanceException(org.apache.geode.cache.query.IndexMaintenanceException) Retained(org.apache.geode.internal.offheap.annotations.Retained)

Example 24 with Retained

use of org.apache.geode.internal.offheap.annotations.Retained in project geode by apache.

the class EntryEventImpl method createRemoveAllEvent.

@Retained
protected static EntryEventImpl createRemoveAllEvent(DistributedRemoveAllOperation op, LocalRegion region, Object entryKey) {
    @Retained EntryEventImpl e;
    final Operation entryOp = Operation.REMOVEALL_DESTROY;
    if (op != null) {
        EntryEventImpl event = op.getBaseEvent();
        if (event.isBridgeEvent()) {
            e = EntryEventImpl.create(region, entryOp, entryKey, null, event.getRawCallbackArgument(), false, event.distributedMember, event.isGenerateCallbacks());
            e.setContext(event.getContext());
        } else {
            e = EntryEventImpl.create(region, entryOp, entryKey, null, event.getCallbackArgument(), false, region.getMyId(), event.isGenerateCallbacks());
        }
    } else {
        e = EntryEventImpl.create(region, entryOp, entryKey, null, null, false, region.getMyId(), true);
    }
    e.removeAllOp = op;
    return e;
}
Also used : Retained(org.apache.geode.internal.offheap.annotations.Retained) Operation(org.apache.geode.cache.Operation) EntryOperation(org.apache.geode.cache.EntryOperation) Retained(org.apache.geode.internal.offheap.annotations.Retained)

Example 25 with Retained

use of org.apache.geode.internal.offheap.annotations.Retained in project geode by apache.

the class DistributedRegion method findObjectInSystem.

/** @return the deserialized value */
@Override
@Retained
protected Object findObjectInSystem(KeyInfo keyInfo, boolean isCreate, TXStateInterface txState, boolean generateCallbacks, Object localValue, boolean disableCopyOnRead, boolean preferCD, ClientProxyMembershipID requestingClient, EntryEventImpl clientEvent, boolean returnTombstones) throws CacheLoaderException, TimeoutException {
    @Released EntryEventImpl event = null;
    checkForLimitedOrNoAccess();
    final Operation op = isCreate ? Operation.CREATE : Operation.UPDATE;
    long lastModified = 0L;
    try {
        event = findOnServer(keyInfo, op, generateCallbacks, clientEvent);
        if (event == null) {
            event = createEventForLoad(keyInfo, generateCallbacks, requestingClient, op);
            lastModified = findUsingSearchLoad(txState, localValue, clientEvent, keyInfo, event);
        }
        // Update region with new value.
        if (event.hasNewValue() && !isMemoryThresholdReachedForLoad()) {
            putNewValueInRegion(isCreate, clientEvent, lastModified, event);
        } else if (isCreate) {
            recordMiss(null, event.getKey());
        }
        return determineResult(preferCD, event);
    } finally {
        if (event != null) {
            event.release();
        }
    }
}
Also used : Released(org.apache.geode.internal.offheap.annotations.Released) Operation(org.apache.geode.cache.Operation) Retained(org.apache.geode.internal.offheap.annotations.Retained)

Aggregations

Retained (org.apache.geode.internal.offheap.annotations.Retained)33 StoredObject (org.apache.geode.internal.offheap.StoredObject)17 Released (org.apache.geode.internal.offheap.annotations.Released)9 VersionTag (org.apache.geode.internal.cache.versions.VersionTag)7 CachedDeserializable (org.apache.geode.internal.cache.CachedDeserializable)5 IOException (java.io.IOException)4 EntryEventImpl (org.apache.geode.internal.cache.EntryEventImpl)4 Unretained (org.apache.geode.internal.offheap.annotations.Unretained)4 Operation (org.apache.geode.cache.Operation)3 GetOperationContext (org.apache.geode.cache.operations.GetOperationContext)3 GetOperationContextImpl (org.apache.geode.cache.operations.internal.GetOperationContextImpl)3 QueryException (org.apache.geode.cache.query.QueryException)3 DistributedMember (org.apache.geode.distributed.DistributedMember)3 AuthorizeRequest (org.apache.geode.internal.security.AuthorizeRequest)3 AuthorizeRequestPP (org.apache.geode.internal.security.AuthorizeRequestPP)3 NotAuthorizedException (org.apache.geode.security.NotAuthorizedException)3 DiskAccessException (org.apache.geode.cache.DiskAccessException)2 IndexMaintenanceException (org.apache.geode.cache.query.IndexMaintenanceException)2 CqService (org.apache.geode.cache.query.internal.cq.CqService)2 IndexManager (org.apache.geode.cache.query.internal.index.IndexManager)2