Search in sources :

Example 1 with ClientHealthMonitor

use of org.apache.geode.internal.cache.tier.sockets.ClientHealthMonitor in project geode by apache.

the class InternalClientMembership method getConnectedClients.

/**
   * Returns a map of client memberIds to count of connections to that client. The map entry key is
   * a String representation of the client memberId, and the map entry value is an Integer count of
   * connections to that client. Since a single client can have multiple ConnectionProxy objects,
   * this map will contain all the Connection objects across the ConnectionProxies
   * 
   * @param onlyClientsNotifiedByThisServer true will return only those clients that are actively
   *        being updated by this server
   * @return map of client memberIds to count of connections to that client
   * 
   * 
   */
public static Map getConnectedClients(boolean onlyClientsNotifiedByThisServer) {
    ClientHealthMonitor chMon = ClientHealthMonitor.getInstance();
    Set filterProxyIDs = null;
    if (onlyClientsNotifiedByThisServer) {
        // since this is only a status (snapshot) of the system.
        for (Iterator bsii = CacheFactory.getAnyInstance().getCacheServers().iterator(); bsii.hasNext(); ) {
            CacheServerImpl bsi = (CacheServerImpl) bsii.next();
            AcceptorImpl ai = bsi.getAcceptor();
            if (ai != null && ai.getCacheClientNotifier() != null) {
                if (filterProxyIDs != null) {
                    // notifierClients is a copy set from CacheClientNotifier
                    filterProxyIDs.addAll(ai.getCacheClientNotifier().getActiveClients());
                } else {
                    // notifierClients is a copy set from CacheClientNotifier
                    filterProxyIDs = ai.getCacheClientNotifier().getActiveClients();
                }
            }
        }
    }
    Map map = chMon.getConnectedClients(filterProxyIDs);
    /*
     * if (onlyClientsNotifiedByThisServer) { Map notifyMap = new HashMap();
     * 
     * for (Iterator iter = map.keySet().iterator(); iter.hasNext();) { String memberId = (String)
     * iter.next(); if (notifierClients.contains(memberId)) { // found memberId that is notified by
     * this server notifyMap.put(memberId, map.get(memberId)); } } map = notifyMap; }
     */
    return map;
}
Also used : Set(java.util.Set) AcceptorImpl(org.apache.geode.internal.cache.tier.sockets.AcceptorImpl) ClientHealthMonitor(org.apache.geode.internal.cache.tier.sockets.ClientHealthMonitor) Iterator(java.util.Iterator) CacheServerImpl(org.apache.geode.internal.cache.CacheServerImpl) HashMap(java.util.HashMap) Map(java.util.Map)

Example 2 with ClientHealthMonitor

use of org.apache.geode.internal.cache.tier.sockets.ClientHealthMonitor in project geode by apache.

the class InternalClientMembership method getConnectedIncomingGateways.

public static Map getConnectedIncomingGateways() {
    Map connectedIncomingGateways = null;
    ClientHealthMonitor chMon = ClientHealthMonitor.getInstance();
    if (chMon == null) {
        connectedIncomingGateways = new HashMap();
    } else {
        connectedIncomingGateways = chMon.getConnectedIncomingGateways();
    }
    return connectedIncomingGateways;
}
Also used : HashMap(java.util.HashMap) ClientHealthMonitor(org.apache.geode.internal.cache.tier.sockets.ClientHealthMonitor) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

HashMap (java.util.HashMap)2 Map (java.util.Map)2 ClientHealthMonitor (org.apache.geode.internal.cache.tier.sockets.ClientHealthMonitor)2 Iterator (java.util.Iterator)1 Set (java.util.Set)1 CacheServerImpl (org.apache.geode.internal.cache.CacheServerImpl)1 AcceptorImpl (org.apache.geode.internal.cache.tier.sockets.AcceptorImpl)1