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