Unverified Commit 48abeec8 authored by ZackYoung's avatar ZackYoung Committed by GitHub

remove_task_config_field (#2189)

parent cbed39e0
...@@ -19,14 +19,11 @@ ...@@ -19,14 +19,11 @@
package org.dinky.data.dto; package org.dinky.data.dto;
import org.dinky.assertion.Asserts;
import org.dinky.job.JobConfig; import org.dinky.job.JobConfig;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.Getter; import lombok.Getter;
...@@ -65,24 +62,10 @@ public class StudioExecuteDTO extends AbstractStatementDTO { ...@@ -65,24 +62,10 @@ public class StudioExecuteDTO extends AbstractStatementDTO {
private Integer parallelism; private Integer parallelism;
private Integer savePointStrategy; private Integer savePointStrategy;
private String savePointPath; private String savePointPath;
private String configJson; private Map<String, String> config = new HashMap<>();
private static final ObjectMapper mapper = new ObjectMapper(); private static final ObjectMapper mapper = new ObjectMapper();
public JobConfig getJobConfig() { public JobConfig getJobConfig() {
Map<String, String> config = new HashMap<>();
if (Asserts.isNotNullString(configJson)) {
try {
JsonNode paras = mapper.readTree(configJson);
paras.forEach(
(JsonNode node) -> {
if (!node.isNull()) {
config.put(node.get("key").asText(), node.get("value").asText());
}
});
} catch (JsonProcessingException e) {
log.error(e.getMessage());
}
}
return new JobConfig( return new JobConfig(
type, type,
useResult, useResult,
......
...@@ -21,17 +21,16 @@ package org.dinky.data.model; ...@@ -21,17 +21,16 @@ package org.dinky.data.model;
import org.dinky.assertion.Asserts; import org.dinky.assertion.Asserts;
import org.dinky.config.Dialect; import org.dinky.config.Dialect;
import org.dinky.data.typehandler.ListTypeHandler;
import org.dinky.job.JobConfig; import org.dinky.job.JobConfig;
import org.dinky.mybatis.model.SuperEntity; import org.dinky.mybatis.model.SuperEntity;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
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;
import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ObjectNode;
...@@ -83,9 +82,6 @@ public class Task extends SuperEntity<Task> { ...@@ -83,9 +82,6 @@ public class Task extends SuperEntity<Task> {
private Integer envId; private Integer envId;
private Integer alertGroupId; private Integer alertGroupId;
private String configJson;
private String note; private String note;
private Integer step; private Integer step;
...@@ -103,8 +99,8 @@ public class Task extends SuperEntity<Task> { ...@@ -103,8 +99,8 @@ public class Task extends SuperEntity<Task> {
@TableField(exist = false) @TableField(exist = false)
private List<Savepoints> savePoints; private List<Savepoints> savePoints;
@TableField(exist = false) @TableField(typeHandler = ListTypeHandler.class)
private List<Map<String, String>> config = new ArrayList<>(); private List<Map<String, String>> configJson;
@TableField(exist = false) @TableField(exist = false)
private String path; private String path;
...@@ -124,26 +120,10 @@ public class Task extends SuperEntity<Task> { ...@@ -124,26 +120,10 @@ public class Task extends SuperEntity<Task> {
@TableField(exist = false) @TableField(exist = false)
private String alertGroupName; private String alertGroupName;
public static final ObjectMapper objectMapper = new ObjectMapper();
@SuppressWarnings("unchecked")
public List<Map<String, String>> parseConfig() {
if (Asserts.isNullString(configJson)) {
return config;
}
try {
config = objectMapper.readValue(configJson, ArrayList.class);
} catch (JsonProcessingException e) {
log.error(e.getMessage());
}
return config;
}
public JobConfig buildSubmitConfig() { public JobConfig buildSubmitConfig() {
boolean useRemote = clusterId != null && clusterId != 0; boolean useRemote = clusterId != null && clusterId != 0;
Map<String, String> map = Map<String, String> map =
parseConfig().stream() configJson.stream()
.filter(Asserts::isNotNull) .filter(Asserts::isNotNull)
.collect( .collect(
Collectors.toMap( Collectors.toMap(
...@@ -190,7 +170,6 @@ public class Task extends SuperEntity<Task> { ...@@ -190,7 +170,6 @@ public class Task extends SuperEntity<Task> {
jsonNode.put("statementSet", this.statementSet); jsonNode.put("statementSet", this.statementSet);
jsonNode.put("batchModel", this.batchModel); jsonNode.put("batchModel", this.batchModel);
jsonNode.put("clusterName", this.clusterName); jsonNode.put("clusterName", this.clusterName);
jsonNode.put("configJson", this.configJson);
jsonNode.put("note", this.note); jsonNode.put("note", this.note);
jsonNode.put("step", this.step); jsonNode.put("step", this.step);
jsonNode.put("enabled", this.getEnabled()); jsonNode.put("enabled", this.getEnabled());
......
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.dinky.data.typehandler;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.MappedJdbcTypes;
import org.apache.ibatis.type.MappedTypes;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.baomidou.mybatisplus.extension.handlers.AbstractJsonTypeHandler;
import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
import cn.hutool.json.JSONArray;
@MappedTypes({List.class})
@MappedJdbcTypes({JdbcType.VARCHAR})
public class ListTypeHandler extends AbstractJsonTypeHandler<List<Map>> {
private static final Logger log = LoggerFactory.getLogger(FastjsonTypeHandler.class);
protected List<Map> parse(String json) {
return new JSONArray(json).toList(Map.class);
}
@Override
protected String toJson(List<Map> obj) {
return new JSONArray(obj).toString();
}
}
...@@ -104,7 +104,7 @@ public class CatalogueServiceImpl extends SuperServiceImpl<CatalogueMapper, Cata ...@@ -104,7 +104,7 @@ public class CatalogueServiceImpl extends SuperServiceImpl<CatalogueMapper, Cata
} }
task.setName(catalogueTaskDTO.getName()); task.setName(catalogueTaskDTO.getName());
task.setDialect(catalogueTaskDTO.getDialect()); task.setDialect(catalogueTaskDTO.getDialect());
task.setConfig(Collections.singletonList(catalogueTaskDTO.getConfig())); task.setConfigJson(Collections.singletonList(catalogueTaskDTO.getConfig()));
taskService.saveOrUpdateTask(task); taskService.saveOrUpdateTask(task);
catalogue.setTenantId(catalogueTaskDTO.getTenantId()); catalogue.setTenantId(catalogueTaskDTO.getTenantId());
......
...@@ -411,8 +411,6 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -411,8 +411,6 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
if (task == null) { if (task == null) {
return null; return null;
} }
task.parseConfig();
if (task.getClusterId() != null) { if (task.getClusterId() != null) {
Cluster cluster = clusterInstanceService.getById(task.getClusterId()); Cluster cluster = clusterInstanceService.getById(task.getClusterId());
if (cluster != null) { if (cluster != null) {
...@@ -444,10 +442,10 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -444,10 +442,10 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
@Override @Override
public boolean saveOrUpdateTask(Task task) { public boolean saveOrUpdateTask(Task task) {
if (Dialect.isUDF(task.getDialect())) { if (Dialect.isUDF(task.getDialect())) {
if (CollUtil.isNotEmpty(task.getConfig()) if (CollUtil.isNotEmpty(task.getConfigJson())
&& Asserts.isNullString(task.getStatement()) && Asserts.isNullString(task.getStatement())
&& Convert.toInt(task.getConfig().get(0).get("templateId"), 0) != 0) { && Convert.toInt(task.getConfigJson().get(0).get("templateId"), 0) != 0) {
Map<String, String> config = task.getConfig().get(0); Map<String, String> config = task.getConfigJson().get(0);
UDFTemplate template = udfTemplateService.getById(config.get("templateId")); UDFTemplate template = udfTemplateService.getById(config.get("templateId"));
if (template != null) { if (template != null) {
String code = String code =
......
...@@ -97,7 +97,7 @@ mybatis-plus: ...@@ -97,7 +97,7 @@ mybatis-plus:
##### mybatis-plus prints complete sql (only for development environment) ##### mybatis-plus prints complete sql (only for development environment)
#log-impl: org.apache.ibatis.logging.stdout.StdOutImpl #log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl
type-handlers-package: org.dinky.data.typehandler
################################################################################################################# #################################################################################################################
################################################# SMS Config #################################################### ################################################# SMS Config ####################################################
################################################################################################################# #################################################################################################################
......
...@@ -4,13 +4,14 @@ import {theme} from "antd"; ...@@ -4,13 +4,14 @@ import {theme} from "antd";
export type ThemeValue = { export type ThemeValue = {
borderColor: string borderColor: string
footerColor: string
} }
const { useToken } = theme; const { useToken } = theme;
const getThemeValue = (isDark: boolean): ThemeValue => { const getThemeValue = (isDark: boolean): ThemeValue => {
if (isDark) { if (isDark) {
return {borderColor: "#343434"} return {borderColor: "#343434", footerColor: "rgba(255, 255, 255, 0.18)"}
} else { } else {
return {borderColor: "rgba(5, 5, 5, 0.06)"} return {borderColor: "rgba(5, 5, 5, 0.06)", footerColor: "#f4f4f4"}
// return {borderColor: "#E0E2E5"} // return {borderColor: "#E0E2E5"}
} }
} }
......
...@@ -6,6 +6,7 @@ import {getCurrentTab} from "@/pages/DataStudio/function"; ...@@ -6,6 +6,7 @@ import {getCurrentTab} from "@/pages/DataStudio/function";
import {getSseData} from "@/services/api"; import {getSseData} from "@/services/api";
import {l} from "@/utils/intl"; import {l} from "@/utils/intl";
import JobRunningModal from "@/pages/DataStudio/FooterContainer/JobRunningModal"; import JobRunningModal from "@/pages/DataStudio/FooterContainer/JobRunningModal";
import useThemeValue from "@/hooks/useThemeValue";
export type FooterContainerProps = { export type FooterContainerProps = {
token: GlobalToken token: GlobalToken
...@@ -30,16 +31,16 @@ const FooterContainer: React.FC<FooterContainerProps & StateType> = (props) => { ...@@ -30,16 +31,16 @@ const FooterContainer: React.FC<FooterContainerProps & StateType> = (props) => {
jobRunningMsg, jobRunningMsg,
}, token, tabs }, token, tabs
} = props; } = props;
const themeValue = useThemeValue();
const [viewJobRunning, setViewJobRunning] = useState(false); const [viewJobRunning, setViewJobRunning] = useState(false);
const [memDetailInfo, setMemDetailInfo] = useState(memDetails); const [memDetailInfo, setMemDetailInfo] = useState(memDetails);
useEffect(() => { useEffect(() => {
const eventSource = getSseData("/api/sse/getJvmInfo"); const eventSource = getSseData("/api/sse/getJvmInfo");
eventSource.onmessage = (event) => { eventSource.onmessage = (event) => {
const data = JSON.parse(event.data); const data = JSON.parse(event.data);
setMemDetailInfo(Number(data["heapUsed"] / 1024 / 1024).toFixed(0) + "/" + Number(data["total"] / 1024 / 1024).toFixed(0) + "M") setMemDetailInfo(Number(data["heapUsed"] / 1024 / 1024).toFixed(0) + "/" + Number(data["max"] / 1024 / 1024).toFixed(0) + "M")
} }
return () => { return () => {
eventSource.close() eventSource.close()
...@@ -112,7 +113,7 @@ const FooterContainer: React.FC<FooterContainerProps & StateType> = (props) => { ...@@ -112,7 +113,7 @@ const FooterContainer: React.FC<FooterContainerProps & StateType> = (props) => {
return <> return <>
<div style={{ <div style={{
backgroundColor: token.colorFill, backgroundColor: themeValue.footerColor,
height: VIEW.footerHeight, height: VIEW.footerHeight,
width: "100%", width: "100%",
display: "flex", display: "flex",
......
...@@ -97,7 +97,6 @@ const HeaderContainer = (props: any) => { ...@@ -97,7 +97,6 @@ const HeaderContainer = (props: any) => {
...current, ...current,
jobName: current.name, jobName: current.name,
taskId: current.id, taskId: current.id,
configJson: JSON.stringify(current.config),
}; };
const key = current.key; const key = current.key;
const taskKey = (Math.random() * 1000) + ''; const taskKey = (Math.random() * 1000) + '';
...@@ -148,7 +147,6 @@ const HeaderContainer = (props: any) => { ...@@ -148,7 +147,6 @@ const HeaderContainer = (props: any) => {
title: l('button.save'), title: l('button.save'),
click: () => { click: () => {
const current = getCurrentData(panes, activeKey); const current = getCurrentData(panes, activeKey);
current.configJson = JSON.stringify(current.config)
handlePutDataJson("/api/task", current).then(()=>saveTabs({...props.tabs})) handlePutDataJson("/api/task", current).then(()=>saveTabs({...props.tabs}))
}, },
hotKey: (e: KeyboardEvent) => e.ctrlKey && e.key === 's', hotKey: (e: KeyboardEvent) => e.ctrlKey && e.key === 's',
...@@ -176,11 +174,7 @@ const HeaderContainer = (props: any) => { ...@@ -176,11 +174,7 @@ const HeaderContainer = (props: any) => {
title: l('button.graph'), title: l('button.graph'),
click: () => { click: () => {
const currentData = getCurrentData(panes, activeKey); const currentData = getCurrentData(panes, activeKey);
const param = { const res = getJobPlan(l("pages.datastudio.editor.explan.tip"), currentData);
...currentData,
configJson: JSON.stringify(currentData.config),
};
const res = getJobPlan(l("pages.datastudio.editor.explan.tip"), param);
res.then((result) => { res.then((result) => {
if (result) { if (result) {
modal.confirm({ modal.confirm({
......
...@@ -13,11 +13,10 @@ import {TagAlignLeft} from "@/components/StyledComponents"; ...@@ -13,11 +13,10 @@ import {TagAlignLeft} from "@/components/StyledComponents";
import SchemaTree from "@/pages/RegCenter/DataSource/components/DataSourceDetail/SchemaTree"; import SchemaTree from "@/pages/RegCenter/DataSource/components/DataSourceDetail/SchemaTree";
import {DataSources} from "@/types/RegCenter/data"; import {DataSources} from "@/types/RegCenter/data";
import {BtnRoute} from "@/pages/DataStudio/route"; import {BtnRoute} from "@/pages/DataStudio/route";
import {transformTreeData} from "@/utils/function";
const MetaData = (props: any) => { const MetaData = (props: any) => {
const {dispatch ,toolContentHeight,leftContainer, database: { dbData , selectDatabaseId , expandKeys, selectKeys} } = props; const {dispatch ,toolContentHeight, database: { dbData , selectDatabaseId , expandKeys, selectKeys} } = props;
const [treeData, setTreeData] = useState<[]>([]); const [treeData, setTreeData] = useState<[]>([]);
const [isLoadingDatabase, setIsLoadingDatabase] = useState(false); const [isLoadingDatabase, setIsLoadingDatabase] = useState(false);
const selectDb = (dbData as DataSources.DataSource[]).filter(x=> x.id === selectDatabaseId)[0] const selectDb = (dbData as DataSources.DataSource[]).filter(x=> x.id === selectDatabaseId)[0]
......
...@@ -226,7 +226,7 @@ const JobConfig = (props: any) => { ...@@ -226,7 +226,7 @@ const JobConfig = (props: any) => {
<ProFormList <ProFormList
label={l('pages.datastudio.label.jobConfig.other')} label={l('pages.datastudio.label.jobConfig.other')}
tooltip={l('pages.datastudio.label.jobConfig.other.tip')} tooltip={l('pages.datastudio.label.jobConfig.other.tip')}
name={'config'} name={'configJson'}
copyIconProps={false} copyIconProps={false}
creatorButtonProps={{ creatorButtonProps={{
style: {width: '100%'}, style: {width: '100%'},
......
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