ruanwenjun commented on code in PR #13948:
URL: 
https://github.com/apache/dolphinscheduler/pull/13948#discussion_r1176631213


##########
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/execute/AsyncMasterTaskDelayQueueLooper.java:
##########
@@ -0,0 +1,129 @@
+/*
+ * 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.dolphinscheduler.server.master.runner.execute;
+
+import org.apache.dolphinscheduler.common.thread.BaseDaemonThread;
+import org.apache.dolphinscheduler.common.thread.ThreadUtils;
+import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
+import org.apache.dolphinscheduler.plugin.task.api.utils.LogUtils;
+import org.apache.dolphinscheduler.server.master.config.MasterConfig;
+
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import lombok.extern.slf4j.Slf4j;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Slf4j
+@Component
+public class AsyncMasterTaskDelayQueueLooper extends BaseDaemonThread 
implements AutoCloseable {
+
+    @Autowired
+    private AsyncMasterTaskDelayQueue asyncMasterTaskDelayQueue;
+
+    @Autowired
+    private MasterConfig masterConfig;
+
+    private static final AtomicBoolean RUNNING_FLAG = new AtomicBoolean(false);
+
+    private ExecutorService asyncTaskStateCheckThreadPool;
+
+    public AsyncMasterTaskDelayQueueLooper() {
+        super("AsyncMasterTaskDelayQueueLooper");
+    }
+
+    @Override
+    public synchronized void start() {
+        if (!RUNNING_FLAG.compareAndSet(false, true)) {
+            log.info("The AsyncMasterTaskDelayQueueLooper has already been 
started, will not start again");
+            return;
+        }
+
+        log.info("AsyncMasterTaskDelayQueueLooper starting...");
+        super.start();
+        log.info("AsyncMasterTaskDelayQueueLooper started...");
+    }
+
+    @Override
+    public void run() {
+        asyncTaskStateCheckThreadPool = 
ThreadUtils.newDaemonFixedThreadExecutor("AsyncTaskStateCheckThreadPool",
+                masterConfig.getMasterAsyncTaskStateCheckThreadPoolSize());
+        while (RUNNING_FLAG.get()) {
+            AsyncTaskExecutionContext asyncTaskExecutionContext;
+            try {
+                asyncTaskExecutionContext = 
asyncMasterTaskDelayQueue.pollAsyncTask();
+            } catch (InterruptedException e) {
+                log.info("AsyncConditionTaskLooper has been interrupted, will 
break this loop", e);

Review Comment:
   Done.



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