cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brandonwilli...@apache.org
Subject [04/13] git commit: Update peer information when a node jumps to normal.
Date Tue, 06 May 2014 21:17:12 GMT
Update peer information when a node jumps to normal.

Patch by brandonwilliams, reviewed by Richard Low for CASSANDRA-7122


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

Branch: refs/heads/cassandra-2.1
Commit: f4460a55b85759d2a631a2d931f10106e1748770
Parents: 64394b2
Author: Brandon Williams <brandonwilliams@apache.org>
Authored: Tue May 6 16:10:10 2014 -0500
Committer: Brandon Williams <brandonwilliams@apache.org>
Committed: Tue May 6 16:10:10 2014 -0500

----------------------------------------------------------------------
 .../cassandra/service/StorageService.java       | 30 ++++++++++++++++++++
 1 file changed, 30 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/f4460a55/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 bfca642..ed6d031 100644
--- a/src/java/org/apache/cassandra/service/StorageService.java
+++ b/src/java/org/apache/cassandra/service/StorageService.java
@@ -1383,6 +1383,35 @@ public class StorageService extends NotificationBroadcasterSupport
implements IE
         }
     }
 
+    private void updatePeerInfo(InetAddress endpoint)
+    {
+        EndpointState epState = Gossiper.instance.getEndpointStateForEndpoint(endpoint);
+        for (Map.Entry<ApplicationState, VersionedValue> entry : epState.getApplicationStateMap().entrySet())
+        {
+            switch (entry.getKey())
+            {
+                case RELEASE_VERSION:
+                    SystemTable.updatePeerInfo(endpoint, "release_version", quote(entry.getValue().value));
+                    break;
+                case DC:
+                    SystemTable.updatePeerInfo(endpoint, "data_center", quote(entry.getValue().value));
+                    break;
+                case RACK:
+                    SystemTable.updatePeerInfo(endpoint, "rack", quote(entry.getValue().value));
+                    break;
+                case RPC_ADDRESS:
+                    SystemTable.updatePeerInfo(endpoint, "rpc_address", quote(entry.getValue().value));
+                    break;
+                case SCHEMA:
+                    SystemTable.updatePeerInfo(endpoint, "schema_version", entry.getValue().value);
+                    break;
+                case HOST_ID:
+                    SystemTable.updatePeerInfo(endpoint, "host_id", entry.getValue().value);
+                    break;
+            }
+        }
+    }
+
     private String quote(String value)
     {
         return "'" + value + "'";
@@ -1484,6 +1513,7 @@ public class StorageService extends NotificationBroadcasterSupport implements
IE
         if (tokenMetadata.isMember(endpoint))
             logger.info("Node " + endpoint + " state jump to normal");
 
+        updatePeerInfo(endpoint);
         // Order Matters, TM.updateHostID() should be called before TM.updateNormalToken(),
(see CASSANDRA-4300).
         if (Gossiper.instance.usesHostId(endpoint))
         {


Mime
View raw message