dcapwell commented on code in PR #3305:
URL: https://github.com/apache/cassandra/pull/3305#discussion_r1612446643


##########
src/java/org/apache/cassandra/db/virtual/AccordVirtualTables.java:
##########
@@ -18,57 +18,162 @@
 
 package org.apache.cassandra.db.virtual;
 
-import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.concurrent.TimeUnit;
 
-import com.google.common.annotations.VisibleForTesting;
-
+import accord.local.CommandStores;
+import accord.primitives.TxnId;
+import accord.utils.async.AsyncChains;
 import org.apache.cassandra.config.DatabaseDescriptor;
 import org.apache.cassandra.cql3.statements.schema.CreateTableStatement;
+import org.apache.cassandra.dht.Range;
+import org.apache.cassandra.dht.Token;
 import org.apache.cassandra.schema.TableMetadata;
+import org.apache.cassandra.service.accord.AccordCommandStore;
 import org.apache.cassandra.service.accord.AccordService;
-import org.apache.cassandra.service.accord.IAccordService;
+import org.apache.cassandra.service.accord.AccordStateCache;
+import 
org.apache.cassandra.service.consensus.migration.ConsensusMigrationState;
+import org.apache.cassandra.service.consensus.migration.TableMigrationState;
+import org.apache.cassandra.tcm.ClusterMetadata;
+import org.apache.cassandra.utils.Clock;
+
+import static com.google.common.collect.ImmutableList.toImmutableList;
 
 public class AccordVirtualTables
 {
-    private AccordVirtualTables()
-    {
-
-    }
+    private AccordVirtualTables() {}
 
     public static Collection<VirtualTable> getAll(String keyspace)
     {
         if (!DatabaseDescriptor.getAccordTransactionsEnabled())
             return Collections.emptyList();
 
-        return Arrays.asList(
-        new Epoch(keyspace)
+        return List.of(
+            new CommandStoreCache(keyspace),
+            new MigrationStates(keyspace),
+            new CoordinationStatus(keyspace)
         );
     }
 
-    @VisibleForTesting
-    public static final class Epoch extends AbstractVirtualTable
+    public static final class CommandStoreCache extends AbstractVirtualTable
     {
+        private CommandStoreCache(String keyspace)

Review Comment:
   it would be useful to include instance as well, either as its own table or a 
column here... having a low hit rate doesn't let you know what's going on, need 
to see which instances are contributing to it.



##########
src/java/org/apache/cassandra/db/virtual/AccordVirtualTables.java:
##########
@@ -73,6 +90,88 @@ public DataSet data()
         }
     }
 
+    public static final class CommandStoreCache extends AbstractVirtualTable
+    {
+        private CommandStoreCache(String keyspace)
+        {
+            super(parse(keyspace,
+                        "Accord Command Store Cache Metrics",
+                        "CREATE TABLE accord_command_store_cache(\n" +
+                        "  id int,\n" +
+                        "  queries bigint,\n" +
+                        "  hits bigint,\n" +
+                        "  misses bigint,\n" +
+                        "  PRIMARY KEY (id)" +
+                        ')'));
+        }
+
+        @Override
+        public DataSet data()
+        {
+            AccordService accord = (AccordService) AccordService.instance();
+            SimpleDataSet result = new SimpleDataSet(metadata());
+
+            Map<Integer, AccordStateCache.ImmutableStats> statsByStore = 
+                accord.node().commandStores().map(PreLoadContext.empty(),
+                                                  store -> 
((AccordCommandStore) store.commandStore()).cache().stats());
+
+            for (Map.Entry<Integer, AccordStateCache.ImmutableStats> stats : 
statsByStore.entrySet())
+            {
+                result.row(stats.getKey());
+                result.column("queries", stats.getValue().queries);
+                result.column("hits", stats.getValue().hits);
+                result.column("misses", stats.getValue().misses);
+            }
+
+            return result;
+        }
+    }
+
+    public static final class MigrationStates extends AbstractVirtualTable
+    {
+        private MigrationStates(String keyspace)
+        {
+            super(parse(keyspace,

Review Comment:
   @aweisberg?



-- 
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