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;
}
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);
}
}
}
}
}
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();
}
}
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());
}
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);
}
}
}
Aggregations