Unverified Commit 623fc445 authored by Licho's avatar Licho

refactor: constant, word error, and Task and TaskServiceImpl file.

parent 105baaed
...@@ -24,9 +24,9 @@ import org.dinky.db.model.SuperEntity; ...@@ -24,9 +24,9 @@ import org.dinky.db.model.SuperEntity;
import org.dinky.job.JobConfig; import org.dinky.job.JobConfig;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
import com.baomidou.mybatisplus.annotation.FieldFill; import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
...@@ -38,6 +38,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode; ...@@ -38,6 +38,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.extern.slf4j.Slf4j;
/** /**
* 任务 * 任务
...@@ -48,7 +49,8 @@ import lombok.EqualsAndHashCode; ...@@ -48,7 +49,8 @@ import lombok.EqualsAndHashCode;
@Data @Data
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
@TableName("dinky_task") @TableName("dinky_task")
public class Task extends SuperEntity { @Slf4j
public class Task extends SuperEntity<Task> {
private static final long serialVersionUID = 5988972129893667154L; private static final long serialVersionUID = 5988972129893667154L;
...@@ -127,32 +129,36 @@ public class Task extends SuperEntity { ...@@ -127,32 +129,36 @@ public class Task extends SuperEntity {
@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() { public List<Map<String, String>> parseConfig() {
ObjectMapper objectMapper = new ObjectMapper(); if (Asserts.isNullString(configJson)) {
return config;
}
try { try {
if (Asserts.isNotNullString(configJson)) {
config = objectMapper.readValue(configJson, ArrayList.class); config = objectMapper.readValue(configJson, ArrayList.class);
}
} catch (JsonProcessingException e) { } catch (JsonProcessingException e) {
e.printStackTrace(); log.error(e.getMessage());
} }
return config; return config;
} }
public JobConfig buildSubmitConfig() { public JobConfig buildSubmitConfig() {
boolean useRemote = true; boolean useRemote = clusterId != null && clusterId != 0;
if (clusterId == null || clusterId == 0) { Map<String, String> map =
useRemote = false; config.stream()
} .filter(Asserts::isNotNull)
Map<String, String> map = new HashMap<>(); .collect(
for (Map<String, String> item : config) { Collectors.toMap(
if (Asserts.isNotNull(item)) { item -> item.get("key"),
map.put(item.get("key"), item.get("value")); item -> item.get("value"),
} (a, b) -> b));
}
int jid = Asserts.isNull(jarId) ? 0 : jarId; int jid = Asserts.isNull(jarId) ? 0 : jarId;
boolean fg = Asserts.isNull(fragment) ? false : fragment; boolean fg = Asserts.isNotNull(fragment) && fragment;
boolean sts = Asserts.isNull(statementSet) ? false : statementSet; boolean sts = Asserts.isNotNull(statementSet) && statementSet;
return new JobConfig( return new JobConfig(
type, type,
step, step,
...@@ -174,30 +180,25 @@ public class Task extends SuperEntity { ...@@ -174,30 +180,25 @@ public class Task extends SuperEntity {
map); map);
} }
public JsonNode parseJsonNode() {
ObjectMapper mapper = new ObjectMapper();
return parseJsonNode(mapper);
}
public JsonNode parseJsonNode(ObjectMapper mapper) { public JsonNode parseJsonNode(ObjectMapper mapper) {
JsonNode jsonNode = mapper.createObjectNode(); ObjectNode jsonNode = mapper.createObjectNode();
((ObjectNode) jsonNode).put("name", this.getName()); jsonNode.put("name", this.getName());
((ObjectNode) jsonNode).put("alias", this.alias); jsonNode.put("alias", this.alias);
((ObjectNode) jsonNode).put("dialect", this.dialect); jsonNode.put("dialect", this.dialect);
((ObjectNode) jsonNode).put("type", this.type); jsonNode.put("type", this.type);
((ObjectNode) jsonNode).put("statement", this.statement); jsonNode.put("statement", this.statement);
((ObjectNode) jsonNode).put("checkPoint", this.checkPoint); jsonNode.put("checkPoint", this.checkPoint);
((ObjectNode) jsonNode).put("savePointStrategy", this.savePointStrategy); jsonNode.put("savePointStrategy", this.savePointStrategy);
((ObjectNode) jsonNode).put("savePointPath", this.savePointPath); jsonNode.put("savePointPath", this.savePointPath);
((ObjectNode) jsonNode).put("parallelism", this.parallelism); jsonNode.put("parallelism", this.parallelism);
((ObjectNode) jsonNode).put("fragment", this.fragment); jsonNode.put("fragment", this.fragment);
((ObjectNode) jsonNode).put("statementSet", this.statementSet); jsonNode.put("statementSet", this.statementSet);
((ObjectNode) jsonNode).put("batchModel", this.batchModel); jsonNode.put("batchModel", this.batchModel);
((ObjectNode) jsonNode).put("clusterName", this.clusterName); jsonNode.put("clusterName", this.clusterName);
((ObjectNode) jsonNode).put("configJson", this.configJson); jsonNode.put("configJson", this.configJson);
((ObjectNode) jsonNode).put("note", this.note); jsonNode.put("note", this.note);
((ObjectNode) jsonNode).put("step", this.step); jsonNode.put("step", this.step);
((ObjectNode) jsonNode).put("enabled", this.getEnabled()); jsonNode.put("enabled", this.getEnabled());
return jsonNode; return jsonNode;
} }
} }
...@@ -373,7 +373,7 @@ public class StudioServiceImpl implements StudioService { ...@@ -373,7 +373,7 @@ public class StudioServiceImpl implements StudioService {
@Override @Override
public LineageResult getLineage(StudioCADTO studioCADTO) { public LineageResult getLineage(StudioCADTO studioCADTO) {
if (Asserts.isNotNullString(studioCADTO.getDialect()) if (Asserts.isNotNullString(studioCADTO.getDialect())
&& !Dialect.FLINKSQL.equalsVal(studioCADTO.getDialect())) { && !Dialect.FLINK_SQL.equalsVal(studioCADTO.getDialect())) {
if (Asserts.isNull(studioCADTO.getDatabaseId())) { if (Asserts.isNull(studioCADTO.getDatabaseId())) {
return null; return null;
} }
......
...@@ -28,9 +28,9 @@ import org.dinky.assertion.Asserts; ...@@ -28,9 +28,9 @@ import org.dinky.assertion.Asserts;
* @since 2021/12/13 * @since 2021/12/13
*/ */
public enum Dialect { public enum Dialect {
FLINKSQL("FlinkSql"), FLINK_SQL("FlinkSql"),
FLINKJAR("FlinkJar"), FLINK_JAR("FlinkJar"),
FLINKSQLENV("FlinkSqlEnv"), FLINK_SQL_ENV("FlinkSqlEnv"),
SQL("Sql"), SQL("Sql"),
JAVA("Java"), JAVA("Java"),
PYTHON("Python"), PYTHON("Python"),
...@@ -43,13 +43,13 @@ public enum Dialect { ...@@ -43,13 +43,13 @@ public enum Dialect {
DORIS("Doris"), DORIS("Doris"),
PHOENIX("Phoenix"), PHOENIX("Phoenix"),
HIVE("Hive"), HIVE("Hive"),
STARROCKS("StarRocks"), STAR_ROCKS("StarRocks"),
PRESTO("Presto"), PRESTO("Presto"),
KUBERNETES_APPLICATION("KubernetesApplaction"); KUBERNETES_APPLICATION("KubernetesApplication");
private String value; private String value;
public static final Dialect DEFAULT = Dialect.FLINKSQL; public static final Dialect DEFAULT = Dialect.FLINK_SQL;
Dialect(String value) { Dialect(String value) {
this.value = value; this.value = value;
...@@ -69,7 +69,7 @@ public enum Dialect { ...@@ -69,7 +69,7 @@ public enum Dialect {
return type; return type;
} }
} }
return Dialect.FLINKSQL; return Dialect.FLINK_SQL;
} }
/** /**
...@@ -90,7 +90,7 @@ public enum Dialect { ...@@ -90,7 +90,7 @@ public enum Dialect {
case DORIS: case DORIS:
case PHOENIX: case PHOENIX:
case HIVE: case HIVE:
case STARROCKS: case STAR_ROCKS:
case PRESTO: case PRESTO:
return true; return true;
default: default:
......
...@@ -25,8 +25,8 @@ package org.dinky.constant; ...@@ -25,8 +25,8 @@ package org.dinky.constant;
* @author wenmo * @author wenmo
* @since 2021/5/28 9:35 * @since 2021/5/28 9:35
*/ */
public interface CommonConstant { public final class CommonConstant {
/** 实例健康 */ /** 实例健康 */
String HEALTHY = "1"; public static final String HEALTHY = "1";
} }
...@@ -19,18 +19,18 @@ ...@@ -19,18 +19,18 @@
package org.dinky.constant; package org.dinky.constant;
public interface NetConstant { public final class NetConstant {
/** http:// */ /** http:// */
String HTTP = "http://"; public static final String HTTP = "http://";
/** 冒号: */ /** 冒号: */
String COLON = ":"; public static final String COLON = ":";
/** 斜杠/ */ /** 斜杠/ */
String SLASH = "/"; public static final String SLASH = "/";
/** 连接运行服务器超时时间 1000 */ /** 连接运行服务器超时时间 1000 */
Integer SERVER_TIME_OUT_ACTIVE = 1000; public static final Integer SERVER_TIME_OUT_ACTIVE = 1000;
/** 读取服务器超时时间 3000 */ /** 读取服务器超时时间 3000 */
Integer READ_TIME_OUT = 3000; public static final Integer READ_TIME_OUT = 3000;
/** 连接FLINK历史服务器超时时间 2000 */ /** 连接FLINK历史服务器超时时间 2000 */
Integer SERVER_TIME_OUT_HISTORY = 3000; public static final Integer SERVER_TIME_OUT_HISTORY = 3000;
} }
/*
*
* 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.utils;
/** */
public class LogicUtil {
public static <T> boolean IfThenRun(T object, Class<?> clazz, Runnable action) {
if (object.getClass() == clazz) {
action.run();
return true;
} else {
return false;
}
}
}
...@@ -43,7 +43,7 @@ export const DIALECT = { ...@@ -43,7 +43,7 @@ export const DIALECT = {
PHOENIX: 'Phoenix', PHOENIX: 'Phoenix',
STARROCKS: 'StarRocks', STARROCKS: 'StarRocks',
PRESTO: 'Presto', PRESTO: 'Presto',
KUBERNETES_APPLICATION: 'KubernetesApplaction', KUBERNETES_APPLICATION: 'KubernetesApplication',
JAVA: 'Java', JAVA: 'Java',
SCALA: 'Scala', SCALA: 'Scala',
PYTHON: 'Python', PYTHON: 'Python',
......
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