From 37595613d1d8ed729bdea46633ac60fc9f9bb6be Mon Sep 17 00:00:00 2001
From: sodaRyCN <757083350@qq.com>
Date: Tue, 30 Jul 2024 19:44:20 +0800
Subject: [PATCH] more admin
---
eventmesh-admin-server/conf/eventmesh.sql | 134 +++++++++++++++++-
.../conf/mapper/EventMeshDataSourceMapper.xml | 9 +-
.../conf/mapper/EventMeshJobInfoMapper.xml | 16 ++-
.../conf/mapper/EventMeshTaskInfoMapper.xml | 19 +--
.../conf/mapper/EventMeshVerifyMapper.xml | 42 ++++++
.../admin/server/web/HttpServer.java | 20 +++
.../eventmesh/admin/server/web/Response.java | 43 +++---
.../web/db/entity/EventMeshDataSource.java | 8 +-
.../web/db/entity/EventMeshJobInfo.java | 40 +++++-
.../web/db/entity/EventMeshTaskInfo.java | 40 ++++--
.../server/web/db/entity/EventMeshVerify.java | 53 +++++++
.../web/db/mapper/EventMeshJobInfoMapper.java | 3 +-
.../db/mapper/EventMeshTaskInfoMapper.java | 4 +
.../web/db/mapper/EventMeshVerifyMapper.java | 37 +++++
.../db/service/EventMeshJobInfoService.java | 35 +++--
.../db/service/EventMeshVerifyService.java | 29 ++++
.../impl/EventMeshJobInfoServiceImpl.java | 46 +++---
.../handler/impl/FetchJobRequestHandler.java | 35 +++--
.../handler/impl/FetchPositionHandler.java | 9 +-
.../handler/impl/ReportHeartBeatHandler.java | 28 ++--
.../handler/impl/ReportPositionHandler.java | 47 +++---
.../web/handler/impl/ReportVerifyHandler.java | 49 +++++++
.../admin/server/web/pojo/JobDetail.java | 29 ++--
.../server/web/service/AdminGrpcServer.java | 17 +--
.../admin/server/web/service/AdminServer.java | 38 +----
.../datasource/DataSourceBizService.java | 48 +++++++
...e.java => RuntimeHeartbeatBizService.java} | 2 +-
...BizService.java => JobInfoBizService.java} | 96 ++++++++-----
...izService.java => PositionBizService.java} | 6 +-
.../position/impl/MysqlPositionHandler.java | 2 +-
.../web/service/task/TaskBizService.java | 46 +++++-
.../web/service/verify/VerifyBizService.java | 42 ++++++
.../{job/JobState.java => TaskState.java} | 17 ++-
.../remote/{task => }/TransportType.java | 11 +-
.../common/remote/datasource/DataSource.java | 39 +++--
.../remote/datasource/DataSourceClassify.java | 3 +-
.../remote/datasource/DataSourceConf.java | 28 +---
.../datasource/DataSourceDriverType.java | 3 +-
.../remote/datasource/DataSourceType.java | 36 +++--
.../MySqlIncDataSourceSourceConf.java | 85 +++++++++++
.../common/remote/job/JobConnectorConfig.java | 4 +-
.../remote/request/BaseRemoteRequest.java | 2 +-
....java => CreateOrUpdateDataSourceReq.java} | 23 +--
.../remote/request/CreateTaskRequest.java | 55 +++++++
.../remote/request/ReportPositionRequest.java | 6 +-
.../remote/request/ReportVerifyRequest.java | 2 +
.../remote/response/BaseRemoteResponse.java | 2 -
...kResponse.java => CreateTaskResponse.java} | 6 +-
.../remote/response/FetchJobResponse.java | 18 +--
...{FailResponse.java => SimpleResponse.java} | 19 ++-
.../common/remote/task/TaskState.java | 32 -----
.../eventmesh/common/utils/JsonUtils.java | 8 ++
.../offsetmgmt/admin/AdminOffsetService.java | 6 +-
.../runtime/connector/ConnectorRuntime.java | 8 --
54 files changed, 1068 insertions(+), 417 deletions(-)
create mode 100644 eventmesh-admin-server/conf/mapper/EventMeshVerifyMapper.xml
create mode 100644 eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/db/entity/EventMeshVerify.java
create mode 100644 eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/db/mapper/EventMeshVerifyMapper.java
create mode 100644 eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/db/service/EventMeshVerifyService.java
create mode 100644 eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/handler/impl/ReportVerifyHandler.java
create mode 100644 eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/service/datasource/DataSourceBizService.java
rename eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/service/heatbeat/{EventMeshRuntimeHeartbeatBizService.java => RuntimeHeartbeatBizService.java} (98%)
rename eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/service/job/{EventMeshJobInfoBizService.java => JobInfoBizService.java} (55%)
rename eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/service/position/{EventMeshPositionBizService.java => PositionBizService.java} (94%)
create mode 100644 eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/service/verify/VerifyBizService.java
rename eventmesh-common/src/main/java/org/apache/eventmesh/common/remote/{job/JobState.java => TaskState.java} (75%)
rename eventmesh-common/src/main/java/org/apache/eventmesh/common/remote/{task => }/TransportType.java (84%)
rename eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/Admin.java => eventmesh-common/src/main/java/org/apache/eventmesh/common/remote/datasource/DataSourceConf.java (56%)
create mode 100644 eventmesh-common/src/main/java/org/apache/eventmesh/common/remote/datasource/MySqlIncDataSourceSourceConf.java
rename eventmesh-common/src/main/java/org/apache/eventmesh/common/remote/request/{CreateOrUpdateTaskReq.java => CreateOrUpdateDataSourceReq.java} (65%)
create mode 100644 eventmesh-common/src/main/java/org/apache/eventmesh/common/remote/request/CreateTaskRequest.java
rename eventmesh-common/src/main/java/org/apache/eventmesh/common/remote/response/{EmptyAckResponse.java => CreateTaskResponse.java} (88%)
rename eventmesh-common/src/main/java/org/apache/eventmesh/common/remote/response/{FailResponse.java => SimpleResponse.java} (67%)
delete mode 100644 eventmesh-common/src/main/java/org/apache/eventmesh/common/remote/task/TaskState.java
diff --git a/eventmesh-admin-server/conf/eventmesh.sql b/eventmesh-admin-server/conf/eventmesh.sql
index 8e9ed4c4c8..c5f1bf1a9a 100644
--- a/eventmesh-admin-server/conf/eventmesh.sql
+++ b/eventmesh-admin-server/conf/eventmesh.sql
@@ -1,34 +1,154 @@
-- --------------------------------------------------------
--- 主机: 192.168.56.102
--- 服务器版本: 8.0.37 - MySQL Community Server - GPL
--- 服务器操作系统: Linux
--- HeidiSQL 版本: 12.7.0.6850
+-- 主机: 127.0.0.1
+-- 服务器版本: 8.0.36 - MySQL Community Server - GPL
+-- 服务器操作系统: Win64
+-- HeidiSQL 版本: 11.3.0.6295
-- --------------------------------------------------------
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET NAMES utf8 */;
/*!50503 SET NAMES utf8mb4 */;
-/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
-/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
+
+-- 导出 eventmesh 的数据库结构
+CREATE DATABASE IF NOT EXISTS `eventmesh` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci */ /*!80016 DEFAULT ENCRYPTION='N' */;
+USE `eventmesh`;
+
+-- 导出 表 eventmesh.event_mesh_data_source 结构
+CREATE TABLE IF NOT EXISTS `event_mesh_data_source` (
+ `id` int unsigned NOT NULL AUTO_INCREMENT,
+ `dataType` varchar(50) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
+ `description` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
+ `configuration` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
+ `region` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ `createUid` varchar(50) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
+ `updateUid` varchar(50) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
+ `createTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ `updateTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+ PRIMARY KEY (`id`) USING BTREE
+) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
+
+-- 数据导出被取消选择。
+
+-- 导出 表 eventmesh.event_mesh_job_info 结构
+CREATE TABLE IF NOT EXISTS `event_mesh_job_info` (
+ `id` int unsigned NOT NULL AUTO_INCREMENT,
+ `jobID` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
+ `desc` varchar(50) COLLATE utf8mb4_general_ci NOT NULL,
+ `taskID` varchar(50) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
+ `transportType` varchar(50) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
+ `sourceData` int NOT NULL DEFAULT '0',
+ `targetData` int NOT NULL DEFAULT '0',
+ `state` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
+ `jobType` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
+ `fromRegion` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
+ `createUid` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
+ `updateUid` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
+ `createTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ `updateTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+ PRIMARY KEY (`id`) USING BTREE,
+ UNIQUE KEY `jobID` (`jobID`)
+) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
+
-- 数据导出被取消选择。
+-- 导出 表 eventmesh.event_mesh_mysql_position 结构
+CREATE TABLE IF NOT EXISTS `event_mesh_mysql_position` (
+ `id` int unsigned NOT NULL AUTO_INCREMENT,
+ `jobID` varchar(50) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
+ `serverUUID` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
+ `address` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
+ `position` bigint DEFAULT NULL,
+ `gtid` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
+ `currentGtid` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
+ `timestamp` bigint DEFAULT NULL,
+ `journalName` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
+ `createTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ `updateTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `jobID` (`jobID`)
+) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC;
+
-- 数据导出被取消选择。
+-- 导出 表 eventmesh.event_mesh_position_reporter_history 结构
+CREATE TABLE IF NOT EXISTS `event_mesh_position_reporter_history` (
+ `id` bigint NOT NULL AUTO_INCREMENT,
+ `job` varchar(50) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
+ `record` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
+ `address` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
+ `createTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ PRIMARY KEY (`id`),
+ KEY `job` (`job`),
+ KEY `address` (`address`)
+) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='记录position上报者变更时,老记录';
+
-- 数据导出被取消选择。
+-- 导出 表 eventmesh.event_mesh_runtime_heartbeat 结构
+CREATE TABLE IF NOT EXISTS `event_mesh_runtime_heartbeat` (
+ `id` bigint unsigned NOT NULL AUTO_INCREMENT,
+ `adminAddr` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
+ `runtimeAddr` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
+ `jobID` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
+ `reportTime` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'runtime本地上报时间',
+ `updateTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+ `createTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `runtimeAddr` (`runtimeAddr`),
+ KEY `jobID` (`jobID`)
+) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
+
-- 数据导出被取消选择。
+-- 导出 表 eventmesh.event_mesh_runtime_history 结构
+CREATE TABLE IF NOT EXISTS `event_mesh_runtime_history` (
+ `id` bigint NOT NULL AUTO_INCREMENT,
+ `job` varchar(50) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
+ `address` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
+ `createTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ PRIMARY KEY (`id`),
+ KEY `address` (`address`)
+) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='记录runtime上运行任务的变更';
+
-- 数据导出被取消选择。
+-- 导出 表 eventmesh.event_mesh_task_info 结构
+CREATE TABLE IF NOT EXISTS `event_mesh_task_info` (
+ `id` int unsigned NOT NULL AUTO_INCREMENT,
+ `taskID` varchar(50) COLLATE utf8mb4_general_ci NOT NULL,
+ `name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
+ `desc` varchar(50) COLLATE utf8mb4_general_ci NOT NULL,
+ `state` varchar(50) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT 'TaskState',
+ `fromRegion` varchar(50) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
+ `createUid` varchar(50) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
+ `updateUid` varchar(50) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
+ `createTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ `updateTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+ PRIMARY KEY (`id`) USING BTREE,
+ UNIQUE KEY `taskID` (`taskID`)
+) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
+
-- 数据导出被取消选择。
+-- 导出 表 eventmesh.event_mesh_verify 结构
+CREATE TABLE IF NOT EXISTS `event_mesh_verify` (
+ `id` int NOT NULL,
+ `taskID` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
+ `recordID` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
+ `recordSig` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
+ `connectorName` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
+ `connectorStage` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
+ `position` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
+ `createTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
+
-- 数据导出被取消选择。
-/*!40103 SET TIME_ZONE=IFNULL(@OLD_TIME_ZONE, 'system') */;
/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
/*!40014 SET FOREIGN_KEY_CHECKS=IFNULL(@OLD_FOREIGN_KEY_CHECKS, 1) */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
diff --git a/eventmesh-admin-server/conf/mapper/EventMeshDataSourceMapper.xml b/eventmesh-admin-server/conf/mapper/EventMeshDataSourceMapper.xml
index a346c81bf6..d100e19033 100644
--- a/eventmesh-admin-server/conf/mapper/EventMeshDataSourceMapper.xml
+++ b/eventmesh-admin-server/conf/mapper/EventMeshDataSourceMapper.xml
@@ -25,18 +25,19 @@
-
+
-
-
+
+
+
id,dataType,description,
- configuration,createUid,updateUid,
+ configuration,region,createUid,updateUid,
createTime,updateTime
diff --git a/eventmesh-admin-server/conf/mapper/EventMeshJobInfoMapper.xml b/eventmesh-admin-server/conf/mapper/EventMeshJobInfoMapper.xml
index d7e65128ab..02e8806680 100644
--- a/eventmesh-admin-server/conf/mapper/EventMeshJobInfoMapper.xml
+++ b/eventmesh-admin-server/conf/mapper/EventMeshJobInfoMapper.xml
@@ -1,4 +1,5 @@
+
+*/
+-->
+
@@ -25,15 +28,22 @@
+
+
+
+
+
+
id,jobID,desc,
- taskID,state,jobType,
- createTime,updateTime
+ taskID,transportType,sourceData,
+ targetData,state,jobType,
+ fromRegion,createTime,updateTime
diff --git a/eventmesh-admin-server/conf/mapper/EventMeshTaskInfoMapper.xml b/eventmesh-admin-server/conf/mapper/EventMeshTaskInfoMapper.xml
index 11074aab9d..05b1dc52a0 100644
--- a/eventmesh-admin-server/conf/mapper/EventMeshTaskInfoMapper.xml
+++ b/eventmesh-admin-server/conf/mapper/EventMeshTaskInfoMapper.xml
@@ -1,4 +1,5 @@
+
+*/
+-->
+
@@ -25,20 +28,18 @@
-
-
-
-
-
+
+
+
id,taskID,name,
- desc,transportType,sourceData,
- targetData,state,createUid,
- updateUid,createTime,updateTime
+ desc,state,fromRegion,
+ createUid,updateUid,createTime,
+ updateTime
diff --git a/eventmesh-admin-server/conf/mapper/EventMeshVerifyMapper.xml b/eventmesh-admin-server/conf/mapper/EventMeshVerifyMapper.xml
new file mode 100644
index 0000000000..b7b042145a
--- /dev/null
+++ b/eventmesh-admin-server/conf/mapper/EventMeshVerifyMapper.xml
@@ -0,0 +1,42 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ id,taskID,recordID,
+ recordSig,connectorName,connectorStage,
+ position,createTime
+
+
diff --git a/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/HttpServer.java b/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/HttpServer.java
index 3f91115bdc..bd896d546c 100644
--- a/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/HttpServer.java
+++ b/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/HttpServer.java
@@ -17,10 +17,30 @@
package org.apache.eventmesh.admin.server.web;
+import org.apache.eventmesh.admin.server.web.service.task.TaskBizService;
+import org.apache.eventmesh.common.remote.request.CreateTaskRequest;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/eventmesh/admin")
public class HttpServer {
+ @Autowired
+ private TaskBizService taskService;
+
+ @RequestMapping("/createTask")
+ public ResponseEntity> createOrUpdateTask(@RequestBody CreateTaskRequest task) {
+ String uuid = taskService.createTask(task);
+ return ResponseEntity.ok(Response.success(uuid));
+ }
+
+ public boolean deleteTask(Long id) {
+ return false;
+ }
+
+
}
diff --git a/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/Response.java b/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/Response.java
index d58312146c..329a00baae 100644
--- a/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/Response.java
+++ b/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/Response.java
@@ -17,35 +17,44 @@
package org.apache.eventmesh.admin.server.web;
-public class Response {
+import org.apache.eventmesh.common.remote.exception.ErrorCode;
+public class Response {
+ private int code;
private boolean success;
private String desc;
private T data;
- public boolean isSuccess() {
- return success;
- }
-
- public void setSuccess(boolean success) {
- this.success = success;
- }
-
- public String getDesc() {
- return desc;
+ public static Response success() {
+ Response response = new Response<>();
+ response.success = true;
+ response.code = ErrorCode.SUCCESS;
+ return response;
}
- public void setDesc(String desc) {
- this.desc = desc;
+ public static Response success(T data) {
+ Response response = new Response<>();
+ response.success = true;
+ response.data = data;
+ return response;
}
- public T getData() {
- return data;
+ public static Response fail(int code, String desc) {
+ Response response = new Response<>();
+ response.success = false;
+ response.code = code;
+ response.desc = desc;
+ return response;
}
- public void setData(T data) {
- this.data = data;
+ public static Response fail(int code, String desc, T data) {
+ Response response = new Response<>();
+ response.success = false;
+ response.code = code;
+ response.desc = desc;
+ response.data = data;
+ return response;
}
}
diff --git a/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/db/entity/EventMeshDataSource.java b/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/db/entity/EventMeshDataSource.java
index 3a4bc453bd..e79d6cd9c6 100644
--- a/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/db/entity/EventMeshDataSource.java
+++ b/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/db/entity/EventMeshDataSource.java
@@ -35,15 +35,17 @@ public class EventMeshDataSource implements Serializable {
@TableId(type = IdType.AUTO)
private Integer id;
- private Integer dataType;
+ private String dataType;
private String description;
private String configuration;
- private Integer createUid;
+ private String region;
- private Integer updateUid;
+ private String createUid;
+
+ private String updateUid;
private Date createTime;
diff --git a/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/db/entity/EventMeshJobInfo.java b/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/db/entity/EventMeshJobInfo.java
index a0690a7830..f198f50806 100644
--- a/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/db/entity/EventMeshJobInfo.java
+++ b/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/db/entity/EventMeshJobInfo.java
@@ -1,32 +1,62 @@
+/*
+ * 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.apache.eventmesh.admin.server.web.db.entity;
+import java.io.Serializable;
+import java.util.Date;
+
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
-import lombok.Data;
-import java.io.Serializable;
-import java.util.Date;
+import lombok.Data;
/**
- * @TableName event_mesh_job_info
+ * TableName event_mesh_job_info
*/
@TableName(value ="event_mesh_job_info")
@Data
public class EventMeshJobInfo implements Serializable {
@TableId(type = IdType.AUTO)
private Integer id;
- @TableId(type = IdType.ASSIGN_UUID)
+
private String jobID;
private String desc;
private String taskID;
+ private String transportType;
+
+ private Integer sourceData;
+
+ private Integer targetData;
+
private String state;
private String jobType;
+ private String fromRegion;
+
+ private String createUid;
+
+ private String updateUid;
+
private Date createTime;
private Date updateTime;
diff --git a/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/db/entity/EventMeshTaskInfo.java b/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/db/entity/EventMeshTaskInfo.java
index 9d25b44660..186da2dc6e 100644
--- a/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/db/entity/EventMeshTaskInfo.java
+++ b/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/db/entity/EventMeshTaskInfo.java
@@ -1,39 +1,53 @@
+/*
+ * 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.apache.eventmesh.admin.server.web.db.entity;
+import java.io.Serializable;
+import java.util.Date;
+
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
-import lombok.Data;
-import java.io.Serializable;
-import java.util.Date;
+import lombok.Data;
/**
- * @TableName event_mesh_task_info
+ * TableName event_mesh_task_info
*/
@TableName(value ="event_mesh_task_info")
@Data
public class EventMeshTaskInfo implements Serializable {
@TableId(type = IdType.AUTO)
private Integer id;
- @TableId(type = IdType.ASSIGN_UUID)
+
private String taskID;
private String name;
private String desc;
- private String transportType;
-
- private Integer sourceData;
-
- private Integer targetData;
-
private String state;
- private Integer createUid;
+ private String fromRegion;
+
+ private String createUid;
- private Integer updateUid;
+ private String updateUid;
private Date createTime;
diff --git a/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/db/entity/EventMeshVerify.java b/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/db/entity/EventMeshVerify.java
new file mode 100644
index 0000000000..c1cb7c0796
--- /dev/null
+++ b/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/db/entity/EventMeshVerify.java
@@ -0,0 +1,53 @@
+/*
+ * 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.apache.eventmesh.admin.server.web.db.entity;
+
+import java.io.Serializable;
+import java.util.Date;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+
+import lombok.Data;
+
+/**
+ * TableName event_mesh_verify
+ */
+@TableName(value ="event_mesh_verify")
+@Data
+public class EventMeshVerify implements Serializable {
+ @TableId(type = IdType.AUTO)
+ private Integer id;
+
+ private String taskID;
+
+ private String recordID;
+
+ private String recordSig;
+
+ private String connectorName;
+
+ private String connectorStage;
+
+ private String position;
+
+ private Date createTime;
+
+ private static final long serialVersionUID = 1L;
+}
\ No newline at end of file
diff --git a/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/db/mapper/EventMeshJobInfoMapper.java b/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/db/mapper/EventMeshJobInfoMapper.java
index eb57c0af2c..39f8a4aed6 100644
--- a/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/db/mapper/EventMeshJobInfoMapper.java
+++ b/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/db/mapper/EventMeshJobInfoMapper.java
@@ -25,8 +25,7 @@
/**
* for table 'event_mesh_job_info' db operation
- * 2024-05-09 15:51:45
- * entity.db.web.server.admin.eventmesh.apache.org.EventMeshJobInfo
+ * entity org.apache.eventmesh.admin.server.web.db.entity.EventMeshJobInfo
*/
@Mapper
public interface EventMeshJobInfoMapper extends BaseMapper {
diff --git a/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/db/mapper/EventMeshTaskInfoMapper.java b/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/db/mapper/EventMeshTaskInfoMapper.java
index e882fd3f34..b9d226fc34 100644
--- a/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/db/mapper/EventMeshTaskInfoMapper.java
+++ b/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/db/mapper/EventMeshTaskInfoMapper.java
@@ -18,12 +18,16 @@
package org.apache.eventmesh.admin.server.web.db.mapper;
import org.apache.eventmesh.admin.server.web.db.entity.EventMeshTaskInfo;
+
+import org.apache.ibatis.annotations.Mapper;
+
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* event_mesh_task_info
* Entity org.apache.eventmesh.admin.server.web.db.entity.EventMeshTaskInfo
*/
+@Mapper
public interface EventMeshTaskInfoMapper extends BaseMapper {
}
diff --git a/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/db/mapper/EventMeshVerifyMapper.java b/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/db/mapper/EventMeshVerifyMapper.java
new file mode 100644
index 0000000000..4919fc84f9
--- /dev/null
+++ b/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/db/mapper/EventMeshVerifyMapper.java
@@ -0,0 +1,37 @@
+/*
+* 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.apache.eventmesh.admin.server.web.db.mapper;
+
+import org.apache.eventmesh.admin.server.web.db.entity.EventMeshVerify;
+
+import org.apache.ibatis.annotations.Mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+* event_mesh_verify
+* Entity org.apache.eventmesh.admin.server.web.db.entity.EventMeshVerify
+*/
+@Mapper
+public interface EventMeshVerifyMapper extends BaseMapper {
+
+}
+
+
+
+
diff --git a/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/db/service/EventMeshJobInfoService.java b/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/db/service/EventMeshJobInfoService.java
index c5ad399854..16dc36c119 100644
--- a/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/db/service/EventMeshJobInfoService.java
+++ b/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/db/service/EventMeshJobInfoService.java
@@ -1,29 +1,28 @@
/*
- * 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.
- */
+* 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.apache.eventmesh.admin.server.web.db.service;
import org.apache.eventmesh.admin.server.web.db.entity.EventMeshJobInfo;
-
import com.baomidou.mybatisplus.extension.service.IService;
/**
-* for table `event_mesh_job_info' db operation
-* 2024-05-09 15:51:45
+* event_mesh_job_info
*/
public interface EventMeshJobInfoService extends IService {
+
}
diff --git a/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/db/service/EventMeshVerifyService.java b/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/db/service/EventMeshVerifyService.java
new file mode 100644
index 0000000000..6aa896fd83
--- /dev/null
+++ b/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/db/service/EventMeshVerifyService.java
@@ -0,0 +1,29 @@
+/*
+* 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.apache.eventmesh.admin.server.web.db.service;
+
+import org.apache.eventmesh.admin.server.web.db.entity.EventMeshVerify;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+* event_mesh_verify
+*/
+public interface EventMeshVerifyService extends IService {
+
+}
diff --git a/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/db/service/impl/EventMeshJobInfoServiceImpl.java b/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/db/service/impl/EventMeshJobInfoServiceImpl.java
index dd7312ceae..0e0de26ea3 100644
--- a/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/db/service/impl/EventMeshJobInfoServiceImpl.java
+++ b/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/db/service/impl/EventMeshJobInfoServiceImpl.java
@@ -1,40 +1,34 @@
/*
- * 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.
- */
+* 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.apache.eventmesh.admin.server.web.db.service.impl;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.eventmesh.admin.server.web.db.entity.EventMeshJobInfo;
-import org.apache.eventmesh.admin.server.web.db.mapper.EventMeshJobInfoMapper;
import org.apache.eventmesh.admin.server.web.db.service.EventMeshJobInfoService;
-
+import org.apache.eventmesh.admin.server.web.db.mapper.EventMeshJobInfoMapper;
import org.springframework.stereotype.Service;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-
-import lombok.extern.slf4j.Slf4j;
-
/**
- * for table 'event_mesh_job_info' db operation
- * 2024-05-09 15:51:45
- */
+* event_mesh_job_info
+*/
@Service
-@Slf4j
public class EventMeshJobInfoServiceImpl extends ServiceImpl
- implements EventMeshJobInfoService {
+ implements EventMeshJobInfoService{
}
diff --git a/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/handler/impl/FetchJobRequestHandler.java b/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/handler/impl/FetchJobRequestHandler.java
index 4c15139566..8f159fa45b 100644
--- a/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/handler/impl/FetchJobRequestHandler.java
+++ b/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/handler/impl/FetchJobRequestHandler.java
@@ -17,13 +17,15 @@
package org.apache.eventmesh.admin.server.web.handler.impl;
-import org.apache.eventmesh.admin.server.AdminServerRuntimeException;
import org.apache.eventmesh.admin.server.web.handler.BaseRequestHandler;
-import org.apache.eventmesh.admin.server.web.service.job.EventMeshJobInfoBizService;
+import org.apache.eventmesh.admin.server.web.pojo.JobDetail;
+import org.apache.eventmesh.admin.server.web.service.job.JobInfoBizService;
import org.apache.eventmesh.common.protocol.grpc.adminserver.Metadata;
import org.apache.eventmesh.common.remote.exception.ErrorCode;
+import org.apache.eventmesh.common.remote.job.JobConnectorConfig;
import org.apache.eventmesh.common.remote.request.FetchJobRequest;
import org.apache.eventmesh.common.remote.response.FetchJobResponse;
+import org.apache.eventmesh.common.utils.JsonUtils;
import org.apache.commons.lang3.StringUtils;
@@ -37,34 +39,29 @@
public class FetchJobRequestHandler extends BaseRequestHandler {
@Autowired
- EventMeshJobInfoBizService jobInfoBizService;
+ JobInfoBizService jobInfoBizService;
@Override
public FetchJobResponse handler(FetchJobRequest request, Metadata metadata) {
if (StringUtils.isBlank(request.getJobID())) {
- throw new AdminServerRuntimeException(ErrorCode.BAD_REQUEST, "job id is empty");
- }
- int jobID;
- try {
- jobID = Integer.parseInt(request.getJobID());
- } catch (NumberFormatException e) {
- throw new AdminServerRuntimeException(ErrorCode.BAD_REQUEST, String.format("illegal job id %s",
- request.getJobID()));
+ return FetchJobResponse.failResponse(ErrorCode.BAD_REQUEST, "job id is empty");
}
FetchJobResponse response = FetchJobResponse.successResponse();
- EventMeshJobDetail detail = jobInfoBizService.getJobDetail(jobID);
+ JobDetail detail = jobInfoBizService.getJobDetail(request.getJobID());
if (detail == null) {
return response;
}
- response.setId(detail.getId());
- response.setName(detail.getName());
- response.setSourceConnectorConfig(detail.getSourceConnectorConfig());
- response.setSourceConnectorDesc(detail.getSourceConnectorDesc());
+ response.setId(detail.getJobID());
+ JobConnectorConfig config = new JobConnectorConfig();
+ config.setSourceConnectorConfig(JsonUtils.objectToMap(detail.getSourceDataSource()));
+ config.setSourceConnectorDesc(detail.getSourceConnectorDesc());
+ config.setSinkConnectorConfig(JsonUtils.objectToMap(detail.getSinkDataSource()));
+ config.setSourceConnectorDesc(detail.getSinkConnectorDesc());
+ response.setConnectorConfig(config);
response.setTransportType(detail.getTransportType());
- response.setSinkConnectorConfig(detail.getSinkConnectorConfig());
- response.setSourceConnectorDesc(detail.getSinkConnectorDesc());
response.setState(detail.getState());
- response.setPosition(detail.getPosition());
+ response.setPosition(detail.getPositions());
+ response.setType(detail.getJobType());
return response;
}
}
diff --git a/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/handler/impl/FetchPositionHandler.java b/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/handler/impl/FetchPositionHandler.java
index 2e6fa31f05..85ef0e6113 100644
--- a/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/handler/impl/FetchPositionHandler.java
+++ b/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/handler/impl/FetchPositionHandler.java
@@ -17,10 +17,9 @@
package org.apache.eventmesh.admin.server.web.handler.impl;
-import org.apache.eventmesh.admin.server.AdminServerRuntimeException;
import org.apache.eventmesh.admin.server.web.db.DBThreadPool;
import org.apache.eventmesh.admin.server.web.handler.BaseRequestHandler;
-import org.apache.eventmesh.admin.server.web.service.position.EventMeshPositionBizService;
+import org.apache.eventmesh.admin.server.web.service.position.PositionBizService;
import org.apache.eventmesh.common.protocol.grpc.adminserver.Metadata;
import org.apache.eventmesh.common.remote.exception.ErrorCode;
import org.apache.eventmesh.common.remote.request.FetchPositionRequest;
@@ -41,15 +40,15 @@ public class FetchPositionHandler extends BaseRequestHandler {
+public class ReportHeartBeatHandler extends BaseRequestHandler {
@Autowired
- EventMeshRuntimeHeartbeatBizService heartbeatBizService;
+ RuntimeHeartbeatBizService heartbeatBizService;
@Autowired
DBThreadPool executor;
@Override
- protected EmptyAckResponse handler(ReportHeartBeatRequest request, Metadata metadata) {
+ protected SimpleResponse handler(ReportHeartBeatRequest request, Metadata metadata) {
+ if (StringUtils.isBlank(request.getJobID()) || StringUtils.isBlank(request.getAddress())) {
+ log.info("request [{}] id or reporter address is empty", request);
+ return SimpleResponse.fail(ErrorCode.BAD_REQUEST, "request id or reporter address is empty");
+ }
executor.getExecutors().execute(() -> {
EventMeshRuntimeHeartbeat heartbeat = new EventMeshRuntimeHeartbeat();
- int job;
- try {
- job = Integer.parseInt(request.getJobID());
- } catch (NumberFormatException e) {
- log.warn("runtime {} report heartbeat fail, illegal job id {}", request.getAddress(), request.getJobID());
- return;
- }
- heartbeat.setJobID(job);
+ heartbeat.setJobID(request.getJobID());
heartbeat.setReportTime(request.getReportedTimeStamp());
heartbeat.setAdminAddr(IPUtils.getLocalAddress());
heartbeat.setRuntimeAddr(request.getAddress());
@@ -65,6 +65,6 @@ protected EmptyAckResponse handler(ReportHeartBeatRequest request, Metadata meta
}
});
- return new EmptyAckResponse();
+ return SimpleResponse.success();
}
}
diff --git a/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/handler/impl/ReportPositionHandler.java b/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/handler/impl/ReportPositionHandler.java
index 0616608541..5e2a968262 100644
--- a/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/handler/impl/ReportPositionHandler.java
+++ b/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/handler/impl/ReportPositionHandler.java
@@ -17,16 +17,15 @@
package org.apache.eventmesh.admin.server.web.handler.impl;
-import org.apache.eventmesh.admin.server.AdminServerRuntimeException;
import org.apache.eventmesh.admin.server.web.db.DBThreadPool;
-import org.apache.eventmesh.admin.server.web.db.entity.EventMeshJobInfo;
import org.apache.eventmesh.admin.server.web.handler.BaseRequestHandler;
-import org.apache.eventmesh.admin.server.web.service.job.EventMeshJobInfoBizService;
-import org.apache.eventmesh.admin.server.web.service.position.EventMeshPositionBizService;
+import org.apache.eventmesh.admin.server.web.pojo.JobDetail;
+import org.apache.eventmesh.admin.server.web.service.job.JobInfoBizService;
+import org.apache.eventmesh.admin.server.web.service.position.PositionBizService;
import org.apache.eventmesh.common.protocol.grpc.adminserver.Metadata;
import org.apache.eventmesh.common.remote.exception.ErrorCode;
import org.apache.eventmesh.common.remote.request.ReportPositionRequest;
-import org.apache.eventmesh.common.remote.response.EmptyAckResponse;
+import org.apache.eventmesh.common.remote.response.SimpleResponse;
import org.apache.commons.lang3.StringUtils;
@@ -37,35 +36,33 @@
@Component
@Slf4j
-public class ReportPositionHandler extends BaseRequestHandler {
+public class ReportPositionHandler extends BaseRequestHandler {
@Autowired
- private EventMeshJobInfoBizService jobInfoBizService;
+ private JobInfoBizService jobInfoBizService;
@Autowired
private DBThreadPool executor;
@Autowired
- private EventMeshPositionBizService positionBizService;
-
+ private PositionBizService positionBizService;
@Override
- protected EmptyAckResponse handler(ReportPositionRequest request, Metadata metadata) {
+ protected SimpleResponse handler(ReportPositionRequest request, Metadata metadata) {
+ if (StringUtils.isBlank(request.getJobID())) {
+ log.info("request [{}] illegal job id", request);
+ return SimpleResponse.fail(ErrorCode.BAD_REQUEST, "illegal job id, it's empty");
+ }
if (request.getDataSourceType() == null) {
- throw new AdminServerRuntimeException(ErrorCode.BAD_REQUEST, "illegal data type, it's empty");
+ log.info("request [{}] illegal data type", request);
+ return SimpleResponse.fail(ErrorCode.BAD_REQUEST, "illegal data type, it's empty");
}
if (StringUtils.isBlank(request.getJobID())) {
- throw new AdminServerRuntimeException(ErrorCode.BAD_REQUEST, "illegal job id, it's empty");
+ log.info("request [{}] illegal job id", request);
+ return SimpleResponse.fail(ErrorCode.BAD_REQUEST, "illegal job id, it's empty");
}
if (request.getRecordPositionList() == null || request.getRecordPositionList().isEmpty()) {
- throw new AdminServerRuntimeException(ErrorCode.BAD_REQUEST, "illegal record position list, it's empty");
- }
- int jobID;
-
- try {
- jobID = Integer.parseInt(request.getJobID());
- } catch (NumberFormatException e) {
- throw new AdminServerRuntimeException(ErrorCode.BAD_REQUEST, String.format("illegal job id [%s] format",
- request.getJobID()));
+ log.info("request [{}] illegal record position", request);
+ return SimpleResponse.fail(ErrorCode.BAD_REQUEST, "illegal record position list, it's empty");
}
positionBizService.isValidatePositionRequest(request.getDataSourceType());
@@ -88,10 +85,10 @@ protected EmptyAckResponse handler(ReportPositionRequest request, Metadata metad
log.warn("handle position request fail, request [{}]", request, e);
} finally {
try {
- EventMeshJobInfo detail = jobInfoBizService.getJobDetail(jobID);
- if (detail != null && !detail.getState().equals(request.getState()) && !jobInfoBizService.updateJobState(jobID,
+ JobDetail detail = jobInfoBizService.getJobDetail(request.getJobID());
+ if (detail != null && !detail.getState().equals(request.getState()) && !jobInfoBizService.updateJobState(request.getJobID(),
request.getState())) {
- log.warn("update job [{}] old state [{}] to [{}] fail", jobID, detail.getState(), request.getState());
+ log.warn("update job [{}] old state [{}] to [{}] fail", request.getJobID(), detail.getState(), request.getState());
}
} catch (Exception e) {
log.warn("update job id [{}] type [{}] state [{}] fail", request.getJobID(),
@@ -99,6 +96,6 @@ protected EmptyAckResponse handler(ReportPositionRequest request, Metadata metad
}
}
});
- return new EmptyAckResponse();
+ return SimpleResponse.success();
}
}
diff --git a/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/handler/impl/ReportVerifyHandler.java b/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/handler/impl/ReportVerifyHandler.java
new file mode 100644
index 0000000000..4f3dcf6230
--- /dev/null
+++ b/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/handler/impl/ReportVerifyHandler.java
@@ -0,0 +1,49 @@
+/*
+ * 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.apache.eventmesh.admin.server.web.handler.impl;
+
+import org.apache.eventmesh.admin.server.web.handler.BaseRequestHandler;
+import org.apache.eventmesh.admin.server.web.service.verify.VerifyBizService;
+import org.apache.eventmesh.common.protocol.grpc.adminserver.Metadata;
+import org.apache.eventmesh.common.remote.exception.ErrorCode;
+import org.apache.eventmesh.common.remote.request.ReportVerifyRequest;
+import org.apache.eventmesh.common.remote.response.SimpleResponse;
+
+import org.apache.commons.lang3.StringUtils;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import lombok.extern.slf4j.Slf4j;
+
+@Component
+@Slf4j
+public class ReportVerifyHandler extends BaseRequestHandler {
+ @Autowired
+ private VerifyBizService verifyService;
+
+ @Override
+ protected SimpleResponse handler(ReportVerifyRequest request, Metadata metadata) {
+ if (StringUtils.isAnyBlank(request.getTaskID(), request.getRecordSig(), request.getRecordID(), request.getConnectorStage())) {
+ log.info("report verify request [{}] illegal", request);
+ return SimpleResponse.fail(ErrorCode.BAD_REQUEST, "request task id, sign, record id or stage is none");
+ }
+ return verifyService.reportVerifyRecord(request) ? SimpleResponse.success() : SimpleResponse.fail(ErrorCode.INTERNAL_ERR, "save verify " +
+ "request fail");
+ }
+}
diff --git a/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/pojo/JobDetail.java b/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/pojo/JobDetail.java
index 33a986fb75..c47b284483 100644
--- a/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/pojo/JobDetail.java
+++ b/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/pojo/JobDetail.java
@@ -17,35 +17,48 @@
package org.apache.eventmesh.admin.server.web.pojo;
-import lombok.Data;
+import org.apache.eventmesh.common.remote.TaskState;
+import org.apache.eventmesh.common.remote.TransportType;
+import org.apache.eventmesh.common.remote.datasource.DataSource;
+import org.apache.eventmesh.common.remote.job.JobType;
import org.apache.eventmesh.common.remote.offset.RecordPosition;
-import org.apache.eventmesh.common.remote.task.TransportType;
import java.util.Date;
import java.util.List;
+import lombok.Data;
+
@Data
public class JobDetail {
private Integer id;
+
private String jobID;
+ private String desc;
+
private String taskID;
- private String state;
+ private TaskState state;
- private String jobType;
+ private JobType jobType;
private Date createTime;
private Date updateTime;
- private String sourceConfig;
+ private String createUid;
+
+ private String updateUid;
+
+ private String region;
+
+ private DataSource sourceDataSource;
- private String sourceDesc;
+ private String sourceConnectorDesc;
- private String targetConfig;
+ private DataSource sinkDataSource;
- private String targetDesc;
+ private String sinkConnectorDesc;
private TransportType transportType;
diff --git a/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/service/AdminGrpcServer.java b/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/service/AdminGrpcServer.java
index 9876f5516a..bc822ad6c3 100644
--- a/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/service/AdminGrpcServer.java
+++ b/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/service/AdminGrpcServer.java
@@ -26,8 +26,7 @@
import org.apache.eventmesh.common.remote.payload.PayloadUtil;
import org.apache.eventmesh.common.remote.request.BaseRemoteRequest;
import org.apache.eventmesh.common.remote.response.BaseRemoteResponse;
-import org.apache.eventmesh.common.remote.response.EmptyAckResponse;
-import org.apache.eventmesh.common.remote.response.FailResponse;
+import org.apache.eventmesh.common.remote.response.SimpleResponse;
import org.apache.commons.lang3.StringUtils;
@@ -48,24 +47,26 @@ public class AdminGrpcServer extends AdminServiceGrpc.AdminServiceImplBase {
private Payload process(Payload value) {
if (value == null || StringUtils.isBlank(value.getMetadata().getType())) {
- return PayloadUtil.from(FailResponse.build(ErrorCode.BAD_REQUEST, "bad request: type not exists"));
+ return PayloadUtil.from(SimpleResponse.fail(ErrorCode.BAD_REQUEST, "bad request: type not exists"));
}
try {
BaseRequestHandler handler = handlerFactory.getHandler(value.getMetadata().getType());
if (handler == null) {
- return PayloadUtil.from(FailResponse.build(BaseRemoteResponse.UNKNOWN, "not match any request handler"));
+ return PayloadUtil.from(SimpleResponse.fail(ErrorCode.BAD_REQUEST, "not match any request handler"));
}
BaseRemoteResponse response = handler.handlerRequest((BaseRemoteRequest) PayloadUtil.parse(value), value.getMetadata());
- if (response == null || response instanceof EmptyAckResponse) {
- return null;
+ if (response == null) {
+ log.warn("received request type [{}] handler [{}], then replay empty response", value.getMetadata().getType(),
+ handler.getClass().getName());
+ response = SimpleResponse.success();
}
return PayloadUtil.from(response);
} catch (Exception e) {
log.warn("process payload {} fail", value.getMetadata().getType(), e);
if (e instanceof AdminServerRuntimeException) {
- return PayloadUtil.from(FailResponse.build(((AdminServerRuntimeException) e).getCode(), e.getMessage()));
+ return PayloadUtil.from(SimpleResponse.fail(((AdminServerRuntimeException) e).getCode(), e.getMessage()));
}
- return PayloadUtil.from(FailResponse.build(ErrorCode.INTERNAL_ERR, "admin server internal err"));
+ return PayloadUtil.from(SimpleResponse.fail(ErrorCode.INTERNAL_ERR, "admin server internal err"));
}
}
diff --git a/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/service/AdminServer.java b/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/service/AdminServer.java
index 94e27ae4d2..fd7582800d 100644
--- a/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/service/AdminServer.java
+++ b/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/service/AdminServer.java
@@ -17,16 +17,14 @@
package org.apache.eventmesh.admin.server.web.service;
-import org.apache.eventmesh.admin.server.web.Admin;
import org.apache.eventmesh.admin.server.AdminServerProperties;
import org.apache.eventmesh.admin.server.AdminServerRuntimeException;
+import org.apache.eventmesh.common.ComponentLifeCycle;
import org.apache.eventmesh.common.Constants;
import org.apache.eventmesh.common.config.CommonConfiguration;
import org.apache.eventmesh.common.config.ConfigService;
import org.apache.eventmesh.common.remote.exception.ErrorCode;
-import org.apache.eventmesh.common.remote.request.ReportHeartBeatRequest;
import org.apache.eventmesh.common.utils.IPUtils;
-import org.apache.eventmesh.common.utils.PagedList;
import org.apache.eventmesh.registry.RegisterServerInfo;
import org.apache.eventmesh.registry.RegistryFactory;
import org.apache.eventmesh.registry.RegistryService;
@@ -43,8 +41,7 @@
@Service
@Slf4j
-public class AdminServer implements Admin, ApplicationListener {
-
+public class AdminServer implements ComponentLifeCycle, ApplicationListener {
private final RegistryService registryService;
private final RegisterServerInfo adminServeInfo;
@@ -69,37 +66,6 @@ public AdminServer(AdminServerProperties properties) {
registryService = RegistryFactory.getInstance(configuration.getEventMeshRegistryPluginType());
}
-
- @Override
- public Task createOrUpdateTask(Task task) {
- if (task.getId() == null) {
-
- } else {
-
- }
- return null;
- }
-
- @Override
- public boolean deleteTask(Long id) {
- return false;
- }
-
- @Override
- public Task getTask(Long id) {
- return null;
- }
-
- @Override
- public PagedList getTaskPaged(Task task) {
- return null;
- }
-
- @Override
- public void reportHeartbeat(ReportHeartBeatRequest heartBeat) {
-
- }
-
@Override
@PostConstruct
public void start() {
diff --git a/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/service/datasource/DataSourceBizService.java b/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/service/datasource/DataSourceBizService.java
new file mode 100644
index 0000000000..433847a4cd
--- /dev/null
+++ b/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/service/datasource/DataSourceBizService.java
@@ -0,0 +1,48 @@
+/*
+ * 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.apache.eventmesh.admin.server.web.service.datasource;
+
+import org.apache.eventmesh.admin.server.AdminServerRuntimeException;
+import org.apache.eventmesh.admin.server.web.db.entity.EventMeshDataSource;
+import org.apache.eventmesh.admin.server.web.db.service.EventMeshDataSourceService;
+import org.apache.eventmesh.common.remote.exception.ErrorCode;
+import org.apache.eventmesh.common.remote.request.CreateOrUpdateDataSourceReq;
+import org.apache.eventmesh.common.utils.JsonUtils;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class DataSourceBizService {
+ @Autowired
+ private EventMeshDataSourceService dataSourceService;
+
+ public EventMeshDataSource createDataSource(CreateOrUpdateDataSourceReq dataSource) {
+ EventMeshDataSource entity = new EventMeshDataSource();
+ entity.setConfiguration(JsonUtils.toJSONString(dataSource.getConfig()));
+ entity.setDataType(dataSource.getType().name());
+ entity.setCreateUid(dataSource.getOperator());
+ entity.setUpdateUid(dataSource.getOperator());
+ entity.setRegion(dataSource.getRegion());
+ entity.setDescription(dataSource.getDesc());
+ if (dataSourceService.save(entity)) {
+ return entity;
+ }
+ throw new AdminServerRuntimeException(ErrorCode.BAD_DB_DATA, "save data source fail");
+ }
+}
diff --git a/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/service/heatbeat/EventMeshRuntimeHeartbeatBizService.java b/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/service/heatbeat/RuntimeHeartbeatBizService.java
similarity index 98%
rename from eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/service/heatbeat/EventMeshRuntimeHeartbeatBizService.java
rename to eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/service/heatbeat/RuntimeHeartbeatBizService.java
index 4fa80b270a..95dff6e5b3 100644
--- a/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/service/heatbeat/EventMeshRuntimeHeartbeatBizService.java
+++ b/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/service/heatbeat/RuntimeHeartbeatBizService.java
@@ -34,7 +34,7 @@
*/
@Service
@Slf4j
-public class EventMeshRuntimeHeartbeatBizService {
+public class RuntimeHeartbeatBizService {
@Autowired
EventMeshRuntimeHistoryService historyService;
diff --git a/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/service/job/EventMeshJobInfoBizService.java b/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/service/job/JobInfoBizService.java
similarity index 55%
rename from eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/service/job/EventMeshJobInfoBizService.java
rename to eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/service/job/JobInfoBizService.java
index 9b7df8dc3f..9225690ab0 100644
--- a/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/service/job/EventMeshJobInfoBizService.java
+++ b/eventmesh-admin-server/src/main/java/org/apache/eventmesh/admin/server/web/service/job/JobInfoBizService.java
@@ -23,28 +23,28 @@
import org.apache.eventmesh.admin.server.web.db.service.EventMeshDataSourceService;
import org.apache.eventmesh.admin.server.web.db.service.EventMeshJobInfoExtService;
import org.apache.eventmesh.admin.server.web.db.service.EventMeshJobInfoService;
-import org.apache.eventmesh.admin.server.web.db.service.EventMeshTaskInfoService;
import org.apache.eventmesh.admin.server.web.pojo.JobDetail;
-import org.apache.eventmesh.admin.server.web.service.position.EventMeshPositionBizService;
-import org.apache.eventmesh.common.remote.job.JobState;
-import org.apache.eventmesh.common.remote.job.JobType;
-import org.apache.eventmesh.common.remote.exception.ErrorCode;
+import org.apache.eventmesh.admin.server.web.service.datasource.DataSourceBizService;
+import org.apache.eventmesh.admin.server.web.service.position.PositionBizService;
+import org.apache.eventmesh.common.remote.TaskState;
+import org.apache.eventmesh.common.remote.TransportType;
+import org.apache.eventmesh.common.remote.datasource.DataSource;
import org.apache.eventmesh.common.remote.datasource.DataSourceType;
-import org.apache.eventmesh.common.remote.task.TransportType;
+import org.apache.eventmesh.common.remote.exception.ErrorCode;
+import org.apache.eventmesh.common.remote.request.CreateOrUpdateDataSourceReq;
import org.apache.eventmesh.common.utils.JsonUtils;
import org.apache.commons.lang3.StringUtils;
import java.util.LinkedList;
import java.util.List;
-import java.util.Map;
+import java.util.UUID;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
-import com.fasterxml.jackson.core.type.TypeReference;
import lombok.extern.slf4j.Slf4j;
@@ -54,47 +54,75 @@
*/
@Service
@Slf4j
-public class EventMeshJobInfoBizService {
+public class JobInfoBizService {
@Autowired
- EventMeshJobInfoService jobInfoService;
+ private EventMeshJobInfoService jobInfoService;
@Autowired
- EventMeshJobInfoExtService jobInfoExtService;
+ private EventMeshJobInfoExtService jobInfoExtService;
@Autowired
- EventMeshTaskInfoService taskInfoService;
+ private DataSourceBizService dataSourceBizService;
@Autowired
- EventMeshDataSourceService dataSourceService;
+ private EventMeshDataSourceService dataSourceService;
@Autowired
- EventMeshPositionBizService positionBizService;
+ private PositionBizService positionBizService;
- public boolean updateJobState(String jobID, JobState state) {
+ public boolean updateJobState(String jobID, TaskState state) {
if (jobID == null || state == null) {
return false;
}
EventMeshJobInfo jobInfo = new EventMeshJobInfo();
jobInfo.setState(state.name());
- jobInfoService.update(jobInfo, Wrappers.update().eq("jobID", jobID).ne("state", JobState.DELETE.name()));
- return true;
+ return jobInfoService.update(jobInfo, Wrappers.update().eq("jobID", jobID).ne("state", TaskState.DELETE.name()));
}
@Transactional
- public List createJobs(String taskID, List type) {
+ public List createJobs(List jobs) {
+ if (jobs == null || jobs.isEmpty() || jobs.stream().anyMatch(job -> StringUtils.isBlank(job.getTaskID()))) {
+ log.warn("when create jobs, task id is empty or jobs config is empty ");
+ return null;
+ }
List entityList = new LinkedList<>();
- for (JobType jobType : type) {
- EventMeshJobInfo job = new EventMeshJobInfo();
- job.setState(JobState.INIT.name());
- job.setTaskID(taskID);
- job.setJobType(jobType.name());
- entityList.add(job);
+ for (JobDetail job : jobs) {
+ CreateOrUpdateDataSourceReq source = new CreateOrUpdateDataSourceReq();
+ source.setType(job.getTransportType().getSrc());
+ source.setOperator(job.getCreateUid());
+ source.setRegion(job.getRegion());
+ source.setDesc(job.getSourceConnectorDesc());
+ source.setConfig(job.getSourceDataSource());
+ EventMeshDataSource createdSource = dataSourceBizService.createDataSource(source);
+
+ CreateOrUpdateDataSourceReq sink = new CreateOrUpdateDataSourceReq();
+ sink.setType(job.getTransportType().getDst());
+ sink.setOperator(job.getCreateUid());
+ sink.setRegion(job.getRegion());
+ sink.setDesc(job.getSinkConnectorDesc());
+ sink.setConfig(job.getSinkDataSource());
+
+ EventMeshDataSource createdSink = dataSourceBizService.createDataSource(source);
+ String jobID = UUID.randomUUID().toString();
+ EventMeshJobInfo entity = new EventMeshJobInfo();
+ entity.setState(TaskState.INIT.name());
+ entity.setTaskID(job.getTaskID());
+ entity.setJobType(job.getJobType().name());
+ entity.setDesc(job.getDesc());
+ entity.setSourceData(createdSource.getId());
+ entity.setTargetData(createdSink.getId());
+ entity.setJobID(jobID);
+ entity.setTransportType(job.getTransportType().name());
+ entity.setCreateUid(job.getCreateUid());
+ entity.setUpdateUid(job.getUpdateUid());
+ entity.setFromRegion(job.getRegion());
+ entityList.add(entity);
}
int changed = jobInfoExtService.batchSave(entityList);
- if (changed != type.size()) {
- throw new AdminServerRuntimeException(ErrorCode.INTERNAL_ERR, String.format("create [%d] jobs of task [%s] not match expect [%d]",
- changed, taskID, type.size()));
+ if (changed != jobs.size()) {
+ throw new AdminServerRuntimeException(ErrorCode.INTERNAL_ERR, String.format("create [%d] jobs of not match expect [%d]",
+ changed, jobs.size()));
}
return entityList;
}
@@ -115,9 +143,7 @@ public JobDetail getJobDetail(String jobID) {
if (source != null) {
if (!StringUtils.isBlank(source.getConfiguration())) {
try {
- detail.setSourceConnectorConfig(JsonUtils.parseTypeReferenceObject(source.getConfiguration(),
- new TypeReference