Unverified Commit be0ff515 authored by Licho's avatar Licho Committed by GitHub

refacotr: DolphinSchedule logic (#2307)

* refacotr: dolphone Signed-off-by: 's avatarLicho <lecho.sun@gmail.com> * Spotless Apply * refacotr: dolphinScheduler undefined error * refactor: fetchData type * refactor: type * refactor: type * refactor: type * fix: type or null * fix: dolphin problem * fix: left corner hide problem * Spotless Apply * fix: minWith --------- Signed-off-by: 's avatarLicho <lecho.sun@gmail.com> Co-authored-by: 's avatarleechor <leechor@users.noreply.github.com>
parent baebf478
......@@ -33,7 +33,9 @@ import org.apache.commons.lang3.StringUtils;
import java.lang.reflect.Method;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
......@@ -71,7 +73,7 @@ public class LogAspect {
*/
@AfterReturning(pointcut = "logPointCut()", returning = "jsonResult")
public void doAfterReturning(JoinPoint joinPoint, Object jsonResult) {
handleLog(joinPoint, null, jsonResult);
handleCommonLogic(joinPoint, null, jsonResult);
}
/**
......@@ -82,10 +84,10 @@ public class LogAspect {
*/
@AfterThrowing(value = "logPointCut()", throwing = "e")
public void doAfterThrowing(JoinPoint joinPoint, Exception e) {
handleLog(joinPoint, e, null);
handleCommonLogic(joinPoint, e, null);
}
protected void handleLog(final JoinPoint joinPoint, final Exception e, Object jsonResult) {
protected void handleCommonLogic(final JoinPoint joinPoint, final Exception e, Object jsonResult) {
try {
// 获得注解
Log controllerLog = getAnnotationLog(joinPoint);
......@@ -165,7 +167,7 @@ public class LogAspect {
* @param operLog 操作日志
* @throws Exception 异常
*/
private void setRequestValue(JoinPoint joinPoint, OperateLog operLog) throws Exception {
private void setRequestValue(JoinPoint joinPoint, OperateLog operLog) {
String requestMethod = operLog.getRequestMethod();
if (HttpMethod.PUT.name().equals(requestMethod)
|| HttpMethod.POST.name().equals(requestMethod)) {
......@@ -192,16 +194,10 @@ public class LogAspect {
/** 参数拼装 */
private String argsArrayToString(Object[] paramsArray) {
String params = "";
if (paramsArray != null && paramsArray.length > 0) {
for (int i = 0; i < paramsArray.length; i++) {
if (!isFilterObject(paramsArray[i])) {
String jsonObj = JSONUtil.toJsonStr(paramsArray[i]);
params += jsonObj + " ";
}
}
}
return params.trim();
return Arrays.stream(paramsArray)
.filter(o -> !isFilterObject(o))
.map(JSONUtil::toJsonStr)
.collect(Collectors.joining(" "));
}
/**
......
......@@ -74,22 +74,22 @@ public class APIController {
@GetMapping("/submitTask")
@ApiOperation("Submit Task")
@Log(title = "Submit Task", businessType = BusinessType.SUBMIT)
// @Log(title = "Submit Task", businessType = BusinessType.SUBMIT)
public Result<JobResult> submitTask(@RequestParam Integer id) {
taskService.initTenantByTaskId(id);
return Result.succeed(taskService.submitTask(id), Status.EXECUTE_SUCCESS);
}
@PostMapping("/executeSql")
@Log(title = "Execute Sql", businessType = BusinessType.EXECUTE)
@ApiOperation("Execute Sql")
// @Log(title = "Execute Sql", businessType = BusinessType.EXECUTE)
public Result<APIJobResult> executeSql(@RequestBody APIExecuteSqlDTO apiExecuteSqlDTO) {
return Result.succeed(apiService.executeSql(apiExecuteSqlDTO), Status.EXECUTE_SUCCESS);
}
@PostMapping("/explainSql")
@Log(title = "Explain Sql", businessType = BusinessType.EXECUTE)
@ApiOperation("Explain Sql")
// @Log(title = "Explain Sql", businessType = BusinessType.EXECUTE)
public Result<ExplainResult> explainSql(@RequestBody APIExplainSqlDTO apiExecuteSqlDTO) {
return Result.succeed(apiService.explainSql(apiExecuteSqlDTO), Status.EXECUTE_SUCCESS);
}
......@@ -127,15 +127,15 @@ public class APIController {
}
@PostMapping("/executeJar")
@Log(title = "Execute Jar", businessType = BusinessType.EXECUTE)
@ApiOperation("Execute Jar")
// @Log(title = "Execute Jar", businessType = BusinessType.EXECUTE)
public Result<APIJobResult> executeJar(@RequestBody APIExecuteJarDTO apiExecuteJarDTO) {
return Result.succeed(apiService.executeJar(apiExecuteJarDTO), Status.EXECUTE_SUCCESS);
}
@PostMapping("/savepointTask")
@Log(title = "Savepoint Task", businessType = BusinessType.TRIGGER)
@ApiOperation("Savepoint Task")
// @Log(title = "Savepoint Task", businessType = BusinessType.TRIGGER)
public Result<Boolean> savepointTask(@RequestBody APISavePointTaskDTO apiSavePointTaskDTO) {
return Result.succeed(
taskService.savepointTask(apiSavePointTaskDTO.getTaskId(), apiSavePointTaskDTO.getType()), "执行成功");
......@@ -144,7 +144,7 @@ public class APIController {
/** 重启任务 */
@GetMapping("/restartTask")
@ApiOperation("Restart Task")
@Log(title = "Restart Task", businessType = BusinessType.EXECUTE)
// @Log(title = "Restart Task", businessType = BusinessType.EXECUTE)
public Result<JobResult> restartTask(@RequestParam Integer id) {
taskService.initTenantByTaskId(id);
return Result.succeed(taskService.restartTask(id, null), Status.RESTART_SUCCESS);
......@@ -153,7 +153,7 @@ public class APIController {
/** 选择保存点重启任务 */
@GetMapping("/selectSavePointRestartTask")
@ApiOperation("Select SavePoint Restart Task")
@Log(title = "Select SavePoint Restart Task", businessType = BusinessType.EXECUTE)
// @Log(title = "Select SavePoint Restart Task", businessType = BusinessType.EXECUTE)
public Result<JobResult> restartTask(@RequestParam Integer id, @RequestParam String savePointPath) {
taskService.initTenantByTaskId(id);
return Result.succeed(taskService.restartTask(id, savePointPath), Status.RESTART_SUCCESS);
......@@ -162,7 +162,7 @@ public class APIController {
/** 上线任务 */
@GetMapping("/onLineTask")
@ApiOperation("Online Task")
@Log(title = "Online Task", businessType = BusinessType.EXECUTE)
// @Log(title = "Online Task", businessType = BusinessType.EXECUTE)
public Result<JobResult> onLineTask(@RequestParam Integer id) {
taskService.initTenantByTaskId(id);
return taskService.onLineTask(id);
......@@ -171,7 +171,7 @@ public class APIController {
/** 下线任务 */
@GetMapping("/offLineTask")
@ApiOperation("Offline Task")
@Log(title = "Offline Task", businessType = BusinessType.EXECUTE)
// @Log(title = "Offline Task", businessType = BusinessType.EXECUTE)
public Result<Void> offLineTask(@RequestParam Integer id) {
taskService.initTenantByTaskId(id);
return taskService.offLineTask(id, null);
......@@ -180,7 +180,7 @@ public class APIController {
/** 重新上线任务 */
@GetMapping("/reOnLineTask")
@ApiOperation("ReOnline Task")
@Log(title = "ReOnline Task", businessType = BusinessType.EXECUTE)
// @Log(title = "ReOnline Task", businessType = BusinessType.EXECUTE)
public Result<JobResult> reOnLineTask(@RequestParam Integer id) {
taskService.initTenantByTaskId(id);
return taskService.reOnLineTask(id, null);
......@@ -189,7 +189,7 @@ public class APIController {
/** 选择保存点重新上线任务 */
@GetMapping("/selectSavePointReOnLineTask")
@ApiOperation("Select SavePoint ReOnline Task")
@Log(title = "Select SavePoint ReOnline Task", businessType = BusinessType.EXECUTE)
// @Log(title = "Select SavePoint ReOnline Task", businessType = BusinessType.EXECUTE)
public Result<JobResult> selectSavePointReOnLineTask(@RequestParam Integer id, @RequestParam String savePointPath) {
taskService.initTenantByTaskId(id);
return taskService.reOnLineTask(id, savePointPath);
......@@ -197,8 +197,8 @@ public class APIController {
/** 获取Job实例的信息 */
@GetMapping("/getJobInstance")
@Log(title = "Get Job Instance", businessType = BusinessType.QUERY)
@ApiOperation("Get Job Instance")
// @Log(title = "Get Job Instance", businessType = BusinessType.QUERY)
public Result<JobInstance> getJobInstance(@RequestParam Integer id) {
jobInstanceService.initTenantByJobInstanceId(id);
return Result.succeed(jobInstanceService.getById(id));
......@@ -206,8 +206,8 @@ public class APIController {
/** 通过 taskId 获取 Task 对应的 Job 实例的信息 */
@GetMapping("/getJobInstanceByTaskId")
@Log(title = "Get Job Instance By Task Id", businessType = BusinessType.QUERY)
@ApiOperation("Get Job Instance By Task Id")
// @Log(title = "Get Job Instance By Task Id", businessType = BusinessType.QUERY)
public Result<JobInstance> getJobInstanceByTaskId(@RequestParam Integer id) {
taskService.initTenantByTaskId(id);
return Result.succeed(jobInstanceService.getJobInstanceByTaskId(id));
......
......@@ -37,9 +37,6 @@ import org.dinky.scheduler.model.TaskMainInfo;
import org.dinky.scheduler.model.TaskRequest;
import org.dinky.service.CatalogueService;
import org.apache.commons.lang3.StringUtils;
import java.util.Collections;
import java.util.List;
import javax.validation.Valid;
......@@ -53,7 +50,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.google.common.collect.Lists;
import com.google.common.base.Strings;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
......@@ -69,6 +66,7 @@ import lombok.RequiredArgsConstructor;
@RequiredArgsConstructor
public class SchedulerController {
public static final String TASK_TYPE = "DINKY";
private final ProcessClient processClient;
private final TaskClient taskClient;
private final CatalogueService catalogueService;
......@@ -77,36 +75,32 @@ public class SchedulerController {
@GetMapping("/task")
@ApiOperation("Get Task Definition")
public Result<TaskDefinition> getTaskDefinition(@ApiParam(value = "dinky任务id") @RequestParam Long dinkyTaskId) {
TaskDefinition taskDefinition = null;
Project dinkyProject = SystemInit.getProject();
Catalogue catalogue =
catalogueService.getOne(new LambdaQueryWrapper<Catalogue>().eq(Catalogue::getTaskId, dinkyTaskId));
if (catalogue == null) {
return Result.failed(Status.DS_GET_NODE_LIST_ERROR);
}
List<String> lists = Lists.newArrayList();
getDinkyNames(lists, catalogue, 0);
Collections.reverse(lists);
String processName = StringUtils.join(lists, "_");
String taskName = catalogue.getName() + ":" + catalogue.getId();
Project dinkyProject = SystemInit.getProject();
long projectCode = dinkyProject.getCode();
TaskMainInfo taskMainInfo = taskClient.getTaskMainInfo(projectCode, processName, taskName);
if (taskMainInfo != null) {
taskDefinition = taskClient.getTaskDefinition(projectCode, taskMainInfo.getTaskCode());
String processName = getDinkyNames(catalogue, 0);
String taskName = catalogue.getName() + ":" + catalogue.getId();
TaskMainInfo taskMainInfo = taskClient.getTaskMainInfo(projectCode, processName, taskName);
TaskDefinition taskDefinition = null;
if (taskMainInfo == null) {
return Result.succeed(taskDefinition);
}
if (taskDefinition != null) {
taskDefinition.setProcessDefinitionCode(taskMainInfo.getProcessDefinitionCode());
taskDefinition.setProcessDefinitionName(taskMainInfo.getProcessDefinitionName());
taskDefinition.setProcessDefinitionVersion(taskMainInfo.getProcessDefinitionVersion());
taskDefinition.setUpstreamTaskMap(taskMainInfo.getUpstreamTaskMap());
} else {
return Result.failed(Status.DS_WORK_FLOW_NOT_SAVE);
}
taskDefinition = taskClient.getTaskDefinition(projectCode, taskMainInfo.getTaskCode());
if (taskDefinition == null) {
return Result.failed(Status.DS_WORK_FLOW_NOT_SAVE);
}
taskDefinition.setProcessDefinitionCode(taskMainInfo.getProcessDefinitionCode());
taskDefinition.setProcessDefinitionName(taskMainInfo.getProcessDefinitionName());
taskDefinition.setProcessDefinitionVersion(taskMainInfo.getProcessDefinitionVersion());
taskDefinition.setUpstreamTaskMap(taskMainInfo.getUpstreamTaskMap());
return Result.succeed(taskDefinition);
}
......@@ -114,22 +108,14 @@ public class SchedulerController {
@GetMapping("/upstream/tasks")
@ApiOperation("Get Upstream Task Definition")
public Result<List<TaskMainInfo>> getTaskMainInfos(@ApiParam(value = "dinky任务id") @RequestParam Long dinkyTaskId) {
Project dinkyProject = SystemInit.getProject();
Catalogue catalogue =
catalogueService.getOne(new LambdaQueryWrapper<Catalogue>().eq(Catalogue::getTaskId, dinkyTaskId));
if (catalogue == null) {
return Result.failed(Status.DS_GET_NODE_LIST_ERROR);
}
List<String> lists = Lists.newArrayList();
getDinkyNames(lists, catalogue, 0);
Collections.reverse(lists);
String processName = StringUtils.join(lists, "_");
long projectCode = dinkyProject.getCode();
long projectCode = SystemInit.getProject().getCode();
String processName = getDinkyNames(catalogue, 0);
List<TaskMainInfo> taskMainInfos = taskClient.getTaskMainInfos(projectCode, processName, "");
// 去掉本身
taskMainInfos.removeIf(taskMainInfo ->
......@@ -150,9 +136,7 @@ public class SchedulerController {
dinkyTaskParams.setAddress(
SystemConfiguration.getInstances().getDinkyAddr().getValue());
taskRequest.setTaskParams(JSONUtil.parseObj(dinkyTaskParams).toString());
taskRequest.setTaskType("DINKY");
Project dinkyProject = SystemInit.getProject();
taskRequest.setTaskType(TASK_TYPE);
Catalogue catalogue =
catalogueService.getOne(new LambdaQueryWrapper<Catalogue>().eq(Catalogue::getTaskId, dinkyTaskId));
......@@ -160,14 +144,11 @@ public class SchedulerController {
return Result.failed(Status.DS_GET_NODE_LIST_ERROR);
}
List<String> lists = Lists.newArrayList();
getDinkyNames(lists, catalogue, 0);
Collections.reverse(lists);
String processName = StringUtils.join(lists, "_");
String taskName = catalogue.getName() + ":" + catalogue.getId();
long projectCode = dinkyProject.getCode();
String processName = getDinkyNames(catalogue, 0);
long projectCode = SystemInit.getProject().getCode();
ProcessDefinition process = processClient.getProcessDefinitionInfo(projectCode, processName);
String taskName = catalogue.getName() + ":" + catalogue.getId();
taskRequest.setName(taskName);
if (process == null) {
Long taskCode = taskClient.genTaskCode(projectCode);
......@@ -176,23 +157,22 @@ public class SchedulerController {
JSONArray array = new JSONArray();
array.set(jsonObject);
processClient.createProcessDefinition(projectCode, processName, taskCode, array.toString());
return Result.succeed(Status.DS_ADD_WORK_FLOW_DEFINITION_SUCCESS);
} else {
if (process.getReleaseState() == ReleaseState.ONLINE) {
return Result.failed(Status.DS_WORK_FLOW_DEFINITION_ONLINE, (Object) processName);
}
long processCode = process.getCode();
TaskMainInfo taskDefinitionInfo = taskClient.getTaskMainInfo(projectCode, processName, taskName);
if (taskDefinitionInfo != null) {
return Result.failed(Status.DS_WORK_FLOW_DEFINITION_TASK_NAME_EXIST, processName, taskName);
}
}
String taskDefinitionJsonObj = JSONUtil.toJsonStr(taskRequest);
taskClient.createTaskDefinition(projectCode, processCode, upstreamCodes, taskDefinitionJsonObj);
if (process.getReleaseState() == ReleaseState.ONLINE) {
return Result.failed(Status.DS_WORK_FLOW_DEFINITION_ONLINE, (Object) processName);
}
return Result.succeed(Status.DS_ADD_TASK_DEFINITION_SUCCESS);
TaskMainInfo taskDefinitionInfo = taskClient.getTaskMainInfo(projectCode, processName, taskName);
if (taskDefinitionInfo != null) {
return Result.failed(Status.DS_WORK_FLOW_DEFINITION_TASK_NAME_EXIST, processName, taskName);
}
String taskDefinitionJsonObj = JSONUtil.toJsonStr(taskRequest);
taskClient.createTaskDefinition(projectCode, process.getCode(), upstreamCodes, taskDefinitionJsonObj);
return Result.succeed(Status.DS_ADD_TASK_DEFINITION_SUCCESS);
}
/** 更新任务定义 */
......@@ -209,46 +189,50 @@ public class SchedulerController {
if (taskDefinition == null) {
return Result.failed(Status.DS_TASK_NOT_EXIST);
}
if (!"DINKY".equals(taskDefinition.getTaskType())) {
if (!TASK_TYPE.equals(taskDefinition.getTaskType())) {
return Result.failed(Status.DS_TASK_TYPE_NOT_SUPPORT, (Object) taskDefinition.getTaskType());
}
DagData dagData = processClient.getProcessDefinitionInfo(projectCode, processCode);
if (dagData == null) {
return Result.failed(Status.DS_WORK_FLOW_DEFINITION_NOT_EXIST);
}
ProcessDefinition process = dagData.getProcessDefinition();
if (process == null) {
return Result.failed(Status.DS_WORK_FLOW_DEFINITION_NOT_EXIST);
}
if (process.getReleaseState() == ReleaseState.ONLINE) {
return Result.failed(Status.DS_WORK_FLOW_DEFINITION_ONLINE, (Object) process.getName());
}
taskRequest.setName(taskDefinition.getName());
taskRequest.setTaskParams(taskDefinition.getTaskParams());
taskRequest.setTaskType("DINKY");
taskRequest.setTaskType(TASK_TYPE);
String taskDefinitionJsonObj = JSONUtil.toJsonStr(taskRequest);
taskClient.updateTaskDefinition(projectCode, taskCode, upstreamCodes, taskDefinitionJsonObj);
return Result.succeed(Status.MODIFY_SUCCESS);
}
private void getDinkyNames(List<String> lists, Catalogue catalogue, int i) {
if (i == 3) {
return;
}
if (catalogue.getParentId().equals(0)) {
return;
private String getDinkyNames(Catalogue catalogue, int i) {
if (i == 3 || catalogue.getParentId().equals(0)) {
return "";
}
catalogue = catalogueService.getById(catalogue.getParentId());
if (catalogue == null) {
throw new SchedulerException("Get Node List Error");
}
if (i == 0) {
lists.add(catalogue.getName() + ":" + catalogue.getId());
} else {
lists.add(catalogue.getName());
String name = i == 0 ? catalogue.getName() + ":" + catalogue.getId() : catalogue.getName();
String next = getDinkyNames(catalogue, ++i);
if (Strings.isNullOrEmpty(next)) {
return name;
}
getDinkyNames(lists, catalogue, ++i);
return name + "_" + next;
}
}
......@@ -116,52 +116,50 @@ public class SystemInit implements ApplicationRunner {
systemConfiguration.getResourcesHdfsDefaultFS(),
systemConfiguration.getResourcesOssAccessKey(),
systemConfiguration.getResourcesOssRegion())
.forEach(x -> {
x.addParameterCheck((y) -> {
if (systemConfiguration.getResourcesEnable().getValue()) {
switch (systemConfiguration.getResourcesModel().getValue()) {
case OSS:
OssProperties ossProperties = new OssProperties();
ossProperties.setAccessKey(systemConfiguration
.getResourcesOssAccessKey()
.getValue());
ossProperties.setSecretKey(systemConfiguration
.getResourcesOssSecretKey()
.getValue());
ossProperties.setEndpoint(systemConfiguration
.getResourcesOssEndpoint()
.getValue());
ossProperties.setBucketName(systemConfiguration
.getResourcesOssBucketName()
.getValue());
ossProperties.setRegion(systemConfiguration
.getResourcesOssRegion()
.getValue());
Singleton.get(OssResourceManager.class)
.setOssTemplate(new OssTemplate(ossProperties));
break;
case HDFS:
final Configuration configuration = new Configuration();
configuration.set(
"fs.defaultFS",
.forEach(x -> x.addParameterCheck(y -> {
if (Boolean.TRUE.equals(
systemConfiguration.getResourcesEnable().getValue())) {
switch (systemConfiguration.getResourcesModel().getValue()) {
case OSS:
OssProperties ossProperties = new OssProperties();
ossProperties.setAccessKey(systemConfiguration
.getResourcesOssAccessKey()
.getValue());
ossProperties.setSecretKey(systemConfiguration
.getResourcesOssSecretKey()
.getValue());
ossProperties.setEndpoint(systemConfiguration
.getResourcesOssEndpoint()
.getValue());
ossProperties.setBucketName(systemConfiguration
.getResourcesOssBucketName()
.getValue());
ossProperties.setRegion(systemConfiguration
.getResourcesOssRegion()
.getValue());
Singleton.get(OssResourceManager.class).setOssTemplate(new OssTemplate(ossProperties));
break;
case HDFS:
final Configuration configuration = new Configuration();
configuration.set(
"fs.defaultFS",
systemConfiguration
.getResourcesHdfsDefaultFS()
.getValue());
try {
FileSystem fileSystem = FileSystem.get(
getDefaultUri(configuration),
configuration,
systemConfiguration
.getResourcesHdfsDefaultFS()
.getResourcesHdfsUser()
.getValue());
try {
FileSystem fileSystem = FileSystem.get(
getDefaultUri(configuration),
configuration,
systemConfiguration
.getResourcesHdfsUser()
.getValue());
Singleton.get(HdfsResourceManager.class).setHdfs(fileSystem);
} catch (Exception e) {
throw new DinkyException(e);
}
}
Singleton.get(HdfsResourceManager.class).setHdfs(fileSystem);
} catch (Exception e) {
throw new DinkyException(e);
}
}
});
});
}
}));
}
/** init task monitor */
......@@ -181,7 +179,8 @@ public class SystemInit implements ApplicationRunner {
.getAllConfiguration()
.get("dolphinscheduler")
.forEach(c -> c.addParameterCheck(v -> {
if (systemConfiguration.getDolphinschedulerEnable().getValue()) {
if (Boolean.TRUE.equals(
systemConfiguration.getDolphinschedulerEnable().getValue())) {
if (StrUtil.isEmpty(Convert.toStr(v))) {
sysConfigService.updateSysConfigByKv(
systemConfiguration
......
......@@ -173,9 +173,7 @@ public class Configuration<T> implements Serializable {
}
public void runParameterCheck() {
getParameterCheckConsumer().forEach(x -> {
x.accept(getValue());
});
getParameterCheckConsumer().forEach(x -> x.accept(getValue()));
}
public void runChangeEvent() {
......
......@@ -67,6 +67,7 @@ public class CustomParserImpl implements CustomParser {
return command.map(Collections::singletonList).orElse(null);
}
@Override
public Parser getParser() {
return parser;
}
......
......@@ -30,9 +30,11 @@ import org.dinky.scheduler.utils.ParamUtil;
import org.dinky.scheduler.utils.ReadFileUtil;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -57,13 +59,10 @@ public class ProcessClient {
* @return {@link List<ProcessDefinition>}
*/
public List<ProcessDefinition> getProcessDefinition(Long projectCode, String processName) {
Map<String, Object> map = new HashMap<>();
map.put("projectCode", projectCode);
String format = StrUtil.format(
SystemConfiguration.getInstances().getDolphinschedulerUrl().getValue()
+ "/projects/{projectCode}/process-definition",
map);
Collections.singletonMap("projectCode", projectCode));
String content = HttpRequest.get(format)
.header(
......@@ -95,14 +94,11 @@ public class ProcessClient {
* @return {@link ProcessDefinition}
*/
public ProcessDefinition getProcessDefinitionInfo(Long projectCode, String processName) {
List<ProcessDefinition> lists = getProcessDefinition(projectCode, processName);
for (ProcessDefinition list : lists) {
if (list.getName().equalsIgnoreCase(processName)) {
return list;
}
}
return null;
Optional<ProcessDefinition> processDefinition = lists.stream()
.filter(list -> list.getName().equalsIgnoreCase(processName))
.findFirst();
return processDefinition.orElse(null);
}
/**
......@@ -143,23 +139,16 @@ public class ProcessClient {
*/
public ProcessDefinition createProcessDefinition(
Long projectCode, String processName, Long taskCode, String taskDefinitionJson) {
Map<String, Object> map = new HashMap<>();
map.put("projectCode", projectCode);
String format = StrUtil.format(
SystemConfiguration.getInstances().getDolphinschedulerUrl().getValue()
+ "/projects/{projectCode}/process-definition",
map);
Map<String, Object> taskMap = new HashMap<>();
taskMap.put("code", taskCode);
String taskRelationJson = ReadFileUtil.taskRelation(taskMap);
Collections.singletonMap("projectCode", projectCode));
Map<String, Object> params = new HashMap<>();
params.put("name", processName);
params.put("description", "系统添加");
params.put("tenantCode", "default");
params.put("taskRelationJson", taskRelationJson);
params.put("taskRelationJson", ReadFileUtil.taskRelation(Collections.singletonMap("code", taskCode)));
params.put("taskDefinitionJson", taskDefinitionJson);
params.put("executionType", "PARALLEL");
......
......@@ -95,9 +95,8 @@ public class ProjectClient {
.execute()
.body();
Project pageBeanAndFindByName = null;
try {
pageBeanAndFindByName = MyJSONUtil.toPageBeanAndFindByName(
return MyJSONUtil.toPageBeanAndFindByName(
content,
SystemConfiguration.getInstances()
.getDolphinschedulerProjectName()
......@@ -107,7 +106,5 @@ public class ProjectClient {
SystemConfiguration.getInstances().getDolphinschedulerEnable().setValue(false);
throw new RuntimeException(content);
}
return pageBeanAndFindByName;
}
}
......@@ -826,7 +826,7 @@ export default {
'地址必须和DolphinScheduler后台配置的地址一致,eg: http://127.0.0.1:12345/dolphinscheduler',
'sys.dolphinscheduler.settings.token': 'DolphinScheduler Token',
'sys.dolphinscheduler.settings.token.note':
'DolphinScheduler的Token,请在DolphinScheduler的安全中心->Token管理中创建一个token,并填入该配置中',
'DolphinScheduler的Token,请在DolphinScheduler的安全中心->令牌管理中创建一个token,并填入该配置中',
'sys.dolphinscheduler.settings.projectName': 'DolphinScheduler 项目名',
'sys.dolphinscheduler.settings.projectName.note':
'DolphinScheduler 中指定的项目名称,不区分大小写',
......
......@@ -285,7 +285,14 @@ const DataStudio = (props: any) => {
<PersistGate loading={null} persistor={persist}>
<div style={{ marginInline: -10, marginTop: -6, width: size.width }}>
<SecondHeaderContainer size={size} activeBreadcrumbTitle={activeBreadcrumbTitle} />
<Layout hasSider style={{ minHeight: size.contentHeight, paddingInline: 0 }}>
<Layout
hasSider
style={{
minHeight: size.contentHeight,
maxHeight: size.contentHeight,
paddingInline: 0
}}
>
<Sider collapsed collapsedWidth={40}>
<div style={{ display: 'flex', flexDirection: 'column', height: '100%' }}>
{LeftTopMenu}
......@@ -293,7 +300,7 @@ const DataStudio = (props: any) => {
</div>
</Sider>
<Content style={{ display: 'flex', flexDirection: 'column' }}>
<Content style={{ display: 'flex', flexDirection: 'column', minWidth: 0 }}>
<div style={{ display: 'flex' }}>
<LeftContainer size={size} />
<Content
......
......@@ -12,9 +12,9 @@ export type VerticesTableListItem = {
status: string;
metrics: any;
parallelism: number;
startTime: string;
duration: number;
endTime: string;
startTime?: string;
duration?: number;
endTime?: string;
tasks: any;
};
......@@ -24,7 +24,7 @@ export type VerticesTableListItem = {
* @param {JobProps} props - The component props containing the job detail.
* @returns {JSX.Element} - The rendered JobConfigTab component.
*/
const FlinkTable = (props: JobProps) => {
const FlinkTable = (props: JobProps): JSX.Element => {
const { jobDetail } = props;
const columns: ProColumns<VerticesTableListItem>[] = [
......@@ -104,7 +104,7 @@ const FlinkTable = (props: JobProps) => {
<ProTable
columns={columns}
style={{ width: '100%' }}
dataSource={jobDetail?.jobHistory?.job.vertices}
dataSource={jobDetail?.jobHistory?.job?.vertices}
rowKey='name'
pagination={{
defaultPageSize: 10,
......
......@@ -69,7 +69,7 @@ const JobDesc = (props: JobProps) => {
<Descriptions.Item label={l('devops.jobinfo.config.RestartStrategy')}>
<Tag color='blue' title={'Restart Strategy'}>
{jobDetail?.jobHistory?.config['execution-config']['restart-strategy']}
{jobDetail?.jobHistory?.config?.['execution-config']?.['restart-strategy']}
</Tag>
</Descriptions.Item>
......@@ -116,7 +116,7 @@ const JobDesc = (props: JobProps) => {
</Descriptions.Item>
<Descriptions.Item label={l('devops.jobinfo.config.JobParallelism')}>
{jobDetail?.jobHistory?.config['execution-config']['job-parallelism']}
{jobDetail?.jobHistory?.config?.['execution-config']?.['job-parallelism']}
</Descriptions.Item>
<Descriptions.Item label={l('global.table.useTime')}>
......
......@@ -52,7 +52,6 @@ const JarList: React.FC<JarListProps> = (props) => {
/**
* columns
* @type {({copyable: boolean, dataIndex: string, tooltip: any, title: any, render: (dom: any, record: BuildJarList) => JSX.Element} | {dataIndex: string, valueType: string} | {copyable: boolean, dataIndex: string, title: any})[]}
*/
const columns: ProColumns<BuildJarList>[] = [
{
......@@ -85,36 +84,32 @@ const JarList: React.FC<JarListProps> = (props) => {
* @param {BuildJarList} record
* @returns {JSX.Element}
*/
const renderUdf = (record: BuildJarList) => {
return (
<>
<ProList
dataSource={record.classList as any[]}
rowKey='index'
size={'small'}
pagination={{
pageSize: 5,
hideOnSinglePage: true,
showSizeChanger: false
}}
renderItem={(item, index) => {
return (
<List.Item className={'child-list'} key={index}>
{item}
</List.Item>
);
}}
/>
</>
);
};
const renderUdf = (record: BuildJarList): JSX.Element => (
<ProList
dataSource={record.classList as any[]}
rowKey='index'
size={'small'}
pagination={{
pageSize: 5,
hideOnSinglePage: true,
showSizeChanger: false
}}
renderItem={(item, index) => {
return (
<List.Item className={'child-list'} key={index}>
{item}
</List.Item>
);
}}
/>
);
/**
* drag sort call
* @param {BuildJarList[]} newDataSource
* @returns {Promise<void>}
*/
const handleDragSortEnd = async (newDataSource: BuildJarList[]) => {
const handleDragSortEnd = async (newDataSource: BuildJarList[]): Promise<void> => {
setLoading(true);
const updatedItems = newDataSource.map((item: BuildJarList, index: number) => ({
...item,
......@@ -133,35 +128,33 @@ const JarList: React.FC<JarListProps> = (props) => {
* render
*/
return (
<>
<DragSortTable<BuildJarList>
style={{
overflowY: 'auto',
msOverflowY: 'hidden',
marginLeft: '0.5vw'
}}
columns={columns}
toolBarRender={false}
sortDirections={['ascend']}
showHeader={false}
actionRef={actionRef}
loading={loading}
dataSource={classes as BuildJarList[]}
search={false}
rowKey='orderLine'
revalidateOnFocus
pagination={{
defaultPageSize: 5,
hideOnSinglePage: true
}}
expandable={{
expandRowByClick: false,
expandedRowRender: (record) => renderUdf(record)
}}
dragSortKey={'orderLine'}
onDragSortEnd={handleDragSortEnd}
/>
</>
<DragSortTable<BuildJarList>
style={{
overflowY: 'auto',
msOverflowY: 'hidden',
marginLeft: '0.5vw'
}}
columns={columns}
toolBarRender={false}
sortDirections={['ascend']}
showHeader={false}
actionRef={actionRef}
loading={loading}
dataSource={classes as BuildJarList[]}
search={false}
rowKey='orderLine'
revalidateOnFocus
pagination={{
defaultPageSize: 5,
hideOnSinglePage: true
}}
expandable={{
expandRowByClick: false,
expandedRowRender: (record) => renderUdf(record)
}}
dragSortKey={'orderLine'}
onDragSortEnd={handleDragSortEnd}
/>
);
};
......
......@@ -128,20 +128,20 @@ const ProjectProTable: React.FC = () => {
* @param {Partial<GitProject>} value
* @returns {Promise<void>}
*/
const handleEdit = async (value: Partial<GitProject>) => {
const handleEdit = async (value: Partial<GitProject>): Promise<void> =>
setGitProjectStatus((prevState) => ({ ...prevState, value: value, editOpen: true }));
};
/**
* drag sort call
* @param {GitProject[]} newDataSource
* @returns {Promise<void>}
*/
const handleDragSortEnd = async (newDataSource: GitProject[]) => {
const handleDragSortEnd = async (newDataSource: GitProject[]): Promise<void> => {
const updatedItems = newDataSource.map((item: GitProject, index: number) => ({
...item,
orderLine: index + 1
}));
await executeAndCallback(async () =>
handleOption(API_CONSTANTS.GIT_DRAGEND_SORT_PROJECT, l('rc.gp.ucl.projectOrder'), {
sortList: updatedItems
......
......@@ -66,18 +66,18 @@ const ResourceOverView: React.FC = () => {
});
const refreshTreeData = async (pid: number, path: string) => {
const data = await queryDataByParams(API_CONSTANTS.RESOURCE_SHOW_TREE, {
const data = await queryDataByParams<any[]>(API_CONSTANTS.RESOURCE_SHOW_TREE, {
pid: pid
});
setResourceState((prevState) => ({
...prevState,
treeData: updateTreeData(prevState.treeData, path, data)
treeData: updateTreeData(prevState.treeData, path, data ?? [])
}));
};
const refreshTree = async () => {
await queryDataByParams(API_CONSTANTS.RESOURCE_SHOW_TREE, { pid: -1 }).then((res) =>
setResourceState((prevState) => ({ ...prevState, treeData: res }))
await queryDataByParams<any[]>(API_CONSTANTS.RESOURCE_SHOW_TREE, { pid: -1 }).then((res) =>
setResourceState((prevState) => ({ ...prevState, treeData: res ?? [] }))
);
};
......@@ -91,9 +91,9 @@ const ResourceOverView: React.FC = () => {
*/
const queryContent = useCallback(
async (id: number) => {
await queryDataByParams(API_CONSTANTS.RESOURCE_GET_CONTENT_BY_ID, {
await queryDataByParams<string>(API_CONSTANTS.RESOURCE_GET_CONTENT_BY_ID, {
id
}).then((res) => setResourceState((prevState) => ({ ...prevState, content: res })));
}).then((res) => setResourceState((prevState) => ({ ...prevState, content: res ?? '' })));
},
[resourceState.clickedNode]
);
......@@ -103,7 +103,7 @@ const ResourceOverView: React.FC = () => {
* @param info
* @returns {Promise<void>}
*/
const handleNodeClick = async (info: any) => {
const handleNodeClick = async (info: any): Promise<void> => {
const {
node: { id, isLeaf, key },
node
......
......@@ -57,8 +57,10 @@ const SettingOverView = () => {
});
const fetchData = async () => {
await queryDataByParams(API_CONSTANTS.SYSTEM_GET_ALL_CONFIG).then((res) => {
setData(res);
await queryDataByParams<Settings>(API_CONSTANTS.SYSTEM_GET_ALL_CONFIG).then((res) => {
if (res) {
setData(res);
}
});
};
......@@ -67,11 +69,12 @@ const SettingOverView = () => {
}, []);
const handleSaveSubmit = async (dataConfig: BaseConfigProperties) => {
const { code } = await handleOption(
API_CONSTANTS.SYSTEM_MODIFY_CONFIG,
l('sys.setting.modify', '', { key: l(`sys.${dataConfig.key}`) }),
dataConfig
);
const { code } =
(await handleOption(
API_CONSTANTS.SYSTEM_MODIFY_CONFIG,
l('sys.setting.modify', '', { key: l(`sys.${dataConfig.key}`) }),
dataConfig
)) ?? {};
if (code === RESPONSE_CODE.ERROR) {
await fetchData();
......
......@@ -405,7 +405,7 @@ export function parseNumStr(num: number) {
* @param {number} second_time
* @returns {any}
*/
export function parseMilliSecondStr(second_time: number) {
export function parseMilliSecondStr(second_time: number | undefined) {
if (second_time == null) {
return 'None';
}
......
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