Search in sources :

Example 1 with ServerCQ

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);
                }
            }
        }
    }
}
Also used : CacheProfile(org.apache.geode.internal.cache.CacheDistributionAdvisor.CacheProfile) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) StoredObject(org.apache.geode.internal.offheap.StoredObject) ServerCQ(org.apache.geode.cache.query.internal.cq.ServerCQ) FilterInfo(org.apache.geode.internal.cache.FilterRoutingInfo.FilterInfo) Map(java.util.Map)

Example 2 with ServerCQ

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;
}
Also used : ClientProxyMembershipID(org.apache.geode.internal.cache.tier.sockets.ClientProxyMembershipID) CacheClientProxy(org.apache.geode.internal.cache.tier.sockets.CacheClientProxy) ClientHealthStatus(org.apache.geode.management.ClientHealthStatus) Region(org.apache.geode.cache.Region) ClientHealthMonitoringRegion(org.apache.geode.internal.admin.ClientHealthMonitoringRegion) ServerCQ(org.apache.geode.cache.query.internal.cq.ServerCQ) CqService(org.apache.geode.cache.query.internal.cq.CqService) ClientHealthStats(org.apache.geode.internal.admin.remote.ClientHealthStats)

Example 3 with ServerCQ

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);
                }
            }
        }
    }
}
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 4 with ServerCQ

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();
        }
    }
}
Also used : ServerCQ(org.apache.geode.cache.query.internal.cq.ServerCQ) CqService(org.apache.geode.cache.query.internal.cq.CqService) CqStateImpl(org.apache.geode.cache.query.internal.CqStateImpl) CancelException(org.apache.geode.CancelException) IOException(java.io.IOException)

Example 5 with ServerCQ

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();
    }
}
Also used : ServerCQ(org.apache.geode.cache.query.internal.cq.ServerCQ) CancelException(org.apache.geode.CancelException) IOException(java.io.IOException)

Aggregations

ServerCQ (org.apache.geode.cache.query.internal.cq.ServerCQ)11 Map (java.util.Map)5 IOException (java.io.IOException)4 HashMap (java.util.HashMap)4 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)4 CancelException (org.apache.geode.CancelException)3 CqService (org.apache.geode.cache.query.internal.cq.CqService)3 InternalDistributedMember (org.apache.geode.distributed.internal.membership.InternalDistributedMember)3 ClientProxyMembershipID (org.apache.geode.internal.cache.tier.sockets.ClientProxyMembershipID)3 Iterator (java.util.Iterator)2 ConcurrentMap (java.util.concurrent.ConcurrentMap)2 CqStateImpl (org.apache.geode.cache.query.internal.CqStateImpl)2 FilterProfile (org.apache.geode.internal.cache.FilterProfile)2 FilterInfo (org.apache.geode.internal.cache.FilterRoutingInfo.FilterInfo)2 LocalRegion (org.apache.geode.internal.cache.LocalRegion)2 HAContainerMap (org.apache.geode.internal.cache.ha.HAContainerMap)2 CopyOnWriteHashMap (org.apache.geode.internal.util.concurrent.CopyOnWriteHashMap)2 HashSet (java.util.HashSet)1 Set (java.util.Set)1 Region (org.apache.geode.cache.Region)1