BePPPower commented on code in PR #21916: URL: https://github.com/apache/doris/pull/21916#discussion_r1279268048
########## fe/fe-core/src/main/java/org/apache/doris/scheduler/registry/MemoryTaskRegister.java: ########## @@ -0,0 +1,31 @@ +// 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.scheduler.registry; + +import org.apache.doris.scheduler.executor.MemoryTaskExecutor; + +/** + * todo + * Support in-memory job registration in the future + */ +public interface MemoryTaskRegister { + + Long registerTask(MemoryTaskExecutor executor); + + void cancelTask(Long taskId); +} Review Comment: Should we need add function: `boolean isTaskWaiting(Long taskId)` `boolean isTaskFinish(Long taskId)` ? ########## fe/fe-core/src/main/java/org/apache/doris/scheduler/manager/JobTaskManager.java: ########## @@ -15,55 +15,87 @@ // specific language governing permissions and limitations // under the License. -package org.apache.doris.scheduler.job; +package org.apache.doris.scheduler.manager; import org.apache.doris.catalog.Env; +import org.apache.doris.common.Config; import org.apache.doris.common.io.Writable; import org.apache.doris.common.util.LogBuilder; import org.apache.doris.common.util.LogKey; +import org.apache.doris.scheduler.job.JobTask; import lombok.extern.slf4j.Slf4j; import java.io.DataInput; import java.io.DataOutput; import java.io.IOException; +import java.util.ArrayList; import java.util.Collections; import java.util.LinkedList; +import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentLinkedQueue; @Slf4j public class JobTaskManager implements Writable { - private ConcurrentHashMap<Long, LinkedList<JobTask>> jobTaskMap = new ConcurrentHashMap<>(16); + private static final Integer TASK_MAX_NUM = Config.scheduler_job_task_max_num; + + private ConcurrentHashMap<Long, ConcurrentLinkedQueue<JobTask>> jobTaskMap = new ConcurrentHashMap<>(16); public void addJobTask(JobTask jobTask) { - LinkedList<JobTask> jobTasks = jobTaskMap.computeIfAbsent(jobTask.getJobId(), k -> new LinkedList<>()); + ConcurrentLinkedQueue<JobTask> jobTasks = jobTaskMap + .computeIfAbsent(jobTask.getJobId(), k -> new ConcurrentLinkedQueue<>()); jobTasks.add(jobTask); + if (jobTasks.size() > TASK_MAX_NUM) { + JobTask oldTak = jobTasks.poll(); Review Comment: oldTak -> oldTask ? -- 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: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org