sanpwc commented on code in PR #2978:
URL: https://github.com/apache/ignite-3/pull/2978#discussion_r1435541018


##########
modules/raft-api/src/main/java/org/apache/ignite/internal/raft/service/RaftCommandRunner.java:
##########
@@ -0,0 +1,39 @@
+/*
+ * 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.ignite.internal.raft.service;
+
+import java.util.concurrent.CompletableFuture;
+import org.apache.ignite.internal.raft.Command;
+
+/**
+ * Raft client that is only able to run commands on a Raft group. For a more 
potent interface, take a look at {@link RaftGroupService}.
+ *
+ * @see RaftGroupService
+ */
+public interface RaftCommandRunner {

Review Comment:
   It's fine for now, however in future we will also need to decorate other 
raft client methods like refreshLeader(), addPeer() and others that sends 
messages.



##########
modules/runner/src/main/java/org/apache/ignite/internal/app/ThreadPools.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * 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.ignite.internal.app;
+
+import java.util.concurrent.TimeUnit;
+import org.apache.ignite.internal.logger.IgniteLogger;
+import org.apache.ignite.internal.logger.Loggers;
+import org.apache.ignite.internal.manager.IgniteComponent;
+import org.apache.ignite.internal.thread.LogUncaughtExceptionHandler;
+import org.apache.ignite.internal.thread.NamedThreadFactory;
+import org.apache.ignite.internal.thread.StripedThreadPoolExecutor;
+import org.apache.ignite.internal.util.IgniteUtils;
+
+/**
+ * Component that hosts thread pools which do not belong to a certain 
component and which are global to an Ignite instance.
+ */
+public class ThreadPools implements IgniteComponent {
+    private static final IgniteLogger LOG = 
Loggers.forClass(ThreadPools.class);
+
+    private final StripedThreadPoolExecutor partitionOperationsExecutor;
+
+    /**
+     * Constructor.
+     */
+    public ThreadPools(String nodeName) {
+        partitionOperationsExecutor = new StripedThreadPoolExecutor(
+                Math.min(Runtime.getRuntime().availableProcessors() * 3, 25),
+                NamedThreadFactory.threadPrefix(nodeName, 
"partition-operations"),
+                new LogUncaughtExceptionHandler(LOG),
+                false,
+                0
+        );
+    }
+
+    @Override
+    public void start() {
+        // No-op.
+    }
+
+    @Override
+    public void stop() throws Exception {
+        IgniteUtils.shutdownAndAwaitTermination(partitionOperationsExecutor, 
10, TimeUnit.SECONDS);
+    }
+
+    public StripedThreadPoolExecutor partitionOperationsExecutor() {

Review Comment:
   Same as above. It's a public method of an IgniteComponent, thus from my 
point of view it deserves the javadoc that will clarify the guarantees.



##########
modules/runner/src/main/java/org/apache/ignite/internal/app/IgniteImpl.java:
##########
@@ -213,6 +213,8 @@ public class IgniteImpl implements Ignite {
     /** Lifecycle manager. */
     private final LifecycleManager lifecycleManager;
 
+    private final ThreadPools threadPools;

Review Comment:
   I'd preserve (almost)common naming patter here, meaning that I'd use Manager 
postfix. 



##########
modules/runner/src/main/java/org/apache/ignite/internal/app/IgniteImpl.java:
##########
@@ -821,6 +827,7 @@ public CompletableFuture<Ignite> start(Path configPath) {
                         // Start all other components after the join request 
has completed and the node has been validated.
                         try {
                             lifecycleManager.startComponents(
+                                    threadPools,

Review Comment:
   True for now, but when we will expand thread switching logic to cover meta 
storage it'll be necessary to move it to the "first" components group.



##########
modules/table/src/test/java/org/apache/ignite/internal/table/distributed/schema/ExecutorInclinedSchemaSyncServiceTest.java:
##########
@@ -0,0 +1,148 @@
+/*
+ * 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.ignite.internal.table.distributed.schema;
+
+import static java.util.concurrent.CompletableFuture.completedFuture;
+import static 
org.apache.ignite.internal.testframework.matchers.CompletableFutureCompletedMatcher.completedFuture;
+import static 
org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willCompleteSuccessfully;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.either;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.not;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicReference;
+import org.apache.ignite.internal.hlc.HybridTimestamp;
+import org.apache.ignite.internal.testframework.BaseIgniteAbstractTest;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+
+@ExtendWith(MockitoExtension.class)
+class ExecutorInclinedSchemaSyncServiceTest extends BaseIgniteAbstractTest {

Review Comment:
   I agree that such duplication it's better than test generification for 
raftCommandRunner and scemaSyncService.



##########
modules/replicator/src/main/java/org/apache/ignite/internal/replicator/ReplicaManager.java:
##########
@@ -129,6 +130,8 @@ public class ReplicaManager extends 
AbstractEventProducer<LocalReplicaEvent, Loc
     /** A hybrid logical clock. */
     private final HybridClock clock;
 
+    private final StripedThreadPoolExecutor requestsExecutor;

Review Comment:
   Well, I'd add javadoc that will clarify what guarantees we have.



##########
modules/runner/src/main/java/org/apache/ignite/internal/app/ThreadPools.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * 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.ignite.internal.app;
+
+import java.util.concurrent.TimeUnit;
+import org.apache.ignite.internal.logger.IgniteLogger;
+import org.apache.ignite.internal.logger.Loggers;
+import org.apache.ignite.internal.manager.IgniteComponent;
+import org.apache.ignite.internal.thread.LogUncaughtExceptionHandler;
+import org.apache.ignite.internal.thread.NamedThreadFactory;
+import org.apache.ignite.internal.thread.StripedThreadPoolExecutor;
+import org.apache.ignite.internal.util.IgniteUtils;
+
+/**
+ * Component that hosts thread pools which do not belong to a certain 
component and which are global to an Ignite instance.
+ */
+public class ThreadPools implements IgniteComponent {
+    private static final IgniteLogger LOG = 
Loggers.forClass(ThreadPools.class);
+
+    private final StripedThreadPoolExecutor partitionOperationsExecutor;
+
+    /**
+     * Constructor.
+     */
+    public ThreadPools(String nodeName) {
+        partitionOperationsExecutor = new StripedThreadPoolExecutor(
+                Math.min(Runtime.getRuntime().availableProcessors() * 3, 25),

Review Comment:
   Almost sure, that someday we will add some configuration possibilities here, 
but for now it's fine.



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

Reply via email to