add inter_dc_tcp_nodelay option
patch by Marcus Eriksson; reviewed by jbellis for CASSANDRA-5148


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

Branch: refs/heads/trunk
Commit: 6487bc50bbe91b559906d90695c91f3d7f54fd2f
Parents: 8d9510a
Author: Jonathan Ellis <jbel...@apache.org>
Authored: Fri Jan 11 16:12:25 2013 -0600
Committer: Jonathan Ellis <jbel...@apache.org>
Committed: Fri Jan 11 16:12:25 2013 -0600

----------------------------------------------------------------------
 CHANGES.txt                                        |    1 +
 conf/cassandra.yaml                                |    6 ++++++
 src/java/org/apache/cassandra/config/Config.java   |    2 ++
 .../cassandra/config/DatabaseDescriptor.java       |    5 +++++
 .../cassandra/net/OutboundTcpConnection.java       |    9 ++++++++-
 5 files changed, 22 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/6487bc50/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 3dfc756..64cc60c 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 1.2.1
+ * add inter_dc_tcp_nodelay setting (CASSANDRA-5148)
  * re-allow wrapping ranges for start_token/end_token range pairing 
(CASSANDRA-5106)
  * fix validation compaction of empty rows (CASSADRA-5136)
  * nodetool methods to enable/disable hint storage/delivery (CASSANDRA-4750)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6487bc50/conf/cassandra.yaml
----------------------------------------------------------------------
diff --git a/conf/cassandra.yaml b/conf/cassandra.yaml
index 364bdd7..cfe01a6 100644
--- a/conf/cassandra.yaml
+++ b/conf/cassandra.yaml
@@ -643,3 +643,9 @@ client_encryption_options:
 #          dc   - traffic between different datacenters is compressed
 #          none - nothing is compressed.
 internode_compression: all
+
+# Enable or disable tcp_nodelay for inter-dc communication.
+# Disabling it will result in larger (but fewer) network packets being sent,
+# reducing overhead from the TCP protocol itself, at the cost of increasing
+# latency if you block for cross-datacenter responses.
+inter_dc_tcp_nodelay: true

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6487bc50/src/java/org/apache/cassandra/config/Config.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/config/Config.java 
b/src/java/org/apache/cassandra/config/Config.java
index 492bb7a..cff578c 100644
--- a/src/java/org/apache/cassandra/config/Config.java
+++ b/src/java/org/apache/cassandra/config/Config.java
@@ -162,6 +162,8 @@ public class Config
     public String row_cache_provider = 
SerializingCacheProvider.class.getSimpleName();
     public boolean populate_io_cache_on_flush = false;
 
+    public boolean inter_dc_tcp_nodelay = true;
+
     private static boolean loadYaml = true;
     private static boolean outboundBindAny = false;
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6487bc50/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/config/DatabaseDescriptor.java 
b/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
index 1319093..88c4e38 100644
--- a/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
+++ b/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
@@ -1256,4 +1256,9 @@ public class DatabaseDescriptor
     {
         return conf.internode_compression;
     }
+
+    public static boolean getInterDCTcpNoDelay()
+    {
+        return conf.inter_dc_tcp_nodelay;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6487bc50/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 ebb6ade..42183f4 100644
--- a/src/java/org/apache/cassandra/net/OutboundTcpConnection.java
+++ b/src/java/org/apache/cassandra/net/OutboundTcpConnection.java
@@ -263,7 +263,14 @@ public class OutboundTcpConnection extends Thread
             {
                 socket = poolReference.newSocket();
                 socket.setKeepAlive(true);
-                socket.setTcpNoDelay(true);
+                if (isLocalDC(poolReference.endPoint()))
+                {
+                    socket.setTcpNoDelay(true);
+                }
+                else
+                {
+                    
socket.setTcpNoDelay(DatabaseDescriptor.getInterDCTcpNoDelay());
+                }
                 out = new DataOutputStream(new 
BufferedOutputStream(socket.getOutputStream(), 4096));
 
                 if (targetVersion >= MessagingService.VERSION_12)

Reply via email to