skoppu22 commented on a change in pull request #1428:
URL: https://github.com/apache/cassandra/pull/1428#discussion_r798555118



##########
File path: src/java/org/apache/cassandra/gms/GossipStateTransition.java
##########
@@ -0,0 +1,145 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.cassandra.gms;
+
+import java.net.InetAddress;
+
+import org.apache.cassandra.locator.InetAddressAndPort;
+
+import static org.apache.cassandra.utils.Clock.Global.currentTimeMillis;
+
+public class GossipStateTransition
+{
+    private final long timestamp;
+    public final InetAddressAndPort endpoint;
+    public final Integer generation;
+    public final Integer heartbeat;
+
+    // Fields coming from @org.apache.cassandra.gms.ApplicationState
+    public final String status;
+    public final String load;
+    public final String schema;
+    public final String dc;
+    public final String rack;
+    public final String releaseVersion;
+    public final String removalCoordinator;
+    public final String internalIp;
+    public final String rpcAddress;
+    public final String severity;
+    public final String netVersion;
+    public final String hostId;
+    public final String tokens;
+    public final String rpcReady;
+    public final String internalAddressAndPort;
+    public final String nativeAddressAndPort;
+    public final String statusWithPort;
+    public final String sstableVersions;
+
+    GossipStateTransition(InetAddressAndPort endpoint)
+    {
+        this(endpoint, (VersionedValue) null);
+    }
+
+    GossipStateTransition(InetAddressAndPort endpoint, VersionedValue 
tokensVersion)
+    {
+        this.timestamp = currentTimeMillis();
+        this.endpoint = endpoint;
+        this.generation = null;
+        this.heartbeat = null;
+        this.status = null;
+        this.load = null;
+        this.schema = null;
+        this.dc = null;
+        this.rack = null;
+        this.releaseVersion = null;
+        this.removalCoordinator = null;
+        this.internalIp = null;
+        this.rpcAddress = null;
+        this.severity = null;
+        this.netVersion = null;
+        this.hostId = null;
+        this.rpcReady = null;
+        this.internalAddressAndPort = null;
+        this.nativeAddressAndPort = null;
+        this.statusWithPort = null;
+        this.sstableVersions = null;
+        this.tokens = getTokensString(tokensVersion);
+    }
+
+    GossipStateTransition(InetAddressAndPort endpoint, EndpointState 
endpointState)
+    {
+        HeartBeatState heartBeatState = endpointState.getHeartBeatState();
+
+        this.timestamp = currentTimeMillis();
+        this.endpoint = endpoint;
+        this.generation = heartBeatState.getGeneration();
+        this.heartbeat = heartBeatState.getHeartBeatVersion();
+
+        this.status = 
getString(endpointState.getApplicationState(ApplicationState.STATUS));
+        this.load = 
getString(endpointState.getApplicationState(ApplicationState.LOAD));
+        this.schema = 
getString(endpointState.getApplicationState(ApplicationState.SCHEMA));
+        this.dc = 
getString(endpointState.getApplicationState(ApplicationState.DC));
+        this.rack = 
getString(endpointState.getApplicationState(ApplicationState.RACK));
+        this.releaseVersion = 
getString(endpointState.getApplicationState(ApplicationState.RELEASE_VERSION));
+        this.removalCoordinator = 
getString(endpointState.getApplicationState(ApplicationState.REMOVAL_COORDINATOR));
+        this.internalIp = 
getString(endpointState.getApplicationState(ApplicationState.INTERNAL_IP));
+        this.rpcAddress = 
getString(endpointState.getApplicationState(ApplicationState.RPC_ADDRESS));
+        this.severity = 
getString(endpointState.getApplicationState(ApplicationState.SEVERITY));
+        this.netVersion = 
getString(endpointState.getApplicationState(ApplicationState.NET_VERSION));
+        this.hostId = 
getString(endpointState.getApplicationState(ApplicationState.HOST_ID));
+        this.rpcReady = 
getString(endpointState.getApplicationState(ApplicationState.RPC_READY));
+        this.internalAddressAndPort = 
getString(endpointState.getApplicationState(ApplicationState.INTERNAL_ADDRESS_AND_PORT));
+        this.nativeAddressAndPort = 
getString(endpointState.getApplicationState(ApplicationState.NATIVE_ADDRESS_AND_PORT));
+        this.statusWithPort = 
getString(endpointState.getApplicationState(ApplicationState.STATUS_WITH_PORT));
+        this.sstableVersions = 
getString(endpointState.getApplicationState(ApplicationState.SSTABLE_VERSIONS));
+        this.tokens = 
getTokensString(endpointState.getApplicationState(ApplicationState.TOKENS));
+    }
+
+    public long timestamp()
+    {
+        return timestamp;
+    }
+
+    public InetAddress address()
+    {
+        return endpoint.getAddress();
+    }
+
+    public int port()
+    {
+        return endpoint.getPort();
+    }
+
+    public String hostname()
+    {
+        return endpoint.getHostName();
+    }
+
+    private String getString(VersionedValue value)
+    {
+        return value == null
+               ? null
+               : value.version + ":" + value.value;
+    }
+
+    private String getTokensString(VersionedValue tokens)
+    {
+        return tokens == null ? null : tokens.version + ":<hidden>";

Review comment:
       Just trying to understand, why are we appending ": hidden" here ?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to