You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by st...@apache.org on 2016/12/12 02:39:16 UTC
[04/10] cassandra git commit: Set RPC_READY to false when draining or
if a node is marked as shutdown
Set RPC_READY to false when draining or if a node is marked as shutdown
patch by Stefania Alborghetti; reviewed by Paulo Motta for CASSANDRA-12781
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/6bd402d1
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/6bd402d1
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/6bd402d1
Branch: refs/heads/trunk
Commit: 6bd402d12eb9216529417294e9af3a5b7c37b048
Parents: 752f5d5
Author: Stefania Alborghetti <st...@datastax.com>
Authored: Fri Oct 21 14:53:52 2016 +0800
Committer: Stefania Alborghetti <st...@datastax.com>
Committed: Mon Dec 12 10:29:44 2016 +0800
----------------------------------------------------------------------
CHANGES.txt | 1 +
src/java/org/apache/cassandra/gms/Gossiper.java | 1 +
.../cassandra/service/StorageService.java | 26 +++++++++++++++++++-
3 files changed, 27 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/6bd402d1/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 1da48bd..266849a 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
3.0.11
+ * Set RPC_READY to false when draining or if a node is marked as shutdown (CASSANDRA-12781)
* CQL often queries static columns unnecessarily (CASSANDRA-12768)
* Make sure sstables only get committed when it's safe to discard commit log records (CASSANDRA-12956)
* Reject default_time_to_live option when creating or altering MVs (CASSANDRA-12868)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/6bd402d1/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 b0ec53f..cbfa750 100644
--- a/src/java/org/apache/cassandra/gms/Gossiper.java
+++ b/src/java/org/apache/cassandra/gms/Gossiper.java
@@ -360,6 +360,7 @@ public class Gossiper implements IFailureDetectionEventListener, GossiperMBean
if (epState == null)
return;
epState.addApplicationState(ApplicationState.STATUS, StorageService.instance.valueFactory.shutdown(true));
+ epState.addApplicationState(ApplicationState.RPC_READY, StorageService.instance.valueFactory.rpcReady(false));
epState.getHeartBeatState().forceHighestPossibleVersionUnsafe();
markDead(endpoint, epState);
FailureDetector.instance.forceConviction(endpoint);
http://git-wip-us.apache.org/repos/asf/cassandra/blob/6bd402d1/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 9bf8c54..d70c8dc 100644
--- a/src/java/org/apache/cassandra/service/StorageService.java
+++ b/src/java/org/apache/cassandra/service/StorageService.java
@@ -426,8 +426,19 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
}
}
+ /**
+ * Set the Gossip flag RPC_READY to false and then
+ * shutdown the client services (thrift and CQL).
+ *
+ * Note that other nodes will do this for us when
+ * they get the Gossip shutdown message, so even if
+ * we don't get time to broadcast this, it is not a problem.
+ *
+ * See {@link Gossiper#markAsShutdown(InetAddress)}
+ */
private void shutdownClientServers()
{
+ setRpcReady(false);
stopRPCServer();
stopNativeTransport();
}
@@ -1830,9 +1841,22 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
Gossiper.instance.getEndpointStateForEndpoint(endpoint).isRpcReady();
}
+ /**
+ * Set the RPC status. Because when draining a node we need to set the RPC
+ * status to not ready, and drain is called by the shutdown hook, it may be that value is false
+ * and there is no local endpoint state. In this case it's OK to just do nothing. Therefore,
+ * we assert that the local endpoint state is not null only when value is true.
+ *
+ * @param value - true indicates that RPC is ready, false indicates the opposite.
+ */
public void setRpcReady(boolean value)
{
- Gossiper.instance.addLocalApplicationState(ApplicationState.RPC_READY, valueFactory.rpcReady(value));
+ EndpointState state = Gossiper.instance.getEndpointStateForEndpoint(FBUtilities.getBroadcastAddress());
+ // if value is false we're OK with a null state, if it is true we are not.
+ assert !value || state != null;
+
+ if (state != null)
+ Gossiper.instance.addLocalApplicationState(ApplicationState.RPC_READY, valueFactory.rpcReady(value));
}
private Collection<Token> getTokensFor(InetAddress endpoint)