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;
}
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);
}
}
}
}
Aggregations