cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brandonwilli...@apache.org
Subject [2/6] git commit: Don't shut MessagingService down.
Date Mon, 07 Apr 2014 20:16:23 GMT
Don't shut MessagingService down.

Patch by brandonwilliams, reviewed by Benedict for CASSANDRA-6948


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

Branch: refs/heads/cassandra-2.1
Commit: 2dd09071be9d149a40c713ed5244ebb9b5df9e7e
Parents: 4b09b8d
Author: Brandon Williams <brandonwilliams@apache.org>
Authored: Mon Apr 7 15:10:37 2014 -0500
Committer: Brandon Williams <brandonwilliams@apache.org>
Committed: Mon Apr 7 15:10:37 2014 -0500

----------------------------------------------------------------------
 .../org/apache/cassandra/net/MessagingService.java    |  5 +++++
 .../org/apache/cassandra/service/StorageService.java  | 14 ++++++++------
 2 files changed, 13 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/2dd09071/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 ad86bbd..cc5dae5 100644
--- a/src/java/org/apache/cassandra/net/MessagingService.java
+++ b/src/java/org/apache/cassandra/net/MessagingService.java
@@ -476,6 +476,11 @@ public final class MessagingService implements MessagingServiceMBean
         }
     }
 
+    public boolean isListening()
+    {
+        return listenGate.isSignaled();
+    }
+
     public void destroyConnectionPool(InetAddress to)
     {
         OutboundTcpConnectionPool cp = connectionManagers.get(to);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/2dd09071/src/java/org/apache/cassandra/service/StorageService.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/StorageService.java b/src/java/org/apache/cassandra/service/StorageService.java
index 32b8b35..6ddfd80 100644
--- a/src/java/org/apache/cassandra/service/StorageService.java
+++ b/src/java/org/apache/cassandra/service/StorageService.java
@@ -409,7 +409,8 @@ public class StorageService extends NotificationBroadcasterSupport implements
IE
     public synchronized Collection<Token> prepareReplacementInfo() throws ConfigurationException
     {
         logger.info("Gathering node replacement information for {}", DatabaseDescriptor.getReplaceAddress());
-        MessagingService.instance().listen(FBUtilities.getLocalAddress());
+        if (!MessagingService.instance().isListening())
+            MessagingService.instance().listen(FBUtilities.getLocalAddress());
 
         // make magic happen
         Gossiper.instance.doShadowRound();
@@ -426,7 +427,6 @@ public class StorageService extends NotificationBroadcasterSupport implements
IE
             Collection<Token> tokens = TokenSerializer.deserialize(getPartitioner(),
new DataInputStream(new ByteArrayInputStream(getApplicationStateValue(DatabaseDescriptor.getReplaceAddress(),
ApplicationState.TOKENS))));
             
             SystemKeyspace.setLocalHostId(hostId); // use the replacee's host Id as our own
so we receive hints, etc
-            MessagingService.instance().shutdown();
             Gossiper.instance.resetEndpointStateMap(); // clean up since we have what we
need
             return tokens;        
         }
@@ -439,7 +439,8 @@ public class StorageService extends NotificationBroadcasterSupport implements
IE
     public synchronized void checkForEndpointCollision() throws ConfigurationException
     {
         logger.debug("Starting shadow gossip round to check for endpoint collision");
-        MessagingService.instance().listen(FBUtilities.getLocalAddress());
+        if (!MessagingService.instance().isListening())
+            MessagingService.instance().listen(FBUtilities.getLocalAddress());
         Gossiper.instance.doShadowRound();
         EndpointState epState = Gossiper.instance.getEndpointStateForEndpoint(FBUtilities.getBroadcastAddress());
         if (epState != null && !Gossiper.instance.isDeadState(epState))
@@ -448,7 +449,6 @@ public class StorageService extends NotificationBroadcasterSupport implements
IE
                                                      "Use cassandra.replace_address if you
want to replace this node.",
                                                      FBUtilities.getBroadcastAddress()));
         }
-        MessagingService.instance().shutdown();
         Gossiper.instance.resetEndpointStateMap();
     }
 
@@ -492,7 +492,8 @@ public class StorageService extends NotificationBroadcasterSupport implements
IE
         Gossiper.instance.start((int) (System.currentTimeMillis() / 1000)); // needed for
node-ring gathering.
         Gossiper.instance.addLocalApplicationState(ApplicationState.NET_VERSION, valueFactory.networkVersion());
 
-        MessagingService.instance().listen(FBUtilities.getLocalAddress());
+        if (!MessagingService.instance().isListening())
+            MessagingService.instance().listen(FBUtilities.getLocalAddress());
         Uninterruptibles.sleepUninterruptibly(ringDelay, TimeUnit.MILLISECONDS);
     }
 
@@ -660,7 +661,8 @@ public class StorageService extends NotificationBroadcasterSupport implements
IE
         Schema.instance.updateVersionAndAnnounce(); // Ensure we know our own actual Schema
UUID in preparation for updates
 
 
-        MessagingService.instance().listen(FBUtilities.getLocalAddress());
+        if (!MessagingService.instance().isListening())
+            MessagingService.instance().listen(FBUtilities.getLocalAddress());
         LoadBroadcaster.instance.startBroadcasting();
 
         HintedHandOffManager.instance.start();


Mime
View raw message