Search in sources :

Example 1 with ClientUpdateMessage

use of org.apache.geode.internal.cache.tier.sockets.ClientUpdateMessage in project geode by apache.

the class BucketRegion method notifyClientsOfTombstoneGC.

@Override
protected void notifyClientsOfTombstoneGC(Map<VersionSource, Long> regionGCVersions, Set<Object> removedKeys, EventID eventID, FilterInfo routing) {
    if (CacheClientNotifier.getInstance() != null) {
        // Only route the event to clients interested in the partitioned region.
        // We do this by constructing a region-level event and then use it to
        // have the filter profile ferret out all of the clients that have interest
        // in this region
        FilterProfile fp = getFilterProfile();
        // fix for bug #46309 - don't send null/empty key set to clients
        if (// bug #51877 - NPE in clients
        (removedKeys != null && !removedKeys.isEmpty()) && (routing != null || (fp != null && fp.hasInterest()))) {
            RegionEventImpl regionEvent = new RegionEventImpl(getPartitionedRegion(), Operation.REGION_DESTROY, null, true, getMyId());
            FilterInfo clientRouting = routing;
            if (clientRouting == null) {
                clientRouting = fp.getLocalFilterRouting(regionEvent);
            }
            regionEvent.setLocalFilterInfo(clientRouting);
            ClientUpdateMessage clientMessage = ClientTombstoneMessage.gc(getPartitionedRegion(), removedKeys, eventID);
            CacheClientNotifier.notifyClients(regionEvent, clientMessage);
        }
    }
}
Also used : ClientUpdateMessage(org.apache.geode.internal.cache.tier.sockets.ClientUpdateMessage) FilterInfo(org.apache.geode.internal.cache.FilterRoutingInfo.FilterInfo)

Example 2 with ClientUpdateMessage

use of org.apache.geode.internal.cache.tier.sockets.ClientUpdateMessage in project geode by apache.

the class PRTombstoneMessage method operateOnPartitionedRegion.

@Override
protected boolean operateOnPartitionedRegion(final DistributionManager dm, PartitionedRegion r, long startTime) throws ForceReattemptException {
    if (logger.isTraceEnabled(LogMarker.DM)) {
        logger.debug("PRTombstoneMessage operateOnRegion: {}", r.getFullPath());
    }
    FilterProfile fp = r.getFilterProfile();
    if (this.keys != null && this.keys.size() > 0) {
        // sanity check
        if (fp != null && CacheClientNotifier.getInstance() != null && this.eventID != null) {
            RegionEventImpl regionEvent = new RegionEventImpl(r, Operation.REGION_DESTROY, null, true, r.getGemFireCache().getMyId());
            regionEvent.setLocalFilterInfo(fp.getLocalFilterRouting(regionEvent));
            ClientUpdateMessage clientMessage = ClientTombstoneMessage.gc(r, this.keys, this.eventID);
            CacheClientNotifier.notifyClients(regionEvent, clientMessage);
        }
    }
    return true;
}
Also used : FilterProfile(org.apache.geode.internal.cache.FilterProfile) ClientUpdateMessage(org.apache.geode.internal.cache.tier.sockets.ClientUpdateMessage) RegionEventImpl(org.apache.geode.internal.cache.RegionEventImpl)

Example 3 with ClientUpdateMessage

use of org.apache.geode.internal.cache.tier.sockets.ClientUpdateMessage in project geode by apache.

the class LocalRegion method notifyClientsOfTombstoneGC.

/**
   * pass tombstone garbage-collection info to clients
   * 
   * @param eventID the ID of the event (see bug #50683)
   * @param routing routing info (routing is computed if this is null)
   */
protected void notifyClientsOfTombstoneGC(Map<VersionSource, Long> regionGCVersions, Set<Object> keysRemoved, EventID eventID, FilterInfo routing) {
    if (CacheClientNotifier.getInstance() != null) {
        // Only route the event to clients interested in the partitioned region.
        // We do this by constructing a region-level event and then use it to
        // have the filter profile ferret out all of the clients that have interest
        // in this region
        FilterProfile fp = getFilterProfile();
        if (fp != null || routing != null) {
            // null check - fix for bug #45614
            RegionEventImpl regionEvent = new RegionEventImpl(this, Operation.REGION_DESTROY, null, true, getMyId());
            regionEvent.setEventID(eventID);
            FilterInfo clientRouting = routing;
            if (clientRouting == null) {
                clientRouting = fp.getLocalFilterRouting(regionEvent);
            }
            regionEvent.setLocalFilterInfo(clientRouting);
            ClientUpdateMessage clientMessage = ClientTombstoneMessage.gc(this, regionGCVersions, eventID);
            CacheClientNotifier.notifyClients(regionEvent, clientMessage);
        }
    }
}
Also used : ClientUpdateMessage(org.apache.geode.internal.cache.tier.sockets.ClientUpdateMessage) FilterInfo(org.apache.geode.internal.cache.FilterRoutingInfo.FilterInfo)

Example 4 with ClientUpdateMessage

use of org.apache.geode.internal.cache.tier.sockets.ClientUpdateMessage in project geode by apache.

the class HARegionQueue method maintainCqStats.

private void maintainCqStats(Object event, long incrementAmount) {
    CqService cqService = region.getGemFireCache().getCqService();
    if (cqService != null) {
        try {
            if (event instanceof HAEventWrapper) {
                HAEventWrapper hw = (HAEventWrapper) event;
                if (hw.getClientUpdateMessage() != null) {
                    event = hw.getClientUpdateMessage();
                } else {
                    event = (Conflatable) this.haContainer.get(event);
                }
                if (event instanceof ClientUpdateMessage) {
                    if (((ClientUpdateMessage) event).hasCqs() && ((ClientUpdateMessage) event).hasCqs(clientProxyID)) {
                        CqNameToOp cqNames = ((ClientUpdateMessage) event).getClientCq(clientProxyID);
                        if (cqNames != null) {
                            for (String cqName : cqNames.getNames()) {
                                InternalCqQuery cq = ((InternalCqQuery) cqService.getClientCqFromServer(clientProxyID, cqName));
                                CqQueryVsdStats cqStats = cq.getVsdStats();
                                if (cq != null && cqStats != null) {
                                    cqStats.incNumHAQueuedEvents(incrementAmount);
                                }
                            }
                        }
                    }
                }
            }
        } catch (Exception e) {
            // as maintaining cq stats should not affect the system.
            if (logger.isTraceEnabled()) {
                logger.trace("Exception while maintaining cq events stats.", e);
            }
        }
    }
}
Also used : ClientUpdateMessage(org.apache.geode.internal.cache.tier.sockets.ClientUpdateMessage) CqNameToOp(org.apache.geode.internal.cache.tier.sockets.ClientUpdateMessageImpl.CqNameToOp) InternalCqQuery(org.apache.geode.cache.query.internal.cq.InternalCqQuery) CqService(org.apache.geode.cache.query.internal.cq.CqService) TimeoutException(org.apache.geode.cache.TimeoutException) RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) EntryNotFoundException(org.apache.geode.cache.EntryNotFoundException) CancelException(org.apache.geode.CancelException) InternalGemFireException(org.apache.geode.InternalGemFireException) CacheWriterException(org.apache.geode.cache.CacheWriterException) ConcurrentModificationException(java.util.ConcurrentModificationException) NoSuchElementException(java.util.NoSuchElementException) IOException(java.io.IOException) CacheException(org.apache.geode.cache.CacheException) HAEventWrapper(org.apache.geode.internal.cache.tier.sockets.HAEventWrapper) CqQueryVsdStats(org.apache.geode.cache.query.internal.CqQueryVsdStats)

Example 5 with ClientUpdateMessage

use of org.apache.geode.internal.cache.tier.sockets.ClientUpdateMessage in project geode by apache.

the class HARQueueNewImplDUnitTest method verifyQueueData.

public static void verifyQueueData(Integer regionsize, Integer msgsRegionsize, Integer port) {
    try {
        // Get the clientMessagesRegion and check the size.
        Region msgsRegion = cache.getRegion(CacheServerImpl.generateNameForClientMsgsRegion(port.intValue()));
        Region region = cache.getRegion("/" + regionName);
        logger.fine("size<serverRegion, clientMsgsRegion>: " + region.size() + ", " + msgsRegion.size());
        assertEquals(regionsize.intValue(), region.size());
        assertEquals(msgsRegionsize.intValue(), msgsRegion.size());
        Iterator iter = msgsRegion.entrySet().iterator();
        while (iter.hasNext()) {
            Region.Entry entry = (Region.Entry) iter.next();
            HAEventWrapper wrapper = (HAEventWrapper) entry.getKey();
            ClientUpdateMessage cum = (ClientUpdateMessage) entry.getValue();
            Object key = cum.getKeyOfInterest();
            logger.fine("key<feedCount, regionCount>: " + key + "<" + ((Long) map.get(key)).longValue() + ", " + wrapper.getReferenceCount() + ">");
            assertEquals(((Long) map.get(key)).longValue(), wrapper.getReferenceCount());
        }
    } catch (Exception e) {
        fail("failed in verifyQueueData()" + e);
    }
}
Also used : ClientUpdateMessage(org.apache.geode.internal.cache.tier.sockets.ClientUpdateMessage) Iterator(java.util.Iterator) LocalRegion(org.apache.geode.internal.cache.LocalRegion) Region(org.apache.geode.cache.Region) HAEventWrapper(org.apache.geode.internal.cache.tier.sockets.HAEventWrapper)

Aggregations

ClientUpdateMessage (org.apache.geode.internal.cache.tier.sockets.ClientUpdateMessage)7 Iterator (java.util.Iterator)3 Region (org.apache.geode.cache.Region)3 LocalRegion (org.apache.geode.internal.cache.LocalRegion)3 Set (java.util.Set)2 FilterInfo (org.apache.geode.internal.cache.FilterRoutingInfo.FilterInfo)2 HAEventWrapper (org.apache.geode.internal.cache.tier.sockets.HAEventWrapper)2 IOException (java.io.IOException)1 ConcurrentModificationException (java.util.ConcurrentModificationException)1 NoSuchElementException (java.util.NoSuchElementException)1 CancelException (org.apache.geode.CancelException)1 InternalGemFireException (org.apache.geode.InternalGemFireException)1 CacheException (org.apache.geode.cache.CacheException)1 CacheWriterException (org.apache.geode.cache.CacheWriterException)1 EntryNotFoundException (org.apache.geode.cache.EntryNotFoundException)1 RegionDestroyedException (org.apache.geode.cache.RegionDestroyedException)1 TimeoutException (org.apache.geode.cache.TimeoutException)1 CqQueryVsdStats (org.apache.geode.cache.query.internal.CqQueryVsdStats)1 CqService (org.apache.geode.cache.query.internal.cq.CqService)1 InternalCqQuery (org.apache.geode.cache.query.internal.cq.InternalCqQuery)1