cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject [3/6] cassandra git commit: JMX RMI server sockets have SO_REUSEADDR enabled
Date Thu, 24 Mar 2016 11:46:39 GMT
JMX RMI server sockets have SO_REUSEADDR enabled

Patch by Aleksandr Sorokoumov; reviewed by Sam Tunnicliffe for
CASSANDRA-11093


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

Branch: refs/heads/trunk
Commit: 3a244d24b8c66e2e6e2664f71e9972b7827ae5f4
Parents: 1d1bfae
Author: Aleksandr Sorokoumov <aleksandr.sorokoumov@gmail.com>
Authored: Thu Mar 24 11:41:35 2016 +0000
Committer: Sam Tunnicliffe <sam@beobal.com>
Committed: Thu Mar 24 11:41:35 2016 +0000

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../utils/RMIServerSocketFactoryImpl.java       | 11 ++++++---
 .../service/RMIServerSocketFactoryImplTest.java | 24 ++++++++++++++++++++
 3 files changed, 33 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/3a244d24/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index cf36047..fe19df7 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 3.0.5
+ * Enable SO_REUSEADDR for JMX RMI server sockets (CASSANDRA-11093)
  * Allocate merkletrees with the correct size (CASSANDRA-11390)
  * Support streaming pre-3.0 sstables (CASSANDRA-10990)
  * Add backpressure to compressed commit log (CASSANDRA-10971)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3a244d24/src/java/org/apache/cassandra/utils/RMIServerSocketFactoryImpl.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/utils/RMIServerSocketFactoryImpl.java b/src/java/org/apache/cassandra/utils/RMIServerSocketFactoryImpl.java
index 75331ab..ec81aa3 100644
--- a/src/java/org/apache/cassandra/utils/RMIServerSocketFactoryImpl.java
+++ b/src/java/org/apache/cassandra/utils/RMIServerSocketFactoryImpl.java
@@ -1,7 +1,8 @@
 package org.apache.cassandra.utils;
 
 import java.io.IOException;
-import java.net.*;
+import java.net.InetAddress;
+import java.net.ServerSocket;
 import java.rmi.server.RMIServerSocketFactory;
 import javax.net.ServerSocketFactory;
 
@@ -9,8 +10,12 @@ import javax.net.ServerSocketFactory;
 public class RMIServerSocketFactoryImpl implements RMIServerSocketFactory
 {
 
-    public ServerSocket createServerSocket(final int pPort) throws IOException  {
-        return ServerSocketFactory.getDefault().createServerSocket(pPort, 0, InetAddress.getLoopbackAddress());
+    public ServerSocket createServerSocket(final int pPort) throws IOException
+    {
+        ServerSocket socket = ServerSocketFactory.getDefault()
+                                                 .createServerSocket(pPort, 0, InetAddress.getLoopbackAddress());
+        socket.setReuseAddress(true);
+        return socket;
     }
 
     public boolean equals(Object obj)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3a244d24/test/unit/org/apache/cassandra/service/RMIServerSocketFactoryImplTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/service/RMIServerSocketFactoryImplTest.java b/test/unit/org/apache/cassandra/service/RMIServerSocketFactoryImplTest.java
new file mode 100644
index 0000000..3459ec3
--- /dev/null
+++ b/test/unit/org/apache/cassandra/service/RMIServerSocketFactoryImplTest.java
@@ -0,0 +1,24 @@
+package org.apache.cassandra.service;
+
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.rmi.server.RMIServerSocketFactory;
+
+import org.junit.Test;
+
+import org.apache.cassandra.utils.RMIServerSocketFactoryImpl;
+
+import static org.junit.Assert.assertTrue;
+
+
+public class RMIServerSocketFactoryImplTest
+{
+    @Test
+    public void testReusableAddrSocket() throws IOException
+    {
+        RMIServerSocketFactory serverFactory = new RMIServerSocketFactoryImpl();
+        ServerSocket socket = serverFactory.createServerSocket(7199);
+        assertTrue(socket.getReuseAddress());
+    }
+
+}


Mime
View raw message