Search in sources :

Example 1 with FilterProfile

use of org.apache.geode.internal.cache.FilterProfile 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 2 with FilterProfile

use of org.apache.geode.internal.cache.FilterProfile in project geode by apache.

the class CacheClientNotifier method removeDestroyTokensFromCqResultKeys.

private void removeDestroyTokensFromCqResultKeys(InternalCacheEvent event, FilterInfo filterInfo) {
    FilterProfile regionProfile = ((LocalRegion) event.getRegion()).getFilterProfile();
    if (event.getOperation().isEntry() && filterInfo.getCQs() != null) {
        EntryEventImpl entryEvent = (EntryEventImpl) event;
        for (Map.Entry<Long, Integer> e : filterInfo.getCQs().entrySet()) {
            Long cqID = e.getKey();
            String cqName = regionProfile.getRealCqID(cqID);
            if (cqName != null) {
                ServerCQ cq = regionProfile.getCq(cqName);
                if (cq != null && e.getValue().equals(Integer.valueOf(MessageType.LOCAL_DESTROY))) {
                    cq.removeFromCqResultKeys(entryEvent.getKey(), true);
                }
            }
        }
    }
}
Also used : FilterProfile(org.apache.geode.internal.cache.FilterProfile) EntryEventImpl(org.apache.geode.internal.cache.EntryEventImpl) LocalRegion(org.apache.geode.internal.cache.LocalRegion) ServerCQ(org.apache.geode.cache.query.internal.cq.ServerCQ) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HAContainerMap(org.apache.geode.internal.cache.ha.HAContainerMap) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap)

Example 3 with FilterProfile

use of org.apache.geode.internal.cache.FilterProfile in project geode by apache.

the class FilterProfileIntegrationJUnitTest method testFilterProfile.

@Test
public void testFilterProfile() throws Exception {
    Cache cache = CacheUtils.getCache();
    try {
        createLocalRegion();
        LocalRegion region = (LocalRegion) cache.getRegion(regionName);
        final FilterProfile filterProfile = new FilterProfile(region);
        filterProfile.registerClientInterest("clientId", ".*", InterestType.REGULAR_EXPRESSION, false);
        final FilterProfileTestHook hook = new FilterProfileTestHook();
        FilterProfile.testHook = hook;
        new Thread(new Runnable() {

            public void run() {
                while (hook.getCount() != 1) {
                }
                filterProfile.unregisterClientInterest("clientId", ".*", InterestType.REGULAR_EXPRESSION);
            }
        }).start();
        filterProfile.hasAllKeysInterestFor("clientId");
    } finally {
        cache.getDistributedSystem().disconnect();
        cache.close();
    }
}
Also used : FilterProfile(org.apache.geode.internal.cache.FilterProfile) LocalRegion(org.apache.geode.internal.cache.LocalRegion) Cache(org.apache.geode.cache.Cache) ClientSubscriptionTest(org.apache.geode.test.junit.categories.ClientSubscriptionTest) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 4 with FilterProfile

use of org.apache.geode.internal.cache.FilterProfile in project geode by apache.

the class UnregisterInterestDUnitTest method checkAllKeys.

public static void checkAllKeys(Integer value, Integer valueInv) {
    FilterProfile fp = ((GemFireCacheImpl) cache).getFilterProfile(regionname);
    assertEquals(value.intValue(), fp.getAllKeyClientsSize());
    assertEquals(valueInv.intValue(), fp.getAllKeyClientsInvSize());
}
Also used : FilterProfile(org.apache.geode.internal.cache.FilterProfile) GemFireCacheImpl(org.apache.geode.internal.cache.GemFireCacheImpl)

Example 5 with FilterProfile

use of org.apache.geode.internal.cache.FilterProfile in project geode by apache.

the class CqServiceImpl method processRegionEvent.

private void processRegionEvent(CacheEvent event, Profile localProfile, Profile[] profiles, FilterRoutingInfo frInfo) throws CqException {
    final boolean isDebugEnabled = logger.isDebugEnabled();
    if (isDebugEnabled) {
        logger.debug("CQ service processing region event {}", event);
    }
    Integer cqRegionEvent = generateCqRegionEvent(event);
    for (int i = -1; i < profiles.length; i++) {
        CacheProfile cf;
        if (i < 0) {
            cf = (CacheProfile) localProfile;
            if (cf == null)
                continue;
        } else {
            cf = (CacheProfile) profiles[i];
        }
        FilterProfile pf = cf.filterProfile;
        if (pf == null || pf.getCqMap().isEmpty()) {
            continue;
        }
        Map cqs = pf.getCqMap();
        HashMap<Long, Integer> cqInfo = new HashMap<>();
        Iterator cqIter = cqs.entrySet().iterator();
        while (cqIter.hasNext()) {
            Map.Entry cqEntry = (Map.Entry) cqIter.next();
            ServerCQImpl cQuery = (ServerCQImpl) cqEntry.getValue();
            if (!event.isOriginRemote() && event.getOperation().isRegionDestroy() && !((LocalRegion) event.getRegion()).isUsedForPartitionedRegionBucket()) {
                try {
                    if (isDebugEnabled) {
                        logger.debug("Closing CQ on region destroy event. CqName : {}", cQuery.getName());
                    }
                    cQuery.close(false);
                } catch (Exception ex) {
                    if (isDebugEnabled) {
                        logger.debug("Failed to Close CQ on region destroy. CqName : {}", cQuery.getName(), ex);
                    }
                }
            }
            cqInfo.put(cQuery.getFilterID(), cqRegionEvent);
            cQuery.getVsdStats().updateStats(cqRegionEvent);
        }
        if (pf.isLocalProfile()) {
            frInfo.setLocalCqInfo(cqInfo);
        } else {
            frInfo.setCqRoutingInfo(cf.getDistributedMember(), cqInfo);
        }
    }
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) LocalRegion(org.apache.geode.internal.cache.LocalRegion) TimeoutException(org.apache.geode.cache.TimeoutException) CqExistsException(org.apache.geode.cache.query.CqExistsException) CqException(org.apache.geode.cache.query.CqException) QueryInvalidException(org.apache.geode.cache.query.QueryInvalidException) InvalidDeltaException(org.apache.geode.InvalidDeltaException) RegionNotFoundException(org.apache.geode.cache.query.RegionNotFoundException) CacheLoaderException(org.apache.geode.cache.CacheLoaderException) CqClosedException(org.apache.geode.cache.query.CqClosedException) QueryException(org.apache.geode.cache.query.QueryException) CacheProfile(org.apache.geode.internal.cache.CacheDistributionAdvisor.CacheProfile) FilterProfile(org.apache.geode.internal.cache.FilterProfile) Iterator(java.util.Iterator) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap)

Aggregations

FilterProfile (org.apache.geode.internal.cache.FilterProfile)14 LocalRegion (org.apache.geode.internal.cache.LocalRegion)8 HashMap (java.util.HashMap)4 Iterator (java.util.Iterator)4 Map (java.util.Map)4 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)4 CqException (org.apache.geode.cache.query.CqException)4 GemFireCacheImpl (org.apache.geode.internal.cache.GemFireCacheImpl)4 Set (java.util.Set)3 InvalidDeltaException (org.apache.geode.InvalidDeltaException)3 CacheLoaderException (org.apache.geode.cache.CacheLoaderException)3 TimeoutException (org.apache.geode.cache.TimeoutException)3 CqClosedException (org.apache.geode.cache.query.CqClosedException)3 CqExistsException (org.apache.geode.cache.query.CqExistsException)3 QueryException (org.apache.geode.cache.query.QueryException)3 QueryInvalidException (org.apache.geode.cache.query.QueryInvalidException)3 RegionNotFoundException (org.apache.geode.cache.query.RegionNotFoundException)3 ClientSubscriptionTest (org.apache.geode.test.junit.categories.ClientSubscriptionTest)3 Test (org.junit.Test)3 HashSet (java.util.HashSet)2