/** * This method returns the CacheClientStatus for all the clients that are * connected to this server. This method returns all clients irrespective of * whether subscription is enabled or not. * * @return Map of ClientProxyMembershipID against CacheClientStatus objects. */ public static Map getStatusForAllClientsIgnoreSubscriptionStatus() { Map result = new HashMap(); if (ClientHealthMonitor.getInstance() != null) result = ClientHealthMonitor.getInstance().getStatusForAllClients(); return result; }
/** * Creates the singleton <code>CacheClientNotifier</code> instance. * * @param cache * The GemFire <code>Cache</code> * @param maximumTimeBetweenPings * The maximum time allowed between pings before determining the * client has died and interrupting its sockets. */ protected static synchronized void createInstance(Cache cache, int maximumTimeBetweenPings, CacheClientNotifierStats stats) { refCount++; if (_instance != null) { return; } _instance = new ClientHealthMonitor(cache, maximumTimeBetweenPings, stats); }
public void removeAllConnectionsAndUnregisterClient( ClientProxyMembershipID proxyID) { // Remove all connections cleanupClientThreads(proxyID, false); unregisterClient(proxyID); }
public static Map getConnectedIncomingGateways() { Map connectedIncomingGateways = null; ClientHealthMonitor chMon = ClientHealthMonitor.getInstance(); if (chMon == null) { connectedIncomingGateways = new HashMap(); } else { connectedIncomingGateways = chMon.getConnectedIncomingGateways(); } return connectedIncomingGateways; }
try { Thread.sleep(CLIENT_MONITOR_INTERVAL); if (getLogger().finerEnabled()) { getLogger().finer( "Monitoring " + getClientHeartbeats().size() + " client(s)"); if (getLogger().finerEnabled()) { getLogger().finer( ClientHealthMonitor.this.toString() + " starting sweep at " + currentTime); for (Iterator i = getClientHeartbeats().entrySet().iterator(); i .hasNext();) { Map.Entry entry = (Map.Entry)i.next(); validateThreads(proxyID); if (getLogger().finerEnabled()) { getLogger() .finer( (currentTime - latestHeartbeat) if (isAnyThreadProcessingMessage(proxyID)) { if (getLogger().fineEnabled()) { getLogger().fine("Monitoring client with member id " + entry.getKey() + ". It has been " + (currentTime - latestHeartbeat) + " ms since the latest heartbeat. This client would have been terminated but at least one of its threads is processing a message."); if (cleanupClientThreads(proxyID, true)) { if (getLogger().warningEnabled()) { getLogger().warning(LocalizedStrings.ClientHealthMonitor_MONITORING_CLIENT_WITH_MEMBER_ID_0_IT_HAD_BEEN_1_MS_SINCE_THE_LATEST_HEARTBEAT_MAX_INTERVAL_IS_2_TERMINATED_CLIENT, new Object[] {entry.getKey(), currentTime - latestHeartbeat, this._maximumTimeBetweenPings});
Thread.sleep(CLIENT_MONITOR_INTERVAL); if (logger.isTraceEnabled()) { logger.trace("Monitoring {} client(s)", getClientHeartbeats().size()); for (Iterator i = getClientHeartbeats().entrySet().iterator(); i .hasNext();) { Map.Entry entry = (Map.Entry)i.next(); validateThreads(proxyID); if (isAnyThreadProcessingMessage(proxyID)) { if (logger.isDebugEnabled()) { logger.debug("Monitoring client with member id {}. It has been {} ms since the latest heartbeat. This client would have been terminated but at least one of its threads is processing a message.", entry.getKey(), (currentTime - latestHeartbeat)); if (cleanupClientThreads(proxyID, true)) { logger.warn(LocalizedMessage.create(LocalizedStrings.ClientHealthMonitor_MONITORING_CLIENT_WITH_MEMBER_ID_0_IT_HAD_BEEN_1_MS_SINCE_THE_LATEST_HEARTBEAT_MAX_INTERVAL_IS_2_TERMINATED_CLIENT, new Object[] {entry.getKey(), currentTime - latestHeartbeat, this._maximumTimeBetweenPings}));
for (Iterator iter = ClientHealthMonitor.getInstance().getClientHeartbeats().keySet().iterator(); iter.hasNext();) ClientHealthMonitor.getInstance().removeAllConnectionsAndUnregisterClient((ClientProxyMembershipID)iter.next());
ClientHealthMonitor chm = ClientHealthMonitor.getInstance(); chm.removeAllConnectionsAndUnregisterClient(proxyID); if (!getProxy().isDurable()) { getProxy().getCacheClientNotifier().unregisterClient(proxyID, false);
/** * Removes an existing <code>CacheClientProxy</code> from the list of known * client proxies * * @param proxy * The <code>CacheClientProxy</code> to remove */ protected void removeClientProxy(CacheClientProxy proxy) { // this._logger.info(LocalizedStrings.DEBUG, "removing client proxy " + proxy, new Exception("stack trace")); ClientProxyMembershipID client = proxy.getProxyID(); this._clientProxies.remove(client); this._connectionListener.queueRemoved(); ((GemFireCacheImpl)this.getCache()).cleanupForClient(this, client); if (!(proxy.clientConflation == HandShake.CONFLATION_ON)) { ClientHealthMonitor chm = ClientHealthMonitor.getInstance(); if (chm != null) { chm.numOfClientsPerVersion .decrementAndGet(proxy.getVersion().ordinal()); } } }
/** * Caller must synchronize on cache.allBridgeServersLock * @return all the clients */ public static Map getConnectedClients() { // Get all clients Map allClients = new HashMap(); for (Iterator bsii = CacheFactory.getAnyInstance().getBridgeServers().iterator(); bsii.hasNext(); ) { BridgeServerImpl bsi = (BridgeServerImpl) bsii.next(); AcceptorImpl ai = bsi.getAcceptor(); if (ai != null && ai.getCacheClientNotifier() != null) { allClients.putAll(ai.getCacheClientNotifier().getAllClients()); } } // Fill in the missing info, if HealthMonitor started if (ClientHealthMonitor.getInstance()!=null) ClientHealthMonitor.getInstance().fillInClientInfo(allClients); return allClients; }
logger.debug("{}: rcv tx: {} from {} rcvTime: {}", servConn.getName(), msg.getTransactionId(), servConn.getSocketString(), (DistributionStats.getStatTime() - start)); ClientHealthMonitor chm = ClientHealthMonitor.getInstance(); if (chm != null) chm.receivedPing(servConn.getProxyID()); CachedRegionHelper crHelper = servConn.getCachedRegionHelper(); if (crHelper.emulateSlowServer() > 0) {
ClientHealthMonitor chMon = ClientHealthMonitor.getInstance(); Set filterProxyIDs = null; if(onlyClientsNotifiedByThisServer) { Map map = chMon.getConnectedClients(filterProxyIDs);
extractDelta = true; if (!extractDelta && ClientHealthMonitor.getInstance() != null) { extractDelta = ClientHealthMonitor.getInstance().hasDeltaClients();
chm.registerClient(this.proxyId); chm.addConnection(this.proxyId, this); this.acceptor.getConnectionListener().connectionOpened(registerClient, communicationMode);
private Map getCleanupProxyIdTable() { return acceptor.getClientHealthMonitor().getCleanupProxyIdTable(); }
/** * Factory method to construct or return the singleton * <code>ClientHealthMonitor</code> instance. * * @param cache * The GemFire <code>Cache</code> * @param maximumTimeBetweenPings * The maximum time allowed between pings before determining the * client has died and interrupting its sockets. * @return The singleton <code>ClientHealthMonitor</code> instance */ public static ClientHealthMonitor getInstance(Cache cache, int maximumTimeBetweenPings, CacheClientNotifierStats stats) { createInstance(cache, maximumTimeBetweenPings, stats); return _instance; }
/** * Takes care of unregistering from the _clientHeatBeats map. * @param proxyID * The id of the client to be unregistered */ private void unregisterClient(ClientProxyMembershipID proxyID) { boolean unregisterClient = false; synchronized (_clientHeartbeatsLock) { Map oldClientHeartbeats = this._clientHeartbeats; if (oldClientHeartbeats.containsKey(proxyID)) { unregisterClient = true; Map newClientHeartbeats = new HashMap(oldClientHeartbeats); newClientHeartbeats.remove(proxyID); this._clientHeartbeats = newClientHeartbeats; } } if (unregisterClient) { if (logger.isDebugEnabled()) { logger.debug(LocalizedMessage.create(LocalizedStrings.ClientHealthMonitor_CLIENTHEALTHMONITOR_UNREGISTERING_CLIENT_WITH_MEMBER_ID_0, new Object[] { proxyID })); } if (this.stats != null) { this.stats.incClientUnRegisterRequests(); } expireTXStates(proxyID); } }
ClientHealthMonitor chm = ClientHealthMonitor.getInstance(); chm.removeAllConnectionsAndUnregisterClient(proxyID); if (!getProxy().isDurable()) { getProxy().getCacheClientNotifier().unregisterClient(proxyID, false);
/** * Removes an existing <code>CacheClientProxy</code> from the list of known * client proxies * * @param proxy * The <code>CacheClientProxy</code> to remove */ protected void removeClientProxy(CacheClientProxy proxy) { // this._logger.info(LocalizedStrings.DEBUG, "removing client proxy " + proxy, new Exception("stack trace")); ClientProxyMembershipID client = proxy.getProxyID(); this._clientProxies.remove(client); this._connectionListener.queueRemoved(); ((GemFireCacheImpl)this.getCache()).cleanupForClient(this, client); if (!(proxy.clientConflation == HandShake.CONFLATION_ON)) { ClientHealthMonitor chm = ClientHealthMonitor.getInstance(); if (chm != null) { chm.numOfClientsPerVersion .decrementAndGet(proxy.getVersion().ordinal()); } } }
public static Map getConnectedIncomingGateways() { Map connectedIncomingGateways = null; ClientHealthMonitor chMon = ClientHealthMonitor.getInstance(); if (chMon == null) { connectedIncomingGateways = new HashMap(); } else { connectedIncomingGateways = chMon.getConnectedIncomingGateways(); } return connectedIncomingGateways; }