Revert changes to names of public methods on Gossiper

Patch and review by Paulo Motta and Stefania Alborghetti to
follow up CASSANDRA-10243
This commit is contained in:
Paulo Motta 2015-12-01 10:41:05 -08:00 committed by Sam Tunnicliffe
parent dbfeeac177
commit 51753263a4
6 changed files with 33 additions and 24 deletions

View File

@ -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> liveEndpoints = new HashSet<InetAddress>(this.liveEndpoints);
if (!liveEndpoints.contains(FBUtilities.getBroadcastAddress()))
liveEndpoints.add(FBUtilities.getBroadcastAddress());
return liveEndpoints;
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()
{
return StorageService.instance.getLiveRingMembers(true);
}
/**

View File

@ -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)
{

View File

@ -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)
{

View File

@ -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

View File

@ -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);

View File

@ -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.