Search in sources :

Example 1 with RemoveAllEntryData

use of org.apache.geode.internal.cache.DistributedRemoveAllOperation.RemoveAllEntryData in project geode by apache.

the class DistTxEntryEvent method removeAllFromData.

/**
   * @param in
   * @throws IOException
   * @throws ClassNotFoundException
   */
private void removeAllFromData(DataInput in) throws IOException, ClassNotFoundException {
    int removeAllSize = DataSerializer.readInteger(in);
    final RemoveAllEntryData[] removeAllData = new RemoveAllEntryData[removeAllSize];
    final Version version = InternalDataSerializer.getVersionForDataStreamOrNull(in);
    final ByteArrayDataInput bytesIn = new ByteArrayDataInput();
    for (int i = 0; i < removeAllSize; i++) {
        removeAllData[i] = new RemoveAllEntryData(in, this.eventID, i, version, bytesIn);
    }
    boolean hasTags = in.readBoolean();
    if (hasTags) {
        EntryVersionsList versionTags = EntryVersionsList.create(in);
        for (int i = 0; i < removeAllSize; i++) {
            removeAllData[i].versionTag = versionTags.get(i);
        }
    }
    // TODO DISTTX: release this event
    EntryEventImpl e = EntryEventImpl.create(this.region, Operation.REMOVEALL_DESTROY, null, null, null, true, this.getDistributedMember(), true, true);
    this.removeAllOp = new DistributedRemoveAllOperation(e, removeAllSize, false);
    this.removeAllOp.setRemoveAllEntryData(removeAllData);
}
Also used : EntryVersionsList(org.apache.geode.internal.cache.DistributedPutAllOperation.EntryVersionsList) DistributedRemoveAllOperation(org.apache.geode.internal.cache.DistributedRemoveAllOperation) Version(org.apache.geode.internal.Version) EntryEventImpl(org.apache.geode.internal.cache.EntryEventImpl) RemoveAllEntryData(org.apache.geode.internal.cache.DistributedRemoveAllOperation.RemoveAllEntryData) ByteArrayDataInput(org.apache.geode.internal.ByteArrayDataInput)

Example 2 with RemoveAllEntryData

use of org.apache.geode.internal.cache.DistributedRemoveAllOperation.RemoveAllEntryData in project geode by apache.

the class DistTxEntryEvent method removeAllToData.

/**
   * @param out
   * @throws IOException
   */
private void removeAllToData(DataOutput out) throws IOException {
    DataSerializer.writeInteger(this.removeAllOp.removeAllDataSize, out);
    EntryVersionsList versionTags = new EntryVersionsList(this.removeAllOp.removeAllDataSize);
    boolean hasTags = false;
    final RemoveAllEntryData[] removeAllData = this.removeAllOp.getRemoveAllEntryData();
    for (int i = 0; i < this.removeAllOp.removeAllDataSize; i++) {
        if (!hasTags && removeAllData[i].versionTag != null) {
            hasTags = true;
        }
        VersionTag<?> tag = removeAllData[i].versionTag;
        versionTags.add(tag);
        removeAllData[i].versionTag = null;
        removeAllData[i].toData(out);
        removeAllData[i].versionTag = tag;
    }
    out.writeBoolean(hasTags);
    if (hasTags) {
        InternalDataSerializer.invokeToData(versionTags, out);
    }
}
Also used : EntryVersionsList(org.apache.geode.internal.cache.DistributedPutAllOperation.EntryVersionsList) RemoveAllEntryData(org.apache.geode.internal.cache.DistributedRemoveAllOperation.RemoveAllEntryData)

Example 3 with RemoveAllEntryData

use of org.apache.geode.internal.cache.DistributedRemoveAllOperation.RemoveAllEntryData in project geode by apache.

the class FilterProfile method getLocalFilterRoutingForRemoveAllOp.

/**
   * computes FilterRoutingInfo objects for each of the given events
   */
public void getLocalFilterRoutingForRemoveAllOp(DistributedRemoveAllOperation op, RemoveAllEntryData[] removeAllData) {
    if (this.region != null && this.localProfile.hasCacheServer) {
        Set clientsInv = null;
        Set clients = null;
        int size = removeAllData.length;
        CqService cqService = getCqService(op.getRegion());
        boolean doCQs = cqService.isRunning() && this.region != null;
        for (int idx = 0; idx < size; idx++) {
            RemoveAllEntryData pEntry = removeAllData[idx];
            if (pEntry != null) {
                @Unretained final EntryEventImpl ev = op.getEventForPosition(idx);
                FilterRoutingInfo fri = pEntry.filterRouting;
                FilterInfo fi = null;
                if (fri != null) {
                    fi = fri.getLocalFilterInfo();
                }
                if (logger.isDebugEnabled()) {
                    logger.debug("Finding locally interested clients for {}", ev);
                }
                if (doCQs) {
                    if (fri == null) {
                        fri = new FilterRoutingInfo();
                    }
                    fillInCQRoutingInfo(ev, true, NO_PROFILES, fri);
                    fi = fri.getLocalFilterInfo();
                }
                if (this.allKeyClientsInv != null || this.keysOfInterestInv != null || this.patternsOfInterestInv != null || this.filtersOfInterestInv != null) {
                    clientsInv = this.getInterestedClients(ev, this.allKeyClientsInv, this.keysOfInterestInv, this.patternsOfInterestInv, this.filtersOfInterestInv);
                }
                if (this.allKeyClients != null || this.keysOfInterest != null || this.patternsOfInterest != null || this.filtersOfInterest != null) {
                    clients = this.getInterestedClients(ev, this.allKeyClients, this.keysOfInterest, this.patternsOfInterest, this.filtersOfInterest);
                }
                if (clients != null || clientsInv != null) {
                    if (fi == null) {
                        fi = new FilterInfo();
                    // no need to create or update a FilterRoutingInfo at this time
                    }
                    fi.setInterestedClients(clients);
                    fi.setInterestedClientsInv(clientsInv);
                }
                // if (this.logger.fineEnabled()) {
                // this.region.getLogWriterI18n().fine("setting event routing to " + fi);
                // }
                ev.setLocalFilterInfo(fi);
            }
        }
    }
}
Also used : Set(java.util.Set) CopyOnWriteHashSet(org.apache.geode.internal.CopyOnWriteHashSet) TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) RemoveAllEntryData(org.apache.geode.internal.cache.DistributedRemoveAllOperation.RemoveAllEntryData) CqService(org.apache.geode.cache.query.internal.cq.CqService) Unretained(org.apache.geode.internal.offheap.annotations.Unretained) FilterInfo(org.apache.geode.internal.cache.FilterRoutingInfo.FilterInfo)

Example 4 with RemoveAllEntryData

use of org.apache.geode.internal.cache.DistributedRemoveAllOperation.RemoveAllEntryData in project geode by apache.

the class RemoveAllPRMessage method fromData.

@Override
public void fromData(DataInput in) throws IOException, ClassNotFoundException {
    super.fromData(in);
    this.bucketId = Integer.valueOf((int) InternalDataSerializer.readSignedVL(in));
    if ((flags & HAS_BRIDGE_CONTEXT) != 0) {
        this.bridgeContext = DataSerializer.readObject(in);
    }
    Version sourceVersion = InternalDataSerializer.getVersionForDataStream(in);
    this.callbackArg = DataSerializer.readObject(in);
    this.removeAllPRDataSize = (int) InternalDataSerializer.readUnsignedVL(in);
    this.removeAllPRData = new RemoveAllEntryData[removeAllPRDataSize];
    if (this.removeAllPRDataSize > 0) {
        final Version version = InternalDataSerializer.getVersionForDataStreamOrNull(in);
        final ByteArrayDataInput bytesIn = new ByteArrayDataInput();
        for (int i = 0; i < this.removeAllPRDataSize; i++) {
            this.removeAllPRData[i] = new RemoveAllEntryData(in, null, i, version, bytesIn);
        }
        boolean hasTags = in.readBoolean();
        if (hasTags) {
            EntryVersionsList versionTags = EntryVersionsList.create(in);
            for (int i = 0; i < this.removeAllPRDataSize; i++) {
                this.removeAllPRData[i].versionTag = versionTags.get(i);
            }
        }
    }
}
Also used : EntryVersionsList(org.apache.geode.internal.cache.DistributedPutAllOperation.EntryVersionsList) Version(org.apache.geode.internal.Version) RemoveAllEntryData(org.apache.geode.internal.cache.DistributedRemoveAllOperation.RemoveAllEntryData) ByteArrayDataInput(org.apache.geode.internal.ByteArrayDataInput)

Example 5 with RemoveAllEntryData

use of org.apache.geode.internal.cache.DistributedRemoveAllOperation.RemoveAllEntryData 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)

Aggregations

RemoveAllEntryData (org.apache.geode.internal.cache.DistributedRemoveAllOperation.RemoveAllEntryData)7 EntryVersionsList (org.apache.geode.internal.cache.DistributedPutAllOperation.EntryVersionsList)5 ByteArrayDataInput (org.apache.geode.internal.ByteArrayDataInput)3 Version (org.apache.geode.internal.Version)3 EntryEventImpl (org.apache.geode.internal.cache.EntryEventImpl)2 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Set (java.util.Set)1 TreeSet (java.util.TreeSet)1 CancelException (org.apache.geode.CancelException)1 CacheException (org.apache.geode.cache.CacheException)1 TransactionDataNotColocatedException (org.apache.geode.cache.TransactionDataNotColocatedException)1 CqService (org.apache.geode.cache.query.internal.cq.CqService)1 InternalDistributedMember (org.apache.geode.distributed.internal.membership.InternalDistributedMember)1 CopyOnWriteHashSet (org.apache.geode.internal.CopyOnWriteHashSet)1 DistributedRemoveAllOperation (org.apache.geode.internal.cache.DistributedRemoveAllOperation)1 FilterInfo (org.apache.geode.internal.cache.FilterRoutingInfo.FilterInfo)1 VersionedObjectList (org.apache.geode.internal.cache.tier.sockets.VersionedObjectList)1