private void finishCon(ServerConnection sc) { if (sc != null) { sc.handleTermination(); } }
protected boolean cleanupClientThreads(ClientProxyMembershipID proxyID, boolean timedOut) { boolean result = false; Set serverConnections = null; synchronized (proxyIdConnections) { ServerConnectionCollection collection = proxyIdConnections.remove(proxyID); if (collection != null) { serverConnections = collection.getConnections(); } } { if (serverConnections != null) { // fix for bug 35343 result = true; for (Iterator it = serverConnections.iterator(); it.hasNext();) { ServerConnection serverConnection = (ServerConnection) it.next(); serverConnection.handleTermination(timedOut); } } } return result; }
void handleTermination() { if (this.crHelper.isShutdown()) { setClientDisconnectCleanly(); } handleTermination(false); }
protected void validateThreads(ClientProxyMembershipID proxyID) { Set<ServerConnection> serverConnections; synchronized (proxyIdConnections) { ServerConnectionCollection collection = proxyIdConnections.get(proxyID); serverConnections = collection != null ? new HashSet<>(collection.getConnections()) : Collections.emptySet(); } // release sync and operation on copy to fix bug 37675 for (ServerConnection serverConnection : serverConnections) { if (serverConnection.hasBeenTimedOutOnClient()) { logger.warn("{} is being terminated because its client timeout of {} has expired.", new Object[] {serverConnection, Integer.valueOf(serverConnection.getClientReadTimeout())}); try { serverConnection.handleTermination(true); // Not all the code in a ServerConnection correctly // handles interrupt. In particular it is possible to be doing // p2p distribution and to have sent a message to one peer but // to never send it to another due to interrupt. // serverConnection.interruptOwner(); } finally { // Just to be sure we clean it up. // This call probably isn't needed. removeConnection(proxyID, serverConnection); } } } }
@Test public void activeServerConnectionNotTerminatedByHealthMonitor() throws Exception { ClientProxyMembershipID mockId = mock(ClientProxyMembershipID.class); ServerConnection mockConnection = mock(ServerConnection.class); clientHealthMonitor.addConnection(mockId, mockConnection); clientHealthMonitor.receivedPing(mockId); HeartbeatOverride heartbeater = new HeartbeatOverride(); clientHealthMonitor.testUseCustomHeartbeatCheck(heartbeater); await().until(() -> heartbeater.numHeartbeats >= 5); // Check that we never tried to terminate the connection verify(mockConnection, times(0)).handleTermination(true); }
@Test public void idleServerConnectionTerminatedByHealthMonitor() throws Exception { ClientProxyMembershipID mockId = mock(ClientProxyMembershipID.class); ServerConnection mockConnection = mock(ServerConnection.class); clientHealthMonitor.addConnection(mockId, mockConnection); clientHealthMonitor.receivedPing(mockId); clientHealthMonitor.testUseCustomHeartbeatCheck((a, b, c) -> true); // Fail all heartbeats await() .untilAsserted(() -> verify(mockConnection).handleTermination(true)); }
if (!finishedMessage) { try { handleTermination(); } catch (CancelException e) { try { this.unsetRequestSpecificTimeout(); handleTermination(); DistributedSystem.releaseThreadsSockets(); } catch (CancelException e) {