cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From slebre...@apache.org
Subject [1/2] git commit: Make native server start block until properly bound
Date Thu, 02 Oct 2014 08:21:54 GMT
Repository: cassandra
Updated Branches:
  refs/heads/trunk e93bcdf45 -> be199a07c


Make native server start block until properly bound

patch by slebresne; reviewed by xedin for CASSANDRA-7885


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

Branch: refs/heads/trunk
Commit: b701dd52fd3b2a53edc995308260d56641cce3d3
Parents: 814e55a
Author: Sylvain Lebresne <sylvain@datastax.com>
Authored: Thu Oct 2 10:20:56 2014 +0200
Committer: Sylvain Lebresne <sylvain@datastax.com>
Committed: Thu Oct 2 10:20:56 2014 +0200

----------------------------------------------------------------------
 CHANGES.txt                                         | 1 +
 src/java/org/apache/cassandra/transport/Server.java | 8 ++++++--
 test/unit/org/apache/cassandra/cql3/DeleteTest.java | 5 -----
 3 files changed, 7 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/b701dd52/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 9fb1274..d83b86f 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.1.1
+ * Make native server start block until properly bound (CASSANDRA-7885)
  * (cqlsh) Fix IPv6 support (CASSANDRA-7988)
  * Ignore fat clients when checking for endpoint collision (CASSANDRA-7939)
  * Make sstablerepairedset take a list of files (CASSANDRA-7995)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/b701dd52/src/java/org/apache/cassandra/transport/Server.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/transport/Server.java b/src/java/org/apache/cassandra/transport/Server.java
index d10b934..d6f01c2 100644
--- a/src/java/org/apache/cassandra/transport/Server.java
+++ b/src/java/org/apache/cassandra/transport/Server.java
@@ -163,8 +163,12 @@ public class Server implements CassandraDaemon.Server
         // Bind and start to accept incoming connections.
         logger.info("Using Netty Version: {}", Version.identify().entrySet());
         logger.info("Starting listening for CQL clients on {}...", socket);
-        Channel channel = bootstrap.bind(socket).channel();
-        connectionTracker.allChannels.add(channel);
+
+        ChannelFuture bindFuture = bootstrap.bind(socket);
+        if (!bindFuture.awaitUninterruptibly().isSuccess())
+            throw new IllegalStateException(String.format("Failed to bind port %d on %s.",
socket.getPort(), socket.getAddress().getHostAddress()));
+
+        connectionTracker.allChannels.add(bindFuture.channel());
         isRunning.set(true);
     }
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/b701dd52/test/unit/org/apache/cassandra/cql3/DeleteTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/cql3/DeleteTest.java b/test/unit/org/apache/cassandra/cql3/DeleteTest.java
index 6ca6b41..c8aa660 100644
--- a/test/unit/org/apache/cassandra/cql3/DeleteTest.java
+++ b/test/unit/org/apache/cassandra/cql3/DeleteTest.java
@@ -57,11 +57,6 @@ public class DeleteTest extends SchemaLoader
         cassandra = new EmbeddedCassandraService();
         cassandra.start();
 
-        // Currently the native server start method return before the server is fully binded
to the socket,
-        // so we need to wait slightly before trying to connect to it. We should fix this
but in the meantime
-        // using a sleep.
-        Thread.sleep(500);
-
         cluster = Cluster.builder().addContactPoint("127.0.0.1").withPort(DatabaseDescriptor.getNativeTransportPort()).build();
         session = cluster.connect();
 


Mime
View raw message