Search in sources :

Example 11 with Retained

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

the class BucketRegion method createEventForPR.

@Retained
EntryEventImpl createEventForPR(EntryEventImpl sourceEvent) {
    EntryEventImpl e2 = new EntryEventImpl(sourceEvent);
    boolean returned = false;
    try {
        e2.setRegion(this.partitionedRegion);
        if (FORCE_LOCAL_LISTENERS_INVOCATION) {
            e2.setInvokePRCallbacks(true);
        } else {
            e2.setInvokePRCallbacks(sourceEvent.getInvokePRCallbacks());
        }
        DistributedMember dm = this.getDistributionManager().getDistributionManagerId();
        e2.setOriginRemote(!e2.getDistributedMember().equals(dm));
        returned = true;
        return e2;
    } finally {
        if (!returned) {
            e2.release();
        }
    }
}
Also used : InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) DistributedMember(org.apache.geode.distributed.DistributedMember) Retained(org.apache.geode.internal.offheap.annotations.Retained)

Example 12 with Retained

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

the class AbstractRegionMap method createCBEvent.

/** create a callback event for applying a transactional change to the local cache */
@Retained
public static EntryEventImpl createCBEvent(final LocalRegion re, Operation op, Object key, Object newValue, TransactionId txId, TXRmtEvent txEvent, EventID eventId, Object aCallbackArgument, FilterRoutingInfo filterRoutingInfo, ClientProxyMembershipID bridgeContext, TXEntryState txEntryState, VersionTag versionTag, long tailKey) {
    DistributedMember originator = null;
    // txId should not be null even on localOrigin
    Assert.assertTrue(txId != null);
    originator = ((TXId) txId).getMemberId();
    LocalRegion eventRegion = re;
    if (eventRegion.isUsedForPartitionedRegionBucket()) {
        eventRegion = re.getPartitionedRegion();
    }
    @Retained EntryEventImpl retVal = EntryEventImpl.create(re, op, key, newValue, aCallbackArgument, txEntryState == null, originator);
    boolean returnedRetVal = false;
    try {
        if (bridgeContext != null) {
            retVal.setContext(bridgeContext);
        }
        if (eventRegion.generateEventID()) {
            retVal.setEventId(eventId);
        }
        if (versionTag != null) {
            retVal.setVersionTag(versionTag);
        }
        retVal.setTailKey(tailKey);
        FilterInfo localRouting = null;
        boolean computeFilterInfo = false;
        if (filterRoutingInfo == null) {
            computeFilterInfo = true;
        } else {
            localRouting = filterRoutingInfo.getLocalFilterInfo();
            if (localRouting != null) {
                // routing was computed in this VM but may need to perform local interest processing
                computeFilterInfo = !filterRoutingInfo.hasLocalInterestBeenComputed();
            } else {
                // routing was computed elsewhere and is in the "remote" routing table
                localRouting = filterRoutingInfo.getFilterInfo(re.getMyId());
            }
            if (localRouting != null) {
                if (!computeFilterInfo) {
                    retVal.setLocalFilterInfo(localRouting);
                }
            } else {
                computeFilterInfo = true;
            }
        }
        if (logger.isTraceEnabled()) {
            logger.trace("createCBEvent filterRouting={} computeFilterInfo={} local routing={}", filterRoutingInfo, computeFilterInfo, localRouting);
        }
        if (re.isUsedForPartitionedRegionBucket()) {
            BucketRegion bucket = (BucketRegion) re;
            if (BucketRegion.FORCE_LOCAL_LISTENERS_INVOCATION || bucket.getBucketAdvisor().isPrimary()) {
                retVal.setInvokePRCallbacks(true);
            } else {
                retVal.setInvokePRCallbacks(false);
            }
            if (computeFilterInfo) {
                if (bucket.getBucketAdvisor().isPrimary()) {
                    if (logger.isTraceEnabled()) {
                        logger.trace("createCBEvent computing routing for primary bucket");
                    }
                    FilterProfile fp = ((BucketRegion) re).getPartitionedRegion().getFilterProfile();
                    if (fp != null) {
                        FilterRoutingInfo fri = fp.getFilterRoutingInfoPart2(filterRoutingInfo, retVal);
                        if (fri != null) {
                            retVal.setLocalFilterInfo(fri.getLocalFilterInfo());
                        }
                    }
                }
            }
        } else if (computeFilterInfo) {
            // not a bucket
            if (logger.isTraceEnabled()) {
                logger.trace("createCBEvent computing routing for non-bucket");
            }
            FilterProfile fp = re.getFilterProfile();
            if (fp != null) {
                retVal.setLocalFilterInfo(fp.getLocalFilterRouting(retVal));
            }
        }
        retVal.setTransactionId(txId);
        returnedRetVal = true;
        return retVal;
    } finally {
        if (!returnedRetVal) {
            retVal.release();
        }
    }
}
Also used : Retained(org.apache.geode.internal.offheap.annotations.Retained) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) DistributedMember(org.apache.geode.distributed.DistributedMember) FilterInfo(org.apache.geode.internal.cache.FilterRoutingInfo.FilterInfo) Retained(org.apache.geode.internal.offheap.annotations.Retained)

Example 13 with Retained

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

the class EntryEventImpl method putExistingEntry.

/**
   * Put a newValue into the given, write synced, existing, region entry. Sets oldValue in event if
   * hasn't been set yet.
   * 
   * @param oldValueForDelta Used by Delta Propagation feature
   */
void putExistingEntry(final LocalRegion owner, final RegionEntry reentry, boolean requireOldValue, Object oldValueForDelta) throws RegionClearedException {
    makeUpdate();
    // only set oldValue if it hasn't already been set to something
    if (this.oldValue == null) {
        if (!reentry.isInvalidOrRemoved()) {
            if (// fix for bug
            requireOldValue || EVENT_OLD_VALUE || this.region instanceof HARegion) // 37909
            {
                @Retained Object ov;
                if (ReferenceCountHelper.trackReferenceCounts()) {
                    ReferenceCountHelper.setReferenceCountOwner(new OldValueOwner());
                    ov = reentry._getValueRetain(owner, true);
                    ReferenceCountHelper.setReferenceCountOwner(null);
                } else {
                    ov = reentry._getValueRetain(owner, true);
                }
                if (ov == null)
                    ov = Token.NOT_AVAILABLE;
                // ov has already been retained so call basicSetOldValue instead of retainAndSetOldValue
                basicSetOldValue(ov);
            } else {
                basicSetOldValue(Token.NOT_AVAILABLE);
            }
        }
    }
    if (this.oldValue == Token.NOT_AVAILABLE) {
        FilterProfile fp = this.region.getFilterProfile();
        if (this.op.guaranteesOldValue() || (fp != null && /* #41532 */
        fp.entryRequiresOldValue(this.getKey()))) {
            setOldValueForQueryProcessing();
        }
    }
    // setNewValueInRegion(null);
    setNewValueInRegion(owner, reentry, oldValueForDelta);
}
Also used : Retained(org.apache.geode.internal.offheap.annotations.Retained) StoredObject(org.apache.geode.internal.offheap.StoredObject)

Example 14 with Retained

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

the class PutMessage method createListenerEvent.

// public final boolean needsDirectAck()
// {
// return this.directAck;
// }
// final public int getProcessorType() {
// return DistributionManager.PARTITIONED_REGION_EXECUTOR;
// }
/**
   * create a new EntryEvent to be used in notifying listeners, bridge servers, etc. Caller must
   * release result if it is != to sourceEvent
   */
@Retained
EntryEventImpl createListenerEvent(EntryEventImpl sourceEvent, PartitionedRegion r, InternalDistributedMember member) {
    final EntryEventImpl e2;
    if (this.notificationOnly && this.bridgeContext == null) {
        e2 = sourceEvent;
    } else {
        e2 = new EntryEventImpl(sourceEvent);
        if (this.bridgeContext != null) {
            e2.setContext(this.bridgeContext);
        }
    }
    e2.setRegion(r);
    e2.setOriginRemote(true);
    e2.setInvokePRCallbacks(!notificationOnly);
    if (!sourceEvent.hasOldValue()) {
        e2.oldValueNotAvailable();
    }
    if (this.filterInfo != null) {
        e2.setLocalFilterInfo(this.filterInfo.getFilterInfo(member));
    }
    if (this.versionTag != null) {
        this.versionTag.replaceNullIDs(getSender());
        e2.setVersionTag(this.versionTag);
    }
    return e2;
}
Also used : EntryEventImpl(org.apache.geode.internal.cache.EntryEventImpl) Retained(org.apache.geode.internal.offheap.annotations.Retained)

Example 15 with Retained

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

the class DestroyMessage method createListenerEvent.

/**
   * create a new EntryEvent to be used in notifying listeners, bridge servers, etc. Caller must
   * release result if it is != to sourceEvent
   */
@Retained
EntryEventImpl createListenerEvent(EntryEventImpl sourceEvent, PartitionedRegion r, InternalDistributedMember member) {
    final EntryEventImpl e2;
    if (this.notificationOnly && this.bridgeContext == null) {
        e2 = sourceEvent;
    } else {
        e2 = new EntryEventImpl(sourceEvent);
        if (this.bridgeContext != null) {
            e2.setContext(this.bridgeContext);
        }
    }
    e2.setRegion(r);
    e2.setOriginRemote(true);
    e2.setInvokePRCallbacks(!notificationOnly);
    if (this.filterInfo != null) {
        e2.setLocalFilterInfo(this.filterInfo.getFilterInfo(member));
    }
    if (this.versionTag != null) {
        this.versionTag.replaceNullIDs(getSender());
        e2.setVersionTag(this.versionTag);
    }
    return e2;
}
Also used : EntryEventImpl(org.apache.geode.internal.cache.EntryEventImpl) 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