Skip to content

Commit

Permalink
[Fix][Server] Fix some bug (#376)
Browse files Browse the repository at this point in the history
  • Loading branch information
zixi0825 authored Mar 10, 2024
1 parent 9cbcd77 commit 8ae35e6
Show file tree
Hide file tree
Showing 30 changed files with 363 additions and 137 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.HashMap;

import com.baomidou.mybatisplus.annotation.EnumValue;
import lombok.Getter;

/**
* running status for workflow and task nodes
Expand All @@ -41,27 +42,32 @@ public enum ExecutionStatus {
* 10 waiting thread
* 11 waiting depend node complete
*/
SUBMITTED_SUCCESS(0, "submitted"),
RUNNING_EXECUTION(1, "running"),
READY_PAUSE(2, "ready pause"),
PAUSE(3, "pause"),
READY_STOP(4, "ready stop"),
STOP(5, "stop"),
FAILURE(6, "failure"),
SUCCESS(7, "success"),
NEED_FAULT_TOLERANCE(8, "need fault tolerance"),
KILL(9, "kill"),
WAITING_THREAD(10, "waiting thread"),
WAITING_DEPEND(11, "waiting depend node complete");

ExecutionStatus(int code, String description){
SUBMITTED_SUCCESS(0, "submitted", "已提交"),
RUNNING_EXECUTION(1, "running", "执行中"),
READY_PAUSE(2, "ready pause", "准备暂停"),
PAUSE(3, "pause", "暂停"),
READY_STOP(4, "ready stop", "准备停止"),
STOP(5, "stop", "停止"),
FAILURE(6, "failure", "失败"),
SUCCESS(7, "success", "成功"),
NEED_FAULT_TOLERANCE(8, "need fault tolerance","需要容错"),
KILL(9, "kill", "强制终止"),
WAITING_THREAD(10, "waiting thread", "等待线程"),
WAITING_DEPEND(11, "waiting depend node complete","");

ExecutionStatus(int code, String description,String zhDescription){
this.code = code;
this.description = description;
this.zhDescription = zhDescription;
}

@Getter
@EnumValue
int code;
String description;
private final int code;
@Getter
private final String description;
@Getter
private final String zhDescription;

private static final HashMap<Integer, ExecutionStatus> EXECUTION_STATUS_MAP = new HashMap<>();

Expand All @@ -71,45 +77,45 @@ public enum ExecutionStatus {
}
}

/**
* status is success
* @return status
*/
public boolean typeIsSuccess(){
/**
* status is success
* @return status
*/
public boolean typeIsSuccess(){
return this == SUCCESS;
}

/**
* status is failure
* @return status
*/
public boolean typeIsFailure(){
/**
* status is failure
* @return status
*/
public boolean typeIsFailure(){
return this == FAILURE || this == NEED_FAULT_TOLERANCE || this == KILL;
}

/**
* status is finished
* @return status
*/
public boolean typeIsFinished(){
/**
* status is finished
* @return status
*/
public boolean typeIsFinished(){

return typeIsSuccess() || typeIsFailure() || typeIsCancel() || typeIsPause()
return typeIsSuccess() || typeIsFailure() || typeIsCancel() || typeIsPause()
|| typeIsStop();
}
}

/**
* status is waiting thread
* @return status
*/
public boolean typeIsWaitingThread(){
public boolean typeIsWaitingThread(){
return this == WAITING_THREAD;
}

/**
* status is pause
* @return status
*/
public boolean typeIsPause(){
public boolean typeIsPause(){
return this == PAUSE;
}
/**
Expand All @@ -124,7 +130,7 @@ public boolean typeIsStop(){
* status is running
* @return status
*/
public boolean typeIsRunning(){
public boolean typeIsRunning(){
return this == RUNNING_EXECUTION || this == WAITING_DEPEND;
}

Expand All @@ -147,11 +153,4 @@ public boolean canPause(){
return this == SUBMITTED_SUCCESS || this == READY_PAUSE;
}

public int getCode() {
return code;
}

public String getDescription() {
return description;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@
@EqualsAndHashCode(callSuper = true)
@Data
public class GetTablesRequestParam extends ConnectorRequestParam {
private String dataBase;
private String database;
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@
public interface ConfigBuilder {

String build(boolean isEn);

String buildErrorDataStorage(boolean isEn);
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ public String build(boolean isEn) {
return result;
}

@Override
public String buildErrorDataStorage(boolean isEn) {
return this.build(isEn);
}

protected InputParam getHostInput(boolean isEn) {
return getInputParam("host",
isEn ? "host":"地址",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public JdbcConnector(DataSourceClient dataSourceClient) {
this.dataSourceClient = dataSourceClient;
}

private Connection getConnection(String dataSourceParam, JdbcConnectionInfo jdbcConnectionInfo) throws SQLException {
protected Connection getConnection(String dataSourceParam, JdbcConnectionInfo jdbcConnectionInfo) throws SQLException {
return dataSourceClient.getConnection(JdbcDataSourceInfoManager.getDatasourceInfo(dataSourceParam, getDatasourceInfo(jdbcConnectionInfo)));
}

Expand Down Expand Up @@ -113,9 +113,9 @@ public ConnectorResponse getTables(GetTablesRequestParam param) throws SQLExcept

if (StringUtils.isNotEmpty(jdbcConnectionInfo.getCatalog())) {
catalog = jdbcConnectionInfo.getCatalog();
schema = param.getDataBase();
schema = param.getDatabase();
} else {
catalog = param.getDataBase();
catalog = param.getDatabase();
schema = StringUtils.isEmptyOrNullStr(jdbcConnectionInfo.getSchema()) ? null : jdbcConnectionInfo.getSchema();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ private MongoClient getMongoClient(JdbcConnectionInfo jdbcConnectionInfo) {
public ConnectorResponse getTables(GetTablesRequestParam param) throws SQLException {
ConnectorResponse.ConnectorResponseBuilder builder = ConnectorResponse.builder();
String dataSourceParam = param.getDataSourceParam();
String dataBase = param.getDataBase();
String dataBase = param.getDatabase();

JdbcConnectionInfo jdbcConnectionInfo = JSONUtils.parseObject(dataSourceParam, JdbcConnectionInfo.class);
if (jdbcConnectionInfo == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,52 @@
*/
package io.datavines.connector.plugin;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.datavines.common.param.form.PluginParams;
import io.datavines.common.param.form.Validate;
import io.datavines.common.param.form.type.InputParam;
import lombok.extern.slf4j.Slf4j;

import java.util.ArrayList;
import java.util.List;

@Slf4j
public class MysqlConfigBuilder extends JdbcConfigBuilder {

@Override
public String buildErrorDataStorage(boolean isEn) {
List<PluginParams> params = new ArrayList<>();
params.add(getHostInput(isEn));
params.add(getPortInput(isEn));
if (getCatalogInput(isEn) != null) {
params.add(getCatalogInput(isEn));
}

params.add(getErrorDataStorageDatabaseInput(isEn));

if (getSchemaInput(isEn) != null) {
params.add(getSchemaInput(isEn));
}

params.add(getUserInput(isEn));
params.add(getPasswordInput(isEn));
params.add(getPropertiesInput(isEn));

ObjectMapper mapper = new ObjectMapper();
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
String result = null;

try {
result = mapper.writeValueAsString(params);
} catch (JsonProcessingException e) {
log.error("json parse error : ", e);
}

return result;
}

@Override
protected InputParam getPropertiesInput(boolean isEn) {
return getInputParam("properties",
Expand All @@ -35,4 +77,12 @@ protected InputParam getDatabaseInput(boolean isEn) {
isEn ? "please enter database" : "请填入数据库", 1, null,
null);
}

protected InputParam getErrorDataStorageDatabaseInput(boolean isEn) {
return getInputParam("database",
isEn ? "database" : "数据库",
isEn ? "please enter database" : "请填入数据库", 1,
Validate.newBuilder().setRequired(true).setMessage(isEn ? "please enter database" : "请填入数据库").build(),
null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class MysqlConnector extends JdbcConnector {
public MysqlConnector(DataSourceClient dataSourceClient) {
super(dataSourceClient);
}

@Override
public BaseJdbcDataSourceInfo getDatasourceInfo(JdbcConnectionInfo jdbcConnectionInfo) {
return new MysqlDataSourceInfo(jdbcConnectionInfo);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public boolean invalidateItemCanOutputToSelf() {

@Override
public boolean supportToBeErrorDataStorage() {
return true;
return false;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ public boolean invalidateItemCanOutputToSelf() {

@Override
public boolean supportToBeErrorDataStorage() {
return true;
return false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* 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 io.datavines.connector.plugin;

import io.datavines.common.param.form.type.InputParam;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class StarRocksConfigBuilder extends JdbcConfigBuilder {

@Override
protected InputParam getPropertiesInput(boolean isEn) {
return getInputParam("properties",
isEn ? "properties" : "参数",
isEn ? "please enter properties,like key=value&key1=value1" : "请填入参数,格式为key=value&key1=value1", 2, null,
"useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&useInformationSchema=true");
}

@Override
protected InputParam getDatabaseInput(boolean isEn) {
return getInputParam("database",
isEn ? "database" : "数据库",
isEn ? "please enter database" : "请填入数据库", 1, null,
null);
}
}
Loading

0 comments on commit 8ae35e6

Please sign in to comment.