wangbo commented on a change in pull request #3055: [Spark load] FE creates 
spark load job and submits spark etl job
URL: https://github.com/apache/incubator-doris/pull/3055#discussion_r394137293
 
 

 ##########
 File path: 
fe/src/main/java/org/apache/doris/load/loadv2/SparkEtlJobHandler.java
 ##########
 @@ -0,0 +1,259 @@
+// 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 com.google.common.collect.Lists;
+import org.apache.doris.PaloFe;
+import org.apache.doris.analysis.BrokerDesc;
+import org.apache.doris.common.LoadException;
+import org.apache.doris.common.UserException;
+import org.apache.doris.common.util.BrokerUtil;
+import org.apache.doris.common.util.Util;
+import org.apache.doris.load.EtlStatus;
+import org.apache.doris.thrift.TBrokerFileStatus;
+import org.apache.doris.thrift.TEtlState;
+import org.apache.http.HttpEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.util.EntityUtils;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import org.apache.spark.launcher.SparkAppHandle;
+import org.apache.spark.launcher.SparkAppHandle.Listener;
+import org.apache.spark.launcher.SparkAppHandle.State;
+import org.apache.spark.launcher.SparkLauncher;
+
+import com.google.common.collect.Maps;
+import com.google.gson.Gson;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.util.List;
+import java.util.Map;
+
+public class SparkEtlJobHandler {
+    private static final Logger LOG = 
LogManager.getLogger(SparkEtlJobHandler.class);
+
+    private static final String JOB_CONFIG_DIR = PaloFe.DORIS_HOME_DIR + 
"/temp/job_conf";
+    private static final String JOB_CONFIG_FILE = "jobconfig.json";
+    private static final String APP_RESOURCE = PaloFe.DORIS_HOME_DIR + 
"/lib/palo-fe.jar";
+    private static final String MAIN_CLASS = 
"org.apache.doris.load.loadv2.etl.SparkEtl";
+    private static final String ETL_JOB_NAME = "doris__%s";
+    // hdfs://host:port/outputPath/dbId/loadLabel/PendingTaskSignature
+    private static final String ETL_OUTPUT_PATH = "%s%s/%d/%s/%d";
+    // http://host:port/api/v1/applications/appid/jobs
+    private static final String STATUS_URL = "%s/api/v1/applications/%s/jobs";
+
+    public static final String NUM_TASKS = "numTasks";
+    public static final String NUM_COMPLETED_TASKS = "numCompletedTasks";
+
+    class SparkAppListener implements Listener {
+        @Override
+        public void stateChanged(SparkAppHandle sparkAppHandle) {}
+
+        @Override
+        public void infoChanged(SparkAppHandle sparkAppHandle) {}
+    }
+
+    public SparkAppHandle submitEtlJob(long loadJobId, String loadLabel, 
String sparkMaster,
+                                       Map<String, String> sparkConfigs, 
String jobJsonConfig) throws LoadException {
+        // check outputPath exist
+
+        // create job config file
+        String configDirPath = JOB_CONFIG_DIR + "/" + loadJobId;
+        String configFilePath = configDirPath + "/" + JOB_CONFIG_FILE;
+        try {
+            createJobConfigFile(configDirPath, configFilePath, loadJobId, 
jobJsonConfig);
+        } catch (LoadException e) {
+            return null;
+        }
+
+        // spark cluster config
+        SparkLauncher launcher = new SparkLauncher();
+        launcher = launcher.setMaster(sparkMaster)
+                .setAppResource(APP_RESOURCE)
+                .setMainClass(MAIN_CLASS)
+                .setAppName(String.format(ETL_JOB_NAME, loadLabel))
+                .addAppArgs(configFilePath);
 
 Review comment:
   I think we'd better use spark cluster mode.
   `.setDeployMode("cluster");`

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

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

Reply via email to