baiyangtx commented on code in PR #3913:
URL: https://github.com/apache/amoro/pull/3913#discussion_r2502510895


##########
amoro-ams/src/main/java/org/apache/amoro/server/process/metric/SchedulerMetrics.java:
##########
@@ -0,0 +1,57 @@
+/*
+ * 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.amoro.server.process.metric;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Map;
+
+public class SchedulerMetrics {

Review Comment:
   You can skip the metric-related content for now in this PR.



##########
amoro-ams/src/main/java/org/apache/amoro/server/process/executor/BaseEngineActionExecutor.java:
##########
@@ -0,0 +1,71 @@
+/*
+ * 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.amoro.server.process.executor;
+
+import org.apache.amoro.Action;
+import org.apache.amoro.process.ProcessStatus;
+import org.apache.amoro.process.TableProcess;
+import org.apache.amoro.server.process.context.ProcessServiceContext;
+import org.apache.amoro.server.process.resource.RunningInstanceManager;
+
+public abstract class BaseEngineActionExecutor implements Runnable {
+
+  public EngineType engineType;
+  public Action action;
+  protected TableProcess tableProcess;
+
+  public RunningInstanceManager runningInstanceManager;
+
+  public BaseEngineActionExecutor(TableProcess tableProcess) {
+    this.tableProcess = tableProcess;
+  }
+
+  @Override
+  public void run() {
+    
ProcessServiceContext.getRunningInstanceManager().addInstance(tableProcess);
+    try {
+      execute();
+    } finally {
+      
ProcessServiceContext.getRunningInstanceManager().removeInstance(tableProcess);
+    }
+  }
+
+  protected void execute() {
+    initialize();
+    validCheck();
+    doSubmit();
+    ProcessStatus status = waitForJob();
+    completeProcess(status, false);

Review Comment:
   I believe ExecutionEngine defines how to submit tasks and track their status 
in an external system (such as Spark on YARN).



##########
amoro-ams/src/main/java/org/apache/amoro/server/process/service/BaseService.java:
##########
@@ -0,0 +1,28 @@
+/*
+ * 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.amoro.server.process.service;
+
+public interface BaseService {

Review Comment:
   The naming should be consistent with other components in Amoro. 
   
   These classes are essentially threads or thread pools within the 
ProcessService. It is recommended to name them as xx-executor. 
   
   You could even evaluate whether Java's ThreadPoolExecutor or Thread objects 
can be used directly



##########
amoro-ams/src/main/java/org/apache/amoro/server/process/executor/BaseEngineActionExecutor.java:
##########
@@ -0,0 +1,71 @@
+/*
+ * 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.amoro.server.process.executor;
+
+import org.apache.amoro.Action;
+import org.apache.amoro.process.ProcessStatus;
+import org.apache.amoro.process.TableProcess;
+import org.apache.amoro.server.process.context.ProcessServiceContext;
+import org.apache.amoro.server.process.resource.RunningInstanceManager;
+
+public abstract class BaseEngineActionExecutor implements Runnable {
+
+  public EngineType engineType;
+  public Action action;
+  protected TableProcess tableProcess;
+
+  public RunningInstanceManager runningInstanceManager;
+
+  public BaseEngineActionExecutor(TableProcess tableProcess) {
+    this.tableProcess = tableProcess;
+  }
+
+  @Override
+  public void run() {
+    
ProcessServiceContext.getRunningInstanceManager().addInstance(tableProcess);
+    try {
+      execute();
+    } finally {
+      
ProcessServiceContext.getRunningInstanceManager().removeInstance(tableProcess);
+    }
+  }
+
+  protected void execute() {
+    initialize();
+    validCheck();
+    doSubmit();
+    ProcessStatus status = waitForJob();
+    completeProcess(status, false);

Review Comment:
   These should be part of the lifecycle management of TableProcess and should 
belong to the internal logic of ProcessService.
   
   I recommend that ExecutionEngine should expose only the following interfaces:
   
   1. `submitProcess(TableProcess): processIdentifier`  
   This interface returns a process identifier in the external system, such as 
a YARN application ID or similar.
   
   2. `processStatus(processIdentifier): ProcessStatus`  
   Returns the status of the process in the external system.



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