You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by "zddr (via GitHub)" <gi...@apache.org> on 2023/06/29 02:39:40 UTC

[GitHub] [doris] zddr commented on a diff in pull request #21113: [Feature](Job)Provide unified internal Job scheduling

zddr commented on code in PR #21113:
URL: https://github.com/apache/doris/pull/21113#discussion_r1245276698


##########
fe/fe-core/src/main/java/org/apache/doris/scheduler/AsyncJobRegister.java:
##########
@@ -0,0 +1,82 @@
+// 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;
+
+import org.apache.doris.scheduler.executor.JobExecutor;
+import org.apache.doris.scheduler.job.AsyncJobManager;
+import org.apache.doris.scheduler.job.Job;
+import org.apache.doris.scheduler.registry.JobRegister;
+
+import lombok.extern.slf4j.Slf4j;
+
+import java.io.IOException;
+
+/**
+ * This class registers timed scheduling events using the Netty time wheel algorithm to trigger events in a timely
+ * manner.
+ * After the event is triggered, it is produced by the Disruptor producer and consumed by the consumer, which is an
+ * asynchronous
+ * consumption model that does not guarantee strict timing accuracy.
+ */
+@Slf4j
+public class AsyncJobRegister implements JobRegister {
+
+    private final AsyncJobManager asyncJobManager;
+
+    public AsyncJobRegister() {
+        this.asyncJobManager = new AsyncJobManager();
+    }
+
+    @Override
+    public Long registerJob(String name, Long intervalMs, JobExecutor executor) {
+        return this.registerJob(name, intervalMs, null, null, executor);
+    }
+
+    @Override
+    public Long registerJob(String name, Long intervalMs, Long startTimeStamp, JobExecutor executor) {
+        return this.registerJob(name, intervalMs, startTimeStamp, null, executor);
+    }
+
+    @Override
+    public Long registerJob(String name, Long intervalMs, Long startTimeStamp, Long endTimeStamp,
+                                 JobExecutor executor) {
+
+        Job job = new Job(name, intervalMs, startTimeStamp, endTimeStamp, executor);
+        return asyncJobManager.registerJob(job);
+    }
+
+    @Override
+    public Boolean pauseJob(Long jobId) {
+        return asyncJobManager.pauseJob(jobId);
+    }
+
+    @Override
+    public Boolean stopJob(Long jobId) {
+        return asyncJobManager.stopJob(jobId);

Review Comment:
   if we need some log?The same goes for other methods



##########
fe/fe-core/src/main/java/org/apache/doris/scheduler/AsyncJobRegister.java:
##########
@@ -0,0 +1,82 @@
+// 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;
+
+import org.apache.doris.scheduler.executor.JobExecutor;
+import org.apache.doris.scheduler.job.AsyncJobManager;
+import org.apache.doris.scheduler.job.Job;
+import org.apache.doris.scheduler.registry.JobRegister;
+
+import lombok.extern.slf4j.Slf4j;
+
+import java.io.IOException;
+
+/**
+ * This class registers timed scheduling events using the Netty time wheel algorithm to trigger events in a timely
+ * manner.
+ * After the event is triggered, it is produced by the Disruptor producer and consumed by the consumer, which is an
+ * asynchronous
+ * consumption model that does not guarantee strict timing accuracy.
+ */
+@Slf4j
+public class AsyncJobRegister implements JobRegister {
+
+    private final AsyncJobManager asyncJobManager;
+
+    public AsyncJobRegister() {
+        this.asyncJobManager = new AsyncJobManager();
+    }
+
+    @Override
+    public Long registerJob(String name, Long intervalMs, JobExecutor executor) {

Review Comment:
   once job how to regist?



##########
fe/fe-core/src/main/java/org/apache/doris/scheduler/AsyncJobRegister.java:
##########
@@ -0,0 +1,82 @@
+// 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;
+
+import org.apache.doris.scheduler.executor.JobExecutor;
+import org.apache.doris.scheduler.job.AsyncJobManager;
+import org.apache.doris.scheduler.job.Job;
+import org.apache.doris.scheduler.registry.JobRegister;
+
+import lombok.extern.slf4j.Slf4j;
+
+import java.io.IOException;
+
+/**
+ * This class registers timed scheduling events using the Netty time wheel algorithm to trigger events in a timely
+ * manner.
+ * After the event is triggered, it is produced by the Disruptor producer and consumed by the consumer, which is an
+ * asynchronous
+ * consumption model that does not guarantee strict timing accuracy.
+ */
+@Slf4j
+public class AsyncJobRegister implements JobRegister {
+
+    private final AsyncJobManager asyncJobManager;
+
+    public AsyncJobRegister() {
+        this.asyncJobManager = new AsyncJobManager();
+    }
+
+    @Override
+    public Long registerJob(String name, Long intervalMs, JobExecutor executor) {
+        return this.registerJob(name, intervalMs, null, null, executor);
+    }
+
+    @Override
+    public Long registerJob(String name, Long intervalMs, Long startTimeStamp, JobExecutor executor) {
+        return this.registerJob(name, intervalMs, startTimeStamp, null, executor);
+    }
+
+    @Override
+    public Long registerJob(String name, Long intervalMs, Long startTimeStamp, Long endTimeStamp,

Review Comment:
   if we need  a job type,convenient access to all jobs of a type, such as materialized views 



##########
fe/fe-core/src/main/java/org/apache/doris/scheduler/constants/JobStatus.java:
##########
@@ -0,0 +1,38 @@
+// 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.constants;
+
+public enum JobStatus {
+
+    /**
+     * When the task is not started, the initial state will be triggered.
+     * The initial state can be started
+     */
+    RUNNING,

Review Comment:
   Missing initialization and completion status?



-- 
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-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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