Search in sources :

Example 1 with PutAllEntryData

use of org.apache.geode.internal.cache.DistributedPutAllOperation.PutAllEntryData in project geode by apache.

the class PutAllPRMessage method fromData.

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

Example 2 with PutAllEntryData

use of org.apache.geode.internal.cache.DistributedPutAllOperation.PutAllEntryData in project geode by apache.

the class RemotePutAllMessage method fromData.

@Override
public void fromData(DataInput in) throws IOException, ClassNotFoundException {
    super.fromData(in);
    this.eventId = (EventID) DataSerializer.readObject(in);
    this.callbackArg = DataSerializer.readObject(in);
    this.posDup = (flags & POS_DUP) != 0;
    if ((flags & HAS_BRIDGE_CONTEXT) != 0) {
        this.bridgeContext = DataSerializer.readObject(in);
    }
    this.skipCallbacks = (flags & SKIP_CALLBACKS) != 0;
    this.putAllDataCount = (int) InternalDataSerializer.readUnsignedVL(in);
    this.putAllData = new PutAllEntryData[putAllDataCount];
    if (this.putAllDataCount > 0) {
        final Version version = InternalDataSerializer.getVersionForDataStreamOrNull(in);
        final ByteArrayDataInput bytesIn = new ByteArrayDataInput();
        for (int i = 0; i < this.putAllDataCount; i++) {
            this.putAllData[i] = new PutAllEntryData(in, this.eventId, i, version, bytesIn);
        }
        boolean hasTags = in.readBoolean();
        if (hasTags) {
            EntryVersionsList versionTags = EntryVersionsList.create(in);
            for (int i = 0; i < this.putAllDataCount; i++) {
                this.putAllData[i].versionTag = versionTags.get(i);
            }
        }
    }
}
Also used : EntryVersionsList(org.apache.geode.internal.cache.DistributedPutAllOperation.EntryVersionsList) Version(org.apache.geode.internal.Version) ByteArrayDataInput(org.apache.geode.internal.ByteArrayDataInput) PutAllEntryData(org.apache.geode.internal.cache.DistributedPutAllOperation.PutAllEntryData)

Example 3 with PutAllEntryData

use of org.apache.geode.internal.cache.DistributedPutAllOperation.PutAllEntryData in project geode by apache.

the class RemotePutAllMessage method distribute.

/*
   * this is similar to send() but it selects an initialized replicate that is used to proxy the
   * message
   * 
   */
public static boolean distribute(EntryEventImpl event, PutAllEntryData[] data, int dataCount) {
    boolean successful = false;
    DistributedRegion r = (DistributedRegion) event.getRegion();
    Collection replicates = r.getCacheDistributionAdvisor().adviseInitializedReplicates();
    if (replicates.isEmpty()) {
        return false;
    }
    if (replicates.size() > 1) {
        ArrayList l = new ArrayList(replicates);
        Collections.shuffle(l);
        replicates = l;
    }
    int attempts = 0;
    for (Iterator<InternalDistributedMember> it = replicates.iterator(); it.hasNext(); ) {
        InternalDistributedMember replicate = it.next();
        try {
            attempts++;
            final boolean posDup = (attempts > 1);
            PutAllResponse response = send(replicate, event, data, dataCount, false, DistributionManager.SERIAL_EXECUTOR, posDup);
            response.waitForCacheException();
            VersionedObjectList result = response.getResponse();
            // Set successful version tags in PutAllEntryData.
            List successfulKeys = result.getKeys();
            List<VersionTag> versions = result.getVersionTags();
            for (PutAllEntryData putAllEntry : data) {
                Object key = putAllEntry.getKey();
                if (successfulKeys.contains(key)) {
                    int index = successfulKeys.indexOf(key);
                    putAllEntry.versionTag = versions.get(index);
                }
            }
            return true;
        } catch (TransactionDataNotColocatedException enfe) {
            throw enfe;
        } catch (CancelException e) {
            event.getRegion().getCancelCriterion().checkCancelInProgress(e);
        } catch (CacheException e) {
            if (logger.isDebugEnabled()) {
                logger.debug("RemotePutMessage caught CacheException during distribution", e);
            }
            // not a cancel-exception, so don't complain any more about it
            successful = true;
        } catch (RemoteOperationException e) {
            if (logger.isTraceEnabled(LogMarker.DM)) {
                logger.trace(LogMarker.DM, "RemotePutMessage caught an unexpected exception during distribution", e);
            }
        }
    }
    return successful;
}
Also used : CacheException(org.apache.geode.cache.CacheException) ArrayList(java.util.ArrayList) VersionedObjectList(org.apache.geode.internal.cache.tier.sockets.VersionedObjectList) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) TransactionDataNotColocatedException(org.apache.geode.cache.TransactionDataNotColocatedException) VersionTag(org.apache.geode.internal.cache.versions.VersionTag) Collection(java.util.Collection) EntryVersionsList(org.apache.geode.internal.cache.DistributedPutAllOperation.EntryVersionsList) ArrayList(java.util.ArrayList) VersionedObjectList(org.apache.geode.internal.cache.tier.sockets.VersionedObjectList) List(java.util.List) CancelException(org.apache.geode.CancelException) PutAllEntryData(org.apache.geode.internal.cache.DistributedPutAllOperation.PutAllEntryData)

Example 4 with PutAllEntryData

use of org.apache.geode.internal.cache.DistributedPutAllOperation.PutAllEntryData in project geode by apache.

the class FilterProfile method getLocalFilterRoutingForPutAllOp.

/**
   * computes FilterRoutingInfo objects for each of the given events
   */
public void getLocalFilterRoutingForPutAllOp(DistributedPutAllOperation dpao, DistributedPutAllOperation.PutAllEntryData[] putAllData) {
    final boolean isDebugEnabled = logger.isDebugEnabled();
    if (this.region != null && this.localProfile.hasCacheServer) {
        Set clientsInv = null;
        Set clients = null;
        int size = putAllData.length;
        CqService cqService = getCqService(dpao.getRegion());
        boolean doCQs = cqService.isRunning() && this.region != null;
        for (int idx = 0; idx < size; idx++) {
            PutAllEntryData pEntry = putAllData[idx];
            if (pEntry != null) {
                @Unretained final EntryEventImpl ev = dpao.getEventForPosition(idx);
                FilterRoutingInfo fri = pEntry.filterRouting;
                FilterInfo fi = null;
                if (fri != null) {
                    fi = fri.getLocalFilterInfo();
                }
                if (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);
                }
                ev.setLocalFilterInfo(fi);
            }
        }
    }
}
Also used : Set(java.util.Set) CopyOnWriteHashSet(org.apache.geode.internal.CopyOnWriteHashSet) TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) CqService(org.apache.geode.cache.query.internal.cq.CqService) PutAllEntryData(org.apache.geode.internal.cache.DistributedPutAllOperation.PutAllEntryData) Unretained(org.apache.geode.internal.offheap.annotations.Unretained) FilterInfo(org.apache.geode.internal.cache.FilterRoutingInfo.FilterInfo)

Example 5 with PutAllEntryData

use of org.apache.geode.internal.cache.DistributedPutAllOperation.PutAllEntryData in project geode by apache.

the class DistTxEntryEvent method putAllToData.

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

Aggregations

PutAllEntryData (org.apache.geode.internal.cache.DistributedPutAllOperation.PutAllEntryData)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 DistributedPutAllOperation (org.apache.geode.internal.cache.DistributedPutAllOperation)1 FilterInfo (org.apache.geode.internal.cache.FilterRoutingInfo.FilterInfo)1 VersionedObjectList (org.apache.geode.internal.cache.tier.sockets.VersionedObjectList)1