当前位置:网站首页>Dolphin scheduler 2.0.5 spark task test summary (source code optimization)
Dolphin scheduler 2.0.5 spark task test summary (source code optimization)
2022-06-23 05:03:00 【Zhun Xiaozhao】
Catalog
spark Task test summary
Various problems encountered during the test , See details I for deployment and definition and Detail II , The manual execution on the environment succeeded , Theoretically, there is no problem with scheduling , Then copy the task scheduling command to the environment and execute it successfully , But the task scheduling itself fails . Finally, it is found that the parameter is too long, resulting in newline , Thus the execution fails .
Modify source code (SparkArgsUtils)
When the parameter is too long , It's easy to enter a carriage return line feed , To prevent input from entering a carriage return , The background shall be replaced uniformly

SparkArgsUtils
/* * 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.dolphinscheduler.plugin.task.spark;
import org.apache.dolphinscheduler.plugin.task.util.ArgsUtils;
import org.apache.dolphinscheduler.spi.task.ResourceInfo;
import org.apache.dolphinscheduler.spi.utils.StringUtils;
import java.util.ArrayList;
import java.util.List;
/** * spark args utils */
public class SparkArgsUtils {
private static final String SPARK_CLUSTER = "cluster";
private static final String SPARK_LOCAL = "local";
private static final String SPARK_ON_YARN = "yarn";
private SparkArgsUtils() {
throw new IllegalStateException("Utility class");
}
/** * build args * * @param param param * @return argument list */
public static List<String> buildArgs(SparkParameters param) {
List<String> args = new ArrayList<>();
args.add(SparkConstants.MASTER);
String deployMode = StringUtils.isNotEmpty(param.getDeployMode()) ? param.getDeployMode() : SPARK_CLUSTER;
if (!SPARK_LOCAL.equals(deployMode)) {
args.add(SPARK_ON_YARN);
args.add(SparkConstants.DEPLOY_MODE);
}
args.add(deployMode);
ProgramType programType = param.getProgramType();
String mainClass = param.getMainClass();
if (programType != null && programType != ProgramType.PYTHON && StringUtils.isNotEmpty(mainClass)) {
args.add(SparkConstants.MAIN_CLASS);
args.add(mainClass);
}
int driverCores = param.getDriverCores();
if (driverCores > 0) {
args.add(SparkConstants.DRIVER_CORES);
args.add(String.format("%d", driverCores));
}
String driverMemory = param.getDriverMemory();
if (StringUtils.isNotEmpty(driverMemory)) {
args.add(SparkConstants.DRIVER_MEMORY);
args.add(driverMemory);
}
int numExecutors = param.getNumExecutors();
if (numExecutors > 0) {
args.add(SparkConstants.NUM_EXECUTORS);
args.add(String.format("%d", numExecutors));
}
int executorCores = param.getExecutorCores();
if (executorCores > 0) {
args.add(SparkConstants.EXECUTOR_CORES);
args.add(String.format("%d", executorCores));
}
String executorMemory = param.getExecutorMemory();
if (StringUtils.isNotEmpty(executorMemory)) {
args.add(SparkConstants.EXECUTOR_MEMORY);
args.add(executorMemory);
}
String appName = param.getAppName();
if (StringUtils.isNotEmpty(appName)) {
args.add(SparkConstants.SPARK_NAME);
args.add(ArgsUtils.escape(appName));
}
String others = param.getOthers();
if (!SPARK_LOCAL.equals(deployMode) && (StringUtils.isEmpty(others) || !others.contains(SparkConstants.SPARK_QUEUE))) {
String queue = param.getQueue();
if (StringUtils.isNotEmpty(queue)) {
args.add(SparkConstants.SPARK_QUEUE);
args.add(queue);
}
}
// --conf --files --jars --packages
if (StringUtils.isNotEmpty(others)) {
args.add(others);
}
ResourceInfo mainJar = param.getMainJar();
if (mainJar != null) {
args.add(mainJar.getRes());
}
String mainArgs = param.getMainArgs();
if (StringUtils.isNotEmpty(mainArgs)) {
// renxiaozhao 20220615 Prevent command line breaks
args.add(mainArgs.replace("\r", " ").replace("\n", " "));
}
return args;
}
}
- Post replacement log ( Entering carriage return will not break the line )

Definition of environment variables
The resource center has uploaded the file , You can only see the file name , Can't see hdfs The full path , All path variables can be defined uniformly , For users, you can splice file names directly through full path variables
- Define global variables

- Reference global variables

- journal ( Result output parameter splicing date , Prevent reporting that there is an error in the directory )

边栏推荐
- Static two position relay xjls-84/440/dc220v
- Please use the NLTK Downloader to obtain the resource
- Flask基础:环境搭建+配置+URL与试图之间的映射+重定向+数据库连接
- 微信小程序实例开发:跑起来
- Laravel中使用 Editor.md 上传图片如何处理?
- 美团好文:从预编译的角度理解Swift与Objective-C及混编机制
- 如何更好地组织最小 WEB API 代码结构
- Shadertoy basic teaching 01. Circle drawing (explanation of smoothstep() function)
- Magnetoresistive saturation
- Win10 view my Ini path
猜你喜欢

The solution to prompt "this list creation could be rewritten as a list literal" when adding elements to the list using the append() method in pychart
Using editor How to handle MD uploading pictures?

Halcon knowledge: binocular_ Discrimination knowledge

Separate use of alertmanager alarms and use of Prometheus configuration alarm rules

Flask Foundation: environment setup + configuration + mapping between URL and attempt + redirection + database connection

静态双位置继电器 XJLS-84/440/DC220V

apache atlas 快速入门

ApiPost接口测试的用法之------Get

Apache atlas quick start

prometheus、influxdb2.2安装及flume_export下载编译使用
随机推荐
OGNL Object-Graph Navigation Language
Can bus Basics
Laravel 8.4 routing problem. At the end is the cross reference table on the left side of the editor, which can be understood by Xiaobai
七年码农路
Mini Homer——几百块钱也能搞到一台远距离图数传链路?
2 万字 + 20张图|细说 Redis 九种数据类型和应用场景
const理解之一
An understanding of free() (an error in C Primer Plus)
自举驱动、top开关电源、光耦拾遗
微信小程序实例开发:跑起来
聊聊 C# 中的 Composite 模式
Halcon knowledge: binocular_ Discrimination knowledge
ICER skill 02makefile script self running VCs simulation
在PCB板边走高频高速信号线的注意事项–高频高速信号设计基本原则
【论文阅读】Semi-Supervised Learning with Ladder Networks
prometheus、influxdb2.2安装及flume_export下载编译使用
ICer技能01正则匹配
ApiPost接口测试的用法之------Post
Thinkphp6 template replacement
开发一年不到,来面试居然敢开口要20K,面完连8K都不想给~