use of org.apache.geode.cache.query.internal.cq.ServerCQ in project geode by apache.
the class DistributedCacheOperation method removeDestroyTokensFromCqResultKeys.
/**
* Cleanup destroyed events in CQ result cache for remote CQs. While maintaining the CQ results
* key caching. the destroy event keys are marked as destroyed instead of removing them, this is
* to take care, arrival of duplicate events. The key marked as destroyed are removed after the
* event is placed in clients HAQueue or distributed to the peers.
*
* This is similar to CacheClientNotifier.removeDestroyTokensFromCqResultKeys() where the
* destroyed events for local CQs are handled.
*/
private void removeDestroyTokensFromCqResultKeys(FilterRoutingInfo filterRouting) {
for (InternalDistributedMember m : filterRouting.getMembers()) {
FilterInfo filterInfo = filterRouting.getFilterInfo(m);
if (filterInfo.getCQs() == null) {
continue;
}
CacheProfile cf = (CacheProfile) ((Bucket) getRegion()).getPartitionedRegion().getCacheDistributionAdvisor().getProfile(m);
if (cf == null || cf.filterProfile == null || cf.filterProfile.isLocalProfile() || cf.filterProfile.getCqMap().isEmpty()) {
continue;
}
for (Object value : cf.filterProfile.getCqMap().values()) {
ServerCQ cq = (ServerCQ) value;
for (Map.Entry<Long, Integer> e : filterInfo.getCQs().entrySet()) {
Long cqID = e.getKey();
// the entry form CQ cache.
if (cq.getFilterID() == cqID && (e.getValue().equals(MessageType.LOCAL_DESTROY))) {
cq.removeFromCqResultKeys(((EntryOperation) event).getKey(), true);
}
}
}
}
}
use of org.apache.geode.cache.query.internal.cq.ServerCQ in project geode by apache.
the class CacheServerBridge method getClientHealthStatus.
private ClientHealthStatus getClientHealthStatus(ClientConnInfo connInfo) {
ClientProxyMembershipID proxyId = connInfo.getClientId();
CacheClientProxy proxy = CacheClientNotifier.getInstance().getClientProxy(proxyId);
if (proxy != null && !proxy.isConnected() && !proxyId.isDurable()) {
return null;
}
CacheServerBridge.clientVersion.set(getClientVersion(connInfo));
int clientCQCount = 0;
CqService cqService = cache.getCqService();
if (cqService != null) {
List<ServerCQ> cqs = cqService.getAllClientCqs(proxyId);
clientCQCount = cqs.size();
}
ClientHealthStatus status = new ClientHealthStatus();
Region clientHealthMonitoringRegion = ClientHealthMonitoringRegion.getInstance(this.cache);
String clientName = proxyId.getDSMembership();
status.setClientId(connInfo.toString());
status.setName(clientName);
status.setHostName(connInfo.getHostName());
status.setClientCQCount(clientCQCount);
// Only available for clients having subscription enabled true
if (proxy != null) {
status.setUpTime(proxy.getUpTime());
status.setQueueSize(proxy.getQueueSizeStat());
status.setConnected(proxy.isConnected());
status.setSubscriptionEnabled(true);
} else {
status.setConnected(true);
status.setSubscriptionEnabled(false);
}
ClientHealthStats stats = (ClientHealthStats) clientHealthMonitoringRegion.get(clientName);
if (stats != null) {
status.setCpus(stats.getCpus());
status.setNumOfCacheListenerCalls(stats.getNumOfCacheListenerCalls());
status.setNumOfGets(stats.getNumOfGets());
status.setNumOfMisses(stats.getNumOfMisses());
status.setNumOfPuts(stats.getNumOfPuts());
status.setNumOfThreads(stats.getNumOfThreads());
status.setProcessCpuTime(stats.getProcessCpuTime());
status.setPoolStats(stats.getPoolStats());
}
return status;
}
use of org.apache.geode.cache.query.internal.cq.ServerCQ 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.cache.query.internal.cq.ServerCQ 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.ServerCQ in project geode by apache.
the class FilterProfile method processCloseCq.
public void processCloseCq(String serverCqName) {
ServerCQ cq = (ServerCQ) this.cqs.get(serverCqName);
if (cq != null) {
try {
cq.close(false);
} catch (Exception ex) {
if (logger.isDebugEnabled()) {
logger.debug("Unable to close the CQ with the filterProfile, on region {} for CQ {}, Error : {}", this.region.getFullPath(), serverCqName, ex.getMessage(), ex);
}
}
this.cqs.remove(serverCqName);
cq.getCqBaseRegion().getFilterProfile().decCqCount();
}
}
Aggregations