Search in sources :

Example 16 with Unretained

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

the class LocalRegion method postRemoveAllFireEvents.

public void postRemoveAllFireEvents(DistributedRemoveAllOperation removeAllOp, VersionedObjectList successfulOps) {
    if (!this.dataPolicy.withStorage() && this.concurrencyChecksEnabled && removeAllOp.getBaseEvent().isBridgeEvent()) {
        // if there is no local storage we need to transfer version information
        // to the successfulOps list for transmission back to the client
        successfulOps.clear();
        removeAllOp.fillVersionedObjectList(successfulOps);
    }
    Set successfulKeys = new HashSet(successfulOps.size());
    for (Object key : successfulOps.getKeys()) {
        successfulKeys.add(key);
    }
    for (Iterator it = removeAllOp.eventIterator(); it.hasNext(); ) {
        @Unretained EntryEventImpl event = (EntryEventImpl) it.next();
        if (successfulKeys.contains(event.getKey())) {
            invokeDestroyCallbacks(EnumListenerEvent.AFTER_DESTROY, event, !event.callbacksInvoked() && !event.isPossibleDuplicate(), this.isUsedForPartitionedRegionBucket);
        }
    }
}
Also used : EnumSet(java.util.EnumSet) HashSet(java.util.HashSet) Set(java.util.Set) AbstractSet(java.util.AbstractSet) Iterator(java.util.Iterator) StoredObject(org.apache.geode.internal.offheap.StoredObject) Unretained(org.apache.geode.internal.offheap.annotations.Unretained) HashSet(java.util.HashSet)

Example 17 with Unretained

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

the class GatewaySenderEventImpl method getSerializedValue.

/**
   * If the value owned of this event is just bytes return that byte array; otherwise serialize the
   * value object and return the serialized bytes. Use {@link #getValueIsObject()} to determine if
   * the result is raw or serialized bytes.
   */
public byte[] getSerializedValue() {
    byte[] result = this.value;
    if (result == null) {
        if (this.substituteValue != null) {
            // The substitute value is set. Serialize it
            isSerializingValue.set(Boolean.TRUE);
            result = EntryEventImpl.serialize(this.substituteValue);
            isSerializingValue.set(Boolean.FALSE);
            return result;
        }
        @Unretained(OffHeapIdentifier.GATEWAY_SENDER_EVENT_IMPL_VALUE) Object vo = this.valueObj;
        if (vo instanceof StoredObject) {
            synchronized (this) {
                result = this.value;
                if (result == null) {
                    StoredObject so = (StoredObject) vo;
                    result = so.getValueAsHeapByteArray();
                    this.value = result;
                }
            }
        } else {
            synchronized (this) {
                result = this.value;
                if (result == null && vo != null && !(vo instanceof Token)) {
                    isSerializingValue.set(Boolean.TRUE);
                    result = EntryEventImpl.serialize(vo);
                    isSerializingValue.set(Boolean.FALSE);
                    this.value = result;
                } else if (result == null) {
                    if (this.valueObjReleased) {
                        this.serializedValueNotAvailable = true;
                        throw new IllegalStateException("Value is no longer available. getSerializedValue must be called before processEvents returns.");
                    }
                }
            }
        }
    }
    return result;
}
Also used : StoredObject(org.apache.geode.internal.offheap.StoredObject) StoredObject(org.apache.geode.internal.offheap.StoredObject) Token(org.apache.geode.internal.cache.Token) Unretained(org.apache.geode.internal.offheap.annotations.Unretained)

Aggregations

Unretained (org.apache.geode.internal.offheap.annotations.Unretained)17 StoredObject (org.apache.geode.internal.offheap.StoredObject)12 HashSet (java.util.HashSet)4 Set (java.util.Set)4 CqService (org.apache.geode.cache.query.internal.cq.CqService)4 Retained (org.apache.geode.internal.offheap.annotations.Retained)4 IOException (java.io.IOException)2 AbstractSet (java.util.AbstractSet)2 EnumSet (java.util.EnumSet)2 Iterator (java.util.Iterator)2 TreeSet (java.util.TreeSet)2 CopyOnWriteHashSet (org.apache.geode.internal.CopyOnWriteHashSet)2 FilterInfo (org.apache.geode.internal.cache.FilterRoutingInfo.FilterInfo)2 VersionSource (org.apache.geode.internal.cache.versions.VersionSource)2 org.apache.geode (org.apache.geode)1 HeapDataOutputStream (org.apache.geode.internal.HeapDataOutputStream)1 PutAllEntryData (org.apache.geode.internal.cache.DistributedPutAllOperation.PutAllEntryData)1 RemoveAllEntryData (org.apache.geode.internal.cache.DistributedRemoveAllOperation.RemoveAllEntryData)1 Token (org.apache.geode.internal.cache.Token)1 LockObject (org.apache.geode.internal.cache.partitioned.LockObject)1