You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by "SbloodyS (via GitHub)" <gi...@apache.org> on 2023/05/06 09:06:56 UTC

[GitHub] [dolphinscheduler] SbloodyS commented on a diff in pull request #14055: [Improvement-14054][Worker] Kill multiple yarn apps at the same time

SbloodyS commented on code in PR #14055:
URL: https://github.com/apache/dolphinscheduler/pull/14055#discussion_r1186667963


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/am/YarnApplicationManager.java:
##########
@@ -19,56 +19,38 @@
 
 import org.apache.dolphinscheduler.common.constants.Constants;
 import org.apache.dolphinscheduler.common.enums.ResourceManagerType;
-import org.apache.dolphinscheduler.common.utils.HttpUtils;
-import org.apache.dolphinscheduler.common.utils.JSONUtils;
-import org.apache.dolphinscheduler.common.utils.KerberosHttpClient;
 import org.apache.dolphinscheduler.common.utils.PropertyUtils;
 import org.apache.dolphinscheduler.plugin.task.api.TaskException;
-import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus;
-
-import org.apache.commons.lang3.StringUtils;
 
 import java.io.File;
 import java.nio.charset.StandardCharsets;
 import java.util.List;
 
 import lombok.extern.slf4j.Slf4j;
 
-import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.google.auto.service.AutoService;
 
 @Slf4j
 @AutoService(ApplicationManager.class)
 public class YarnApplicationManager implements ApplicationManager {
 
-    private static final String RM_HA_IDS = PropertyUtils.getString(Constants.YARN_RESOURCEMANAGER_HA_RM_IDS);
-    private static final String APP_ADDRESS = PropertyUtils.getString(Constants.YARN_APPLICATION_STATUS_ADDRESS);
-    private static final String JOB_HISTORY_ADDRESS =
-            PropertyUtils.getString(Constants.YARN_JOB_HISTORY_STATUS_ADDRESS);
-    private static final int HADOOP_RESOURCE_MANAGER_HTTP_ADDRESS_PORT_VALUE =
-            PropertyUtils.getInt(Constants.HADOOP_RESOURCE_MANAGER_HTTPADDRESS_PORT, 8088);
-
     @Override
     public boolean killApplication(ApplicationManagerContext applicationManagerContext) throws TaskException {
         YarnApplicationManagerContext yarnApplicationManagerContext =
                 (YarnApplicationManagerContext) applicationManagerContext;
         String executePath = yarnApplicationManagerContext.getExecutePath();
         String tenantCode = yarnApplicationManagerContext.getTenantCode();
         List<String> appIds = yarnApplicationManagerContext.getAppIds();
-        for (String appId : appIds) {
-            try {
-                TaskExecutionStatus applicationStatus = getApplicationStatus(appId);
 
-                if (!applicationStatus.isFinished()) {
-                    String commandFile = String.format("%s/%s.kill", executePath, appId);
-                    String cmd = getKerberosInitCommand() + "yarn application -kill " + appId;
-                    execYarnKillCommand(tenantCode, appId, commandFile, cmd);
-                }
-            } catch (Exception e) {
-                log.error("Get yarn application app id [{}}] status failed", appId, e);
-                throw new TaskException(e.getMessage());
-            }
+        try {
+            String commandFile = String.format("%s/%s.kill", executePath, String.join(Constants.UNDERLINE, appIds));
+            String cmd = getKerberosInitCommand() + "yarn application -kill " + String.join(Constants.SPACE, appIds);

Review Comment:
   Generally LGTM.
   
   Just some NIT. We could use yarn rest api to kill jobs just like the way we do in monitoring yarn job status. So that we can reduce dependence on worker node yarn components.



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

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