diff --git a/lanius-orchestrate-server/modules/lanius-orchestrate-serv/src/main/java/org/yzbdl/lanius/orchestrate/serv/quartz/handler/category/impl/KettleExecutorHandler.java b/lanius-orchestrate-server/modules/lanius-orchestrate-serv/src/main/java/org/yzbdl/lanius/orchestrate/serv/quartz/handler/category/impl/KettleExecutorHandler.java
index 6943bfd8b93cbed314f63fcdf1725e399f2ca2a9..18c4df1d2fa4472f2288a0d38963e393b2e2c83f 100644
--- a/lanius-orchestrate-server/modules/lanius-orchestrate-serv/src/main/java/org/yzbdl/lanius/orchestrate/serv/quartz/handler/category/impl/KettleExecutorHandler.java
+++ b/lanius-orchestrate-server/modules/lanius-orchestrate-serv/src/main/java/org/yzbdl/lanius/orchestrate/serv/quartz/handler/category/impl/KettleExecutorHandler.java
@@ -28,6 +28,7 @@ import org.springframework.util.MultiValueMap;
import org.springframework.web.client.ResourceAccessException;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
+import org.yzbdl.lanius.orchestrate.common.dto.resource.DatabaseConfigurationDTO;
import org.yzbdl.lanius.orchestrate.common.dto.resource.ServerProgramInfoDTO;
import org.yzbdl.lanius.orchestrate.common.dto.task.TaskInstanceResourceDTO;
import org.yzbdl.lanius.orchestrate.common.dto.task.TaskPlanResourceDTO;
@@ -46,7 +47,8 @@ import org.yzbdl.lanius.orchestrate.common.xml.XMLHandler;
import org.yzbdl.lanius.orchestrate.serv.constant.*;
import org.yzbdl.lanius.orchestrate.serv.constant.schedule.kettle.KettleConstant;
import org.yzbdl.lanius.orchestrate.serv.constant.schedule.kettle.KettleXmlConstant;
-import org.yzbdl.lanius.orchestrate.serv.database.DynamicDatabase;
+import org.yzbdl.lanius.orchestrate.serv.database.DbRepositoryFactory;
+import org.yzbdl.lanius.orchestrate.serv.database.DbRepositoryInvokeHandler;
import org.yzbdl.lanius.orchestrate.serv.quartz.handler.category.ProgramCategoryExecutorFactory;
import org.yzbdl.lanius.orchestrate.serv.quartz.handler.category.ProgramCategoryExecutorInvokerHandler;
import org.yzbdl.lanius.orchestrate.serv.quartz.handler.resourcetype.ResourceTypeFactory;
@@ -60,7 +62,6 @@ import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.net.ConnectException;
-import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.text.DecimalFormat;
import java.text.ParseException;
@@ -546,29 +547,43 @@ public class KettleExecutorHandler implements ProgramCategoryExecutorInvokerHand
repConfigJsonMap.put(EtlRequestConstant.HEADER_REPO_ID, "KettleDatabaseRepository");
// 连接名
repConfigJsonMap.put(EtlRequestConstant.HEADER_DB_CONN_NAME, resourceConfigEntity.getConnectName());
- // 地址
- // 地址
- String connectUrl = DynamicDatabase.getDbUrlByEntity(resourceConfigEntity.getConnectUrl(),
- resourceConfigEntity.getConnectCategory());
- URI uri = JdbcUtil.parseJdbcUrl(connectUrl);
+
+ // 数据库资源库处理Handler
+ DbRepositoryInvokeHandler handler
+ = DbRepositoryFactory.getHandler(resourceConfigEntity.getConnectCategory());
+ if(Objects.isNull(handler)) {
+ throw new BusinessException(MessageUtil.get("task.resource.retrieve.handler.fail"));
+ }
+
+ DatabaseConfigurationDTO databaseConfigurationDTO;
+ try{
+ databaseConfigurationDTO
+ = JSONUtil.toBean(resourceConfigEntity.getConnectUrl(), DatabaseConfigurationDTO.class);
+ } catch (Exception e){
+ log.error("[解析资源库数据失败!],[资源库Json配置解析异常],[请清除资源库数据重新填写资源库数据!]");
+ throw new BusinessException("资源库链接配置不正确,请重新编辑修改!");
+ }
+
// ip
- repConfigJsonMap.put(EtlRequestConstant.HEADER_DB_CONN_HOST, uri.getHost());
+ repConfigJsonMap.put(EtlRequestConstant.HEADER_DB_CONN_HOST, databaseConfigurationDTO.getIp());
String dataBaseTypeName = CommonUtil.getDataBaseTypeNameByType(resourceConfigEntity.getConnectCategory());
// 旧版数据库类型 保留参数兼容CKettle1.0
repConfigJsonMap.put(EtlRequestConstant.HEADER_DB_TYPE, dataBaseTypeName.toUpperCase() + "/1.0.0");
// 数据库名
- repConfigJsonMap.put(EtlRequestConstant.HEADER_DB_NAME, JdbcUtil.getDbName(uri));
+ repConfigJsonMap.put(EtlRequestConstant.HEADER_DB_NAME, databaseConfigurationDTO.getDbName());
// 端口
- repConfigJsonMap.put(EtlRequestConstant.HEADER_DB_PORT, String.valueOf(uri.getPort()));
+ repConfigJsonMap.put(EtlRequestConstant.HEADER_DB_PORT, String.valueOf(databaseConfigurationDTO.getPort()));
// 账号
repConfigJsonMap.put(EtlRequestConstant.HEADER_DB_USER, resourceConfigEntity.getConnectAccount());
// 密码
repConfigJsonMap.put(EtlRequestConstant.HEADER_DB_PASS, resourceConfigEntity.getConnectPassword());
// url 写法是jdbc:mysql://127.0.0.1:3306/db_rep
- if (StringUtils.isNotBlank(uri.getQuery())) {
- // 资源库用户名
- repConfigJsonMap.put(EtlRequestConstant.HEADER_DB_EO, uri.getQuery());
+ if (Objects.nonNull(databaseConfigurationDTO.getParams())
+ && !databaseConfigurationDTO.getParams().isEmpty()) {
+ // 资源库扩展参数
+ repConfigJsonMap.put(EtlRequestConstant.HEADER_DB_EO,
+ handler.generateParams(databaseConfigurationDTO.getParams()));
}
}
diff --git a/lanius-orchestrate-server/modules/lanius-orchestrate-serv/src/main/java/org/yzbdl/lanius/orchestrate/serv/quartz/resource/ResourceScheduledTask.java b/lanius-orchestrate-server/modules/lanius-orchestrate-serv/src/main/java/org/yzbdl/lanius/orchestrate/serv/quartz/resource/ResourceScheduledTask.java
index cda4f603cc463225206c84dfb11e015cd9420268..6b78176d33a2fc514224451cb2be434615289dfe 100644
--- a/lanius-orchestrate-server/modules/lanius-orchestrate-serv/src/main/java/org/yzbdl/lanius/orchestrate/serv/quartz/resource/ResourceScheduledTask.java
+++ b/lanius-orchestrate-server/modules/lanius-orchestrate-serv/src/main/java/org/yzbdl/lanius/orchestrate/serv/quartz/resource/ResourceScheduledTask.java
@@ -14,19 +14,23 @@ package org.yzbdl.lanius.orchestrate.serv.quartz.resource;
import cn.hutool.core.lang.TypeReference;
import cn.hutool.json.JSONUtil;
import lombok.AllArgsConstructor;
+import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
+import org.yzbdl.lanius.orchestrate.common.dto.resource.DatabaseConfigurationDTO;
import org.yzbdl.lanius.orchestrate.common.dto.resource.ServerProgramAndServerDto;
import org.yzbdl.lanius.orchestrate.common.entity.resource.ServerEntity;
import org.yzbdl.lanius.orchestrate.common.entity.resource.ServerProgramEntity;
import org.yzbdl.lanius.orchestrate.common.entity.resource.TaskResourceConfigEntity;
import org.yzbdl.lanius.orchestrate.common.enums.ResourceDataStatusEnum;
import org.yzbdl.lanius.orchestrate.common.enums.ServerProgramStatusEnum;
+import org.yzbdl.lanius.orchestrate.common.exception.runtime.BusinessException;
import org.yzbdl.lanius.orchestrate.serv.constant.TaskResourceConstant;
-import org.yzbdl.lanius.orchestrate.serv.database.DynamicDatabase;
+import org.yzbdl.lanius.orchestrate.serv.database.DbRepositoryFactory;
+import org.yzbdl.lanius.orchestrate.serv.database.DbRepositoryInvokeHandler;
import org.yzbdl.lanius.orchestrate.serv.mapper.resource.ServerMapper;
import org.yzbdl.lanius.orchestrate.serv.mapper.resource.ServerProgramMapper;
import org.yzbdl.lanius.orchestrate.serv.mapper.resource.TaskResourceConfigMapper;
@@ -36,6 +40,7 @@ import org.yzbdl.lanius.orchestrate.serv.utils.SshUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
/**
* 资源定时任务
@@ -68,7 +73,8 @@ public class ResourceScheduledTask {
all.forEach(server -> {
boolean isConnected = SshUtils.serverTestConnection(server.getServerIp(), server.getServerPort(),
server.getAccountName(), server.getPassword());
- Integer status = isConnected ? ResourceDataStatusEnum.NORMAL.getCode() : ResourceDataStatusEnum.ABNORMAL.getCode();
+ Integer status = isConnected ?
+ ResourceDataStatusEnum.NORMAL.getCode() : ResourceDataStatusEnum.ABNORMAL.getCode();
if (!status.equals(server.getStatus())) {
checkedList.add(ServerEntity.builder().id(server.getId()).status(status).build());
}
@@ -86,18 +92,42 @@ public class ResourceScheduledTask {
logger.info("定时任务检测资源配置状态!");
List