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


##########
src/java/org/apache/cassandra/tcm/sequences/DropAccordTable.java:
##########
@@ -0,0 +1,364 @@
+/*
+ * 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.sequences;
+
+import java.io.IOException;
+import java.time.Duration;
+import java.util.Objects;
+import java.util.concurrent.ExecutionException;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.cassandra.cql3.ColumnIdentifier;
+import org.apache.cassandra.db.TypeSizes;
+import org.apache.cassandra.io.util.DataInputPlus;
+import org.apache.cassandra.io.util.DataOutputPlus;
+import org.apache.cassandra.schema.Keyspaces;
+import org.apache.cassandra.schema.TableId;
+import org.apache.cassandra.schema.TableMetadata;
+import org.apache.cassandra.service.accord.AccordService;
+import org.apache.cassandra.tcm.ClusterMetadata;
+import org.apache.cassandra.tcm.ClusterMetadataService;
+import org.apache.cassandra.tcm.Epoch;
+import org.apache.cassandra.tcm.MultiStepOperation;
+import org.apache.cassandra.tcm.Transformation;
+import org.apache.cassandra.tcm.serialization.AsymmetricMetadataSerializer;
+import org.apache.cassandra.tcm.serialization.MetadataSerializer;
+import org.apache.cassandra.tcm.serialization.Version;
+import org.apache.cassandra.tcm.transformations.FinishDropAccordTable;
+import org.apache.cassandra.utils.JVMStabilityInspector;
+
+import static java.lang.String.format;
+import static 
org.apache.cassandra.tcm.Transformation.Kind.FINISH_DROP_ACCORD_TABLE;
+import static org.apache.cassandra.tcm.sequences.SequenceState.continuable;
+import static org.apache.cassandra.tcm.sequences.SequenceState.error;
+import static org.apache.cassandra.tcm.sequences.SequenceState.halted;
+import static org.apache.cassandra.utils.Clock.Global.nanoTime;
+
+/**
+ * A slightly atypical implementation as it consists of only a single step. To 
perform the drop of an
+ * Accord table, we first commit a PrepareDropAccordTable transformation. Upon 
enactement, that
+ * marks the table as pending drop, which blocks any new transactions from 
being started. It also
+ * instantiates an instance of this operation and adds it to the set of in 
progress operations.
+ *
+ * The intention is to introduce a barrier which blocks until the Accord 
service acknowledges that
+ * it was learned of the epoch in which the table was marked for deletion and 
that all prior transactions
+ * are completed. Once this is complete, we can proceed to actually drop the 
table. The transformation
+ * which performs that schema modification also removes this MSO from 
ClusterMetadata's in-flight set.
+ * This obviates the need to 'advance' this MSO in the way that other 
implementations with more steps do.
+ *
+ */
+public class DropAccordTable extends MultiStepOperation<Epoch>
+{
+    private static final Logger logger = 
LoggerFactory.getLogger(DropAccordTable.class);
+
+    public static final Serializer serializer = new Serializer();
+
+    public final TableReference table;
+
+    /**
+     * Used by factory method for external callers and by the serializer.
+     * We don't need to include the serialized FinishDropAccordTable step in 
the serialization
+     * of the MSO itself because they have no parameters other than the table 
reference and so
+     * we can just construct a new one when we execute it
+     */
+    private DropAccordTable(TableReference table, Epoch latestModification)
+    {
+        super(0, latestModification);
+        this.table = table;
+    }
+
+    public static DropAccordTable newSequence(TableReference table, Epoch 
preparedAt)
+    {
+        return new DropAccordTable(table, preparedAt);
+    }
+
+    @Override
+    public boolean equals(Object o)
+    {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+        DropAccordTable that = (DropAccordTable) o;
+        return latestModification.equals(that.latestModification)
+               && table.equals(that.table);
+    }
+
+    @Override
+    public int hashCode()
+    {
+        return Objects.hash(latestModification, table);
+    }
+
+    @Override
+    public Kind kind()
+    {
+        return Kind.DROP_ACCORD_TABLE;
+    }
+
+    @Override
+    protected SequenceKey sequenceKey()
+    {
+        return table;
+    }
+
+    @Override
+    public MetadataSerializer<? extends SequenceKey> keySerializer()
+    {
+        return TableReference.serializer;
+    }
+
+    @Override
+    public Transformation.Kind nextStep()
+    {
+        return FINISH_DROP_ACCORD_TABLE;
+    }
+
+    @Override
+    public SequenceState executeNext()
+    {
+        try
+        {
+            SequenceState failure = awaitSafeFromAccord();

Review Comment:
   ok, fair enough. Perhaps we should add a TODO?



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