cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brandonwilli...@apache.org
Subject [1/3] git commit: When all seeds are unreachable don't bootstrap into a standalone cluster. Patch by brandonwilliams, reviewed by jasobrown for CASSANDRA-5768
Date Thu, 18 Jul 2013 21:17:37 GMT
Updated Branches:
  refs/heads/cassandra-1.2 01b881cb2 -> 76ad645a3
  refs/heads/trunk c4c04e780 -> ee85c8ea9


When all seeds are unreachable don't bootstrap into a standalone
cluster.
Patch by brandonwilliams, reviewed by jasobrown for CASSANDRA-5768


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

Branch: refs/heads/cassandra-1.2
Commit: 76ad645a3a8591dd7d5062dc97e2590631bf5970
Parents: 01b881c
Author: Brandon Williams <brandonwilliams@apache.org>
Authored: Thu Jul 18 16:14:37 2013 -0500
Committer: Brandon Williams <brandonwilliams@apache.org>
Committed: Thu Jul 18 16:14:37 2013 -0500

----------------------------------------------------------------------
 CHANGES.txt                                           |  1 +
 .../cassandra/gms/GossipDigestAckVerbHandler.java     |  2 ++
 .../cassandra/gms/GossipDigestSynVerbHandler.java     |  1 +
 src/java/org/apache/cassandra/gms/Gossiper.java       | 14 ++++++++++++++
 .../org/apache/cassandra/service/StorageService.java  |  2 ++
 5 files changed, 20 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/76ad645a/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index c0dda21..80b73f4 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 1.2.7
+ * if no seeds can be a reached a node won't start in a ring by itself (CASSANDRA-5768)
  * add cassandra.unsafesystem property (CASSANDRA-5704)
  * (Hadoop) quote identifiers in CqlPagingRecordReader (CASSANDRA-5763)
  * Add replace_node functionality for vnodes (CASSANDRA-5337)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/76ad645a/src/java/org/apache/cassandra/gms/GossipDigestAckVerbHandler.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/gms/GossipDigestAckVerbHandler.java b/src/java/org/apache/cassandra/gms/GossipDigestAckVerbHandler.java
index cdc9686..2a03ff2 100644
--- a/src/java/org/apache/cassandra/gms/GossipDigestAckVerbHandler.java
+++ b/src/java/org/apache/cassandra/gms/GossipDigestAckVerbHandler.java
@@ -57,6 +57,8 @@ public class GossipDigestAckVerbHandler implements IVerbHandler<GossipDigestAck>
             Gossiper.instance.applyStateLocally(epStateMap);
         }
 
+        Gossiper.instance.checkSeedContact(from);
+
         /* Get the state required to send to this gossipee - construct GossipDigestAck2Message
*/
         Map<InetAddress, EndpointState> deltaEpStateMap = new HashMap<InetAddress,
EndpointState>();
         for( GossipDigest gDigest : gDigestList )

http://git-wip-us.apache.org/repos/asf/cassandra/blob/76ad645a/src/java/org/apache/cassandra/gms/GossipDigestSynVerbHandler.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/gms/GossipDigestSynVerbHandler.java b/src/java/org/apache/cassandra/gms/GossipDigestSynVerbHandler.java
index 6e90ac4..61d21ed 100644
--- a/src/java/org/apache/cassandra/gms/GossipDigestSynVerbHandler.java
+++ b/src/java/org/apache/cassandra/gms/GossipDigestSynVerbHandler.java
@@ -82,6 +82,7 @@ public class GossipDigestSynVerbHandler implements IVerbHandler<GossipDigestSyn>
                                                                                         
             GossipDigestAck.serializer);
         if (logger.isTraceEnabled())
             logger.trace("Sending a GossipDigestAckMessage to {}", from);
+        Gossiper.instance.checkSeedContact(from);
         MessagingService.instance().sendOneWay(gDigestAckMessage, from);
     }
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/76ad645a/src/java/org/apache/cassandra/gms/Gossiper.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/gms/Gossiper.java b/src/java/org/apache/cassandra/gms/Gossiper.java
index efa9865..b0284c1 100644
--- a/src/java/org/apache/cassandra/gms/Gossiper.java
+++ b/src/java/org/apache/cassandra/gms/Gossiper.java
@@ -101,6 +101,9 @@ public class Gossiper implements IFailureDetectionEventListener, GossiperMBean
 
     private final Map<InetAddress, Long> expireTimeEndpointMap = new ConcurrentHashMap<InetAddress,
Long>();
 
+    // have we ever in our lifetime reached a seed?
+    private boolean seedContacted = false;
+
     private class GossipTask implements Runnable
     {
         public void run()
@@ -181,6 +184,17 @@ public class Gossiper implements IFailureDetectionEventListener, GossiperMBean
         }
     }
 
+    protected void checkSeedContact(InetAddress ep)
+    {
+        if (!seedContacted && seeds.contains(ep))
+            seedContacted = true;
+    }
+
+    public boolean seenAnySeed()
+    {
+        return seedContacted;
+    }
+
     /**
      * Register for interesting state changes.
      * @param subscriber module which implements the IEndpointStateChangeSubscriber

http://git-wip-us.apache.org/repos/asf/cassandra/blob/76ad645a/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 7f1bdbc..c4ceee5 100644
--- a/src/java/org/apache/cassandra/service/StorageService.java
+++ b/src/java/org/apache/cassandra/service/StorageService.java
@@ -943,6 +943,8 @@ public class StorageService extends NotificationBroadcasterSupport implements
IE
             tokenMetadata.updateNormalTokens(tokens, FBUtilities.getBroadcastAddress());
         }
         Tracing.instance();
+        if (!Gossiper.instance.seenAnySeed())
+            throw new IllegalStateException("Unable to contact any seeds!")
         setMode(Mode.JOINING, "Starting to bootstrap...", true);
         new BootStrapper(FBUtilities.getBroadcastAddress(), tokens, tokenMetadata).bootstrap();
// handles token update
         logger.info("Bootstrap completed! for the tokens {}", tokens);


Mime
View raw message