Search in sources :

Example 1 with ClientHealthMonitoringRegion

use of org.apache.geode.internal.admin.ClientHealthMonitoringRegion 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 2 with ClientHealthMonitoringRegion

use of org.apache.geode.internal.admin.ClientHealthMonitoringRegion in project geode by apache.

the class GemFireMemberStatus method initializeServer.

protected void initializeServer() {
    Collection servers = cache.getCacheServers();
    if (servers.size() == 0) {
        setIsServer(false);
    } else {
        setIsServer(true);
        // Get connected clients.
        // The following method returns a map of client member id to a cache
        // client info. For now, keep track of the member ids in the set of
        // _connectedClients.
        Map allConnectedClients = InternalClientMembership.getStatusForAllClientsIgnoreSubscriptionStatus();
        Iterator allConnectedClientsIterator = allConnectedClients.values().iterator();
        while (allConnectedClientsIterator.hasNext()) {
            CacheClientStatus ccs = (CacheClientStatus) allConnectedClientsIterator.next();
            addConnectedClient(ccs.getMemberId());
            // host address is available directly by id, hence CacheClientStatus need not be populated
            putClientHostName(ccs.getMemberId(), ccs.getHostAddress());
        }
        // Get client queue sizes
        Map clientQueueSize = getClientIDMap(InternalClientMembership.getClientQueueSizes());
        setClientQueueSizes(clientQueueSize);
        // Set server acceptor port (set it based on the first CacheServer)
        CacheServer server = (CacheServer) servers.toArray()[0];
        setServerPort(server.getPort());
        // Get Client Health Stats
        // Assert.assertTrue(cache != null); (cannot be null)
        Region clientHealthMonitoringRegion = ClientHealthMonitoringRegion.getInstance((InternalCache) cache);
        if (clientHealthMonitoringRegion != null) {
            String[] clients = (String[]) clientHealthMonitoringRegion.keySet().toArray(new String[0]);
            for (int i = 0; i < clients.length; i++) {
                String clientId = clients[i];
                ClientHealthStats stats = (ClientHealthStats) clientHealthMonitoringRegion.get(clientId);
                setClientHealthStats(clientId, stats);
            }
        }
    }
}
Also used : CacheClientStatus(org.apache.geode.internal.cache.CacheClientStatus) Iterator(java.util.Iterator) Collection(java.util.Collection) CacheServer(org.apache.geode.cache.server.CacheServer) HARegion(org.apache.geode.internal.cache.HARegion) LocalRegion(org.apache.geode.internal.cache.LocalRegion) Region(org.apache.geode.cache.Region) ClientHealthMonitoringRegion(org.apache.geode.internal.admin.ClientHealthMonitoringRegion) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) HashMap(java.util.HashMap) Map(java.util.Map) ClientHealthStats(org.apache.geode.internal.admin.remote.ClientHealthStats)

Aggregations

Region (org.apache.geode.cache.Region)2 ClientHealthMonitoringRegion (org.apache.geode.internal.admin.ClientHealthMonitoringRegion)2 ClientHealthStats (org.apache.geode.internal.admin.remote.ClientHealthStats)2 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 Map (java.util.Map)1 CqService (org.apache.geode.cache.query.internal.cq.CqService)1 ServerCQ (org.apache.geode.cache.query.internal.cq.ServerCQ)1 CacheServer (org.apache.geode.cache.server.CacheServer)1 CacheClientStatus (org.apache.geode.internal.cache.CacheClientStatus)1 HARegion (org.apache.geode.internal.cache.HARegion)1 LocalRegion (org.apache.geode.internal.cache.LocalRegion)1 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)1 CacheClientProxy (org.apache.geode.internal.cache.tier.sockets.CacheClientProxy)1 ClientProxyMembershipID (org.apache.geode.internal.cache.tier.sockets.ClientProxyMembershipID)1 ClientHealthStatus (org.apache.geode.management.ClientHealthStatus)1