PakhomovAlexander commented on code in PR #2894:
URL: https://github.com/apache/ignite-3/pull/2894#discussion_r1415753107


##########
modules/compute/src/main/java/org/apache/ignite/internal/compute/state/InMemoryComputeStateMachine.java:
##########
@@ -0,0 +1,163 @@
+/*
+ * 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.compute.state;
+
+import static org.apache.ignite.compute.JobState.CANCELED;
+import static org.apache.ignite.compute.JobState.CANCELING;
+import static org.apache.ignite.compute.JobState.COMPLETED;
+import static org.apache.ignite.compute.JobState.EXECUTING;
+import static org.apache.ignite.compute.JobState.FAILED;
+import static org.apache.ignite.compute.JobState.QUEUED;
+import static 
org.apache.ignite.internal.util.IgniteUtils.shutdownAndAwaitTermination;
+
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+import java.util.function.Function;
+import org.apache.ignite.compute.JobState;
+import org.apache.ignite.internal.compute.configuration.ComputeConfiguration;
+import org.apache.ignite.internal.logger.IgniteLogger;
+import org.apache.ignite.internal.logger.Loggers;
+import org.apache.ignite.internal.thread.NamedThreadFactory;
+
+/**
+ * In memory implementation of {@link ComputeStateMachine}.
+ */
+public class InMemoryComputeStateMachine implements ComputeStateMachine {
+    private static final IgniteLogger LOG = 
Loggers.forClass(InMemoryComputeStateMachine.class);
+
+    private final ComputeConfiguration configuration;
+
+    private ExecutorService cleaner;
+
+    private final Set<UUID> toRemove = new HashSet<>();
+
+    private final Map<UUID, JobState> states = new ConcurrentHashMap<>();
+
+    public InMemoryComputeStateMachine(ComputeConfiguration configuration) {
+        this.configuration = configuration;
+    }
+
+    @Override
+    public void start() {
+        Long lifetime = configuration.statesLifetimeMillis().value();
+        ScheduledExecutorService result = 
Executors.newSingleThreadScheduledExecutor(
+                new NamedThreadFactory("InMemoryComputeStateMachine-pool", LOG)
+        );
+        result.scheduleAtFixedRate(() -> {

Review Comment:
   why is the name of the executor `result`? Could you rename it?



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