cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brandonwilli...@apache.org
Subject [2/3] git commit: Set socket timeout when reading remote version
Date Mon, 03 Nov 2014 20:43:04 GMT
Set socket timeout when reading remote version

Patch by wy96f, reviewed by Brandon Williams for CASSANDRA-8188


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/399a4ecf
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/399a4ecf
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/399a4ecf

Branch: refs/heads/trunk
Commit: 399a4ecf9e0974488bc5a60fcff90c7f84e5b044
Parents: ad84e4d
Author: Brandon Williams <brandonwilliams@apache.org>
Authored: Mon Nov 3 14:42:03 2014 -0600
Committer: Brandon Williams <brandonwilliams@apache.org>
Committed: Mon Nov 3 14:42:03 2014 -0600

----------------------------------------------------------------------
 CHANGES.txt                                                  | 1 +
 src/java/org/apache/cassandra/net/MessagingService.java      | 2 ++
 src/java/org/apache/cassandra/net/OutboundTcpConnection.java | 2 +-
 3 files changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/399a4ecf/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index b9b92fb..50a540f 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.1.2
+ * Set socket timeout when reading remote version (CASSANDRA-8188)
  * Refactor how we track live size (CASSANDRA-7852)
  * Make sure unfinished compaction files are removed (CASSANDRA-8124)
  * Fix shutdown when run as Windows service (CASSANDRA-8136)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/399a4ecf/src/java/org/apache/cassandra/net/MessagingService.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/net/MessagingService.java b/src/java/org/apache/cassandra/net/MessagingService.java
index c6b0098..05b449c 100644
--- a/src/java/org/apache/cassandra/net/MessagingService.java
+++ b/src/java/org/apache/cassandra/net/MessagingService.java
@@ -918,6 +918,7 @@ public final class MessagingService implements MessagingServiceMBean
                     }
 
                     socket.setKeepAlive(true);
+                    socket.setSoTimeout(2 * OutboundTcpConnection.WAIT_FOR_VERSION_MAX_TIME);
                     // determine the connection type to decide whether to buffer
                     DataInputStream in = new DataInputStream(socket.getInputStream());
                     MessagingService.validateMagic(in.readInt());
@@ -925,6 +926,7 @@ public final class MessagingService implements MessagingServiceMBean
                     boolean isStream = MessagingService.getBits(header, 3, 1) == 1;
                     int version = MessagingService.getBits(header, 15, 8);
                     logger.debug("Connection version {} from {}", version, socket.getInetAddress());
+                    socket.setSoTimeout(0);
 
                     Thread thread = isStream
                                   ? new IncomingStreamingConnection(version, socket)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/399a4ecf/src/java/org/apache/cassandra/net/OutboundTcpConnection.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/net/OutboundTcpConnection.java b/src/java/org/apache/cassandra/net/OutboundTcpConnection.java
index 996e606..a0ad011 100644
--- a/src/java/org/apache/cassandra/net/OutboundTcpConnection.java
+++ b/src/java/org/apache/cassandra/net/OutboundTcpConnection.java
@@ -65,7 +65,7 @@ public class OutboundTcpConnection extends Thread
     private volatile boolean isStopped = false;
 
     private static final int OPEN_RETRY_DELAY = 100; // ms between retries
-    private static final int WAIT_FOR_VERSION_MAX_TIME = 5000;
+    public static final int WAIT_FOR_VERSION_MAX_TIME = 5000;
     private static final int NO_VERSION = Integer.MIN_VALUE;
 
     static final int LZ4_HASH_SEED = 0x9747b28c;


Mime
View raw message