You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@doris.apache.org by GitBox <gi...@apache.org> on 2018/11/21 10:53:46 UTC

[GitHub] morningman commented on a change in pull request #333: Add distributor which allocate task to be fairly

morningman commented on a change in pull request #333: Add distributor which allocate task to be fairly
URL: https://github.com/apache/incubator-doris/pull/333#discussion_r235330761
 
 

 ##########
 File path: fe/src/main/java/org/apache/doris/load/routineload/RoutineLoadTaskScheduler.java
 ##########
 @@ -0,0 +1,97 @@
+// 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.doris.load.routineload;
+
+import org.apache.doris.catalog.Catalog;
+import org.apache.doris.common.util.Daemon;
+import org.apache.doris.task.AgentBatchTask;
+import org.apache.doris.task.AgentTaskExecutor;
+import org.apache.doris.task.AgentTaskQueue;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import java.util.Queue;
+
+/**
+ * Routine load task scheduler is a function which allocate task to be.
+ * Step1: get total idle task num of backends.
+ * Step2: equally divide to be
+ * Step3: submit tasks to be
+ */
+public class RoutineLoadTaskScheduler extends Daemon {
+
+    private static final Logger LOG = LogManager.getLogger(RoutineLoadTaskScheduler.class);
+
+    private RoutineLoad routineLoad = Catalog.getInstance().getRoutineLoadInstance();
+
+    @Override
+    protected void runOneCycle() {
+        // update current beIdMaps for tasks
+        routineLoad.updateBeIdTaskMaps();
+
+        // check timeout tasks
+        routineLoad.processTimeOutTasks();
+
+        // get idle be task num
+        int totalIdleTaskNum = routineLoad.getTotalIdleTaskNum();
+        int allocatedTaskNum = 0;
+        Queue<RoutineLoadTaskInfo> routineLoadTaskList = routineLoad.getNeedSchedulerRoutineLoadTasks();
+        AgentBatchTask batchTask = new AgentBatchTask();
+
+        // allocate task to be
+        while (totalIdleTaskNum > 0) {
+            RoutineLoadTaskInfo routineLoadTaskInfo = routineLoadTaskList.poll();
+            // queue is not empty
+            if (routineLoadTaskInfo != null) {
+                // when routine load task is not abandoned
+                if (routineLoad.getIdToRoutineLoadTask().get(routineLoadTaskInfo.getSignature()) != null) {
 
 Review comment:
   routineLoad.getIdToRoutineLoadTask() is not protected by any locks?
   I think you should review your lock usage, not looking good...
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@doris.apache.org
For additional commands, e-mail: dev-help@doris.apache.org