frankgh commented on a change in pull request #1428: URL: https://github.com/apache/cassandra/pull/1428#discussion_r798048193
########## File path: src/java/org/apache/cassandra/db/virtual/GossipStateTransitionsTable.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.db.virtual; + +import java.util.Date; + +import org.apache.cassandra.db.marshal.InetAddressType; +import org.apache.cassandra.db.marshal.Int32Type; +import org.apache.cassandra.db.marshal.TimestampType; +import org.apache.cassandra.db.marshal.UTF8Type; +import org.apache.cassandra.dht.LocalPartitioner; +import org.apache.cassandra.gms.GossipStateTransition; +import org.apache.cassandra.gms.Gossiper; +import org.apache.cassandra.schema.TableMetadata; + +/** + * A {@link VirtualTable} that returns the {@code max_gossip_state_transitions_size} most recent gossip state + * transitions. The table only considers peers in the ring (it doesn't track transitions for evicted peers). + * + * <p>The {@code max_gossip_state_transitions_size} property can be configured in the {@code cassandra.yaml} + * configuration file. + */ +final class GossipStateTransitionsTable extends AbstractVirtualTable +{ + public static final String TABLE_NAME = "gossip_state_transitions"; + public static final String TABLE_COMMENT = "recent gossip state transitions"; + + private static final String ADDRESS = "address"; + private static final String PORT = "port"; + private static final String TIMESTAMP = "timestamp"; + private static final String HOSTNAME = "hostname"; + private static final String GENERATION = "generation"; + private static final String HEARTBEAT = "heartbeat"; + + // Fields coming from @org.apache.cassandra.gms.ApplicationState + private static final String STATUS = "status"; + private static final String LOAD = "load"; + private static final String SCHEMA = "schema"; + private static final String DC = "dc"; + private static final String RACK = "rack"; + private static final String RELEASE_VERSION = "release_version"; + private static final String REMOVAL_COORDINATOR = "removal_coordinator"; + private static final String INTERNAL_IP = "internal_ip"; + private static final String RPC_ADDRESS = "rpc_address"; + private static final String SEVERITY = "severity"; + private static final String NET_VERSION = "net_version"; + private static final String HOST_ID = "host_id"; + private static final String TOKENS = "tokens"; + private static final String RPC_READY = "rpc_ready"; + private static final String INTERNAL_ADDRESS_AND_PORT = "internal_address_and_port"; + private static final String NATIVE_ADDRESS_AND_PORT = "native_address_and_port"; + private static final String STATUS_WITH_PORT = "status_with_port"; + private static final String SSTABLE_VERSIONS = "sstable_versions"; + + /** + * Constructs a new {@link GossipStateTransitionsTable} with the given {@code keyspace}. + * + * @param keyspace the name of the keyspace + */ + GossipStateTransitionsTable(String keyspace) + { + super(TableMetadata.builder(keyspace, TABLE_NAME) + .comment(TABLE_COMMENT) + .kind(TableMetadata.Kind.VIRTUAL) + .partitioner(new LocalPartitioner(InetAddressType.instance)) + .addPartitionKeyColumn(ADDRESS, InetAddressType.instance) + .addClusteringColumn(PORT, Int32Type.instance) Review comment: One of the use cases is to provide the ability of checking the state of a host. I am thinking that we partition by `(address, port), timestamp` for this particular use case. Another use case is debugging. For debugging it also seems important to have a view from the (host, port). What do you think? -- 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]

