You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by sa...@apache.org on 2015/12/02 14:22:57 UTC

[04/15] cassandra git commit: Revert changes to names of public methods on Gossiper

Revert changes to names of public methods on Gossiper

Patch and review by Paulo Motta and Stefania Alborghetti to
follow up CASSANDRA-10243


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

Branch: refs/heads/cassandra-3.0
Commit: 51753263a4c4d50c5bbe7bb80636cca5b6458ecf
Parents: dbfeeac
Author: Paulo Motta <pa...@gmail.com>
Authored: Tue Dec 1 10:41:05 2015 -0800
Committer: Sam Tunnicliffe <sa...@beobal.com>
Committed: Wed Dec 2 13:05:37 2015 +0000

----------------------------------------------------------------------
 src/java/org/apache/cassandra/gms/Gossiper.java | 21 +++++++++++++++-----
 .../cassandra/locator/PropertyFileSnitch.java   |  6 ++----
 .../locator/YamlFileNetworkTopologySnitch.java  |  4 ++--
 .../cassandra/service/MigrationManager.java     |  4 ++--
 .../apache/cassandra/service/StorageProxy.java  |  8 ++++----
 .../cassandra/service/StorageService.java       | 14 ++++++-------
 6 files changed, 33 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/51753263/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 09851b2..130b531 100644
--- a/src/java/org/apache/cassandra/gms/Gossiper.java
+++ b/src/java/org/apache/cassandra/gms/Gossiper.java
@@ -256,12 +256,23 @@ public class Gossiper implements IFailureDetectionEventListener, GossiperMBean
         subscribers.remove(subscriber);
     }
 
-    public Set<InetAddress> getLiveEndpoints()
+    /**
+     * @return a list of live gossip participants, including fat clients
+     */
+    public Set<InetAddress> getLiveMembers()
+    {
+        Set<InetAddress> liveMembers = new HashSet<>(liveEndpoints);
+        if (!liveMembers.contains(FBUtilities.getBroadcastAddress()))
+            liveMembers.add(FBUtilities.getBroadcastAddress());
+        return liveMembers;
+    }
+
+    /**
+     * @return a list of live ring members.
+     */
+    public Set<InetAddress> getLiveTokenOwners()
     {
-        Set<InetAddress> liveEndpoints = new HashSet<InetAddress>(this.liveEndpoints);
-        if (!liveEndpoints.contains(FBUtilities.getBroadcastAddress()))
-            liveEndpoints.add(FBUtilities.getBroadcastAddress());
-        return liveEndpoints;
+        return StorageService.instance.getLiveRingMembers(true);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/cassandra/blob/51753263/src/java/org/apache/cassandra/locator/PropertyFileSnitch.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/locator/PropertyFileSnitch.java b/src/java/org/apache/cassandra/locator/PropertyFileSnitch.java
index 6115572..dc9a3b8 100644
--- a/src/java/org/apache/cassandra/locator/PropertyFileSnitch.java
+++ b/src/java/org/apache/cassandra/locator/PropertyFileSnitch.java
@@ -23,7 +23,6 @@ import java.net.UnknownHostException;
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Map;
-import java.util.Objects;
 import java.util.Properties;
 import java.util.Set;
 
@@ -32,7 +31,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import org.apache.cassandra.exceptions.ConfigurationException;
-import org.apache.cassandra.gms.Gossiper;
 import org.apache.cassandra.io.util.FileUtils;
 import org.apache.cassandra.service.StorageService;
 import org.apache.cassandra.utils.FBUtilities;
@@ -238,9 +236,9 @@ public class PropertyFileSnitch extends AbstractNetworkTopologySnitch
         // host quickly and interrupt the loop. Otherwise we only check the live hosts that were either
         // in the old set or in the new set
         Set<InetAddress> hosts = Arrays.equals(defaultDCRack, reloadedDefaultDCRack)
-                                 ? Sets.intersection(StorageService.instance.getLiveMembers(), // same default
+                                 ? Sets.intersection(StorageService.instance.getLiveRingMembers(), // same default
                                                      Sets.union(endpointMap.keySet(), reloadedMap.keySet()))
-                                 : StorageService.instance.getLiveMembers(); // default updated
+                                 : StorageService.instance.getLiveRingMembers(); // default updated
 
         for (InetAddress host : hosts)
         {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/51753263/src/java/org/apache/cassandra/locator/YamlFileNetworkTopologySnitch.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/locator/YamlFileNetworkTopologySnitch.java b/src/java/org/apache/cassandra/locator/YamlFileNetworkTopologySnitch.java
index 870eea8..0279e9f 100644
--- a/src/java/org/apache/cassandra/locator/YamlFileNetworkTopologySnitch.java
+++ b/src/java/org/apache/cassandra/locator/YamlFileNetworkTopologySnitch.java
@@ -386,9 +386,9 @@ public class YamlFileNetworkTopologySnitch
         // host quickly and interrupt the loop. Otherwise we only check the live hosts that were either
         // in the old set or in the new set
         Set<InetAddress> hosts = NodeData.isSameDcRack(defaultNodeData, reloadedDefaultData)
-                                 ? Sets.intersection(StorageService.instance.getLiveMembers(), // same default
+                                 ? Sets.intersection(StorageService.instance.getLiveRingMembers(), // same default
                                                      Sets.union(nodeDataMap.keySet(), reloadedMap.keySet()))
-                                 : StorageService.instance.getLiveMembers(); // default updated
+                                 : StorageService.instance.getLiveRingMembers(); // default updated
 
         for (InetAddress host : hosts)
         {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/51753263/src/java/org/apache/cassandra/service/MigrationManager.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/MigrationManager.java b/src/java/org/apache/cassandra/service/MigrationManager.java
index 3539602..bebfa43 100644
--- a/src/java/org/apache/cassandra/service/MigrationManager.java
+++ b/src/java/org/apache/cassandra/service/MigrationManager.java
@@ -395,7 +395,7 @@ public class MigrationManager
             }
         });
 
-        for (InetAddress endpoint : Gossiper.instance.getLiveEndpoints())
+        for (InetAddress endpoint : Gossiper.instance.getLiveMembers())
         {
             // only push schema to nodes with known and equal versions
             if (!endpoint.equals(FBUtilities.getBroadcastAddress()) &&
@@ -439,7 +439,7 @@ public class MigrationManager
 
         Schema.instance.clear();
 
-        Set<InetAddress> liveEndpoints = Gossiper.instance.getLiveEndpoints();
+        Set<InetAddress> liveEndpoints = Gossiper.instance.getLiveMembers();
         liveEndpoints.remove(FBUtilities.getBroadcastAddress());
 
         // force migration if there are nodes around

http://git-wip-us.apache.org/repos/asf/cassandra/blob/51753263/src/java/org/apache/cassandra/service/StorageProxy.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/StorageProxy.java b/src/java/org/apache/cassandra/service/StorageProxy.java
index 0e90ea6..fedcf3a 100644
--- a/src/java/org/apache/cassandra/service/StorageProxy.java
+++ b/src/java/org/apache/cassandra/service/StorageProxy.java
@@ -1863,7 +1863,7 @@ public class StorageProxy implements StorageProxyMBean
     {
         final String myVersion = Schema.instance.getVersion().toString();
         final Map<InetAddress, UUID> versions = new ConcurrentHashMap<InetAddress, UUID>();
-        final Set<InetAddress> liveHosts = Gossiper.instance.getLiveEndpoints();
+        final Set<InetAddress> liveHosts = Gossiper.instance.getLiveMembers();
         final CountDownLatch latch = new CountDownLatch(liveHosts.size());
 
         IAsyncCallback<UUID> cb = new IAsyncCallback<UUID>()
@@ -1897,7 +1897,7 @@ public class StorageProxy implements StorageProxyMBean
 
         // maps versions to hosts that are on that version.
         Map<String, List<String>> results = new HashMap<String, List<String>>();
-        Iterable<InetAddress> allHosts = Iterables.concat(Gossiper.instance.getLiveEndpoints(), Gossiper.instance.getUnreachableMembers());
+        Iterable<InetAddress> allHosts = Iterables.concat(Gossiper.instance.getLiveMembers(), Gossiper.instance.getUnreachableMembers());
         for (InetAddress host : allHosts)
         {
             UUID version = versions.get(host);
@@ -2125,11 +2125,11 @@ public class StorageProxy implements StorageProxyMBean
             // Since the truncate operation is so aggressive and is typically only
             // invoked by an admin, for simplicity we require that all nodes are up
             // to perform the operation.
-            int liveMembers = Gossiper.instance.getLiveEndpoints().size();
+            int liveMembers = Gossiper.instance.getLiveMembers().size();
             throw new UnavailableException(ConsistencyLevel.ALL, liveMembers + Gossiper.instance.getUnreachableMembers().size(), liveMembers);
         }
 
-        Set<InetAddress> allEndpoints = StorageService.instance.getLiveMembers(true);
+        Set<InetAddress> allEndpoints = StorageService.instance.getLiveRingMembers(true);
 
         int blockFor = allEndpoints.size();
         final TruncateResponseHandler responseHandler = new TruncateResponseHandler(blockFor);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/51753263/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 5503123..0d9e9ef 100644
--- a/src/java/org/apache/cassandra/service/StorageService.java
+++ b/src/java/org/apache/cassandra/service/StorageService.java
@@ -572,7 +572,7 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
         while (true)
         {
             Uninterruptibles.sleepUninterruptibly(1, TimeUnit.SECONDS);
-            for (InetAddress address : Gossiper.instance.getLiveEndpoints())
+            for (InetAddress address : Gossiper.instance.getLiveMembers())
             {
                 if (!Gossiper.instance.isFatClient(address))
                     break outer;
@@ -2301,18 +2301,18 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
 
     public List<String> getLiveNodes()
     {
-        return stringify(Gossiper.instance.getLiveEndpoints());
+        return stringify(Gossiper.instance.getLiveMembers());
     }
 
-    public Set<InetAddress> getLiveMembers()
+    public Set<InetAddress> getLiveRingMembers()
     {
-        return getLiveMembers(false);
+        return getLiveRingMembers(false);
     }
 
-    public Set<InetAddress> getLiveMembers(boolean excludeDeadStates)
+    public Set<InetAddress> getLiveRingMembers(boolean excludeDeadStates)
     {
         Set<InetAddress> ret = new HashSet<>();
-        for (InetAddress ep : Gossiper.instance.getLiveEndpoints())
+        for (InetAddress ep : Gossiper.instance.getLiveMembers())
         {
             if (excludeDeadStates)
             {
@@ -3768,7 +3768,7 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
         if (endpoint.equals(myAddress))
              throw new UnsupportedOperationException("Cannot remove self");
 
-        if (Gossiper.instance.getLiveEndpoints().contains(endpoint))
+        if (Gossiper.instance.getLiveMembers().contains(endpoint))
             throw new UnsupportedOperationException("Node " + endpoint + " is alive and owns this ID. Use decommission command to remove it from the ring");
 
         // A leaving endpoint that is dead is already being removed.