ekaterinadimitrova2 commented on code in PR #2807:
URL: https://github.com/apache/cassandra/pull/2807#discussion_r1375129388


##########
src/java/org/apache/cassandra/tcm/Commit.java:
##########
@@ -0,0 +1,429 @@
+/*
+ * 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;
+
+import java.io.IOException;
+import java.util.function.BiConsumer;
+import java.util.function.Supplier;
+
+import com.google.common.annotations.VisibleForTesting;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.cassandra.db.TypeSizes;
+import org.apache.cassandra.exceptions.ExceptionCode;
+import org.apache.cassandra.io.IVersionedSerializer;
+import org.apache.cassandra.io.util.DataInputPlus;
+import org.apache.cassandra.io.util.DataOutputPlus;
+import org.apache.cassandra.locator.InetAddressAndPort;
+import org.apache.cassandra.metrics.TCMMetrics;
+import org.apache.cassandra.tcm.log.Replication;
+import org.apache.cassandra.tcm.membership.NodeVersion;
+import org.apache.cassandra.tcm.serialization.Version;
+import org.apache.cassandra.net.*;
+import org.apache.cassandra.tcm.membership.Directory;
+import org.apache.cassandra.tcm.membership.NodeId;
+import org.apache.cassandra.tcm.log.Entry;
+import org.apache.cassandra.utils.FBUtilities;
+import org.apache.cassandra.utils.vint.VIntCoding;
+
+import static org.apache.cassandra.tcm.ClusterMetadataService.State.*;
+
+/**
+ * Commit request send by a {@code RemoteProcessor} from a non-CMS node.
+ *
+ */
+public class Commit
+{
+    private static final Logger logger = LoggerFactory.getLogger(Commit.class);
+
+    public static final IVersionedSerializer<Commit> defaultMessageSerializer 
= new Serializer(NodeVersion.CURRENT.serializationVersion());
+
+    private static volatile Serializer serializerCache;
+    public static IVersionedSerializer<Commit> messageSerializer(Version 
version)
+    {
+        Serializer cached = serializerCache;
+        if (cached != null && cached.serializationVersion.equals(version))
+            return cached;
+        cached = new Serializer(version);
+        serializerCache = cached;
+        return cached;
+    }
+
+    private final Entry.Id entryId;
+    private final Transformation transform;
+    private final Epoch lastKnown;
+
+    public Commit(Entry.Id entryId, Transformation transform, Epoch lastKnown)
+    {
+        this.entryId = entryId;
+        this.transform = transform;
+        this.lastKnown = lastKnown;
+    }
+
+    public String toString()
+    {
+        return "Commit{" +
+               "transformation=" + transform +
+               ", lastKnown=" + lastKnown +
+               '}';
+    }
+
+    static class Serializer implements IVersionedSerializer<Commit>
+    {
+        private final Version serializationVersion;
+
+        public Serializer(Version serializationVersion)
+        {
+            this.serializationVersion = serializationVersion;
+        }
+
+        public void serialize(Commit t, DataOutputPlus out, int version) 
throws IOException
+        {
+            out.writeInt(serializationVersion.asInt());
+            Entry.Id.serializer.serialize(t.entryId, out, 
serializationVersion);
+            Transformation.serializer.serialize(t.transform, out, 
serializationVersion);
+            Epoch.serializer.serialize(t.lastKnown, out, serializationVersion);
+        }
+
+        public Commit deserialize(DataInputPlus in, int version) throws 
IOException
+        {
+            Version deserializationVersion = Version.fromInt(in.readInt());
+            Entry.Id entryId = Entry.Id.serializer.deserialize(in, 
deserializationVersion);
+            Transformation transform = 
Transformation.serializer.deserialize(in, deserializationVersion);
+            Epoch lastKnown = Epoch.serializer.deserialize(in, 
deserializationVersion);
+            return new Commit(entryId, transform, lastKnown);
+        }
+
+        public long serializedSize(Commit t, int version)
+        {
+            return TypeSizes.sizeof(serializationVersion.asInt()) +
+                   Transformation.serializer.serializedSize(t.transform, 
serializationVersion) +
+                   Entry.Id.serializer.serializedSize(t.entryId, 
serializationVersion) +
+                   Epoch.serializer.serializedSize(t.lastKnown, 
serializationVersion);
+        }
+    }
+
+    static volatile Result.Serializer resultSerializerCache;
+    public static interface Result

Review Comment:
   ```suggestion
       public interface Result
   ```



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