use of org.apache.geode.cache.query.internal.cq.CqService in project geode by apache.
the class DurableClientTestCase method flushEntries.
/*
* Due to the way removal from ha region queue is implemented a dummy cq or interest needs to be
* created and a dummy value used so that none of the actual cqs will be triggered and yet an
* event will flush the queue
*/
protected void flushEntries(VM server, VM client, final String regionName) {
// ack counts
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
registerInterest(client, regionName, false);
server.invoke(new CacheSerializableRunnable("flush entries") {
public void run2() throws CacheException {
CqService service = ((InternalCache) CacheServerTestUtil.getCache()).getCqService();
// Get the region
Region region = CacheServerTestUtil.getCache().getRegion(regionName);
assertNotNull(region);
region.put("LAST", "ENTRY");
}
});
}
use of org.apache.geode.cache.query.internal.cq.CqService in project geode by apache.
the class FilterProfile method fillInCQRoutingInfo.
/**
* get continuous query routing information
*
* @param event the event to process
* @param peerProfiles the profiles getting this event
* @param frInfo the routing table to update
*/
private void fillInCQRoutingInfo(CacheEvent event, boolean processLocalProfile, Profile[] peerProfiles, FilterRoutingInfo frInfo) {
CqService cqService = getCqService(event.getRegion());
if (cqService != null) {
try {
Profile local = processLocalProfile ? this.localProfile : null;
cqService.processEvents(event, local, peerProfiles, frInfo);
} catch (VirtualMachineError err) {
SystemFailure.initiateFailure(err);
// now, so don't let this thread continue.
throw err;
} catch (Throwable t) {
SystemFailure.checkFailure();
logger.error(LocalizedMessage.create(LocalizedStrings.CacheClientNotifier_EXCEPTION_OCCURRED_WHILE_PROCESSING_CQS), t);
}
}
}
use of org.apache.geode.cache.query.internal.cq.CqService in project geode by apache.
the class FilterProfile method processRegisterCq.
/**
* adds a new CQ to this profile during a delta operation or deserialization
*
* @param serverCqName the query objects' name
* @param ServerCQ the new query object
* @param addToCqMap whether to add the query to this.cqs
*/
void processRegisterCq(String serverCqName, ServerCQ ServerCQ, boolean addToCqMap) {
ServerCQ cq = (ServerCQ) ServerCQ;
try {
CqService cqService = GemFireCacheImpl.getInstance().getCqService();
cqService.start();
cq.setCqService(cqService);
CqStateImpl cqState = (CqStateImpl) cq.getState();
cq.setName(generateCqName(serverCqName));
cq.registerCq(null, null, cqState.getState());
} catch (Exception ex) {
// Change it to Info level.
if (logger.isDebugEnabled()) {
logger.debug("Error while initializing the CQs with FilterProfile for CQ {}, Error : {}", serverCqName, ex.getMessage(), ex);
}
}
if (logger.isDebugEnabled()) {
logger.debug("Adding CQ to remote members FilterProfile using name: {}", serverCqName);
}
if (addToCqMap) {
this.cqs.put(serverCqName, cq);
}
// region is not set on the FilterProfile created for the peer nodes.
if (cq.getCqBaseRegion() != null) {
FilterProfile pf = cq.getCqBaseRegion().getFilterProfile();
if (pf != null) {
pf.incCqCount();
}
}
}
use of org.apache.geode.cache.query.internal.cq.CqService in project geode by apache.
the class FilterProfile method getFilterRoutingInfoPart2.
/**
* get local routing information
*
* @param part1Info routing information for peers, if any
* @param event the event to process
* @return routing information for clients connected to this server
*/
public FilterRoutingInfo getFilterRoutingInfoPart2(FilterRoutingInfo part1Info, CacheEvent event) {
FilterRoutingInfo result = part1Info;
if (localProfile.hasCacheServer) {
// bug #45520 - CQ events arriving out of order causes result set
// inconsistency, so don't compute routings for events in conflict
boolean isInConflict = event.getOperation().isEntry() && ((EntryEventImpl) event).isConcurrencyConflict();
CqService cqService = getCqService(event.getRegion());
if (!isInConflict && cqService.isRunning() && this.region != null) /*
* && !( this.region.isUsedForPartitionedRegionBucket() || //
* partitioned region CQ this.region instanceof PartitionedRegion)
*/
{
// processing is done in part 1
if (result == null) {
result = new FilterRoutingInfo();
}
if (logger.isDebugEnabled()) {
logger.debug("getting local cq matches for {}", event);
}
fillInCQRoutingInfo(event, true, NO_PROFILES, result);
}
result = fillInInterestRoutingInfo(event, localProfileArray, result, Collections.emptySet());
}
return result;
}
use of org.apache.geode.cache.query.internal.cq.CqService 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);
}
}
}
}
Aggregations