You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by kl...@apache.org on 2016/02/01 21:55:49 UTC
[32/50] [abbrv] incubator-geode git commit: GEODE-871: Frequient use
of executeOnAllServers causes build-up of TIME_WAIT sockets
GEODE-871: Frequient use of executeOnAllServers causes build-up of TIME_WAIT sockets
Modified the fix to not abort the connection if a response wasn't read.
I also propagated this pattern to GMSHealthMonitor so that the "final
check" sockets are quickly released.
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/d22176bb
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/d22176bb
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/d22176bb
Branch: refs/heads/feature/GEODE-773-2
Commit: d22176bb1632dc5593a1755a1355aacd0360c5e8
Parents: 02c67e2
Author: Bruce Schuchardt <bs...@pivotal.io>
Authored: Mon Feb 1 08:35:00 2016 -0800
Committer: Bruce Schuchardt <bs...@pivotal.io>
Committed: Mon Feb 1 08:37:05 2016 -0800
----------------------------------------------------------------------
.../membership/gms/fd/GMSHealthMonitor.java | 3 +--
.../distributed/internal/tcpserver/TcpClient.java | 15 +++++++++++----
.../distributed/internal/tcpserver/TcpServer.java | 17 +----------------
3 files changed, 13 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/d22176bb/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/fd/GMSHealthMonitor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/fd/GMSHealthMonitor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/fd/GMSHealthMonitor.java
index b6f6c12..dc549bf 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/fd/GMSHealthMonitor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/fd/GMSHealthMonitor.java
@@ -312,7 +312,6 @@ public class GMSHealthMonitor implements HealthMonitor, MessageHandler {
&& uuidLSBs == myUUID.getLeastSignificantBits()
&& uuidMSBs == myUUID.getMostSignificantBits()
&& vmViewId == myVmViewId) {
- socket.setSoLinger(true, (int)memberTimeout);
out.write(OK);
out.flush();
socket.shutdownOutput();
@@ -323,7 +322,6 @@ public class GMSHealthMonitor implements HealthMonitor, MessageHandler {
}
}
else {
- socket.setSoLinger(true, (int)memberTimeout);
out.write(ERROR);
out.flush();
socket.shutdownOutput();
@@ -494,6 +492,7 @@ public class GMSHealthMonitor implements HealthMonitor, MessageHandler {
finally {
try {
if (clientSocket != null) {
+ clientSocket.setSoLinger(true, 0); // abort the connection
clientSocket.close();
}
} catch (IOException e) {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/d22176bb/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/tcpserver/TcpClient.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/tcpserver/TcpClient.java b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/tcpserver/TcpClient.java
index 47f50b3..dfcb78c 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/tcpserver/TcpClient.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/tcpserver/TcpClient.java
@@ -167,14 +167,21 @@ public class TcpClient {
}
return null;
} finally {
- if (out != null) {
- out.close();
- }
try {
+ if (replyExpected) {
+ // Since we've read a response we know that the Locator is finished
+ // with the socket and is closing it. Aborting the connection by
+ // setting SO_LINGER to zero will clean up the TIME_WAIT socket on
+ // the locator's machine.
+ sock.setSoLinger(true, 0);
+ }
sock.close();
} catch(Exception e) {
logger.error("Error closing socket ", e);
}
+ if (out != null) {
+ out.close();
+ }
}
}
@@ -184,7 +191,6 @@ public class TcpClient {
Short serverVersion = null;
// Get GemFire version of TcpServer first, before sending any other request.
- VersionResponse verRes = null;
synchronized(serverVersions) {
serverVersion = serverVersions.get(ipAddr);
}
@@ -223,6 +229,7 @@ public class TcpClient {
}
} finally {
try {
+ sock.setSoLinger(true, 0); // initiate an abort on close to shut down the server's socket
sock.close();
} catch(Exception e) {
logger.error("Error closing socket ", e);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/d22176bb/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/tcpserver/TcpServer.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/tcpserver/TcpServer.java b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/tcpserver/TcpServer.java
index f52b9ab..e5ad416 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/tcpserver/TcpServer.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/tcpserver/TcpServer.java
@@ -398,7 +398,6 @@ public class TcpServer {
DataSerializer.writeObject(response, output);
output.flush();
- output.close();
}
handler.endResponse(request,startTime);
@@ -467,24 +466,10 @@ public class TcpServer {
t.printStackTrace();
}
} finally {
- // Normal path closes input first, so let's do that here...
- if (input != null) {
- try {
- input.close();
- } catch (IOException e) {
- log.warn(
- "Exception closing input stream", e);
- }
- }
-
- // Closing the ObjectInputStream is supposed to close
- // the underlying InputStream, but we do it here just for
- // good measure. Closing a closed socket is a no-op.
try {
sock.close();
} catch (IOException e) {
- log.warn(
- "Exception closing socket", e);
+ // ignore
}
}
}