ifesdjeen commented on code in PR #4562:
URL: https://github.com/apache/cassandra/pull/4562#discussion_r2773862326


##########
src/java/org/apache/cassandra/service/accord/api/AccordAgent.java:
##########
@@ -204,9 +205,11 @@ public static void handleException(Throwable t)
             return;
 
         AccordSystemMetrics.metrics.errors.inc();
-        if (t instanceof CancellationException || t instanceof 
TimeoutException || t instanceof Timeout)
-            return;
-        JVMStabilityInspector.uncaughtException(Thread.currentThread(), t);
+        if (t instanceof CancellationException || t instanceof 
TimeoutException || t instanceof Timeout || t instanceof Preempted)
+            // TODO (required): leaky logger, permitting multiple messages per 
time period and reporting how many were dropped
+            noSpamLogger.warn("", t);

Review Comment:
   Was this intended to be fixed in the scope of this issue?



##########
src/java/org/apache/cassandra/service/accord/debug/CoordinationKinds.java:
##########
@@ -0,0 +1,78 @@
+/*
+ * 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.service.accord.debug;
+
+import accord.coordinate.Coordination;
+import accord.utils.TinyEnumSet;
+
+public class CoordinationKinds extends 
TinyEnumSet<Coordination.CoordinationKind>
+{
+    private static final int ALL_BITS = 
Coordination.CoordinationKind.ALL.bitset();
+    public static final CoordinationKinds ALL = new CoordinationKinds(false, 
ALL_BITS);
+    public static final CoordinationKinds NONE = new CoordinationKinds(false, 
0);
+
+    final boolean printAsSubtraction;
+
+    public CoordinationKinds(boolean printAsSubtraction, int bitset)
+    {
+        super(bitset);
+        this.printAsSubtraction = printAsSubtraction;
+    }
+
+    @Override
+    public String toString()
+    {
+        if (bitset == ALL_BITS)
+            return "*";
+        if (printAsSubtraction)
+            return '-' + toString(ALL_BITS & ~bitset);
+        return toString(bitset, Coordination.CoordinationKind::forOrdinal);
+    }
+
+    public static CoordinationKinds parse(String input)
+    {
+        input = input.trim();
+        if (input.equals("*"))
+            return ALL;
+        if (input.equals("{}"))
+            return NONE;
+
+        boolean subtraction = false;
+        if (input.length() >= 1 && input.charAt(0) == '-')
+        {
+            subtraction = true;
+            input = input.substring(1);
+        }
+        if (input.length() < 2 || input.charAt(0) != '{' || 
input.charAt(input.length() - 1) != '}')
+            throw new IllegalArgumentException("Invalid CoordinationKinds 
specification: " + input);

Review Comment:
   should we stash the original input somewhere and append it here? to avoid 
stripping `-` 



##########
test/unit/org/apache/cassandra/db/virtual/AccordDebugKeyspaceTest.java:
##########
@@ -673,6 +717,305 @@ public void blocked() throws ExecutionException, 
InterruptedException
         }
     }
 
+    // TODO (expected): test graph_all (though mostly shared logic)
+    @Test
+    public void graph() throws TopologyException
+    {
+        AccordService accord = accord();
+        String tableName = createTable("CREATE TABLE %s (k int, c int, v int, 
PRIMARY KEY (k, c)) WITH transactional_mode = 'full'");
+        String insertTxn = String.format("BEGIN TRANSACTION\n" +
+                                         "    LET r = (SELECT * FROM %s.%s 
WHERE k = ? AND c = ?);\n" +
+                                         "    IF r IS NULL THEN\n " +
+                                         "        INSERT INTO %s.%s (k, c, v) 
VALUES (?, ?, ?);\n" +
+                                         "    END IF\n" +
+                                         "COMMIT TRANSACTION", KEYSPACE, 
tableName, KEYSPACE, tableName);
+        Txn txa = createTxn(insertTxn, 0, 0, 0, 0, 0);
+        AccordCommandStore commandStore = (AccordCommandStore) 
accord.node().commandStores().unsafeForKey((RoutingKey) 
txa.keys().get(0).toUnseekable());
+        // TODO (expected): test multi-key transactions (though functionally 
the same as range txns)
+        Txn txb, txc;
+        {
+            int i = 0;
+            Txn tmp;
+            do { ++i; tmp = createTxn(insertTxn, i, 0, i, 0, 0); }
+            while 
(!commandStore.unsafeGetRangesForEpoch().all().contains(tmp.keys().get(0).asKey()));
+            txb = tmp;
+            txc = createTxn(insertTxn, i, 0, 0, 0, 0);
+        }
+
+        long epoch = accord.currentEpoch();
+
+        TxnId[] ida = ids(epoch, Txn.Kind.Write, Routable.Domain.Key, new 
Node.Id(1), 1, 2, 3, 4, 6);
+        SaveStatus[] ssa = new SaveStatus[] { SaveStatus.PreAccepted, 
SaveStatus.Committed, SaveStatus.Committed, SaveStatus.Committed, 
SaveStatus.Committed };
+        Timestamp[] tsa = toTimestamps(ida);
+        tsa[2] = Timestamp.fromValues(epoch, 5, new Node.Id(1));
+        FullRoute<?> rta = accord.node().computeRoute(ida[0], 
txa.keys().toParticipants());
+
+        TxnId[] idb = ids(epoch, Txn.Kind.Write, Routable.Domain.Key, new 
Node.Id(2), 1, 2, 3, 4, 6);
+        SaveStatus[] ssb = new SaveStatus[] { SaveStatus.PreAccepted, 
SaveStatus.PreAccepted, SaveStatus.Committed, SaveStatus.Committed, 
SaveStatus.Committed };
+        Timestamp[] tsb = toTimestamps(idb);
+        tsb[2] = Timestamp.fromValues(epoch, 5, new Node.Id(2));
+        FullRoute<?> rtb = accord.node().computeRoute(idb[0], 
txb.keys().toParticipants());
+
+        TxnId[] ide = ids(epoch, Txn.Kind.ExclusiveSyncPoint, 
Routable.Domain.Range, new Node.Id(3), 1, 2, 3, 4, 6);
+        SaveStatus[] sse = new SaveStatus[] { SaveStatus.Committed, 
SaveStatus.Committed, SaveStatus.Committed, SaveStatus.Committed, 
SaveStatus.Committed };
+        Timestamp[] tse = toTimestamps(ide);
+        Txn txe = 
accord.node().agent().emptySystemTxn(Txn.Kind.ExclusiveSyncPoint, 
Routable.Domain.Range);
+        FullRoute<?> rte = accord.node().computeRoute(ide[0], 
txa.keys().toParticipants().toRanges().with(txb.keys().toParticipants().toRanges()));
+
+        write(commandStore, preaccepted(rta, ida[0], tsa[0], txa));
+        write(commandStore, committed(rta, ida[1], tsa[1], txa, ida, 0));
+        write(commandStore, committed(rta, ida[2], tsa[2], txa, ida, 0, 1, 3));
+        write(commandStore, committed(rta, ida[3], tsa[3], txa, ida, 0, 1, 2));
+        write(commandStore, committed(rta, ida[4], tsa[4], txa, ida, 0, 1, 2, 
3));
+
+        write(commandStore, preaccepted(rtb, idb[0], tsb[0], txb));
+        write(commandStore, preaccepted(rtb, idb[1], tsb[1], txb));
+        write(commandStore, committed(rtb, idb[2], tsb[2], txb, idb, 0, 1, 3));
+        write(commandStore, committed(rtb, idb[3], tsb[3], txb, idb, 0, 1, 2));
+        write(commandStore, committed(rtb, idb[4], tsb[4], txb, idb, 0, 1, 2, 
3));
+
+        write(commandStore, committed1(rte, ide[0], ide[0], txe, rta, ida, new 
int[] { 0 }, rtb, idb, new int[] { 0 }, rte, ide, new int[] { }));
+        write(commandStore, committed1(rte, ide[1], ide[1], txe, rta, ida, new 
int[] { 0, 1 }, rtb, idb, new int[] { 0, 1 }, rte, ide, new int[] { 0 }));
+        write(commandStore, committed1(rte, ide[2], ide[2], txe, rta, ida, new 
int[] { 0, 1, 2 }, rtb, idb, new int[] { 0, 1, 2 }, rte, ide, new int[] { 0, 1 
}));
+
+        // txn_id, depth, command_store_id, parent_txn_id, execute_at, 
child_txn_id
+        assertRows(execute(QUERY_TXN_GRAPH, ida[0].toString()));
+        assertRows(execute(QUERY_TXN_GRAPH, ida[1].toString()), 
graphRows(commandStore, txa, ida, ssa, tsa, 1, 0));
+        assertRows(execute(QUERY_TXN_GRAPH, ida[2].toString()), 
graphRows(commandStore, txa, ida, ssa, tsa, 2, 3, 0, 1));
+        assertRows(execute(QUERY_TXN_GRAPH, ida[3].toString()), 
graphRows(commandStore, txa, ida, ssa, tsa, 3, 1, 0));
+        assertRows(execute(QUERY_TXN_GRAPH, ida[4].toString()), 
graphRows(commandStore, txa, ida, ssa, tsa, 4, 2, 0, 3, 1));
+        assertRows(execute(QUERY_TXN_GRAPH_INTERSECTS, ida[4].toString(), 
rta.homeKey().toString()), graphRows(commandStore, txa, ida, ssa, tsa, 4, 2, 0, 
3, 1));
+        assertRows(execute(QUERY_TXN_GRAPH_INTERSECTS, ida[4].toString(), 
rtb.homeKey().toString()));
+        assertRows(execute(QUERY_TXN_GRAPH_INTERSECTS, ida[4].toString(), ""));
+        assertRows(execute(QUERY_TXN_GRAPH_KIND, ida[4].toString(), "{R*}"));
+        assertRows(execute(QUERY_TXN_GRAPH_KIND, ida[4].toString(), "{*R}"));
+        assertRows(execute(QUERY_TXN_GRAPH_KIND, ida[4].toString(), "{KW}"), 
graphRows(commandStore, txa, ida, ssa, tsa, 4, 2, 0, 3, 1));
+
+        assertRows(execute(QUERY_TXN_GRAPH, idb[0].toString()));
+        assertRows(execute(QUERY_TXN_GRAPH, idb[1].toString()));
+        assertRows(execute(QUERY_TXN_GRAPH, idb[2].toString()), 
graphRows(commandStore, txb, idb, ssb, tsb, 2, 3, 1, 0));
+        assertRows(execute(QUERY_TXN_GRAPH, idb[3].toString()), 
graphRows(commandStore, txb, idb, ssb, tsb, 3, 1, 0));
+        assertRows(execute(QUERY_TXN_GRAPH, idb[4].toString()), 
graphRows(commandStore, txb, idb, ssb, tsb, 4, 2, 1, 0, 3));
+        assertRows(execute(QUERY_TXN_GRAPH_INTERSECTS, idb[4].toString(), 
rtb.homeKey().toString()), graphRows(commandStore, txb, idb, ssb, tsb, 4, 2, 1, 
0, 3));
+        assertRows(execute(QUERY_TXN_GRAPH_INTERSECTS, idb[4].toString(), 
rta.homeKey().toString()));
+        assertRows(execute(QUERY_TXN_GRAPH_INTERSECTS, idb[4].toString(), ""));
+
+        FullRoute[] rts = new FullRoute[] { rta, rtb, rte };
+        TxnId[][] ids = new TxnId[][] { ida, idb, ide };
+        Timestamp[][] tss = new Timestamp[][] { tsa, tsb, tse };
+        SaveStatus[][] sss = new SaveStatus[][] { ssa, ssb, sse };
+
+        int[] ide0_rows = new int[]
+                          {
+                          0, 2, 0, 1, 0,
+                          0, 2, 0, 0, 0
+                          };
+
+        assertRows(execute(QUERY_TXN_GRAPH, ide[0].toString()), 
graphRows(commandStore, rts, ids, sss, tss, ALL, null, null, ide[0], 
ide0_rows));
+        assertRows(execute(QUERY_TXN_GRAPH_REMOTE, 1, ide[0].toString()), 
prepend(new Object[] { 1 }, graphRows(commandStore, rts, ids, sss, tss, ALL, 
null, null, ide[0], ide0_rows)));
+
+        int[] ide1_rows = new int[]
+                          {
+                          0, 2, 1, 0, 1,
+                          0, 2, 1, 2, 0,
+                          0, 2, 1, 1, 1,
+                          0, 2, 1, 1, 0,
+                          0, 2, 1, 0, 0
+                          };
+
+        assertRows(execute(QUERY_TXN_GRAPH, ide[1].toString()), 
graphRows(commandStore, rts, ids, sss, tss, ALL, null, null, ide[1], 
ide1_rows));
+        assertRows(execute(QUERY_TXN_GRAPH_REMOTE, 1, ide[1].toString()), 
prepend(new Object[] { 1 }, graphRows(commandStore, rts, ids, sss, tss, ALL, 
null, null, ide[1], ide1_rows)));
+
+        int[] ide2_rows = new int[]
+        {
+            0, 2, 2, 1, 2,
+            0, 2, 2, 0, 2,
+            0, 2, 2, 2, 1,
+            0, 2, 2, 1, 1,
+            0, 2, 2, 1, 0,
+            0, 2, 2, 0, 0,
+            1, 1, 2, 1, 3,
+            1, 0, 2, 0, 3,
+            1, 2, 1, 0, 1,
+            1, 2, 1, 2, 0,
+            2, 0, 3, 0, 1
+        };
+
+        assertRows(execute(QUERY_TXN_GRAPH, ide[2].toString()), 
graphRows(commandStore, rts, ids, sss, tss, ALL, null, null, ide[2], 
ide2_rows));
+        assertRows(execute(QUERY_TXN_GRAPH_DESC, ide[2].toString()), 
graphRows(commandStore, rts, ids, sss, tss, ALL, null, null, ide[2], 
reverse(ide2_rows, 5)));
+        assertRows(execute(QUERY_TXN_GRAPH_REMOTE, 1, ide[2].toString()), 
prepend(new Object[] { 1 }, graphRows(commandStore, rts, ids, sss, tss, ALL, 
null, null, ide[2], ide2_rows)));
+        assertRows(execute(QUERY_TXN_GRAPH_INTERSECTS, ide[2].toString(), 
AccordDebugKeyspace.toString(rte)), graphRows(commandStore, rts, ids, sss, tss, 
ALL, null, null, ide[2], ide2_rows));
+        assertRows(execute(QUERY_TXN_GRAPH_INTERSECTS, ide[2].toString(), ""));
+        assertRows(execute(QUERY_TXN_GRAPH_INTERSECTS, ide[2].toString(), 
AccordDebugKeyspace.toString(rta)), graphRows(commandStore, rts, ids, sss, tss, 
ALL, rta, null, ide[2], ide2_rows));
+        assertRows(execute(QUERY_TXN_GRAPH_INTERSECTS, ide[2].toString(), 
AccordDebugKeyspace.toString(rtb)), graphRows(commandStore, rts, ids, sss, tss, 
ALL, rtb, null, ide[2], ide2_rows));
+        assertRows(execute(QUERY_TXN_GRAPH_KIND, ide[2].toString(), "{KR}"));
+        assertRows(execute(QUERY_TXN_GRAPH_KIND, ide[2].toString(), 
"{KW,RX}"), graphRows(commandStore, rts, ids, sss, tss, ALL, null, null, 
ide[2], ide2_rows));
+        assertRows(execute(QUERY_TXN_GRAPH_KIND, ide[2].toString(), "{RX}"), 
graphRows(commandStore, rts, ids, sss, tss, TxnKindsAndDomains.parse("{RX}"), 
null, null, ide[2], ide2_rows));
+        assertRows(execute(QUERY_TXN_GRAPH_KIND, ide[2].toString(), "{KW}"), 
graphRows(commandStore, rts, ids, sss, tss, TxnKindsAndDomains.parse("{KW}"), 
null, null, ide[2], ide2_rows));
+        assertRows(execute(QUERY_TXN_GRAPH_INTERSECTS_AND_KIND, 
ide[2].toString(), AccordDebugKeyspace.toString(rta), "{KW}"), 
graphRows(commandStore, rts, ids, sss, tss, TxnKindsAndDomains.parse("{KW}"), 
rta, null, ide[2], ide2_rows));
+        assertRows(execute(QUERY_TXN_GRAPH_INTERSECTS_AND_KIND, 
ide[2].toString(), AccordDebugKeyspace.toString(rtb), "{KW}"), 
graphRows(commandStore, rts, ids, sss, tss, TxnKindsAndDomains.parse("{KW}"), 
rtb, null, ide[2], ide2_rows));
+        assertRows(execute(QUERY_TXN_GRAPH_MIN, ide[2].toString(), 
ida[0].toString()), graphRows(commandStore, rts, ids, sss, tss, ALL, null, 
null, ide[2], ide2_rows));
+        assertRows(execute(QUERY_TXN_GRAPH_MIN, ide[2].toString(), 
ida[1].toString()), graphRows(commandStore, rts, ids, sss, tss, ALL, null, 
ida[1], ide[2], ide2_rows));
+    }
+
+    private static int[] reverse(int[] copy, int stride)
+    {
+        int[] tmp = new int[stride];
+        copy = copy.clone();
+        for (int i = 0 ; i < copy.length/2 ; i += 5)
+        {
+            int j = copy.length - (stride + i);
+            System.arraycopy(copy, i, tmp, 0, stride);
+            System.arraycopy(copy, j, copy, i, stride);
+            System.arraycopy(tmp, 0, copy, j, stride);
+        }
+        return copy;
+    }
+
+    private static Object[][] graphRows(CommandStore commandStore, Txn txn, 
TxnId[] ids, SaveStatus[] saveStatuses, Timestamp[] timestamps, int pk, int ... 
children)
+    {
+        int depth = 0;
+        Object[][] result = new Object[children.length][];
+        int nextParent = Integer.MAX_VALUE;
+        int parent = pk;
+        for (int i = 0 ; i < children.length ; i++)
+        {
+            int child = children[i];
+            if (saveStatuses[child].hasBeen(Status.Committed))
+            {
+                if (i > 0)
+                {
+                    ++depth;
+                    parent = nextParent;
+                }
+                nextParent = child;
+            }
+
+            result[i] = row(ids[pk].toString(), depth, commandStore.id(), 
ids[parent].toString(),
+                            saveStatuses[child].hasBeen(Status.Committed) ? 
timestamps[child].toString() : "",
+                            ids[child].toString(), 
saveStatuses[child].toString(), txn.keys().toParticipants().toString());
+        }
+        return result;
+    }
+
+    private static Object[][] prepend(Object[] prefix, Object[][] rows)
+    {
+        Object[][] result = new Object[rows.length][];
+        for (int i = 0 ; i < result.length ; ++i)
+        {
+            result[i] = new Object[rows[i].length + prefix.length];
+            System.arraycopy(prefix, 0, result[i], 0, prefix.length);
+            System.arraycopy(rows[i], 0, result[i], prefix.length, 
rows[i].length);
+        }
+        return result;
+    }
+
+    private static Object[][] graphRows(CommandStore commandStore, FullRoute[] 
rts,
+                                        TxnId[][] ids, SaveStatus[][] 
saveStatuses, Timestamp[][] timestamps,
+                                        TxnKindsAndDomains kinds, 
Participants<?> intersecting, @Nullable TxnId min,
+                                        TxnId pk, int ... children)
+    {
+        int count = 0;
+        Object[][] result = new Object[children.length/5][];
+        for (int i = 0 ; i < children.length ; i+=5)
+        {
+            int depth = children[i];
+            int parentGroup = children[i + 1];
+            int parent = children[i + 2];
+            int childGroup = children[i + 3];
+            int child = children[i + 4];
+
+            TxnId childId = ids[childGroup][child];
+            TxnId parentId = ids[parentGroup][parent];
+            if (!kinds.matches(childId) || (!kinds.matches(parentId) && 
!parentId.equals(pk)))
+                continue;
+
+            if (intersecting != null && 
!intersecting.intersects(rts[childGroup]))
+                continue;
+
+            if (min != null && min.compareTo(childId) > 0)
+                continue;
+
+            Participants<?> via = 
rts[childGroup].participantsOnly().intersecting(rts[parentGroup], Minimal);
+            if (intersecting != null)
+                via = via.intersecting(intersecting, Minimal);
+
+            result[count++] = row(pk.toString(), depth, commandStore.id(), 
parentId.toString(),
+                                  
saveStatuses[childGroup][child].hasBeen(Status.Committed) ? 
timestamps[childGroup][child].toString() : "",
+                                  childId.toString(), 
saveStatuses[childGroup][child].toString(), via.toString());
+        }
+        if (count != result.length)
+            result = Arrays.copyOf(result, count);
+        return result;
+    }
+
+    private static Timestamp[] toTimestamps(TxnId[] ids)
+    {
+        Timestamp[] ts = new Timestamp[ids.length];
+        System.arraycopy(ids, 0, ts, 0, ids.length);
+        return ts;
+    }
+
+    private static TxnId[] ids(long epoch, Txn.Kind kind, Routable.Domain 
domain, Node.Id id, long ... hlcs)
+    {
+        TxnId[] ids = new TxnId[hlcs.length];
+        for (int i = 0 ; i < hlcs.length ; ++i)
+            ids[i] = new TxnId(epoch, hlcs[i], kind, domain, id);
+        return ids;
+    }
+
+    private static void write(AccordCommandStore commandStore, Command command)
+    {
+        commandStore.journal.saveCommand(commandStore.id(), new 
Journal.CommandUpdate(null, command), ()->{});
+    }
+
+    private static Command committed(FullRoute<?> route, TxnId txnId, 
Timestamp executeAt, Txn txn, TxnId[] ids, int ... deps)
+    {
+        Arrays.sort(deps);
+        try (KeyDeps.Builder keys = KeyDeps.builder(); 
RangeDeps.BuilderByTxnId ranges = RangeDeps.byTxnIdBuilder())
+        {
+            for (int depIndex : deps)
+            {
+                TxnId dep = ids[depIndex];
+                if (dep.is(Routable.Domain.Key)) keys.add(route.homeKey(), 
dep);
+                else ranges.add(route.homeKey().asRange(), dep);
+            }
+            PartialDeps partialDeps = new PartialDeps(route, keys.build(), 
ranges.build());
+            return Command.Committed.committed(txnId, SaveStatus.Committed, 
NotDurable, StoreParticipants.all(route), Ballot.ZERO, executeAt, 
txn.intersecting(route, true), partialDeps, Ballot.ZERO, null);
+        }
+    }
+
+    private static Command committed1(FullRoute<?> route, TxnId txnId, 
Timestamp executeAt, Txn txn, Object ... triples)
+    {
+        try (KeyDeps.Builder keys = KeyDeps.builder(); 
RangeDeps.BuilderByTxnId ranges = RangeDeps.byTxnIdBuilder())
+        {
+            for (int i = 0 ; i < triples.length ; i+= 3)
+            {
+                FullRoute<?> rt = (FullRoute<?>) triples[i];
+                TxnId[] ids = (TxnId[]) triples[i + 1];
+                int[] deps = (int[]) triples[i + 2];
+                for (int depIndex : deps)
+                {
+                    TxnId dep = ids[depIndex];
+                    if (dep.is(Routable.Domain.Key)) keys.add(rt.homeKey(), 
dep);
+                    else
+                    {
+                        for (Range range : rt.toRanges())
+                            ranges.add(range, dep);
+                    }
+                }
+            }
+            PartialDeps partialDeps = new PartialDeps(route, keys.build(), 
ranges.build());
+            return Command.Committed.committed(txnId, SaveStatus.Committed, 
NotDurable, StoreParticipants.all(route), Ballot.ZERO, executeAt, 
txn.intersecting(route, true), partialDeps, Ballot.ZERO, null);
+        }
+    }
+
+    private static Command preaccepted(FullRoute<?> route, TxnId txnId, 
Timestamp executeAt, Txn txn) throws TopologyException
+    {
+        return Command.PreAccepted.preaccepted(txnId, SaveStatus.PreAccepted, 
NotDurable, StoreParticipants.all(route), Ballot.ZERO, executeAt, 
txn.intersecting(route, true), null);
+    }
+
+    @Ignore

Review Comment:
   Should this one be ignored?



##########
src/java/org/apache/cassandra/db/virtual/AccordDebugKeyspace.java:
##########
@@ -2432,4 +2545,48 @@ private static TxnKindsAndDomains 
tryParseTxnKinds(Object input)
 
         return TxnKindsAndDomains.parse((String) input);
     }
+
+    public static Participants<?> parseParticipants(Object input)
+    {
+        if (input == null)
+            return null;
+
+        String str = (String) input;
+        if (str.isEmpty())
+            return RoutingKeys.EMPTY;
+
+        String[] vs = str.split("\\|");
+        if (!vs[0].endsWith("]"))
+        {
+            RoutingKey[] keys = new RoutingKey[vs.length];
+            for (int i = 0 ; i < keys.length ; ++i)
+            {
+                try { keys[i] = TokenKey.parse(vs[i], 
DatabaseDescriptor.getPartitioner()); }
+                catch (Throwable t) { throw new InvalidRequestException("Could 
not parse TokenKey " + vs[0]); }

Review Comment:
   Should this be `vs[i]`? 



##########
src/java/org/apache/cassandra/db/virtual/AccordDebugKeyspace.java:
##########
@@ -2432,4 +2545,48 @@ private static TxnKindsAndDomains 
tryParseTxnKinds(Object input)
 
         return TxnKindsAndDomains.parse((String) input);
     }
+
+    public static Participants<?> parseParticipants(Object input)
+    {
+        if (input == null)
+            return null;
+
+        String str = (String) input;
+        if (str.isEmpty())
+            return RoutingKeys.EMPTY;
+
+        String[] vs = str.split("\\|");
+        if (!vs[0].endsWith("]"))
+        {
+            RoutingKey[] keys = new RoutingKey[vs.length];
+            for (int i = 0 ; i < keys.length ; ++i)
+            {
+                try { keys[i] = TokenKey.parse(vs[i], 
DatabaseDescriptor.getPartitioner()); }
+                catch (Throwable t) { throw new InvalidRequestException("Could 
not parse TokenKey " + vs[0]); }
+            }
+            return RoutingKeys.of(keys);
+        }
+        else
+        {
+            TokenRange[] ranges = new TokenRange[vs.length];
+            for (int i = 0 ; i < ranges.length ; ++i)
+            {
+                try { ranges[i] = TokenRange.parse(vs[i], 
DatabaseDescriptor.getPartitioner()); }
+                catch (Throwable t) { throw new InvalidRequestException("Could 
not parse TokenKey " + vs[0]); }

Review Comment:
   Should this be `vs[i]`? 



##########
src/java/org/apache/cassandra/service/accord/debug/CoordinationKinds.java:
##########
@@ -0,0 +1,78 @@
+/*
+ * 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.service.accord.debug;
+
+import accord.coordinate.Coordination;
+import accord.utils.TinyEnumSet;
+
+public class CoordinationKinds extends 
TinyEnumSet<Coordination.CoordinationKind>
+{
+    private static final int ALL_BITS = 
Coordination.CoordinationKind.ALL.bitset();
+    public static final CoordinationKinds ALL = new CoordinationKinds(false, 
ALL_BITS);
+    public static final CoordinationKinds NONE = new CoordinationKinds(false, 
0);
+
+    final boolean printAsSubtraction;
+
+    public CoordinationKinds(boolean printAsSubtraction, int bitset)
+    {
+        super(bitset);
+        this.printAsSubtraction = printAsSubtraction;
+    }
+
+    @Override
+    public String toString()
+    {
+        if (bitset == ALL_BITS)
+            return "*";
+        if (printAsSubtraction)
+            return '-' + toString(ALL_BITS & ~bitset);
+        return toString(bitset, Coordination.CoordinationKind::forOrdinal);
+    }
+
+    public static CoordinationKinds parse(String input)
+    {
+        input = input.trim();
+        if (input.equals("*"))
+            return ALL;
+        if (input.equals("{}"))
+            return NONE;
+
+        boolean subtraction = false;
+        if (input.length() >= 1 && input.charAt(0) == '-')

Review Comment:
   nit: can we end up with `-{}` ? 



##########
src/java/org/apache/cassandra/metrics/AccordSystemMetrics.java:
##########
@@ -158,6 +159,7 @@ private AccordSystemMetrics()
         errors = Metrics.counter(factory.createMetricName(ERRORS));
         epochTimeouts = 
Metrics.counter(factory.createMetricName(EPOCH_TIMEOUTS));
         epochWaits = Metrics.counter(factory.createMetricName(EPOCH_WAITS));
+        pausedExecutorLoading = 
Metrics.counter(factory.createMetricName(EPOCH_WAITS));

Review Comment:
   Should it have same as the one above?



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