mirror of https://github.com/apache/cassandra
Remove unnecessary shuffling of GossipDigests in Gossiper#makeRandomGossipDigest
This patch also fixes the bug when creating GossipDigests in case epState in Gossiper#makeRandomGossipDigest was null. Previously, if it was null, it used generation and maxVersion of the last non-null epState instead of zeros. patch by Cameron Zemek; reviewed by Stefan Miklosovic and Brandon Williams for CASSANDRA-18546
This commit is contained in:
parent
71b79cfbe3
commit
f66adb0278
|
|
@ -1,4 +1,5 @@
|
|||
4.0.11
|
||||
* Remove unnecessary shuffling of GossipDigests in Gossiper#makeRandomGossipDigest (CASSANDRA-18546)
|
||||
Merged from 3.11:
|
||||
Merged from 3.0:
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@ import com.google.common.collect.ImmutableList;
|
|||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.util.concurrent.ListenableFutureTask;
|
||||
import com.google.common.util.concurrent.Uninterruptibles;
|
||||
|
|
@ -52,7 +51,6 @@ import org.apache.cassandra.utils.Pair;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import io.netty.util.concurrent.FastThreadLocal;
|
||||
import org.apache.cassandra.concurrent.DebuggableScheduledThreadPoolExecutor;
|
||||
import org.apache.cassandra.concurrent.JMXEnabledThreadPoolExecutor;
|
||||
import org.apache.cassandra.concurrent.Stage;
|
||||
|
|
@ -63,13 +61,8 @@ import org.apache.cassandra.net.RequestCallback;
|
|||
import org.apache.cassandra.net.Message;
|
||||
import org.apache.cassandra.net.MessagingService;
|
||||
import org.apache.cassandra.service.StorageService;
|
||||
import org.apache.cassandra.utils.CassandraVersion;
|
||||
import org.apache.cassandra.utils.ExecutorUtils;
|
||||
import org.apache.cassandra.utils.FBUtilities;
|
||||
import org.apache.cassandra.utils.JVMStabilityInspector;
|
||||
import org.apache.cassandra.utils.MBeanWrapper;
|
||||
import org.apache.cassandra.utils.NoSpamLogger;
|
||||
import org.apache.cassandra.utils.Pair;
|
||||
import org.apache.cassandra.utils.RecomputingSupplier;
|
||||
|
||||
import static org.apache.cassandra.config.CassandraRelevantProperties.GOSSIPER_QUARANTINE_DELAY;
|
||||
|
|
@ -293,7 +286,7 @@ public class Gossiper implements IFailureDetectionEventListener, GossiperMBean
|
|||
if (logger.isTraceEnabled())
|
||||
logger.trace("My heartbeat is now {}", endpointStateMap.get(FBUtilities.getBroadcastAddressAndPort()).getHeartBeatState().getHeartBeatVersion());
|
||||
final List<GossipDigest> gDigests = new ArrayList<>();
|
||||
Gossiper.instance.makeRandomGossipDigest(gDigests);
|
||||
Gossiper.instance.makeGossipDigest(gDigests);
|
||||
|
||||
if (gDigests.size() > 0)
|
||||
{
|
||||
|
|
@ -699,29 +692,29 @@ public class Gossiper implements IFailureDetectionEventListener, GossiperMBean
|
|||
}
|
||||
|
||||
/**
|
||||
* The gossip digest is built based on randomization
|
||||
* rather than just looping through the collection of live endpoints.
|
||||
*
|
||||
* @param gDigests list of Gossip Digests.
|
||||
* @param gDigests list of Gossip Digests to be filled
|
||||
*/
|
||||
private void makeRandomGossipDigest(List<GossipDigest> gDigests)
|
||||
private void makeGossipDigest(List<GossipDigest> gDigests)
|
||||
{
|
||||
EndpointState epState;
|
||||
int generation = 0;
|
||||
int maxVersion = 0;
|
||||
int generation;
|
||||
int maxVersion;
|
||||
|
||||
// local epstate will be part of endpointStateMap
|
||||
List<InetAddressAndPort> endpoints = new ArrayList<>(endpointStateMap.keySet());
|
||||
Collections.shuffle(endpoints, random);
|
||||
for (InetAddressAndPort endpoint : endpoints)
|
||||
for (Entry<InetAddressAndPort, EndpointState> entry : endpointStateMap.entrySet())
|
||||
{
|
||||
epState = endpointStateMap.get(endpoint);
|
||||
epState = entry.getValue();
|
||||
if (epState != null)
|
||||
{
|
||||
generation = epState.getHeartBeatState().getGeneration();
|
||||
maxVersion = getMaxEndpointStateVersion(epState);
|
||||
}
|
||||
gDigests.add(new GossipDigest(endpoint, generation, maxVersion));
|
||||
else
|
||||
{
|
||||
generation = 0;
|
||||
maxVersion = 0;
|
||||
}
|
||||
gDigests.add(new GossipDigest(entry.getKey(), generation, maxVersion));
|
||||
}
|
||||
|
||||
if (logger.isTraceEnabled())
|
||||
|
|
|
|||
Loading…
Reference in New Issue