beobal commented on code in PR #3426:
URL: https://github.com/apache/cassandra/pull/3426#discussion_r1701457256


##########
src/java/org/apache/cassandra/tcm/transformations/AccordMarkStale.java:
##########
@@ -0,0 +1,119 @@
+/*
+ * 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.tcm.transformations;
+
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import accord.local.Node;
+import accord.topology.Shard;
+import org.apache.cassandra.io.util.DataInputPlus;
+import org.apache.cassandra.io.util.DataOutputPlus;
+import org.apache.cassandra.schema.KeyspaceMetadata;
+import org.apache.cassandra.schema.SchemaConstants;
+import org.apache.cassandra.service.accord.AccordTopology;
+import org.apache.cassandra.tcm.ClusterMetadata;
+import org.apache.cassandra.tcm.Transformation;
+import org.apache.cassandra.tcm.membership.NodeId;
+import org.apache.cassandra.tcm.sequences.LockedRanges;
+import org.apache.cassandra.tcm.serialization.AsymmetricMetadataSerializer;
+import org.apache.cassandra.tcm.serialization.Version;
+
+import static org.apache.cassandra.exceptions.ExceptionCode.INVALID;
+
+public class AccordMarkStale implements Transformation
+{
+
+    private final NodeId tcmId;
+
+    public AccordMarkStale(NodeId tcmId)
+    {
+        this.tcmId = tcmId;

Review Comment:
   Can we just name this `id` or `nodeId` please?



##########
src/java/org/apache/cassandra/tcm/transformations/AccordMarkStale.java:
##########
@@ -0,0 +1,119 @@
+/*
+ * 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.tcm.transformations;
+
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import accord.local.Node;
+import accord.topology.Shard;
+import org.apache.cassandra.io.util.DataInputPlus;
+import org.apache.cassandra.io.util.DataOutputPlus;
+import org.apache.cassandra.schema.KeyspaceMetadata;
+import org.apache.cassandra.schema.SchemaConstants;
+import org.apache.cassandra.service.accord.AccordTopology;
+import org.apache.cassandra.tcm.ClusterMetadata;
+import org.apache.cassandra.tcm.Transformation;
+import org.apache.cassandra.tcm.membership.NodeId;
+import org.apache.cassandra.tcm.sequences.LockedRanges;
+import org.apache.cassandra.tcm.serialization.AsymmetricMetadataSerializer;
+import org.apache.cassandra.tcm.serialization.Version;
+
+import static org.apache.cassandra.exceptions.ExceptionCode.INVALID;
+
+public class AccordMarkStale implements Transformation
+{
+
+    private final NodeId tcmId;

Review Comment:
   I would suggest making this a collection of ids so that we can mark multiple 
nodes stale in a single operation. The obvious side effect of that is that it 
becomes all or nothing, so any condition which causes the transformation to be 
rejected will mean none of the ids are marked stale. This is probably better 
than the current state though as a rejection mid-way through the iteration in 
`CMSOperations::accordMarkStale` would mean you'd need to query metadata to 
figure out which nodes where successfully marked stale.



##########
src/java/org/apache/cassandra/tcm/serialization/Version.java:
##########
@@ -37,6 +37,7 @@ public enum Version
      *  - Added version to PlacementForRange serializer
      *  - Serialize MemtableParams when serializing TableParams
      *  - Added AccordFastPath
+     *  - Added StaleReplicas

Review Comment:
   Just a note: if there are any deployments out there, adding elements without 
actually bumping the version is likely to break them. Of course, this is not a 
released version yet so there isn't any guarantee that we won't do that but we 
will need to bump it prior to merging to trunk. 



##########
src/java/org/apache/cassandra/tcm/compatibility/GossipHelper.java:
##########
@@ -286,7 +287,8 @@ public static ClusterMetadata 
emptyWithSchemaFromSystemTables(Set<String> allKno
                                    LockedRanges.EMPTY,
                                    InProgressSequences.EMPTY,
                                    ConsensusMigrationState.EMPTY,
-                                   Collections.emptyMap());
+                                   Collections.emptyMap(),
+                                                  StaleReplicas.EMPTY);

Review Comment:
   nit: alignment



##########
src/java/org/apache/cassandra/tcm/compatibility/GossipHelper.java:
##########
@@ -358,7 +360,8 @@ public static ClusterMetadata 
fromEndpointStates(Map<InetAddressAndPort, Endpoin
                                                                       
LockedRanges.EMPTY,
                                                                       
InProgressSequences.EMPTY,
                                                                       
ConsensusMigrationState.EMPTY,
-                                                                      
extensions);
+                                                                      
extensions,
+                                                                               
                      StaleReplicas.EMPTY);

Review Comment:
   nit: alignment



##########
src/java/org/apache/cassandra/service/accord/StaleReplicas.java:
##########
@@ -0,0 +1,111 @@
+/*
+ * 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;
+
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.annotation.concurrent.Immutable;
+
+import com.google.common.collect.ImmutableSet;
+
+import accord.local.Node;
+import org.apache.cassandra.io.util.DataInputPlus;
+import org.apache.cassandra.io.util.DataOutputPlus;
+import org.apache.cassandra.service.accord.serializers.TopologySerializers;
+import org.apache.cassandra.tcm.Epoch;
+import org.apache.cassandra.tcm.MetadataValue;
+import org.apache.cassandra.tcm.serialization.MetadataSerializer;
+import org.apache.cassandra.tcm.serialization.Version;
+import org.apache.cassandra.utils.CollectionSerializers;
+
+@Immutable
+public class StaleReplicas implements MetadataValue<StaleReplicas>

Review Comment:
   It would be nice to name this `AccordStaleReplicas` to give a bit more 
context when looking at code outside this package (e.g. in `ClusterMetadata` 
itself). c.f. `AccordFastPath`



##########
src/java/org/apache/cassandra/tcm/ClusterMetadata.java:
##########
@@ -98,6 +99,8 @@ public class ClusterMetadata
     public final InProgressSequences inProgressSequences;
     public final ConsensusMigrationState consensusMigrationState;
     public final ImmutableMap<ExtensionKey<?,?>, ExtensionValue<?>> extensions;
+    

Review Comment:
   nit: additional newline



##########
src/java/org/apache/cassandra/tcm/CMSOperations.java:
##########
@@ -243,4 +244,16 @@ public void unregisterLeftNodes(List<String> nodeIdStrings)
             cms.commit(new Unregister(nodeId, EnumSet.of(NodeState.LEFT)));
         }
     }
+
+    @Override
+    public void accordMarkStale(List<String> nodeIdStrings)
+    {
+        List<NodeId> nodeIds = 
nodeIdStrings.stream().map(NodeId::fromString).collect(Collectors.toList());
+
+        for (NodeId nodeId : nodeIds)

Review Comment:
   This is going to bump the epoch for each node in the list. I left a more 
detailed comment on `AccordMarkStale` but tl;dr I would make the transformation 
mark them all stale in one hit.



##########
src/java/org/apache/cassandra/tools/NodeTool.java:
##########
@@ -262,7 +262,8 @@ public int execute(String... args)
                .withCommand(CMSAdmin.InitializeCMS.class)
                .withCommand(CMSAdmin.ReconfigureCMS.class)
                .withCommand(CMSAdmin.Snapshot.class)
-               .withCommand(CMSAdmin.Unregister.class);
+               .withCommand(CMSAdmin.Unregister.class)
+               .withCommand(AccordAdmin.MarkStaleCmd.class);

Review Comment:
   This shouldn't be here



##########
src/java/org/apache/cassandra/tcm/ClusterMetadata.java:
##########
@@ -169,7 +175,8 @@ private ClusterMetadata(int metadataIdentifier,
                            LockedRanges lockedRanges,
                            InProgressSequences inProgressSequences,
                            ConsensusMigrationState consensusMigrationState,
-                           Map<ExtensionKey<?, ?>, ExtensionValue<?>> 
extensions)
+                           Map<ExtensionKey<?, ?>, ExtensionValue<?>> 
extensions,
+                            StaleReplicas staleReplicas)

Review Comment:
   nit: alignment



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