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;
import org.dinky.data.result.Result;
import org.dinky.data.result.SelectResult;
import org.dinky.explainer.lineage.LineageResult;
import org.dinky.metadata.result.JdbcSelectResult;
import org.dinky.service.StudioService;
import java.util.List;
......@@ -90,19 +89,6 @@ public class StudioController {
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")
@ApiOperation("Get Job Lineage")
......
......@@ -28,7 +28,6 @@ import org.dinky.data.model.Schema;
import org.dinky.data.result.IResult;
import org.dinky.data.result.SelectResult;
import org.dinky.explainer.lineage.LineageResult;
import org.dinky.metadata.result.JdbcSelectResult;
import java.util.List;
......@@ -43,8 +42,6 @@ public interface StudioService {
IResult executeDDL(StudioDDLDTO studioDDLDTO);
JdbcSelectResult getCommonSqlData(Integer taskId);
SelectResult getJobData(String jobId);
LineageResult getLineage(StudioLineageDTO studioCADTO);
......
......@@ -113,8 +113,7 @@ public class ClusterInstanceServiceImpl extends SuperServiceImpl<ClusterInstance
}
private String buildLocalEnvironmentAddress(int port) {
String host = IpUtils.getHostIp();
return host + ":" + port;
return "0.0.0.0:" + port;
}
@Override
......
......@@ -33,7 +33,6 @@ import org.dinky.data.model.Schema;
import org.dinky.data.model.Table;
import org.dinky.data.result.DDLResult;
import org.dinky.data.result.IResult;
import org.dinky.data.result.ResultPool;
import org.dinky.data.result.SelectResult;
import org.dinky.executor.CustomTableEnvironment;
import org.dinky.explainer.lineage.LineageBuilder;
......@@ -42,7 +41,6 @@ import org.dinky.explainer.sqllineage.SQLLineageBuilder;
import org.dinky.job.JobConfig;
import org.dinky.job.JobManager;
import org.dinky.metadata.driver.Driver;
import org.dinky.metadata.result.JdbcSelectResult;
import org.dinky.service.ClusterInstanceService;
import org.dinky.service.DataBaseService;
import org.dinky.service.StudioService;
......@@ -87,11 +85,6 @@ public class StudioServiceImpl implements StudioService {
return jobResult;
}
@Override
public JdbcSelectResult getCommonSqlData(Integer taskId) {
return (JdbcSelectResult) ResultPool.getCommonSqlCache(taskId);
}
@Override
public IResult executeDDL(StudioDDLDTO studioDDLDTO) {
JobConfig config = studioDDLDTO.getJobConfig();
......
......@@ -201,6 +201,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
return jobResult;
}
// Submit and export task
@ProcessStep(type = ProcessStepType.SUBMIT_BUILD_CONFIG)
public JobConfig buildJobSubmitConfig(TaskDTO task) {
task.setStatement(buildEnvSql(task) + task.getStatement());
......@@ -234,6 +235,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
return config;
}
// Savepoint and cancel task
@ProcessStep(type = ProcessStepType.SUBMIT_BUILD_CONFIG)
public JobConfig buildJobConfig(TaskDTO task) {
JobConfig config = task.getJobConfig();
......
......@@ -23,7 +23,6 @@ import org.dinky.config.Dialect;
import org.dinky.data.annotations.SupportDialect;
import org.dinky.data.dto.SqlDTO;
import org.dinky.data.dto.TaskDTO;
import org.dinky.data.result.ResultPool;
import org.dinky.data.result.SqlExplainResult;
import org.dinky.job.JobResult;
import org.dinky.service.DataBaseService;
......@@ -65,7 +64,6 @@ public class CommonSqlTask extends BaseTask {
SqlDTO sqlDTO = SqlDTO.build(task.getStatement(), task.getDatabaseId(), null);
DataBaseService dataBaseService = SpringUtil.getBean(DataBaseService.class);
JobResult jobResult = dataBaseService.executeCommonSql(sqlDTO);
ResultPool.putCommonSqlCache(task.getId(), jobResult.getResult());
return jobResult;
}
......
......@@ -33,8 +33,6 @@ public final class 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));
public static boolean containsKey(String key) {
......@@ -45,14 +43,6 @@ public final class ResultPool {
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) {
if (containsKey(key)) {
return results.get(key);
......
......@@ -57,11 +57,11 @@ public class Job {
@Getter
public enum JobStatus {
INITIALIZE(1),
RUNNING(2),
SUCCESS(3),
FAILED(4),
CANCEL(5);
INITIALIZE(0),
RUNNING(1),
SUCCESS(2),
FAILED(3),
CANCEL(4);
final int code;
JobStatus(int code) {
......
......@@ -37,6 +37,7 @@ import { FilterConfirmProps } from 'antd/es/table/interface';
import { DataIndex } from 'rc-table/es/interface';
import { useEffect, useRef, useState } from 'react';
import { connect } from 'umi';
import {DIALECT} from "@/services/constants";
type Data = {
[c: string]: any;
......@@ -130,16 +131,7 @@ const Result = (props: any) => {
if (consoleData.result && !isRefresh) {
setData(consoleData.result);
} else {
if (isSql(current.dialect)) {
// 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 {
if (current.dialect == DIALECT.FLINK_SQL) {
// flink sql
// to do: get job data by history id list, not flink jid
if (current.id) {
......@@ -147,7 +139,7 @@ const Result = (props: any) => {
id: current.id
});
const historyData = res.data;
if (historyData && '2' == historyData.status) {
if (historyData) {
const historyId = historyData.id;
const tableData = await handleGetOption(
'api/studio/getJobData',
......
......@@ -33,7 +33,7 @@ import {
changeTaskLife,
debugTask,
executeSql,
getJobPlan
getJobPlan, isSql
} from '@/pages/DataStudio/HeaderContainer/service';
import { DataStudioTabsItemType, StateType, TabsPageType, VIEW } from '@/pages/DataStudio/model';
import { JOB_LIFE_CYCLE, JOB_STATUS } from '@/pages/DevOps/constants';
......@@ -177,6 +177,10 @@ const HeaderContainer = (props: any) => {
});
await SuccessMessageAsync(l('pages.datastudio.editor.exec.success'));
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;
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