Unverified Commit 4a932b74 authored by aiwenmo's avatar aiwenmo Committed by GitHub

[Optimization-2655][core] Optimize data preview in data studio (#2656)

* [Optimization-2655][core] Optimize data preview in data studio * optimize code --------- Co-authored-by: 's avatarwenmo <32723967+wenmo@users.noreply.github.com>
parent eb0b5714
...@@ -33,7 +33,6 @@ import org.dinky.data.result.IResult; ...@@ -33,7 +33,6 @@ import org.dinky.data.result.IResult;
import org.dinky.data.result.Result; import org.dinky.data.result.Result;
import org.dinky.data.result.SelectResult; import org.dinky.data.result.SelectResult;
import org.dinky.explainer.lineage.LineageResult; import org.dinky.explainer.lineage.LineageResult;
import org.dinky.metadata.result.JdbcSelectResult;
import org.dinky.service.StudioService; import org.dinky.service.StudioService;
import java.util.List; import java.util.List;
...@@ -90,19 +89,6 @@ public class StudioController { ...@@ -90,19 +89,6 @@ public class StudioController {
return Result.succeed(studioService.getJobData(jobId)); return Result.succeed(studioService.getJobData(jobId));
} }
/** 根据jobId获取数据 */
@GetMapping("/getCommonSqlData")
@ApiOperation("Get Common Sql Data")
@ApiImplicitParam(
name = "taskId",
value = "Get Common Sql Data",
required = true,
dataType = "Integer",
paramType = "query")
public Result<JdbcSelectResult> getJobData(@RequestParam Integer taskId) {
return Result.succeed(studioService.getCommonSqlData(taskId));
}
/** 获取单任务实例的血缘分析 */ /** 获取单任务实例的血缘分析 */
@PostMapping("/getLineage") @PostMapping("/getLineage")
@ApiOperation("Get Job Lineage") @ApiOperation("Get Job Lineage")
......
...@@ -28,7 +28,6 @@ import org.dinky.data.model.Schema; ...@@ -28,7 +28,6 @@ import org.dinky.data.model.Schema;
import org.dinky.data.result.IResult; import org.dinky.data.result.IResult;
import org.dinky.data.result.SelectResult; import org.dinky.data.result.SelectResult;
import org.dinky.explainer.lineage.LineageResult; import org.dinky.explainer.lineage.LineageResult;
import org.dinky.metadata.result.JdbcSelectResult;
import java.util.List; import java.util.List;
...@@ -43,8 +42,6 @@ public interface StudioService { ...@@ -43,8 +42,6 @@ public interface StudioService {
IResult executeDDL(StudioDDLDTO studioDDLDTO); IResult executeDDL(StudioDDLDTO studioDDLDTO);
JdbcSelectResult getCommonSqlData(Integer taskId);
SelectResult getJobData(String jobId); SelectResult getJobData(String jobId);
LineageResult getLineage(StudioLineageDTO studioCADTO); LineageResult getLineage(StudioLineageDTO studioCADTO);
......
...@@ -113,8 +113,7 @@ public class ClusterInstanceServiceImpl extends SuperServiceImpl<ClusterInstance ...@@ -113,8 +113,7 @@ public class ClusterInstanceServiceImpl extends SuperServiceImpl<ClusterInstance
} }
private String buildLocalEnvironmentAddress(int port) { private String buildLocalEnvironmentAddress(int port) {
String host = IpUtils.getHostIp(); return "0.0.0.0:" + port;
return host + ":" + port;
} }
@Override @Override
......
...@@ -33,7 +33,6 @@ import org.dinky.data.model.Schema; ...@@ -33,7 +33,6 @@ import org.dinky.data.model.Schema;
import org.dinky.data.model.Table; import org.dinky.data.model.Table;
import org.dinky.data.result.DDLResult; import org.dinky.data.result.DDLResult;
import org.dinky.data.result.IResult; import org.dinky.data.result.IResult;
import org.dinky.data.result.ResultPool;
import org.dinky.data.result.SelectResult; import org.dinky.data.result.SelectResult;
import org.dinky.executor.CustomTableEnvironment; import org.dinky.executor.CustomTableEnvironment;
import org.dinky.explainer.lineage.LineageBuilder; import org.dinky.explainer.lineage.LineageBuilder;
...@@ -42,7 +41,6 @@ import org.dinky.explainer.sqllineage.SQLLineageBuilder; ...@@ -42,7 +41,6 @@ import org.dinky.explainer.sqllineage.SQLLineageBuilder;
import org.dinky.job.JobConfig; import org.dinky.job.JobConfig;
import org.dinky.job.JobManager; import org.dinky.job.JobManager;
import org.dinky.metadata.driver.Driver; import org.dinky.metadata.driver.Driver;
import org.dinky.metadata.result.JdbcSelectResult;
import org.dinky.service.ClusterInstanceService; import org.dinky.service.ClusterInstanceService;
import org.dinky.service.DataBaseService; import org.dinky.service.DataBaseService;
import org.dinky.service.StudioService; import org.dinky.service.StudioService;
...@@ -87,11 +85,6 @@ public class StudioServiceImpl implements StudioService { ...@@ -87,11 +85,6 @@ public class StudioServiceImpl implements StudioService {
return jobResult; return jobResult;
} }
@Override
public JdbcSelectResult getCommonSqlData(Integer taskId) {
return (JdbcSelectResult) ResultPool.getCommonSqlCache(taskId);
}
@Override @Override
public IResult executeDDL(StudioDDLDTO studioDDLDTO) { public IResult executeDDL(StudioDDLDTO studioDDLDTO) {
JobConfig config = studioDDLDTO.getJobConfig(); JobConfig config = studioDDLDTO.getJobConfig();
......
...@@ -201,6 +201,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -201,6 +201,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
return jobResult; return jobResult;
} }
// Submit and export task
@ProcessStep(type = ProcessStepType.SUBMIT_BUILD_CONFIG) @ProcessStep(type = ProcessStepType.SUBMIT_BUILD_CONFIG)
public JobConfig buildJobSubmitConfig(TaskDTO task) { public JobConfig buildJobSubmitConfig(TaskDTO task) {
task.setStatement(buildEnvSql(task) + task.getStatement()); task.setStatement(buildEnvSql(task) + task.getStatement());
...@@ -234,6 +235,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -234,6 +235,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
return config; return config;
} }
// Savepoint and cancel task
@ProcessStep(type = ProcessStepType.SUBMIT_BUILD_CONFIG) @ProcessStep(type = ProcessStepType.SUBMIT_BUILD_CONFIG)
public JobConfig buildJobConfig(TaskDTO task) { public JobConfig buildJobConfig(TaskDTO task) {
JobConfig config = task.getJobConfig(); JobConfig config = task.getJobConfig();
......
...@@ -23,7 +23,6 @@ import org.dinky.config.Dialect; ...@@ -23,7 +23,6 @@ import org.dinky.config.Dialect;
import org.dinky.data.annotations.SupportDialect; import org.dinky.data.annotations.SupportDialect;
import org.dinky.data.dto.SqlDTO; import org.dinky.data.dto.SqlDTO;
import org.dinky.data.dto.TaskDTO; import org.dinky.data.dto.TaskDTO;
import org.dinky.data.result.ResultPool;
import org.dinky.data.result.SqlExplainResult; import org.dinky.data.result.SqlExplainResult;
import org.dinky.job.JobResult; import org.dinky.job.JobResult;
import org.dinky.service.DataBaseService; import org.dinky.service.DataBaseService;
...@@ -65,7 +64,6 @@ public class CommonSqlTask extends BaseTask { ...@@ -65,7 +64,6 @@ public class CommonSqlTask extends BaseTask {
SqlDTO sqlDTO = SqlDTO.build(task.getStatement(), task.getDatabaseId(), null); SqlDTO sqlDTO = SqlDTO.build(task.getStatement(), task.getDatabaseId(), null);
DataBaseService dataBaseService = SpringUtil.getBean(DataBaseService.class); DataBaseService dataBaseService = SpringUtil.getBean(DataBaseService.class);
JobResult jobResult = dataBaseService.executeCommonSql(sqlDTO); JobResult jobResult = dataBaseService.executeCommonSql(sqlDTO);
ResultPool.putCommonSqlCache(task.getId(), jobResult.getResult());
return jobResult; return jobResult;
} }
......
...@@ -33,8 +33,6 @@ public final class ResultPool { ...@@ -33,8 +33,6 @@ public final class ResultPool {
private ResultPool() {} private ResultPool() {}
private static final Cache<Integer, IResult> COMMON_SQL_SEARCH_CACHE =
new TimedCache<>(TimeUnit.MINUTES.toMillis(10));
private static final Cache<String, SelectResult> results = new TimedCache<>(TimeUnit.MINUTES.toMillis(10)); private static final Cache<String, SelectResult> results = new TimedCache<>(TimeUnit.MINUTES.toMillis(10));
public static boolean containsKey(String key) { public static boolean containsKey(String key) {
...@@ -45,14 +43,6 @@ public final class ResultPool { ...@@ -45,14 +43,6 @@ public final class ResultPool {
results.put(result.getJobId(), result); results.put(result.getJobId(), result);
} }
public static void putCommonSqlCache(Integer taskId, IResult result) {
COMMON_SQL_SEARCH_CACHE.put(taskId, result);
}
public static IResult getCommonSqlCache(Integer taskId) {
return COMMON_SQL_SEARCH_CACHE.get(taskId);
}
public static SelectResult get(String key) { public static SelectResult get(String key) {
if (containsKey(key)) { if (containsKey(key)) {
return results.get(key); return results.get(key);
......
...@@ -57,11 +57,11 @@ public class Job { ...@@ -57,11 +57,11 @@ public class Job {
@Getter @Getter
public enum JobStatus { public enum JobStatus {
INITIALIZE(1), INITIALIZE(0),
RUNNING(2), RUNNING(1),
SUCCESS(3), SUCCESS(2),
FAILED(4), FAILED(3),
CANCEL(5); CANCEL(4);
final int code; final int code;
JobStatus(int code) { JobStatus(int code) {
......
...@@ -37,6 +37,7 @@ import { FilterConfirmProps } from 'antd/es/table/interface'; ...@@ -37,6 +37,7 @@ import { FilterConfirmProps } from 'antd/es/table/interface';
import { DataIndex } from 'rc-table/es/interface'; import { DataIndex } from 'rc-table/es/interface';
import { useEffect, useRef, useState } from 'react'; import { useEffect, useRef, useState } from 'react';
import { connect } from 'umi'; import { connect } from 'umi';
import {DIALECT} from "@/services/constants";
type Data = { type Data = {
[c: string]: any; [c: string]: any;
...@@ -130,16 +131,7 @@ const Result = (props: any) => { ...@@ -130,16 +131,7 @@ const Result = (props: any) => {
if (consoleData.result && !isRefresh) { if (consoleData.result && !isRefresh) {
setData(consoleData.result); setData(consoleData.result);
} else { } else {
if (isSql(current.dialect)) { if (current.dialect == DIALECT.FLINK_SQL) {
// common sql
const res = await handleGetOption('api/studio/getCommonSqlData', l('global.getdata.tips'), {
taskId: params.taskId
});
if (res.data) {
consoleData.result = res.data;
setData(res.data);
}
} else {
// flink sql // flink sql
// to do: get job data by history id list, not flink jid // to do: get job data by history id list, not flink jid
if (current.id) { if (current.id) {
...@@ -147,7 +139,7 @@ const Result = (props: any) => { ...@@ -147,7 +139,7 @@ const Result = (props: any) => {
id: current.id id: current.id
}); });
const historyData = res.data; const historyData = res.data;
if (historyData && '2' == historyData.status) { if (historyData) {
const historyId = historyData.id; const historyId = historyData.id;
const tableData = await handleGetOption( const tableData = await handleGetOption(
'api/studio/getJobData', 'api/studio/getJobData',
......
...@@ -33,7 +33,7 @@ import { ...@@ -33,7 +33,7 @@ import {
changeTaskLife, changeTaskLife,
debugTask, debugTask,
executeSql, executeSql,
getJobPlan getJobPlan, isSql
} from '@/pages/DataStudio/HeaderContainer/service'; } from '@/pages/DataStudio/HeaderContainer/service';
import { DataStudioTabsItemType, StateType, TabsPageType, VIEW } from '@/pages/DataStudio/model'; import { DataStudioTabsItemType, StateType, TabsPageType, VIEW } from '@/pages/DataStudio/model';
import { JOB_LIFE_CYCLE, JOB_STATUS } from '@/pages/DevOps/constants'; import { JOB_LIFE_CYCLE, JOB_STATUS } from '@/pages/DevOps/constants';
...@@ -177,6 +177,10 @@ const HeaderContainer = (props: any) => { ...@@ -177,6 +177,10 @@ const HeaderContainer = (props: any) => {
}); });
await SuccessMessageAsync(l('pages.datastudio.editor.exec.success')); await SuccessMessageAsync(l('pages.datastudio.editor.exec.success'));
currentData.status = JOB_STATUS.RUNNING; currentData.status = JOB_STATUS.RUNNING;
// Common sql task is synchronized, so it needs to automatically update the status to finished.
if(isSql(currentData.dialect)){
currentData.status = JOB_STATUS.FINISHED;
}
if (currentTab) currentTab.console.result = res.data.result; if (currentTab) currentTab.console.result = res.data.result;
saveTabs({ ...props.tabs }); saveTabs({ ...props.tabs });
}; };
......
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