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


##########
src/java/org/apache/cassandra/service/accord/AccordExecutorLoops.java:
##########
@@ -19,83 +19,70 @@
 package org.apache.cassandra.service.accord;
 
 import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
 import java.util.function.Function;
 import java.util.function.IntFunction;
 
 import accord.utils.Invariants;
 import org.agrona.collections.LongHashSet;
-import org.apache.cassandra.concurrent.InfiniteLoopExecutor;
-import org.apache.cassandra.concurrent.Interruptible;
-import org.apache.cassandra.concurrent.Shutdownable;
 import org.apache.cassandra.service.accord.AccordExecutor.Mode;
+import org.apache.cassandra.utils.concurrent.Condition;
 
 import static 
org.apache.cassandra.concurrent.ExecutorFactory.Global.executorFactory;
-import static 
org.apache.cassandra.concurrent.InfiniteLoopExecutor.Daemon.NON_DAEMON;
-import static 
org.apache.cassandra.concurrent.InfiniteLoopExecutor.Interrupts.UNSYNCHRONIZED;
-import static 
org.apache.cassandra.concurrent.InfiniteLoopExecutor.SimulatorSafe.SAFE;
 import static 
org.apache.cassandra.service.accord.AccordExecutor.Mode.RUN_WITH_LOCK;
 import static org.apache.cassandra.utils.Clock.Global.nanoTime;
 
-class AccordExecutorInfiniteLoops implements Shutdownable
+class AccordExecutorLoops

Review Comment:
   Looking closer this class is only used by: `AccordExecutorAsyncSubmit`, 
`AccordExecutorSemiSyncSubmit`, `AccordExecutorSyncSubmit`.  So this class 
really doesn't care about directly being shutdown



##########
src/java/org/apache/cassandra/service/accord/AccordExecutorLoops.java:
##########
@@ -19,83 +19,70 @@
 package org.apache.cassandra.service.accord;
 
 import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
 import java.util.function.Function;
 import java.util.function.IntFunction;
 
 import accord.utils.Invariants;
 import org.agrona.collections.LongHashSet;
-import org.apache.cassandra.concurrent.InfiniteLoopExecutor;
-import org.apache.cassandra.concurrent.Interruptible;
-import org.apache.cassandra.concurrent.Shutdownable;
 import org.apache.cassandra.service.accord.AccordExecutor.Mode;
+import org.apache.cassandra.utils.concurrent.Condition;
 
 import static 
org.apache.cassandra.concurrent.ExecutorFactory.Global.executorFactory;
-import static 
org.apache.cassandra.concurrent.InfiniteLoopExecutor.Daemon.NON_DAEMON;
-import static 
org.apache.cassandra.concurrent.InfiniteLoopExecutor.Interrupts.UNSYNCHRONIZED;
-import static 
org.apache.cassandra.concurrent.InfiniteLoopExecutor.SimulatorSafe.SAFE;
 import static 
org.apache.cassandra.service.accord.AccordExecutor.Mode.RUN_WITH_LOCK;
 import static org.apache.cassandra.utils.Clock.Global.nanoTime;
 
-class AccordExecutorInfiniteLoops implements Shutdownable
+class AccordExecutorLoops

Review Comment:
   can you explain why you moved away from `implements Shutdownable`?  During 
shutdown we don't look to directly tell this class anymore that we are shutting 
down, and we hope that each thread was told to shutdown; this feels like it 
should cause stability issues during `nodetool drain` and jvm-dtest shutdown no?



##########
src/java/org/apache/cassandra/service/accord/AccordExecutorAbstractLockLoop.java:
##########
@@ -266,4 +273,18 @@ protected void runWithoutLock(Interruptible.State state) 
throws InterruptedExcep
             }
         }
     }
+
+    @Override
+    public void shutdown()
+    {
+        shutdown = true;
+        notifyWorkExclusive();
+    }
+
+    @Override
+    public Object shutdownNow()
+    {
+        shutdown();
+        return null;

Review Comment:
   isn't the semantics that we don't to drop the backlog, yet this abstract 
class looks to push that to each implementation.  In the locking case we only 
check if its shutdown if we get a `null` task.



##########
src/java/org/apache/cassandra/service/accord/AccordExecutorLoops.java:
##########
@@ -19,83 +19,70 @@
 package org.apache.cassandra.service.accord;
 
 import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
 import java.util.function.Function;
 import java.util.function.IntFunction;
 
 import accord.utils.Invariants;
 import org.agrona.collections.LongHashSet;
-import org.apache.cassandra.concurrent.InfiniteLoopExecutor;
-import org.apache.cassandra.concurrent.Interruptible;
-import org.apache.cassandra.concurrent.Shutdownable;
 import org.apache.cassandra.service.accord.AccordExecutor.Mode;
+import org.apache.cassandra.utils.concurrent.Condition;
 
 import static 
org.apache.cassandra.concurrent.ExecutorFactory.Global.executorFactory;
-import static 
org.apache.cassandra.concurrent.InfiniteLoopExecutor.Daemon.NON_DAEMON;
-import static 
org.apache.cassandra.concurrent.InfiniteLoopExecutor.Interrupts.UNSYNCHRONIZED;
-import static 
org.apache.cassandra.concurrent.InfiniteLoopExecutor.SimulatorSafe.SAFE;
 import static 
org.apache.cassandra.service.accord.AccordExecutor.Mode.RUN_WITH_LOCK;
 import static org.apache.cassandra.utils.Clock.Global.nanoTime;
 
-class AccordExecutorInfiniteLoops implements Shutdownable
+class AccordExecutorLoops
 {
-    private final Interruptible[] loops;
+    private final Thread[] loops;
     private final LongHashSet threadIds;
 
-    public AccordExecutorInfiniteLoops(Mode mode, int threads, 
IntFunction<String> name, Function<Mode, Interruptible.Task> tasks)
+    private final AtomicInteger running = new AtomicInteger();
+    private final Condition terminated = Condition.newOneTimeCondition();
+
+    public AccordExecutorLoops(Mode mode, int threads, IntFunction<String> 
name, Function<Mode, Runnable> tasks)

Review Comment:
   given that this class no longer `Loops` this name feels off to me.  We 
define that there are `N` threads, and we are done w/e all `N` finish running 
their `task`.  This class doesn't really have anything to do with "looping", 
nor does it enforce that the sub-tasks are looped (old logic did enforce this)



-- 
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-unsubscr...@cassandra.apache.org

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


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

Reply via email to