use of org.apache.geode.cache.query.internal.cq.CqService 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);
}
}
}
}
use of org.apache.geode.cache.query.internal.cq.CqService in project geode by apache.
the class DistributedPutAllOperation method getEventForPosition.
@Unretained
public EntryEventImpl getEventForPosition(int position) {
PutAllEntryData entry = this.putAllData[position];
if (entry == null) {
return null;
}
if (entry.event != null) {
return entry.event;
}
LocalRegion region = (LocalRegion) this.event.getRegion();
@Retained EntryEventImpl ev = EntryEventImpl.create(region, entry.getOp(), entry.getKey(), null, /* value */
this.event.getCallbackArgument(), false, /* originRemote */
this.event.getDistributedMember(), this.event.isGenerateCallbacks(), entry.getEventID());
boolean returnedEv = false;
try {
ev.setPossibleDuplicate(entry.isPossibleDuplicate());
if (entry.versionTag != null && region.concurrencyChecksEnabled) {
VersionSource id = entry.versionTag.getMemberID();
if (id != null) {
entry.versionTag.setMemberID(ev.getRegion().getVersionVector().getCanonicalId(id));
}
ev.setVersionTag(entry.versionTag);
}
entry.event = ev;
returnedEv = true;
if (entry.getValue() == null && ev.getRegion().getAttributes().getDataPolicy() == DataPolicy.NORMAL) {
ev.setLocalInvalid(true);
}
ev.setNewValue(entry.getValue());
ev.setOldValue(entry.getOldValue());
CqService cqService = region.getCache().getCqService();
if (cqService.isRunning() && !entry.getOp().isCreate() && !ev.hasOldValue()) {
ev.setOldValueForQueryProcessing();
}
ev.setInvokePRCallbacks(!entry.isNotifyOnly());
if (getBaseEvent().getContext() != null) {
ev.setContext(getBaseEvent().getContext());
}
ev.callbacksInvoked(entry.isCallbacksInvoked());
ev.setTailKey(entry.getTailKey());
return ev;
} finally {
if (!returnedEv) {
ev.release();
}
}
}
use of org.apache.geode.cache.query.internal.cq.CqService in project geode by apache.
the class DistributedRemoveAllOperation method getEventForPosition.
@Unretained
public EntryEventImpl getEventForPosition(int position) {
RemoveAllEntryData entry = this.removeAllData[position];
if (entry == null) {
return null;
}
if (entry.event != null) {
return entry.event;
}
LocalRegion region = (LocalRegion) this.event.getRegion();
// owned by this.removeAllData once entry.event = ev is done
@Retained EntryEventImpl ev = EntryEventImpl.create(region, entry.getOp(), entry.getKey(), null, /* value */
this.event.getCallbackArgument(), false, /* originRemote */
this.event.getDistributedMember(), this.event.isGenerateCallbacks(), entry.getEventID());
boolean returnedEv = false;
try {
ev.setPossibleDuplicate(entry.isPossibleDuplicate());
ev.setIsRedestroyedEntry(entry.getRedestroyedEntry());
if (entry.versionTag != null && region.concurrencyChecksEnabled) {
VersionSource id = entry.versionTag.getMemberID();
if (id != null) {
entry.versionTag.setMemberID(ev.getRegion().getVersionVector().getCanonicalId(id));
}
ev.setVersionTag(entry.versionTag);
}
entry.event = ev;
returnedEv = true;
ev.setOldValue(entry.getOldValue());
CqService cqService = region.getCache().getCqService();
if (cqService.isRunning() && !entry.getOp().isCreate() && !ev.hasOldValue()) {
ev.setOldValueForQueryProcessing();
}
ev.setInvokePRCallbacks(!entry.isNotifyOnly());
if (getBaseEvent().getContext() != null) {
ev.setContext(getBaseEvent().getContext());
}
ev.callbacksInvoked(entry.isCallbacksInvoked());
ev.setTailKey(entry.getTailKey());
return ev;
} finally {
if (!returnedEv) {
ev.release();
}
}
}
use of org.apache.geode.cache.query.internal.cq.CqService in project geode by apache.
the class CacheClientUpdater method processCqs.
private int processCqs(Message clientMessage, int startMessagePart, int numCqParts, int messageType, Object key, Object value, byte[] delta, EventID eventId) {
HashMap cqs = new HashMap();
final boolean isDebugEnabled = logger.isDebugEnabled();
for (int cqCnt = 0; cqCnt < numCqParts; ) {
StringBuilder sb = null;
if (isDebugEnabled) {
sb = new StringBuilder(100);
sb.append("found these queries: ");
}
try {
// Get CQ Name.
Part cqNamePart = clientMessage.getPart(startMessagePart + cqCnt++);
// Get CQ Op.
Part cqOpPart = clientMessage.getPart(startMessagePart + cqCnt++);
cqs.put(cqNamePart.getString(), cqOpPart.getInt());
if (sb != null) {
sb.append(cqNamePart.getString()).append(" op=").append(cqOpPart.getInt()).append(" ");
}
} catch (Exception ignore) {
logger.warn(LocalizedMessage.create(LocalizedStrings.CacheClientUpdater_ERROR_WHILE_PROCESSING_THE_CQ_MESSAGE_PROBLEM_WITH_READING_MESSAGE_FOR_CQ_0, cqCnt));
}
if (isDebugEnabled) {
logger.debug(sb);
}
}
CqService cqService = this.cache.getCqService();
try {
cqService.dispatchCqListeners(cqs, messageType, key, value, delta, this.qManager, eventId);
} catch (Exception ex) {
logger.warn(LocalizedMessage.create(LocalizedStrings.CacheClientUpdater_FAILED_TO_INVOKE_CQ_DISPATCHER_ERROR___0, ex.getMessage()));
if (isDebugEnabled) {
logger.debug("Failed to invoke CQ Dispatcher.", ex);
}
}
return startMessagePart + numCqParts;
}
use of org.apache.geode.cache.query.internal.cq.CqService in project geode by apache.
the class QueueManagerImpl method cqsConnected.
private void cqsConnected() {
InternalCache cache = GemFireCacheImpl.getInstance();
if (cache != null) {
CqService cqService = cache.getCqService();
// Primary queue was found, alert the affected cqs if necessary
cqService.cqsConnected(pool);
}
}
Aggregations