Unverified Commit 1ee17894 authored by aiwenmo's avatar aiwenmo Committed by GitHub

[Fix-1277] [monitor] The status of per-job and application always is unknown…

[Fix-1277] [monitor] The status of per-job and application always is unknown when the job completes (#1278) Co-authored-by: 's avatarwenmo <32723967+wenmo@users.noreply.github.com>
parent 011e193e
...@@ -62,7 +62,7 @@ public class MybatisPlusConfig { ...@@ -62,7 +62,7 @@ public class MybatisPlusConfig {
public Expression getTenantId() { public Expression getTenantId() {
Integer tenantId = (Integer) TenantContextHolder.get(); Integer tenantId = (Integer) TenantContextHolder.get();
if (tenantId == null) { if (tenantId == null) {
log.warn("request context tenant id is null"); // log.warn("request context tenant id is null");
return new NullValue(); return new NullValue();
} }
return new LongValue(tenantId); return new LongValue(tenantId);
......
...@@ -103,8 +103,8 @@ public interface TaskService extends ISuperService<Task> { ...@@ -103,8 +103,8 @@ public interface TaskService extends ISuperService<Task> {
Result queryAllCatalogue(); Result queryAllCatalogue();
Result<List<Task>> queryOnLineTaskByDoneStatus(List<JobLifeCycle> jobLifeCycle Result<List<Task>> queryOnLineTaskByDoneStatus(List<JobLifeCycle> jobLifeCycle, List<JobStatus> jobStatuses,
, List<JobStatus> jobStatuses, boolean includeNull, Integer catalogueId); boolean includeNull, Integer catalogueId);
void selectSavepointOnLineTask(TaskOperatingResult taskOperatingResult); void selectSavepointOnLineTask(TaskOperatingResult taskOperatingResult);
...@@ -112,4 +112,5 @@ public interface TaskService extends ISuperService<Task> { ...@@ -112,4 +112,5 @@ public interface TaskService extends ISuperService<Task> {
Task getTaskByNameAndTenantId(String name, Integer tenantId); Task getTaskByNameAndTenantId(String name, Integer tenantId);
JobStatus checkJobStatus(JobInfoDetail jobInfoDetail);
} }
...@@ -41,7 +41,9 @@ import com.dlink.dto.TaskVersionConfigureDTO; ...@@ -41,7 +41,9 @@ import com.dlink.dto.TaskVersionConfigureDTO;
import com.dlink.exception.BusException; import com.dlink.exception.BusException;
import com.dlink.function.compiler.CustomStringJavaCompiler; import com.dlink.function.compiler.CustomStringJavaCompiler;
import com.dlink.function.util.UDFUtil; import com.dlink.function.util.UDFUtil;
import com.dlink.gateway.Gateway;
import com.dlink.gateway.GatewayType; import com.dlink.gateway.GatewayType;
import com.dlink.gateway.config.GatewayConfig;
import com.dlink.gateway.config.SavePointStrategy; import com.dlink.gateway.config.SavePointStrategy;
import com.dlink.gateway.config.SavePointType; import com.dlink.gateway.config.SavePointType;
import com.dlink.gateway.model.JobInfo; import com.dlink.gateway.model.JobInfo;
...@@ -198,7 +200,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -198,7 +200,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
private String buildParas(Integer id) { private String buildParas(Integer id) {
return "--id " + id + " --driver " + driver + " --url " + url + " --username " + username + " --password " return "--id " + id + " --driver " + driver + " --url " + url + " --username " + username + " --password "
+ password; + password;
} }
@Override @Override
...@@ -207,7 +209,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -207,7 +209,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
Asserts.checkNull(task, Tips.TASK_NOT_EXIST); Asserts.checkNull(task, Tips.TASK_NOT_EXIST);
if (Dialect.notFlinkSql(task.getDialect())) { if (Dialect.notFlinkSql(task.getDialect())) {
return executeCommonSql(SqlDTO.build(task.getStatement(), return executeCommonSql(SqlDTO.build(task.getStatement(),
task.getDatabaseId(), null)); task.getDatabaseId(), null));
} }
JobConfig config = buildJobConfig(task); JobConfig config = buildJobConfig(task);
// init UDF // init UDF
...@@ -228,7 +230,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -228,7 +230,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
task.setStep(JobLifeCycle.ONLINE.getValue()); task.setStep(JobLifeCycle.ONLINE.getValue());
if (Dialect.notFlinkSql(task.getDialect())) { if (Dialect.notFlinkSql(task.getDialect())) {
return executeCommonSql(SqlDTO.build(task.getStatement(), return executeCommonSql(SqlDTO.build(task.getStatement(),
task.getDatabaseId(), null)); task.getDatabaseId(), null));
} }
JobConfig config = buildJobConfig(task); JobConfig config = buildJobConfig(task);
JobManager jobManager = JobManager.build(config); JobManager jobManager = JobManager.build(config);
...@@ -248,7 +250,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -248,7 +250,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
} }
if (Dialect.notFlinkSql(task.getDialect())) { if (Dialect.notFlinkSql(task.getDialect())) {
return executeCommonSql(SqlDTO.build(task.getStatement(), return executeCommonSql(SqlDTO.build(task.getStatement(),
task.getDatabaseId(), null)); task.getDatabaseId(), null));
} }
if (StringUtils.isBlank(savePointPath)) { if (StringUtils.isBlank(savePointPath)) {
task.setSavePointStrategy(SavePointStrategy.LATEST.getValue()); task.setSavePointStrategy(SavePointStrategy.LATEST.getValue());
...@@ -373,13 +375,13 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -373,13 +375,13 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
UDFTemplate template = udfTemplateService.getById(config.get("templateId")); UDFTemplate template = udfTemplateService.getById(config.get("templateId"));
if (template != null) { if (template != null) {
String code = UDFUtil.templateParse(task.getDialect(), template.getTemplateCode(), String code = UDFUtil.templateParse(task.getDialect(), template.getTemplateCode(),
config.get("className")); config.get("className"));
task.setStatement(code); task.setStatement(code);
} }
} }
// to compiler udf // to compiler udf
if (Asserts.isNotNullString(task.getDialect()) && Dialect.JAVA.equalsVal(task.getDialect()) if (Asserts.isNotNullString(task.getDialect()) && Dialect.JAVA.equalsVal(task.getDialect())
&& Asserts.isNotNullString(task.getStatement())) { && Asserts.isNotNullString(task.getStatement())) {
CustomStringJavaCompiler compiler = new CustomStringJavaCompiler(task.getStatement()); CustomStringJavaCompiler compiler = new CustomStringJavaCompiler(task.getStatement());
task.setSavePointPath(compiler.getFullClassName()); task.setSavePointPath(compiler.getFullClassName());
} else if (Dialect.PYTHON.equalsVal(task.getDialect())) { } else if (Dialect.PYTHON.equalsVal(task.getDialect())) {
...@@ -394,8 +396,8 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -394,8 +396,8 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
Task taskInfo = getById(task.getId()); Task taskInfo = getById(task.getId());
Assert.check(taskInfo); Assert.check(taskInfo);
if (JobLifeCycle.RELEASE.equalsValue(taskInfo.getStep()) if (JobLifeCycle.RELEASE.equalsValue(taskInfo.getStep())
|| JobLifeCycle.ONLINE.equalsValue(taskInfo.getStep()) || JobLifeCycle.ONLINE.equalsValue(taskInfo.getStep())
|| JobLifeCycle.CANCEL.equalsValue(taskInfo.getStep())) { || JobLifeCycle.CANCEL.equalsValue(taskInfo.getStep())) {
throw new BusException("该作业已" + JobLifeCycle.get(taskInfo.getStep()).getLabel() + ",禁止修改!"); throw new BusException("该作业已" + JobLifeCycle.get(taskInfo.getStep()).getLabel() + ",禁止修改!");
} }
task.setStep(JobLifeCycle.DEVELOP.getValue()); task.setStep(JobLifeCycle.DEVELOP.getValue());
...@@ -487,6 +489,19 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -487,6 +489,19 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
return task; return task;
} }
@Override
public JobStatus checkJobStatus(JobInfoDetail jobInfoDetail) {
JobConfig jobConfig = new JobConfig();
Map<String, Object> gatewayConfigMap =
clusterConfigurationService.getGatewayConfig(jobInfoDetail.getClusterConfiguration().getId());
jobConfig.buildGatewayConfig(gatewayConfigMap);
GatewayConfig gatewayConfig = jobConfig.getGatewayConfig();
gatewayConfig.setType(GatewayType.get(jobInfoDetail.getCluster().getType()));
gatewayConfig.getClusterConfig().setAppId(jobInfoDetail.getCluster().getName());
Gateway gateway = Gateway.build(gatewayConfig);
return gateway.getJobStatusById(jobInfoDetail.getCluster().getName());
}
@Override @Override
public String exportSql(Integer id) { public String exportSql(Integer id) {
Task task = getTaskInfoById(id); Task task = getTaskInfoById(id);
...@@ -506,8 +521,8 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -506,8 +521,8 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
@Override @Override
public Task getUDFByClassName(String className) { public Task getUDFByClassName(String className) {
Task task = getOne( Task task = getOne(
new QueryWrapper<Task>().in("dialect", Dialect.JAVA, Dialect.SCALA, Dialect.PYTHON).eq("enabled", 1) new QueryWrapper<Task>().in("dialect", Dialect.JAVA, Dialect.SCALA, Dialect.PYTHON).eq("enabled", 1)
.eq("save_point_path", className)); .eq("save_point_path", className));
Assert.check(task); Assert.check(task);
task.setStatement(statementService.getById(task.getId()).getStatement()); task.setStatement(statementService.getById(task.getId()).getStatement());
return task; return task;
...@@ -516,8 +531,8 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -516,8 +531,8 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
@Override @Override
public List<Task> getAllUDF() { public List<Task> getAllUDF() {
List<Task> tasks = List<Task> tasks =
list(new QueryWrapper<Task>().in("dialect", Dialect.JAVA, Dialect.SCALA, Dialect.PYTHON) list(new QueryWrapper<Task>().in("dialect", Dialect.JAVA, Dialect.SCALA, Dialect.PYTHON)
.eq("enabled", 1).isNotNull("save_point_path")); .eq("enabled", 1).isNotNull("save_point_path"));
return tasks.stream().peek(task -> { return tasks.stream().peek(task -> {
Assert.check(task); Assert.check(task);
task.setStatement(statementService.getById(task.getId()).getStatement()); task.setStatement(statementService.getById(task.getId()).getStatement());
...@@ -554,7 +569,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -554,7 +569,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
List<TaskVersion> taskVersions = taskVersionService.getTaskVersionByTaskId(task.getId()); List<TaskVersion> taskVersions = taskVersionService.getTaskVersionByTaskId(task.getId());
List<Integer> versionIds = taskVersions.stream().map(TaskVersion::getVersionId).collect(Collectors.toList()); List<Integer> versionIds = taskVersions.stream().map(TaskVersion::getVersionId).collect(Collectors.toList());
Map<Integer, TaskVersion> versionMap = Map<Integer, TaskVersion> versionMap =
taskVersions.stream().collect(Collectors.toMap(TaskVersion::getVersionId, t -> t)); taskVersions.stream().collect(Collectors.toMap(TaskVersion::getVersionId, t -> t));
TaskVersion taskVersion = new TaskVersion(); TaskVersion taskVersion = new TaskVersion();
BeanUtil.copyProperties(task, taskVersion); BeanUtil.copyProperties(task, taskVersion);
...@@ -593,14 +608,14 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -593,14 +608,14 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
Task taskInfo = getTaskInfoById(dto.getId()); Task taskInfo = getTaskInfoById(dto.getId());
if (JobLifeCycle.RELEASE.equalsValue(taskInfo.getStep()) if (JobLifeCycle.RELEASE.equalsValue(taskInfo.getStep())
|| JobLifeCycle.ONLINE.equalsValue(taskInfo.getStep()) || JobLifeCycle.ONLINE.equalsValue(taskInfo.getStep())
|| JobLifeCycle.CANCEL.equalsValue(taskInfo.getStep())) { || JobLifeCycle.CANCEL.equalsValue(taskInfo.getStep())) {
// throw new BusException("该作业已" + JobLifeCycle.get(taskInfo.getStep()).getLabel() + ",禁止回滚!"); // throw new BusException("该作业已" + JobLifeCycle.get(taskInfo.getStep()).getLabel() + ",禁止回滚!");
return Result.failed("该作业已" + JobLifeCycle.get(taskInfo.getStep()).getLabel() + ",禁止回滚!"); return Result.failed("该作业已" + JobLifeCycle.get(taskInfo.getStep()).getLabel() + ",禁止回滚!");
} }
LambdaQueryWrapper<TaskVersion> queryWrapper = new LambdaQueryWrapper<TaskVersion>() LambdaQueryWrapper<TaskVersion> queryWrapper = new LambdaQueryWrapper<TaskVersion>()
.eq(TaskVersion::getTaskId, dto.getId()).eq(TaskVersion::getVersionId, dto.getVersionId()); .eq(TaskVersion::getTaskId, dto.getId()).eq(TaskVersion::getVersionId, dto.getVersionId());
TaskVersion taskVersion = taskVersionService.getOne(queryWrapper); TaskVersion taskVersion = taskVersionService.getOne(queryWrapper);
...@@ -747,7 +762,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -747,7 +762,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
} }
if (Asserts.isNotNull(cluster.getClusterConfigurationId())) { if (Asserts.isNotNull(cluster.getClusterConfigurationId())) {
Map<String, Object> gatewayConfig = Map<String, Object> gatewayConfig =
clusterConfigurationService.getGatewayConfig(cluster.getClusterConfigurationId()); clusterConfigurationService.getGatewayConfig(cluster.getClusterConfigurationId());
jobConfig.buildGatewayConfig(gatewayConfig); jobConfig.buildGatewayConfig(gatewayConfig);
jobConfig.getGatewayConfig().getClusterConfig().setAppId(cluster.getName()); jobConfig.getGatewayConfig().getClusterConfig().setAppId(cluster.getName());
useGateway = true; useGateway = true;
...@@ -783,7 +798,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -783,7 +798,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
private JobConfig buildJobConfig(Task task) { private JobConfig buildJobConfig(Task task) {
boolean isJarTask = Dialect.FLINKJAR.equalsVal(task.getDialect()) boolean isJarTask = Dialect.FLINKJAR.equalsVal(task.getDialect())
|| Dialect.KUBERNETES_APPLICATION.equalsVal(task.getDialect()); || Dialect.KUBERNETES_APPLICATION.equalsVal(task.getDialect());
if (!isJarTask && Asserts.isNotNull(task.getFragment()) ? task.getFragment() : false) { if (!isJarTask && Asserts.isNotNull(task.getFragment()) ? task.getFragment() : false) {
String flinkWithSql = dataBaseService.getEnabledFlinkWithSql(); String flinkWithSql = dataBaseService.getEnabledFlinkWithSql();
if (Asserts.isNotNullString(flinkWithSql)) { if (Asserts.isNotNullString(flinkWithSql)) {
...@@ -803,20 +818,20 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -803,20 +818,20 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
} }
// support custom K8s app submit, rather than clusterConfiguration // support custom K8s app submit, rather than clusterConfiguration
else if (Dialect.KUBERNETES_APPLICATION.equalsVal(task.getDialect()) else if (Dialect.KUBERNETES_APPLICATION.equalsVal(task.getDialect())
&& GatewayType.KUBERNETES_APPLICATION.equalsValue(config.getType())) { && GatewayType.KUBERNETES_APPLICATION.equalsValue(config.getType())) {
Map<String, Object> gatewayConfig = JSONUtil.toMap(task.getStatement(), String.class, Object.class); Map<String, Object> gatewayConfig = JSONUtil.toMap(task.getStatement(), String.class, Object.class);
config.buildGatewayConfig(gatewayConfig); config.buildGatewayConfig(gatewayConfig);
} else { } else {
Map<String, Object> gatewayConfig = Map<String, Object> gatewayConfig =
clusterConfigurationService.getGatewayConfig(task.getClusterConfigurationId()); clusterConfigurationService.getGatewayConfig(task.getClusterConfigurationId());
// submit application type with clusterConfiguration // submit application type with clusterConfiguration
if (GatewayType.YARN_APPLICATION.equalsValue(config.getType()) if (GatewayType.YARN_APPLICATION.equalsValue(config.getType())
|| GatewayType.KUBERNETES_APPLICATION.equalsValue(config.getType())) { || GatewayType.KUBERNETES_APPLICATION.equalsValue(config.getType())) {
if (!isJarTask) { if (!isJarTask) {
SystemConfiguration systemConfiguration = SystemConfiguration.getInstances(); SystemConfiguration systemConfiguration = SystemConfiguration.getInstances();
gatewayConfig.put("userJarPath", systemConfiguration.getSqlSubmitJarPath()); gatewayConfig.put("userJarPath", systemConfiguration.getSqlSubmitJarPath());
gatewayConfig.put("userJarParas", gatewayConfig.put("userJarParas",
systemConfiguration.getSqlSubmitJarParas() + buildParas(config.getTaskId())); systemConfiguration.getSqlSubmitJarParas() + buildParas(config.getTaskId()));
gatewayConfig.put("userJarMainAppClass", systemConfiguration.getSqlSubmitJarMainAppClass()); gatewayConfig.put("userJarMainAppClass", systemConfiguration.getSqlSubmitJarMainAppClass());
} else { } else {
Jar jar = jarService.getById(task.getJarId()); Jar jar = jarService.getById(task.getJarId());
...@@ -874,7 +889,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -874,7 +889,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
history.setConfig(JSONUtil.parseObject(history.getConfigJson())); history.setConfig(JSONUtil.parseObject(history.getConfigJson()));
if (Asserts.isNotNull(history) && Asserts.isNotNull(history.getClusterConfigurationId())) { if (Asserts.isNotNull(history) && Asserts.isNotNull(history.getClusterConfigurationId())) {
jobInfoDetail.setClusterConfiguration( jobInfoDetail.setClusterConfiguration(
clusterConfigurationService.getClusterConfigById(history.getClusterConfigurationId())); clusterConfigurationService.getClusterConfigById(history.getClusterConfigurationId()));
} }
jobInfoDetail.setHistory(history); jobInfoDetail.setHistory(history);
jobInfoDetail.setJobHistory(jobHistoryService.getJobHistory(id)); jobInfoDetail.setJobHistory(jobHistoryService.getJobHistory(id));
...@@ -884,26 +899,37 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -884,26 +899,37 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
return jobInfoDetail.getInstance(); return jobInfoDetail.getInstance();
} }
JobHistory jobHistoryJson = JobHistory jobHistoryJson =
jobHistoryService.refreshJobHistory(id, jobInfoDetail.getCluster().getJobManagerHost(), jobHistoryService.refreshJobHistory(id, jobInfoDetail.getCluster().getJobManagerHost(),
jobInfoDetail.getInstance().getJid(), jobInfoDetail.isNeedSave()); jobInfoDetail.getInstance().getJid(), jobInfoDetail.isNeedSave());
JobHistory jobHistory = jobHistoryService.getJobHistoryInfo(jobHistoryJson); JobHistory jobHistory = jobHistoryService.getJobHistoryInfo(jobHistoryJson);
jobInfoDetail.setJobHistory(jobHistory); jobInfoDetail.setJobHistory(jobHistory);
JobStatus checkStatus = null;
if (JobStatus.isDone(jobInfoDetail.getInstance().getStatus()) if (JobStatus.isDone(jobInfoDetail.getInstance().getStatus())
&& (Asserts.isNull(jobHistory.getJob()) || jobHistory.isError())) { && (Asserts.isNull(jobHistory.getJob()) || jobHistory.isError())) {
return jobInfoDetail.getInstance(); checkStatus = checkJobStatus(jobInfoDetail);
log.debug("YarnState: " + checkStatus.getValue());
if (checkStatus.isDone()) {
jobInfoDetail.getInstance().setStatus(checkStatus.getValue());
jobInstanceService.updateById(jobInfoDetail.getInstance());
return jobInfoDetail.getInstance();
}
} }
String status = jobInfoDetail.getInstance().getStatus(); String status = jobInfoDetail.getInstance().getStatus();
boolean jobStatusChanged = false; boolean jobStatusChanged = false;
if (Asserts.isNull(jobInfoDetail.getJobHistory().getJob()) || jobInfoDetail.getJobHistory().isError()) { if (Asserts.isNull(jobInfoDetail.getJobHistory().getJob()) || jobInfoDetail.getJobHistory().isError()) {
jobInfoDetail.getInstance().setStatus(JobStatus.UNKNOWN.getValue()); if (Asserts.isNotNull(checkStatus)) {
jobInfoDetail.getInstance().setStatus(checkStatus.getValue());
} else {
jobInfoDetail.getInstance().setStatus(JobStatus.UNKNOWN.getValue());
}
} else { } else {
jobInfoDetail.getInstance().setDuration( jobInfoDetail.getInstance().setDuration(
jobInfoDetail.getJobHistory().getJob().get(FlinkRestResultConstant.JOB_DURATION).asLong() / 1000); jobInfoDetail.getJobHistory().getJob().get(FlinkRestResultConstant.JOB_DURATION).asLong() / 1000);
jobInfoDetail.getInstance() jobInfoDetail.getInstance()
.setStatus(jobInfoDetail.getJobHistory().getJob().get(FlinkRestResultConstant.JOB_STATE).asText()); .setStatus(jobInfoDetail.getJobHistory().getJob().get(FlinkRestResultConstant.JOB_STATE).asText());
} }
if (JobStatus.isDone(jobInfoDetail.getInstance().getStatus()) if (JobStatus.isDone(jobInfoDetail.getInstance().getStatus())
&& !status.equals(jobInfoDetail.getInstance().getStatus())) { && !status.equals(jobInfoDetail.getInstance().getStatus())) {
jobStatusChanged = true; jobStatusChanged = true;
jobInfoDetail.getInstance().setFinishTime(LocalDateTime.now()); jobInfoDetail.getInstance().setFinishTime(LocalDateTime.now());
// handleJobDone(jobInfoDetail.getInstance()); // handleJobDone(jobInfoDetail.getInstance());
...@@ -920,7 +946,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -920,7 +946,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
private boolean inRefreshPlan(JobInstance jobInstance) { private boolean inRefreshPlan(JobInstance jobInstance) {
if ((!JobStatus.isDone(jobInstance.getStatus())) || (Asserts.isNotNull(jobInstance.getFinishTime()) if ((!JobStatus.isDone(jobInstance.getStatus())) || (Asserts.isNotNull(jobInstance.getFinishTime())
&& Duration.between(jobInstance.getFinishTime(), LocalDateTime.now()).toMinutes() < 1)) { && Duration.between(jobInstance.getFinishTime(), LocalDateTime.now()).toMinutes() < 1)) {
return true; return true;
} else { } else {
return false; return false;
...@@ -967,9 +993,9 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -967,9 +993,9 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
// clusterConfigurationName // clusterConfigurationName
if (Asserts.isNotNull(task.getClusterConfigurationId())) { if (Asserts.isNotNull(task.getClusterConfigurationId())) {
ClusterConfiguration clusterConfiguration = ClusterConfiguration clusterConfiguration =
clusterConfigurationService.getById(task.getClusterConfigurationId()); clusterConfigurationService.getById(task.getClusterConfigurationId());
((ObjectNode) jsonNode).put("clusterConfigurationName", ((ObjectNode) jsonNode).put("clusterConfigurationName",
Asserts.isNotNull(clusterConfiguration) ? clusterConfiguration.getName() : null); Asserts.isNotNull(clusterConfiguration) ? clusterConfiguration.getName() : null);
} }
// databaseName // databaseName
if (Asserts.isNotNull(task.getDatabaseId())) { if (Asserts.isNotNull(task.getDatabaseId())) {
...@@ -1045,15 +1071,15 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -1045,15 +1071,15 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
} }
if (Asserts.isNotNull(task.getClusterConfigurationName())) { if (Asserts.isNotNull(task.getClusterConfigurationName())) {
ClusterConfiguration clusterConfiguration = clusterConfigurationService ClusterConfiguration clusterConfiguration = clusterConfigurationService
.getOne(new QueryWrapper<ClusterConfiguration>().eq("name", .getOne(new QueryWrapper<ClusterConfiguration>().eq("name",
task.getClusterConfigurationName())); task.getClusterConfigurationName()));
if (Asserts.isNotNull(clusterConfiguration)) { if (Asserts.isNotNull(clusterConfiguration)) {
task.setClusterConfigurationId(clusterConfiguration.getId()); task.setClusterConfigurationId(clusterConfiguration.getId());
} }
} }
if (Asserts.isNotNull(task.getDatabaseName())) { if (Asserts.isNotNull(task.getDatabaseName())) {
DataBase dataBase = DataBase dataBase =
dataBaseService.getOne(new QueryWrapper<DataBase>().eq("name", task.getDatabaseName())); dataBaseService.getOne(new QueryWrapper<DataBase>().eq("name", task.getDatabaseName()));
if (Asserts.isNotNull(dataBase)) { if (Asserts.isNotNull(dataBase)) {
task.setDatabaseId(dataBase.getId()); task.setDatabaseId(dataBase.getId());
} }
...@@ -1070,7 +1096,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -1070,7 +1096,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
*/ */
if (Asserts.isNotNull(task.getAlertGroupName())) { if (Asserts.isNotNull(task.getAlertGroupName())) {
AlertGroup alertGroup = AlertGroup alertGroup =
alertGroupService.getOne(new QueryWrapper<AlertGroup>().eq("name", task.getAlertGroupName())); alertGroupService.getOne(new QueryWrapper<AlertGroup>().eq("name", task.getAlertGroupName()));
if (Asserts.isNotNull(alertGroup)) { if (Asserts.isNotNull(alertGroup)) {
task.setAlertGroupId(alertGroup.getId()); task.setAlertGroupId(alertGroup.getId());
} }
...@@ -1106,7 +1132,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -1106,7 +1132,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
return Result.failed("一共" + jsonNodes.size() + "个作业,全部导入失败"); return Result.failed("一共" + jsonNodes.size() + "个作业,全部导入失败");
} else if (errorNumber > 0) { } else if (errorNumber > 0) {
return Result.failed("一共" + jsonNodes.size() + "个作业,其中成功导入" + (jsonNode.size() - errorNumber) + "个,失败" return Result.failed("一共" + jsonNodes.size() + "个作业,其中成功导入" + (jsonNode.size() - errorNumber) + "个,失败"
+ errorNumber + "个"); + errorNumber + "个");
} }
return Result.succeed("成功导入" + jsonNodes.size() + "个作业"); return Result.succeed("成功导入" + jsonNodes.size() + "个作业");
} }
...@@ -1157,7 +1183,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -1157,7 +1183,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
long minutes = ChronoUnit.MINUTES.between(startTime, endTime); long minutes = ChronoUnit.MINUTES.between(startTime, endTime);
long seconds = ChronoUnit.SECONDS.between(startTime, endTime); long seconds = ChronoUnit.SECONDS.between(startTime, endTime);
String duration = days + "天 " + (hours - (days * 24)) + "小时 " + (minutes - (hours * 60)) + "分 " String duration = days + "天 " + (hours - (days * 24)) + "小时 " + (minutes - (hours * 60)) + "分 "
+ (seconds - (minutes * 60)) + "秒"; + (seconds - (minutes * 60)) + "秒";
return duration; return duration;
} }
...@@ -1237,7 +1263,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -1237,7 +1263,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
private void sendAlert(AlertInstance alertInstance, JobInstance jobInstance, Task task, AlertMsg alertMsg) { private void sendAlert(AlertInstance alertInstance, JobInstance jobInstance, Task task, AlertMsg alertMsg) {
AlertConfig alertConfig = AlertConfig.build(alertInstance.getName(), alertInstance.getType(), AlertConfig alertConfig = AlertConfig.build(alertInstance.getName(), alertInstance.getType(),
JSONUtil.toMap(alertInstance.getParams())); JSONUtil.toMap(alertInstance.getParams()));
Alert alert = Alert.build(alertConfig); Alert alert = Alert.build(alertConfig);
String title = "任务【" + task.getAlias() + "】:" + jobInstance.getStatus(); String title = "任务【" + task.getAlias() + "】:" + jobInstance.getStatus();
String content = alertMsg.toString(); String content = alertMsg.toString();
...@@ -1256,10 +1282,10 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -1256,10 +1282,10 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
@Override @Override
public Result queryAllCatalogue() { public Result queryAllCatalogue() {
final LambdaQueryWrapper<Catalogue> queryWrapper = new LambdaQueryWrapper<Catalogue>() final LambdaQueryWrapper<Catalogue> queryWrapper = new LambdaQueryWrapper<Catalogue>()
.select(Catalogue::getId, Catalogue::getName, Catalogue::getParentId) .select(Catalogue::getId, Catalogue::getName, Catalogue::getParentId)
.eq(Catalogue::getIsLeaf, 0) .eq(Catalogue::getIsLeaf, 0)
.eq(Catalogue::getEnabled, 1) .eq(Catalogue::getEnabled, 1)
.isNull(Catalogue::getTaskId); .isNull(Catalogue::getTaskId);
final List<Catalogue> catalogueList = catalogueService.list(queryWrapper); final List<Catalogue> catalogueList = catalogueService.list(queryWrapper);
return Result.succeed(TreeUtil.build(dealWithCatalogue(catalogueList), -1).get(0)); return Result.succeed(TreeUtil.build(dealWithCatalogue(catalogueList), -1).get(0));
} }
...@@ -1285,7 +1311,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -1285,7 +1311,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
public Result<List<Task>> queryOnLineTaskByDoneStatus(List<JobLifeCycle> jobLifeCycle, List<JobStatus> jobStatuses, public Result<List<Task>> queryOnLineTaskByDoneStatus(List<JobLifeCycle> jobLifeCycle, List<JobStatus> jobStatuses,
boolean includeNull, Integer catalogueId) { boolean includeNull, Integer catalogueId) {
final Tree<Integer> node = ((Tree<Integer>) queryAllCatalogue().getDatas()) final Tree<Integer> node = ((Tree<Integer>) queryAllCatalogue().getDatas())
.getNode(Objects.isNull(catalogueId) ? 0 : catalogueId); .getNode(Objects.isNull(catalogueId) ? 0 : catalogueId);
final List<Integer> parentIds = new ArrayList<>(0); final List<Integer> parentIds = new ArrayList<>(0);
parentIds.add(node.getId()); parentIds.add(node.getId());
childrenNodeParse(node, parentIds); childrenNodeParse(node, parentIds);
...@@ -1296,8 +1322,8 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -1296,8 +1322,8 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
private List<Task> getTasks(List<JobLifeCycle> jobLifeCycle, List<JobStatus> jobStatuses, boolean includeNull, private List<Task> getTasks(List<JobLifeCycle> jobLifeCycle, List<JobStatus> jobStatuses, boolean includeNull,
List<Integer> parentIds) { List<Integer> parentIds) {
return this.baseMapper.queryOnLineTaskByDoneStatus(parentIds, return this.baseMapper.queryOnLineTaskByDoneStatus(parentIds,
jobLifeCycle.stream().filter(Objects::nonNull).map(JobLifeCycle::getValue).collect(Collectors.toList()), jobLifeCycle.stream().filter(Objects::nonNull).map(JobLifeCycle::getValue).collect(Collectors.toList()),
includeNull, jobStatuses.stream().map(JobStatus::name).collect(Collectors.toList())); includeNull, jobStatuses.stream().map(JobStatus::name).collect(Collectors.toList()));
} }
private void childrenNodeParse(Tree<Integer> node, List<Integer> parentIds) { private void childrenNodeParse(Tree<Integer> node, List<Integer> parentIds) {
...@@ -1317,7 +1343,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -1317,7 +1343,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
@Override @Override
public void selectSavepointOnLineTask(TaskOperatingResult taskOperatingResult) { public void selectSavepointOnLineTask(TaskOperatingResult taskOperatingResult) {
final JobInstance jobInstanceByTaskId = final JobInstance jobInstanceByTaskId =
jobInstanceService.getJobInstanceByTaskId(taskOperatingResult.getTask().getId()); jobInstanceService.getJobInstanceByTaskId(taskOperatingResult.getTask().getId());
if (jobInstanceByTaskId == null) { if (jobInstanceByTaskId == null) {
startGoingLiveTask(taskOperatingResult, null); startGoingLiveTask(taskOperatingResult, null);
return; return;
...@@ -1336,8 +1362,8 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -1336,8 +1362,8 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
private void findTheConditionSavePointToOnline(TaskOperatingResult taskOperatingResult, private void findTheConditionSavePointToOnline(TaskOperatingResult taskOperatingResult,
JobInstance jobInstanceByTaskId) { JobInstance jobInstanceByTaskId) {
final LambdaQueryWrapper<JobHistory> queryWrapper = new LambdaQueryWrapper<JobHistory>() final LambdaQueryWrapper<JobHistory> queryWrapper = new LambdaQueryWrapper<JobHistory>()
.select(JobHistory::getId, JobHistory::getCheckpointsJson) .select(JobHistory::getId, JobHistory::getCheckpointsJson)
.eq(JobHistory::getId, jobInstanceByTaskId.getId()); .eq(JobHistory::getId, jobInstanceByTaskId.getId());
final JobHistory jobHistory = jobHistoryService.getOne(queryWrapper); final JobHistory jobHistory = jobHistoryService.getOne(queryWrapper);
if (jobHistory != null && StringUtils.isNotBlank(jobHistory.getCheckpointsJson())) { if (jobHistory != null && StringUtils.isNotBlank(jobHistory.getCheckpointsJson())) {
final ObjectNode jsonNodes = JSONUtil.parseObject(jobHistory.getCheckpointsJson()); final ObjectNode jsonNodes = JSONUtil.parseObject(jobHistory.getCheckpointsJson());
......
...@@ -31,6 +31,7 @@ import java.util.List; ...@@ -31,6 +31,7 @@ import java.util.List;
* @since 2022/2/22 14:29 * @since 2022/2/22 14:29
**/ **/
public enum JobStatus { public enum JobStatus {
/** /**
* The job has been received by the Dispatcher, and is waiting for the job manager to receive * The job has been received by the Dispatcher, and is waiting for the job manager to receive
* leadership and to be created. * leadership and to be created.
...@@ -124,6 +125,18 @@ public enum JobStatus { ...@@ -124,6 +125,18 @@ public enum JobStatus {
} }
} }
public boolean isDone() {
switch (this) {
case FAILED:
case CANCELED:
case FINISHED:
case UNKNOWN:
return true;
default:
return false;
}
}
public static List<JobStatus> getAllDoneStatus() { public static List<JobStatus> getAllDoneStatus() {
final List<JobStatus> list = new ArrayList<>(4); final List<JobStatus> list = new ArrayList<>(4);
list.add(FAILED); list.add(FAILED);
......
...@@ -33,6 +33,9 @@ import java.util.Iterator; ...@@ -33,6 +33,9 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
...@@ -47,6 +50,9 @@ import cn.hutool.http.Method; ...@@ -47,6 +50,9 @@ import cn.hutool.http.Method;
* @since 2021/6/24 13:56 * @since 2021/6/24 13:56
**/ **/
public class FlinkAPI { public class FlinkAPI {
private static final Logger logger = LoggerFactory.getLogger(FlinkAPI.class);
private String address; private String address;
public FlinkAPI(String address) { public FlinkAPI(String address) {
...@@ -69,8 +75,14 @@ public class FlinkAPI { ...@@ -69,8 +75,14 @@ public class FlinkAPI {
} }
private JsonNode get(String route) { private JsonNode get(String route) {
String res = HttpUtil.get(NetConstant.HTTP + address + NetConstant.SLASH + route, NetConstant.SERVER_TIME_OUT_ACTIVE); try {
return parse(res); String res = HttpUtil.get(NetConstant.HTTP + address + NetConstant.SLASH + route,
NetConstant.SERVER_TIME_OUT_ACTIVE);
return parse(res);
} catch (Exception e) {
logger.info("Unable to connect to Flink JobManager: {}", NetConstant.HTTP + address);
}
return null;
} }
/** /**
...@@ -80,17 +92,20 @@ public class FlinkAPI { ...@@ -80,17 +92,20 @@ public class FlinkAPI {
* @return * @return
*/ */
private String getResult(String route) { private String getResult(String route) {
String res = HttpUtil.get(NetConstant.HTTP + address + NetConstant.SLASH + route, NetConstant.SERVER_TIME_OUT_ACTIVE); String res = HttpUtil.get(NetConstant.HTTP + address + NetConstant.SLASH + route,
NetConstant.SERVER_TIME_OUT_ACTIVE);
return res; return res;
} }
private JsonNode post(String route, String body) { private JsonNode post(String route, String body) {
String res = HttpUtil.post(NetConstant.HTTP + address + NetConstant.SLASH + route, body, NetConstant.SERVER_TIME_OUT_ACTIVE); String res = HttpUtil.post(NetConstant.HTTP + address + NetConstant.SLASH + route, body,
NetConstant.SERVER_TIME_OUT_ACTIVE);
return parse(res); return parse(res);
} }
private JsonNode patch(String route, String body) { private JsonNode patch(String route, String body) {
String res = HttpUtil.createRequest(Method.PATCH, NetConstant.HTTP + address + NetConstant.SLASH + route).timeout(NetConstant.SERVER_TIME_OUT_ACTIVE).body(body).execute().body(); String res = HttpUtil.createRequest(Method.PATCH, NetConstant.HTTP + address + NetConstant.SLASH + route)
.timeout(NetConstant.SERVER_TIME_OUT_ACTIVE).body(body).execute().body();
return parse(res); return parse(res);
} }
...@@ -130,7 +145,7 @@ public class FlinkAPI { ...@@ -130,7 +145,7 @@ public class FlinkAPI {
break; break;
case TRIGGER: case TRIGGER:
paramMap.put("cancel-job", false); paramMap.put("cancel-job", false);
//paramMap.put("target-directory","hdfs:///flink13/ss1"); // paramMap.put("target-directory","hdfs:///flink13/ss1");
paramType = FlinkRestAPIConstant.SAVEPOINTS; paramType = FlinkRestAPIConstant.SAVEPOINTS;
jobInfo.setStatus(JobInfo.JobStatus.RUN); jobInfo.setStatus(JobInfo.JobStatus.RUN);
break; break;
...@@ -148,7 +163,8 @@ public class FlinkAPI { ...@@ -148,7 +163,8 @@ public class FlinkAPI {
while (triggerid != null) { while (triggerid != null) {
try { try {
Thread.sleep(1000); Thread.sleep(1000);
JsonNode node = get(FlinkRestAPIConstant.JOBS + jobId + FlinkRestAPIConstant.SAVEPOINTS + NetConstant.SLASH + triggerid); JsonNode node = get(FlinkRestAPIConstant.JOBS + jobId + FlinkRestAPIConstant.SAVEPOINTS
+ NetConstant.SLASH + triggerid);
String status = node.get("status").get("id").asText(); String status = node.get("status").get("id").asText();
if (Asserts.isEquals(status, "IN_PROGRESS")) { if (Asserts.isEquals(status, "IN_PROGRESS")) {
continue; continue;
...@@ -213,7 +229,8 @@ public class FlinkAPI { ...@@ -213,7 +229,8 @@ public class FlinkAPI {
* @Description: getJobManagerMetrics 获取jobManager的监控信息 * @Description: getJobManagerMetrics 获取jobManager的监控信息
*/ */
public JsonNode getJobManagerMetrics() { public JsonNode getJobManagerMetrics() {
return get(FlinkRestAPIConstant.JOB_MANAGER + FlinkRestAPIConstant.METRICS + FlinkRestAPIConstant.GET + buildMetricsParms(FlinkRestAPIConstant.JOB_MANAGER)); return get(FlinkRestAPIConstant.JOB_MANAGER + FlinkRestAPIConstant.METRICS + FlinkRestAPIConstant.GET
+ buildMetricsParms(FlinkRestAPIConstant.JOB_MANAGER));
} }
/** /**
...@@ -307,7 +324,8 @@ public class FlinkAPI { ...@@ -307,7 +324,8 @@ public class FlinkAPI {
* @Description: getJobManagerLog 获取jobManager的日志信息 * @Description: getJobManagerLog 获取jobManager的日志信息
*/ */
public JsonNode getTaskManagerMetrics(String containerId) { public JsonNode getTaskManagerMetrics(String containerId) {
return get(FlinkRestAPIConstant.TASK_MANAGER + containerId + FlinkRestAPIConstant.METRICS + FlinkRestAPIConstant.GET + buildMetricsParms(FlinkRestAPIConstant.JOB_MANAGER)); return get(FlinkRestAPIConstant.TASK_MANAGER + containerId + FlinkRestAPIConstant.METRICS
+ FlinkRestAPIConstant.GET + buildMetricsParms(FlinkRestAPIConstant.JOB_MANAGER));
} }
/** /**
......
...@@ -64,11 +64,6 @@ ...@@ -64,11 +64,6 @@
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-shaded-guava</artifactId>
<version>30.1.1-jre-14.0</version>
</dependency>
<dependency> <dependency>
<groupId>org.apache.flink</groupId> <groupId>org.apache.flink</groupId>
<artifactId>flink-clients_${scala.binary.version}</artifactId> <artifactId>flink-clients_${scala.binary.version}</artifactId>
...@@ -181,6 +176,12 @@ ...@@ -181,6 +176,12 @@
<groupId>com.starrocks</groupId> <groupId>com.starrocks</groupId>
<artifactId>flink-connector-starrocks</artifactId> <artifactId>flink-connector-starrocks</artifactId>
<version>1.2.3_flink-1.14_${scala.binary.version}</version> <version>1.2.3_flink-1.14_${scala.binary.version}</version>
<exclusions>
<exclusion>
<groupId>com.github.jsqlparser</groupId>
<artifactId>jsqlparser</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.flink</groupId> <groupId>org.apache.flink</groupId>
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
package com.dlink.gateway; package com.dlink.gateway;
import com.dlink.gateway.config.GatewayConfig; import com.dlink.gateway.config.GatewayConfig;
import com.dlink.model.JobStatus;
import org.apache.flink.configuration.Configuration; import org.apache.flink.configuration.Configuration;
...@@ -33,6 +34,7 @@ import org.slf4j.LoggerFactory; ...@@ -33,6 +34,7 @@ import org.slf4j.LoggerFactory;
* @since 2021/10/29 * @since 2021/10/29
**/ **/
public abstract class AbstractGateway implements Gateway { public abstract class AbstractGateway implements Gateway {
protected static final Logger logger = LoggerFactory.getLogger(AbstractGateway.class); protected static final Logger logger = LoggerFactory.getLogger(AbstractGateway.class);
protected GatewayConfig config; protected GatewayConfig config;
protected Configuration configuration; protected Configuration configuration;
...@@ -55,4 +57,9 @@ public abstract class AbstractGateway implements Gateway { ...@@ -55,4 +57,9 @@ public abstract class AbstractGateway implements Gateway {
} }
protected abstract void init(); protected abstract void init();
@Override
public JobStatus getJobStatusById(String id) {
return JobStatus.UNKNOWN;
}
} }
...@@ -25,6 +25,7 @@ import com.dlink.gateway.exception.GatewayException; ...@@ -25,6 +25,7 @@ import com.dlink.gateway.exception.GatewayException;
import com.dlink.gateway.result.GatewayResult; import com.dlink.gateway.result.GatewayResult;
import com.dlink.gateway.result.SavePointResult; import com.dlink.gateway.result.SavePointResult;
import com.dlink.gateway.result.TestResult; import com.dlink.gateway.result.TestResult;
import com.dlink.model.JobStatus;
import org.apache.flink.runtime.jobgraph.JobGraph; import org.apache.flink.runtime.jobgraph.JobGraph;
...@@ -83,4 +84,5 @@ public interface Gateway { ...@@ -83,4 +84,5 @@ public interface Gateway {
TestResult test(); TestResult test();
JobStatus getJobStatusById(String id);
} }
...@@ -88,28 +88,35 @@ public class YarnApplicationGateway extends YarnGateway { ...@@ -88,28 +88,35 @@ public class YarnApplicationGateway extends YarnGateway {
if (Asserts.isNull(userJarParas)) { if (Asserts.isNull(userJarParas)) {
userJarParas = new String[0]; userJarParas = new String[0];
} }
ApplicationConfiguration applicationConfiguration = new ApplicationConfiguration(userJarParas, appConfig.getUserJarMainAppClass()); ApplicationConfiguration applicationConfiguration =
new ApplicationConfiguration(userJarParas, appConfig.getUserJarMainAppClass());
YarnClusterDescriptor yarnClusterDescriptor = new YarnClusterDescriptor( YarnClusterDescriptor yarnClusterDescriptor = new YarnClusterDescriptor(
configuration, yarnConfiguration, yarnClient, YarnClientYarnClusterInformationRetriever.create(yarnClient), true); configuration, yarnConfiguration, yarnClient,
YarnClientYarnClusterInformationRetriever.create(yarnClient), true);
ClusterSpecification.ClusterSpecificationBuilder clusterSpecificationBuilder = new ClusterSpecification.ClusterSpecificationBuilder(); ClusterSpecification.ClusterSpecificationBuilder clusterSpecificationBuilder =
new ClusterSpecification.ClusterSpecificationBuilder();
if (configuration.contains(JobManagerOptions.TOTAL_PROCESS_MEMORY)) { if (configuration.contains(JobManagerOptions.TOTAL_PROCESS_MEMORY)) {
clusterSpecificationBuilder.setMasterMemoryMB(configuration.get(JobManagerOptions.TOTAL_PROCESS_MEMORY).getMebiBytes()); clusterSpecificationBuilder
.setMasterMemoryMB(configuration.get(JobManagerOptions.TOTAL_PROCESS_MEMORY).getMebiBytes());
} }
if (configuration.contains(TaskManagerOptions.TOTAL_PROCESS_MEMORY)) { if (configuration.contains(TaskManagerOptions.TOTAL_PROCESS_MEMORY)) {
clusterSpecificationBuilder.setTaskManagerMemoryMB(configuration.get(TaskManagerOptions.TOTAL_PROCESS_MEMORY).getMebiBytes()); clusterSpecificationBuilder
.setTaskManagerMemoryMB(configuration.get(TaskManagerOptions.TOTAL_PROCESS_MEMORY).getMebiBytes());
} }
if (configuration.contains(TaskManagerOptions.NUM_TASK_SLOTS)) { if (configuration.contains(TaskManagerOptions.NUM_TASK_SLOTS)) {
clusterSpecificationBuilder.setSlotsPerTaskManager(configuration.get(TaskManagerOptions.NUM_TASK_SLOTS)).createClusterSpecification(); clusterSpecificationBuilder.setSlotsPerTaskManager(configuration.get(TaskManagerOptions.NUM_TASK_SLOTS))
.createClusterSpecification();
} }
if (config.getJarPaths() != null) { if (Asserts.isNotNull(config.getJarPaths())) {
yarnClusterDescriptor.addShipFiles(Arrays.stream(config.getJarPaths()).map(FileUtil::file).collect(Collectors.toList())); yarnClusterDescriptor
.addShipFiles(Arrays.stream(config.getJarPaths()).map(FileUtil::file).collect(Collectors.toList()));
} }
try { try {
ClusterClientProvider<ApplicationId> clusterClientProvider = yarnClusterDescriptor.deployApplicationCluster( ClusterClientProvider<ApplicationId> clusterClientProvider = yarnClusterDescriptor.deployApplicationCluster(
clusterSpecificationBuilder.createClusterSpecification(), clusterSpecificationBuilder.createClusterSpecification(),
applicationConfiguration); applicationConfiguration);
ClusterClient<ApplicationId> clusterClient = clusterClientProvider.getClusterClient(); ClusterClient<ApplicationId> clusterClient = clusterClientProvider.getClusterClient();
Collection<JobStatusMessage> jobStatusMessages = clusterClient.listJobs().get(); Collection<JobStatusMessage> jobStatusMessages = clusterClient.listJobs().get();
int counts = SystemConfiguration.getInstances().getJobIdWait(); int counts = SystemConfiguration.getInstances().getJobIdWait();
......
...@@ -28,6 +28,7 @@ import com.dlink.gateway.exception.GatewayException; ...@@ -28,6 +28,7 @@ import com.dlink.gateway.exception.GatewayException;
import com.dlink.gateway.model.JobInfo; import com.dlink.gateway.model.JobInfo;
import com.dlink.gateway.result.SavePointResult; import com.dlink.gateway.result.SavePointResult;
import com.dlink.gateway.result.TestResult; import com.dlink.gateway.result.TestResult;
import com.dlink.model.JobStatus;
import com.dlink.utils.FlinkUtil; import com.dlink.utils.FlinkUtil;
import com.dlink.utils.LogUtil; import com.dlink.utils.LogUtil;
...@@ -51,9 +52,13 @@ import org.apache.hadoop.fs.Path; ...@@ -51,9 +52,13 @@ import org.apache.hadoop.fs.Path;
import org.apache.hadoop.security.UserGroupInformation; import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.service.Service; import org.apache.hadoop.service.Service;
import org.apache.hadoop.yarn.api.records.ApplicationId; import org.apache.hadoop.yarn.api.records.ApplicationId;
import org.apache.hadoop.yarn.api.records.ApplicationReport;
import org.apache.hadoop.yarn.api.records.YarnApplicationState;
import org.apache.hadoop.yarn.client.api.YarnClient; import org.apache.hadoop.yarn.client.api.YarnClient;
import org.apache.hadoop.yarn.conf.YarnConfiguration; import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.hadoop.yarn.exceptions.YarnException;
import java.io.IOException;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.io.StringWriter; import java.io.StringWriter;
import java.net.URI; import java.net.URI;
...@@ -100,7 +105,8 @@ public abstract class YarnGateway extends AbstractGateway { ...@@ -100,7 +105,8 @@ public abstract class YarnGateway extends AbstractGateway {
if (Asserts.isNotNullString(config.getFlinkConfig().getSavePoint())) { if (Asserts.isNotNullString(config.getFlinkConfig().getSavePoint())) {
configuration.setString(SavepointConfigOptions.SAVEPOINT_PATH, config.getFlinkConfig().getSavePoint()); configuration.setString(SavepointConfigOptions.SAVEPOINT_PATH, config.getFlinkConfig().getSavePoint());
} }
configuration.set(YarnConfigOptions.PROVIDED_LIB_DIRS, Collections.singletonList(config.getClusterConfig().getFlinkLibPath())); configuration.set(YarnConfigOptions.PROVIDED_LIB_DIRS,
Collections.singletonList(config.getClusterConfig().getFlinkLibPath()));
if (Asserts.isNotNullString(config.getFlinkConfig().getJobName())) { if (Asserts.isNotNullString(config.getFlinkConfig().getJobName())) {
configuration.set(YarnConfigOptions.APPLICATION_NAME, config.getFlinkConfig().getJobName()); configuration.set(YarnConfigOptions.APPLICATION_NAME, config.getFlinkConfig().getJobName());
} }
...@@ -123,10 +129,12 @@ public abstract class YarnGateway extends AbstractGateway { ...@@ -123,10 +129,12 @@ public abstract class YarnGateway extends AbstractGateway {
if (getType().isApplicationMode()) { if (getType().isApplicationMode()) {
String uuid = UUID.randomUUID().toString().replace("-", ""); String uuid = UUID.randomUUID().toString().replace("-", "");
if (configuration.contains(CheckpointingOptions.CHECKPOINTS_DIRECTORY)) { if (configuration.contains(CheckpointingOptions.CHECKPOINTS_DIRECTORY)) {
configuration.set(CheckpointingOptions.CHECKPOINTS_DIRECTORY, configuration.getString(CheckpointingOptions.CHECKPOINTS_DIRECTORY) + "/" + uuid); configuration.set(CheckpointingOptions.CHECKPOINTS_DIRECTORY,
configuration.getString(CheckpointingOptions.CHECKPOINTS_DIRECTORY) + "/" + uuid);
} }
if (configuration.contains(CheckpointingOptions.SAVEPOINT_DIRECTORY)) { if (configuration.contains(CheckpointingOptions.SAVEPOINT_DIRECTORY)) {
configuration.set(CheckpointingOptions.SAVEPOINT_DIRECTORY, configuration.getString(CheckpointingOptions.SAVEPOINT_DIRECTORY) + "/" + uuid); configuration.set(CheckpointingOptions.SAVEPOINT_DIRECTORY,
configuration.getString(CheckpointingOptions.SAVEPOINT_DIRECTORY) + "/" + uuid);
} }
} }
YarnLogConfigUtil.setLogConfigFileInConfig(configuration, config.getClusterConfig().getFlinkConfigPath()); YarnLogConfigUtil.setLogConfigFileInConfig(configuration, config.getClusterConfig().getFlinkConfigPath());
...@@ -134,9 +142,12 @@ public abstract class YarnGateway extends AbstractGateway { ...@@ -134,9 +142,12 @@ public abstract class YarnGateway extends AbstractGateway {
private void initYarnClient() { private void initYarnClient() {
yarnConfiguration = new YarnConfiguration(); yarnConfiguration = new YarnConfiguration();
yarnConfiguration.addResource(new Path(URI.create(config.getClusterConfig().getYarnConfigPath() + "/yarn-site.xml"))); yarnConfiguration
yarnConfiguration.addResource(new Path(URI.create(config.getClusterConfig().getYarnConfigPath() + "/core-site.xml"))); .addResource(new Path(URI.create(config.getClusterConfig().getYarnConfigPath() + "/yarn-site.xml")));
yarnConfiguration.addResource(new Path(URI.create(config.getClusterConfig().getYarnConfigPath() + "/hdfs-site.xml"))); yarnConfiguration
.addResource(new Path(URI.create(config.getClusterConfig().getYarnConfigPath() + "/core-site.xml")));
yarnConfiguration
.addResource(new Path(URI.create(config.getClusterConfig().getYarnConfigPath() + "/hdfs-site.xml")));
yarnClient = YarnClient.createYarnClient(); yarnClient = YarnClient.createYarnClient();
yarnClient.init(yarnConfiguration); yarnClient.init(yarnConfiguration);
yarnClient.start(); yarnClient.start();
...@@ -160,26 +171,22 @@ public abstract class YarnGateway extends AbstractGateway { ...@@ -160,26 +171,22 @@ public abstract class YarnGateway extends AbstractGateway {
if (Asserts.isNull(yarnClient)) { if (Asserts.isNull(yarnClient)) {
init(); init();
} }
/*if(Asserts.isNotNullString(config.getClusterConfig().getYarnConfigPath())) { /*
configuration = GlobalConfiguration.loadConfiguration(config.getClusterConfig().getYarnConfigPath()); * if(Asserts.isNotNullString(config.getClusterConfig().getYarnConfigPath())) { configuration =
}else { * GlobalConfiguration.loadConfiguration(config.getClusterConfig().getYarnConfigPath()); }else { configuration =
configuration = new Configuration(); * new Configuration(); }
}*/ */
SavePointResult result = SavePointResult.build(getType()); SavePointResult result = SavePointResult.build(getType());
YarnClusterClientFactory clusterClientFactory = new YarnClusterClientFactory(); ApplicationId applicationId = getApplicationId();
configuration.set(YarnConfigOptions.APPLICATION_ID, config.getClusterConfig().getAppId()); /*
ApplicationId applicationId = clusterClientFactory.getClusterId(configuration); * YarnClusterDescriptor clusterDescriptor = clusterClientFactory .createClusterDescriptor( configuration);
if (applicationId == null) { */
throw new GatewayException(
"No cluster id was specified. Please specify a cluster to which you would like to connect.");
}
/*YarnClusterDescriptor clusterDescriptor = clusterClientFactory
.createClusterDescriptor(
configuration);*/
YarnClusterDescriptor clusterDescriptor = new YarnClusterDescriptor( YarnClusterDescriptor clusterDescriptor = new YarnClusterDescriptor(
configuration, yarnConfiguration, yarnClient, YarnClientYarnClusterInformationRetriever.create(yarnClient), true); configuration, yarnConfiguration, yarnClient,
try (ClusterClient<ApplicationId> clusterClient = clusterDescriptor.retrieve( YarnClientYarnClusterInformationRetriever.create(yarnClient), true);
applicationId).getClusterClient()) { try (
ClusterClient<ApplicationId> clusterClient = clusterDescriptor.retrieve(
applicationId).getClusterClient()) {
List<JobInfo> jobInfos = new ArrayList<>(); List<JobInfo> jobInfos = new ArrayList<>();
CompletableFuture<Collection<JobStatusMessage>> listJobsFuture = clusterClient.listJobs(); CompletableFuture<Collection<JobStatusMessage>> listJobsFuture = clusterClient.listJobs();
for (JobStatusMessage jobStatusMessage : listJobsFuture.get()) { for (JobStatusMessage jobStatusMessage : listJobsFuture.get()) {
...@@ -210,28 +217,24 @@ public abstract class YarnGateway extends AbstractGateway { ...@@ -210,28 +217,24 @@ public abstract class YarnGateway extends AbstractGateway {
} }
if (Asserts.isNull(config.getFlinkConfig().getJobId())) { if (Asserts.isNull(config.getFlinkConfig().getJobId())) {
throw new GatewayException( throw new GatewayException(
"No job id was specified. Please specify a job to which you would like to savepont."); "No job id was specified. Please specify a job to which you would like to savepont.");
} }
/*if(Asserts.isNotNullString(config.getClusterConfig().getYarnConfigPath())) { /*
configuration = GlobalConfiguration.loadConfiguration(config.getClusterConfig().getYarnConfigPath()); * if(Asserts.isNotNullString(config.getClusterConfig().getYarnConfigPath())) { configuration =
}else { * GlobalConfiguration.loadConfiguration(config.getClusterConfig().getYarnConfigPath()); }else { configuration =
configuration = new Configuration(); * new Configuration(); }
}*/ */
SavePointResult result = SavePointResult.build(getType()); SavePointResult result = SavePointResult.build(getType());
YarnClusterClientFactory clusterClientFactory = new YarnClusterClientFactory(); ApplicationId applicationId = getApplicationId();
configuration.set(YarnConfigOptions.APPLICATION_ID, config.getClusterConfig().getAppId()); /*
ApplicationId applicationId = clusterClientFactory.getClusterId(configuration); * YarnClusterDescriptor clusterDescriptor = clusterClientFactory .createClusterDescriptor( configuration);
if (Asserts.isNull(applicationId)) { */
throw new GatewayException(
"No cluster id was specified. Please specify a cluster to which you would like to connect.");
}
/*YarnClusterDescriptor clusterDescriptor = clusterClientFactory
.createClusterDescriptor(
configuration);*/
YarnClusterDescriptor clusterDescriptor = new YarnClusterDescriptor( YarnClusterDescriptor clusterDescriptor = new YarnClusterDescriptor(
configuration, yarnConfiguration, yarnClient, YarnClientYarnClusterInformationRetriever.create(yarnClient), true); configuration, yarnConfiguration, yarnClient,
try (ClusterClient<ApplicationId> clusterClient = clusterDescriptor.retrieve( YarnClientYarnClusterInformationRetriever.create(yarnClient), true);
applicationId).getClusterClient()) { try (
ClusterClient<ApplicationId> clusterClient = clusterDescriptor.retrieve(
applicationId).getClusterClient()) {
List<JobInfo> jobInfos = new ArrayList<>(); List<JobInfo> jobInfos = new ArrayList<>();
jobInfos.add(new JobInfo(config.getFlinkConfig().getJobId(), JobInfo.JobStatus.FAIL)); jobInfos.add(new JobInfo(config.getFlinkConfig().getJobId(), JobInfo.JobStatus.FAIL));
runSavePointJob(jobInfos, clusterClient, savePoint); runSavePointJob(jobInfos, clusterClient, savePoint);
...@@ -239,7 +242,8 @@ public abstract class YarnGateway extends AbstractGateway { ...@@ -239,7 +242,8 @@ public abstract class YarnGateway extends AbstractGateway {
} catch (Exception e) { } catch (Exception e) {
result.fail(LogUtil.getError(e)); result.fail(LogUtil.getError(e));
} }
if (ActionType.CANCEL == config.getFlinkConfig().getAction() || SavePointType.CANCEL.equals(config.getFlinkConfig().getSavePointType())) { if (ActionType.CANCEL == config.getFlinkConfig().getAction()
|| SavePointType.CANCEL.equals(config.getFlinkConfig().getSavePointType())) {
try { try {
autoCancelCluster(clusterDescriptor.retrieve(applicationId).getClusterClient()); autoCancelCluster(clusterDescriptor.retrieve(applicationId).getClusterClient());
} catch (ClusterRetrieveException e) { } catch (ClusterRetrieveException e) {
...@@ -249,7 +253,8 @@ public abstract class YarnGateway extends AbstractGateway { ...@@ -249,7 +253,8 @@ public abstract class YarnGateway extends AbstractGateway {
return result; return result;
} }
private void runSavePointJob(List<JobInfo> jobInfos, ClusterClient<ApplicationId> clusterClient, String savePoint) throws Exception { private void runSavePointJob(List<JobInfo> jobInfos, ClusterClient<ApplicationId> clusterClient,
String savePoint) throws Exception {
for (JobInfo jobInfo : jobInfos) { for (JobInfo jobInfo : jobInfos) {
if (ActionType.CANCEL == config.getFlinkConfig().getAction()) { if (ActionType.CANCEL == config.getFlinkConfig().getAction()) {
clusterClient.cancel(JobID.fromHexString(jobInfo.getJobId())); clusterClient.cancel(JobID.fromHexString(jobInfo.getJobId()));
...@@ -258,14 +263,14 @@ public abstract class YarnGateway extends AbstractGateway { ...@@ -258,14 +263,14 @@ public abstract class YarnGateway extends AbstractGateway {
} }
switch (config.getFlinkConfig().getSavePointType()) { switch (config.getFlinkConfig().getSavePointType()) {
case TRIGGER: case TRIGGER:
jobInfo.setSavePoint(FlinkUtil.triggerSavepoint(clusterClient,jobInfo.getJobId(),savePoint)); jobInfo.setSavePoint(FlinkUtil.triggerSavepoint(clusterClient, jobInfo.getJobId(), savePoint));
break; break;
case STOP: case STOP:
jobInfo.setSavePoint(FlinkUtil.stopWithSavepoint(clusterClient,jobInfo.getJobId(),savePoint)); jobInfo.setSavePoint(FlinkUtil.stopWithSavepoint(clusterClient, jobInfo.getJobId(), savePoint));
jobInfo.setStatus(JobInfo.JobStatus.STOP); jobInfo.setStatus(JobInfo.JobStatus.STOP);
break; break;
case CANCEL: case CANCEL:
jobInfo.setSavePoint(FlinkUtil.cancelWithSavepoint(clusterClient,jobInfo.getJobId(),savePoint)); jobInfo.setSavePoint(FlinkUtil.cancelWithSavepoint(clusterClient, jobInfo.getJobId(), savePoint));
jobInfo.setStatus(JobInfo.JobStatus.CANCEL); jobInfo.setStatus(JobInfo.JobStatus.CANCEL);
break; break;
default: default:
...@@ -307,4 +312,47 @@ public abstract class YarnGateway extends AbstractGateway { ...@@ -307,4 +312,47 @@ public abstract class YarnGateway extends AbstractGateway {
return TestResult.fail("测试 Yarn 配置失败:" + e.getMessage()); return TestResult.fail("测试 Yarn 配置失败:" + e.getMessage());
} }
} }
private ApplicationId getApplicationId() {
YarnClusterClientFactory clusterClientFactory = new YarnClusterClientFactory();
configuration.set(YarnConfigOptions.APPLICATION_ID, config.getClusterConfig().getAppId());
ApplicationId applicationId = clusterClientFactory.getClusterId(configuration);
if (Asserts.isNull(applicationId)) {
throw new GatewayException(
"No cluster id was specified. Please specify a cluster to which you would like to connect.");
}
return applicationId;
}
@Override
public JobStatus getJobStatusById(String id) {
if (Asserts.isNull(yarnClient)) {
init();
}
config.getClusterConfig().setAppId(id);
ApplicationReport applicationReport = null;
try {
applicationReport = yarnClient.getApplicationReport(getApplicationId());
YarnApplicationState yarnApplicationState = applicationReport.getYarnApplicationState();
switch (yarnApplicationState) {
case FINISHED:
return JobStatus.FINISHED;
case RUNNING:
return JobStatus.RUNNING;
case FAILED:
return JobStatus.FAILED;
case KILLED:
return JobStatus.CANCELED;
case SUBMITTED:
return JobStatus.CREATED;
default:
return JobStatus.INITIALIZING;
}
} catch (YarnException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return JobStatus.UNKNOWN;
}
} }
...@@ -75,24 +75,32 @@ public class YarnPerJobGateway extends YarnGateway { ...@@ -75,24 +75,32 @@ public class YarnPerJobGateway extends YarnGateway {
} }
YarnResult result = YarnResult.build(getType()); YarnResult result = YarnResult.build(getType());
YarnClusterDescriptor yarnClusterDescriptor = new YarnClusterDescriptor( YarnClusterDescriptor yarnClusterDescriptor = new YarnClusterDescriptor(
configuration, yarnConfiguration, yarnClient, YarnClientYarnClusterInformationRetriever.create(yarnClient), true); configuration, yarnConfiguration, yarnClient,
YarnClientYarnClusterInformationRetriever.create(yarnClient), true);
ClusterSpecification.ClusterSpecificationBuilder clusterSpecificationBuilder = new ClusterSpecification.ClusterSpecificationBuilder(); ClusterSpecification.ClusterSpecificationBuilder clusterSpecificationBuilder =
new ClusterSpecification.ClusterSpecificationBuilder();
if (configuration.contains(JobManagerOptions.TOTAL_PROCESS_MEMORY)) { if (configuration.contains(JobManagerOptions.TOTAL_PROCESS_MEMORY)) {
clusterSpecificationBuilder.setMasterMemoryMB(configuration.get(JobManagerOptions.TOTAL_PROCESS_MEMORY).getMebiBytes()); clusterSpecificationBuilder
.setMasterMemoryMB(configuration.get(JobManagerOptions.TOTAL_PROCESS_MEMORY).getMebiBytes());
} }
if (configuration.contains(TaskManagerOptions.TOTAL_PROCESS_MEMORY)) { if (configuration.contains(TaskManagerOptions.TOTAL_PROCESS_MEMORY)) {
clusterSpecificationBuilder.setTaskManagerMemoryMB(configuration.get(TaskManagerOptions.TOTAL_PROCESS_MEMORY).getMebiBytes()); clusterSpecificationBuilder
.setTaskManagerMemoryMB(configuration.get(TaskManagerOptions.TOTAL_PROCESS_MEMORY).getMebiBytes());
} }
if (configuration.contains(TaskManagerOptions.NUM_TASK_SLOTS)) { if (configuration.contains(TaskManagerOptions.NUM_TASK_SLOTS)) {
clusterSpecificationBuilder.setSlotsPerTaskManager(configuration.get(TaskManagerOptions.NUM_TASK_SLOTS)).createClusterSpecification(); clusterSpecificationBuilder.setSlotsPerTaskManager(configuration.get(TaskManagerOptions.NUM_TASK_SLOTS))
.createClusterSpecification();
} }
jobGraph.addJars(Arrays.stream(config.getJarPaths()).map(path -> URLUtil.getURL(FileUtil.file(path))).collect(Collectors.toList())); if (Asserts.isNotNull(config.getJarPaths())) {
jobGraph.addJars(Arrays.stream(config.getJarPaths()).map(path -> URLUtil.getURL(FileUtil.file(path)))
.collect(Collectors.toList()));
}
try { try {
ClusterClientProvider<ApplicationId> clusterClientProvider = yarnClusterDescriptor.deployJobCluster( ClusterClientProvider<ApplicationId> clusterClientProvider = yarnClusterDescriptor.deployJobCluster(
clusterSpecificationBuilder.createClusterSpecification(), jobGraph, true); clusterSpecificationBuilder.createClusterSpecification(), jobGraph, true);
ClusterClient<ApplicationId> clusterClient = clusterClientProvider.getClusterClient(); ClusterClient<ApplicationId> clusterClient = clusterClientProvider.getClusterClient();
ApplicationId applicationId = clusterClient.getClusterId(); ApplicationId applicationId = clusterClient.getClusterId();
result.setAppId(applicationId.toString()); result.setAppId(applicationId.toString());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment