You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@cassandra.apache.org by GitBox <gi...@apache.org> on 2022/03/11 17:20:32 UTC

[GitHub] [cassandra] frankgh opened a new pull request #1495: CASSANDRA-17002: Virtual table for gossip info

frankgh opened a new pull request #1495:
URL: https://github.com/apache/cassandra/pull/1495


   This commit adds a new virtual table that exposes the gossip information in tabular format.
   
   The information is the same as the information presented through the `nodetool gossipinfo`
   command, but the virtual table splits the version and value from `VersionedValue` into two
   different columns. This is intended to help clients reading the vtable without the need of
   parsing the version:value information (as it currently stands in gossipinfo).
   
   The token value does not have a column. This is consistent with the gossipinfo output which
   always renders ":<hidden>" for the Token value. Only the token_version column is available.


-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] yifan-c commented on a change in pull request #1495: CASSANDRA-17002: Virtual table for gossip info

Posted by GitBox <gi...@apache.org>.
yifan-c commented on a change in pull request #1495:
URL: https://github.com/apache/cassandra/pull/1495#discussion_r825201907



##########
File path: src/java/org/apache/cassandra/db/virtual/GossipInfoTable.java
##########
@@ -0,0 +1,182 @@
+/*
+ * 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.db.virtual;
+
+import java.util.EnumSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.cassandra.db.marshal.InetAddressType;
+import org.apache.cassandra.db.marshal.Int32Type;
+import org.apache.cassandra.db.marshal.UTF8Type;
+import org.apache.cassandra.dht.LocalPartitioner;
+import org.apache.cassandra.gms.ApplicationState;
+import org.apache.cassandra.gms.EndpointState;
+import org.apache.cassandra.gms.Gossiper;
+import org.apache.cassandra.gms.VersionedValue;
+import org.apache.cassandra.locator.InetAddressAndPort;
+import org.apache.cassandra.schema.TableMetadata;
+
+/**
+ * A {@link VirtualTable} that return the Gossip information in tabular format.
+ */
+final class GossipInfoTable extends AbstractVirtualTable
+{
+    static final String TABLE_NAME = "gossip_info";
+    static final String TABLE_COMMENT = "lists the gossip information for the cluster";
+
+    static final String ADDRESS = "address";
+    static final String PORT = "port";
+    static final String HOSTNAME = "hostname";
+    static final String GENERATION = "generation";
+    static final String HEARTBEAT = "heartbeat";
+
+    @SuppressWarnings("deprecation")
+    static final Set<ApplicationState> APPLICATION_STATE_SET =
+    EnumSet.of(ApplicationState.STATUS, ApplicationState.LOAD, ApplicationState.SCHEMA, ApplicationState.DC,
+               ApplicationState.RACK, ApplicationState.RELEASE_VERSION, ApplicationState.REMOVAL_COORDINATOR,
+               ApplicationState.INTERNAL_IP, ApplicationState.RPC_ADDRESS, ApplicationState.SEVERITY,
+               ApplicationState.NET_VERSION, ApplicationState.HOST_ID, ApplicationState.TOKENS,
+               ApplicationState.RPC_READY, ApplicationState.INTERNAL_ADDRESS_AND_PORT,
+               ApplicationState.NATIVE_ADDRESS_AND_PORT, ApplicationState.STATUS_WITH_PORT,
+               ApplicationState.SSTABLE_VERSIONS);
+
+    /**
+     * Construct a new {@link GossipInfoTable} for the given {@code keyspace}.
+     *
+     * @param keyspace the name of the keyspace
+     */
+    GossipInfoTable(String keyspace)
+    {
+        super(buildTableMetadata(keyspace));
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public DataSet data()
+    {
+        SimpleDataSet result = new SimpleDataSet(metadata());
+        for (Map.Entry<InetAddressAndPort, EndpointState> entry : Gossiper.instance.endpointStateMap.entrySet())
+        {
+            InetAddressAndPort endpoint = entry.getKey();
+            EndpointState localState = entry.getValue();
+
+            SimpleDataSet dataSet = result.row(endpoint.getAddress(), endpoint.getPort())
+                                          .column(HOSTNAME, endpoint.getHostName())
+                                          .column(GENERATION, getGeneration(localState))
+                                          .column(HEARTBEAT, getHeartBeat(localState));
+
+            APPLICATION_STATE_SET.forEach(applicationState -> {
+                String lowercaseName = applicationState.name().toLowerCase();
+                if (!"tokens".equals(lowercaseName))
+                {
+                    // do not a column for the ApplicationState.TOKENS value

Review comment:
       do not (add?) a column




-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic closed pull request #1495: CASSANDRA-17002: Virtual table for gossip info

Posted by GitBox <gi...@apache.org>.
smiklosovic closed pull request #1495:
URL: https://github.com/apache/cassandra/pull/1495


   


-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org