You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2020/08/18 11:07:14 UTC

[GitHub] [incubator-doris] morningman commented on a change in pull request #4383: [SparkLoad]Use the yarn command to get status and kill the application

morningman commented on a change in pull request #4383:
URL: https://github.com/apache/incubator-doris/pull/4383#discussion_r472090745



##########
File path: fe/fe-core/src/main/java/org/apache/doris/load/loadv2/YarnApplicationReport.java
##########
@@ -0,0 +1,121 @@
+// 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.loadv2;
+
+import org.apache.doris.common.LoadException;
+import com.google.common.base.Preconditions;
+import com.google.common.base.Splitter;
+import com.google.common.collect.Maps;
+
+import org.apache.hadoop.yarn.api.records.ApplicationReport;
+import org.apache.hadoop.yarn.api.records.FinalApplicationStatus;
+import org.apache.hadoop.yarn.api.records.YarnApplicationState;
+import org.apache.hadoop.yarn.api.records.impl.pb.ApplicationReportPBImpl;
+import org.apache.hadoop.yarn.util.ConverterUtils;
+
+import java.text.NumberFormat;
+import java.text.ParseException;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Covert output string of command `yarn application -status` to application report.
+ * Input sample:
+ * -------------------
+ * Application Report :
+ * 	Application-Id : application_1573630236805_6763648
+ * 	Application-Name : doris_label_test
+ * 	Application-Type : SPARK-2.4.1
+ * 	User : test
+ * 	Queue : test-queue
+ * 	Start-Time : 1597654469958
+ * 	Finish-Time : 1597654801939
+ * 	Progress : 100%
+ * 	State : FINISHED
+ * 	Final-State : SUCCEEDED
+ * 	Tracking-URL : 127.0.0.1:8004/history/application_1573630236805_6763648/1
+ * 	RPC Port : 40236
+ * 	AM Host : host-name
+ * 	------------------
+ *
+ * 	Output:
+ * 	ApplicationReport
+ */
+public class YarnApplicationReport {
+    private static final String APPLICATION_ID = "Application-Id";
+    private static final String APPLICATION_TYPE = "Application-Type";
+    private static final String APPLICATION_NAME = "Application-Name";
+    private static final String USER = "User";
+    private static final String QUEUE = "Queue";
+    private static final String START_TIME = "Start-Time";
+    private static final String FINISH_TIME = "Finish-Time";
+    private static final String PROGRESS = "Progress";
+    private static final String STATE = "State";
+    private static final String FINAL_STATE = "Final-State";
+    private static final String TRACKING_URL = "Tracking-URL";
+    private static final String RPC_PORT = "RPC Port";
+    private static final String AM_HOST = "AM Host";
+    private static final String DIAGNOSTICS = "Diagnostics";
+
+    private ApplicationReport report;
+
+    public YarnApplicationReport(String output) throws LoadException {
+        this.report = new ApplicationReportPBImpl();
+        parseFromOutput(output);
+    }
+
+    public ApplicationReport getReport() {
+        return report;
+    }
+
+    private void parseFromOutput(String output) throws LoadException {
+        Map<String, String> reportMap = Maps.newHashMap();
+        List<String> lines = Splitter.onPattern("\n").trimResults().splitToList(output);
+        // Application-Id : application_1573630236805_6763648 ==> (Application-Id, application_1573630236805_6763648)
+        for (String line : lines) {
+            List<String> entry = Splitter.onPattern(":").limit(2).trimResults().splitToList(line);
+            Preconditions.checkState(entry.size() <= 2);

Review comment:
       Preconditions.checkState(entry.size() <= 2, line);




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

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