cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brandonwilli...@apache.org
Subject git commit: Allow OutboundTcpConnectionPool to bind any interface. Patch by brandonwilliams, reviewed by Vijay for CASSANDRA-3839
Date Thu, 02 Feb 2012 23:18:46 GMT
Updated Branches:
  refs/heads/cassandra-1.1 a7f1e7a62 -> cba4087cf


Allow OutboundTcpConnectionPool to bind any interface.
Patch by brandonwilliams, reviewed by Vijay for CASSANDRA-3839


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

Branch: refs/heads/cassandra-1.1
Commit: cba4087cf696e6520082313bc575d88858f5e260
Parents: a7f1e7a
Author: Brandon Williams <brandonwilliams@apache.org>
Authored: Thu Feb 2 17:08:59 2012 -0600
Committer: Brandon Williams <brandonwilliams@apache.org>
Committed: Thu Feb 2 17:08:59 2012 -0600

----------------------------------------------------------------------
 src/java/org/apache/cassandra/config/Config.java   |   12 ++++++++++++
 .../cassandra/net/OutboundTcpConnectionPool.java   |   11 +++++++++--
 .../org/apache/cassandra/security/SSLFactory.java  |   10 ++++++++++
 3 files changed, 31 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/cba4087c/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 030bdd1..42a71a4 100644
--- a/src/java/org/apache/cassandra/config/Config.java
+++ b/src/java/org/apache/cassandra/config/Config.java
@@ -134,6 +134,18 @@ public class Config
     public int row_cache_keys_to_save = Integer.MAX_VALUE;
     public String row_cache_provider = ConcurrentLinkedHashCacheProvider.class.getSimpleName();
 
+    private static boolean outboundBindAny = false;
+
+    public static boolean getOutboundBindAny()
+    {
+        return outboundBindAny;
+    }
+
+    public static void setOutboundBindAny(boolean value)
+    {
+        outboundBindAny = value;
+    }
+
     public static enum CommitLogSync {
         periodic,
         batch

http://git-wip-us.apache.org/repos/asf/cassandra/blob/cba4087c/src/java/org/apache/cassandra/net/OutboundTcpConnectionPool.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/net/OutboundTcpConnectionPool.java b/src/java/org/apache/cassandra/net/OutboundTcpConnectionPool.java
index a75dafe..1bf28b5 100644
--- a/src/java/org/apache/cassandra/net/OutboundTcpConnectionPool.java
+++ b/src/java/org/apache/cassandra/net/OutboundTcpConnectionPool.java
@@ -23,6 +23,7 @@ import java.net.InetAddress;
 import java.net.Socket;
 
 import org.apache.cassandra.concurrent.Stage;
+import org.apache.cassandra.config.Config;
 import org.apache.cassandra.config.DatabaseDescriptor;
 import org.apache.cassandra.locator.IEndpointSnitch;
 import org.apache.cassandra.security.SSLFactory;
@@ -77,11 +78,17 @@ public class OutboundTcpConnectionPool
         // zero means 'bind on any available port.'
         if (isEncryptedChannel())
         {
-            return SSLFactory.getSocket(DatabaseDescriptor.getEncryptionOptions(), endPoint(),
DatabaseDescriptor.getSSLStoragePort(), FBUtilities.getLocalAddress(), 0);
+            if (Config.getOutboundBindAny())
+                return SSLFactory.getSocket(DatabaseDescriptor.getEncryptionOptions(), endPoint(),
DatabaseDescriptor.getSSLStoragePort());
+            else
+                return SSLFactory.getSocket(DatabaseDescriptor.getEncryptionOptions(), endPoint(),
DatabaseDescriptor.getSSLStoragePort(), FBUtilities.getLocalAddress(), 0);
         }
         else 
         {
-            return new Socket(endPoint(), DatabaseDescriptor.getStoragePort(), FBUtilities.getLocalAddress(),
0);
+            if (Config.getOutboundBindAny())
+                return new Socket(endPoint(), DatabaseDescriptor.getStoragePort());
+            else
+                return new Socket(endPoint(), DatabaseDescriptor.getStoragePort(), FBUtilities.getLocalAddress(),
0);
         }
     }
     

http://git-wip-us.apache.org/repos/asf/cassandra/blob/cba4087c/src/java/org/apache/cassandra/security/SSLFactory.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/security/SSLFactory.java b/src/java/org/apache/cassandra/security/SSLFactory.java
index 82a97d7..794f7d9 100644
--- a/src/java/org/apache/cassandra/security/SSLFactory.java
+++ b/src/java/org/apache/cassandra/security/SSLFactory.java
@@ -71,6 +71,16 @@ public final class SSLFactory
         return socket;
     }
 
+    /** Create a socket and connect, using any local address */
+    public static SSLSocket getSocket(EncryptionOptions options, InetAddress address, int
port) throws IOException
+    {
+        SSLContext ctx = createSSLContext(options);
+        SSLSocket socket = (SSLSocket) ctx.getSocketFactory().createSocket(address, port);
+        String[] suits = filterCipherSuites(socket.getSupportedCipherSuites(), options.cipher_suites);
+        socket.setEnabledCipherSuites(suits);
+        return socket;
+    }
+
     /** Just create a socket */
     public static SSLSocket getSocket(EncryptionOptions options) throws IOException
     {


Mime
View raw message