You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@cassandra.apache.org by "aweisberg (via GitHub)" <gi...@apache.org> on 2023/04/10 18:28:45 UTC

[GitHub] [cassandra] aweisberg commented on a diff in pull request #2245: CASSANDRA-18364: CEP-15: (C*) Accord message processing should avoid being passed on to a Stage and run directly in the messageing handler

aweisberg commented on code in PR #2245:
URL: https://github.com/apache/cassandra/pull/2245#discussion_r1156297664


##########
src/java/org/apache/cassandra/service/accord/AccordCallback.java:
##########
@@ -32,18 +34,18 @@
 class AccordCallback<T extends Reply> implements RequestCallback<T>
 {
     private static final Logger logger = LoggerFactory.getLogger(AccordCallback.class);
-    private final Callback<T> callback;
+    private final SafeCallback<T> callback;

Review Comment:
   Extends safe callback instead of allocating an another object?



##########
src/java/org/apache/cassandra/config/PositiveInt.java:
##########
@@ -0,0 +1,88 @@
+/*
+ * 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.config;
+
+import java.util.Objects;
+import java.util.function.IntSupplier;
+
+public class PositiveInt
+{
+    public final int value;
+
+    public PositiveInt(int value)
+    {
+        if (value < 1)
+            throw new IllegalArgumentException(String.format("Only positive values are allowed; given %d", value));
+        this.value = value;
+    }
+
+    private PositiveInt(int value, boolean ignored)
+    {
+        this.value = value;
+    }
+
+    @Override
+    public String toString()
+    {
+        return Integer.toString(value);
+    }
+
+    @Override
+    public boolean equals(Object o)
+    {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+        PositiveInt that = (PositiveInt) o;
+        return value == that.value;
+    }
+
+    @Override
+    public int hashCode()
+    {
+        return Objects.hash(value);
+    }
+
+    public static class UndefinedPositiveInt extends PositiveInt

Review Comment:
   Why have a base class `PositiveInt` and a separate derived `UndefinedPositiveInt`?
   
   It doesn't encapsulate and hide the base class `value` (like say `Optional`) so maybe collapse it to just one class?



##########
test/simulator/main/org/apache/cassandra/simulator/systems/SimulatedAction.java:
##########
@@ -382,8 +382,11 @@ List<Action> applyToMessage(IInvokableInstance from, IInvokableInstance to, IMes
                     notify = from;
                 }
                 boolean isTimeout = deliver != FAILURE;
+                Executor notifierExecutor = notify.executorFor(verb.id);
+                if (notifierExecutor instanceof ImmediateExecutor)

Review Comment:
   Why is this unwrapping necessary? Worth a comment?



##########
test/simulator/main/org/apache/cassandra/simulator/paxos/PaxosSimulation.java:
##########
@@ -286,19 +288,39 @@ RuntimeException failWith(Throwable t)
 
     private RuntimeException logAndThrow()

Review Comment:
   This doesn't return a RuntimeException, but I know it can also be handy for this kind of method to return something to throw so in the calling method the compiler knows execution stops there.



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org