当前位置:网站首页>dolphinscheduler 2.0.5 spark 任务测试总结(源码优化)
dolphinscheduler 2.0.5 spark 任务测试总结(源码优化)
2022-06-23 03:52:00 【韧小钊】
spark 任务测试总结
测试过程中遇到各种问题,部署及定义见详情一和详情二,在环境上手动执行成功,理论上上通过调度执行也是没问题的,然后复制任务调度的命令到环境上执行能够成功,而任务调度本身执行却失败。最终发现是参数过长导致换行,从而执行失败。
修改源码(SparkArgsUtils)
参数过长时,很容易回车换行输入,为了防止输入回车,后台统一做替换

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 防止命令换行
args.add(mainArgs.replace("\r", " ").replace("\n", " "));
}
return args;
}
}
- 替换后日志(输入回车也不会换行了)

环境变量定义
资源中心上传完文件,只能看到文件名称,无法看到hdfs全路径,可以统一定义全路径变量,对于使用者来说直接通过全路径变量拼接文件名称即可
- 定义全局变量

- 引用全局变量

- 日志(结果输出参数拼接日期,防止报目录已存在错)

边栏推荐
- altium designer 09丝印靠近焊盘显示绿色警告,如何阻止其报警?
- Shadertoy basic teaching 01. Circle drawing (explanation of smoothstep() function)
- 重装Cadence16.3,失败与成功
- 开关磁阻电机悬浮驱动IR2128小结
- Welcome to the CSDN markdown editor
- Please use the NLTK Downloader to obtain the resource
- 实战| 记一次借Viper来多重内网渗透
- thinkphp6 模版替换
- Left and right values
- PCB任意角度和距离放置元器件
猜你喜欢

CVE-2019-14287(sudo提权)

Abnova ACTN4纯化兔多克隆抗体说明书

Abnova LiquidCell-负富集细胞分离和回收系统

Halcon knowledge: binocular_ Discrimination knowledge

微信小程序实例开发:跑起来

Please use the NLTK Downloader to obtain the resource

PCB----理论与现实的桥梁

如何解决独立站多渠道客户沟通难题?这款跨境电商插件一定要知道!

Win10 view my Ini path

Examples of corpus data processing cases (part of speech encoding, part of speech restoration)
随机推荐
Li Kou today's question 513 Find the value in the lower left corner of the tree
An understanding of free() (an error in C Primer Plus)
在PCB板边走高频高速信号线的注意事项–高频高速信号设计基本原则
Question bank and answers of 2022 hoisting machinery safety management examination
mysql json
DPR-34V/V双位置继电器
Abnova fluorescent dye 555-c3 maleimide scheme
五年连续亏损42亿,蘑菇如何渡劫?
win10下安装、运行MongoDB
Icer Skill 02makefile script Running VCS Simulation
McKinsey: in 2021, the investment in quantum computing market grew strongly and the talent gap expanded
Experience of Tencent cloud installed by Kali
WPF 基础控件之 TabControl样式
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
How to solve multi-channel customer communication problems in independent stations? This cross-border e-commerce plug-in must be known!
ZK has a node reporting it is possible not running and the log has no obvious error
Reinstallation of cadence16.3, failure and success
云原生数据库如荼如火,未来可期
Alkylation process test questions and simulation test in 2022
Can bus Basics