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


##########
src/java/org/apache/cassandra/service/accord/FetchMinEpoch.java:
##########
@@ -0,0 +1,150 @@
+/*
+ * 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.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.annotation.Nullable;
+
+import org.apache.cassandra.db.TypeSizes;
+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.net.IVerbHandler;
+import org.apache.cassandra.net.Message;
+import org.apache.cassandra.net.MessageDelivery;
+import org.apache.cassandra.net.MessagingService;
+import org.apache.cassandra.net.Verb;
+import org.apache.cassandra.utils.concurrent.Future;
+import org.apache.cassandra.utils.concurrent.FutureCombiner;
+
+public class FetchMinEpoch
+{
+    public static final IVersionedSerializer<FetchMinEpoch> serializer = new 
IVersionedSerializer<>()
+    {
+
+        @Override
+        public void serialize(FetchMinEpoch t, DataOutputPlus out, int 
version) throws IOException
+        {
+            out.writeUnsignedVInt32(t.ranges.size());
+            for (TokenRange range : t.ranges)
+                TokenRange.serializer.serialize(range, out, version);
+        }
+
+        @Override
+        public FetchMinEpoch deserialize(DataInputPlus in, int version) throws 
IOException
+        {
+            int size = in.readUnsignedVInt32();
+            List<TokenRange> ranges = new ArrayList<>(size);
+            for (int i = 0; i < size; i++)
+                ranges.add(TokenRange.serializer.deserialize(in, version));
+            return new FetchMinEpoch(ranges);
+        }
+
+        @Override
+        public long serializedSize(FetchMinEpoch t, int version)
+        {
+            int size = TypeSizes.sizeofUnsignedVInt(t.ranges.size());
+            for (TokenRange range : t.ranges)
+                size += TokenRange.serializer.serializedSize(range, version);
+            return size;
+        }
+    };
+    public static final IVerbHandler<FetchMinEpoch> handler = new 
IVerbHandler<FetchMinEpoch>()
+    {
+        @Override
+        public void doVerb(Message<FetchMinEpoch> message) throws IOException
+        {
+            Long epoch = 
AccordService.instance().minEpoch(message.payload.ranges);
+            MessagingService.instance().respond(new Response(epoch), message);
+        }
+    };
+    private final Collection<TokenRange> ranges;
+
+    public FetchMinEpoch(Collection<TokenRange> ranges)
+    {
+        this.ranges = ranges;
+    }
+
+    public static Future<Long> fetch(MessageDelivery messaging, 
Map<InetAddressAndPort, Set<TokenRange>> peers)

Review Comment:
   pushed this change.  I did a few refactors:
   
   1) TCM and Repair's logic were super similar but subtly different... I tried 
to create a new `MessageDelivery.sendWithRetries` method that supported both 
cases and replaced both
   2) epoch fetch now uses this new `MessageDelivery.sendWithRetries`
   3) Testing extracted (but didn't modify... this patch is already giant) 
Repair's and EpochSyncTest simulated cluster logic and made it a reusable 
class... this let me test the new fetch logic with/without failures in 
simulation quickly.



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