From 58f9ea7c1f504b16b5d2c307ca57eed1aed61448 Mon Sep 17 00:00:00 2001 From: "lambert@arch" Date: Sat, 27 Jan 2024 20:18:18 +0800 Subject: [PATCH] fixes #21 fixed according to PR#22 conversation Database schema definition modified --- ...ava => EventMeshDashboardApplication.java} | 8 +- .../ConnectionResponse.java} | 15 ++- .../console/entity/base/BaseEntity.java | 4 +- .../console/entity/client/ClientEntity.java | 11 +- .../entity/connection/ConnectionEntity.java | 35 ++---- .../entity/connector/ConnectorEntity.java | 22 ++-- .../health/HealthCheckResultEntity.java | 47 ++++++++ .../console/entity/meta/MetaEntity.java | 56 ++++++++++ .../console/enums/KubernetesPodStatus.java | 29 +++++ .../health/HealthCheckDimensionEnum.java | 33 ++++++ .../console/mapper/client/ClientMapper.java | 30 +++-- .../mapper/connection/ConnectionMapper.java | 25 +++-- .../mapper/connector/ConnectorMapper.java | 51 +++++++-- .../console/mapper/meta/MetaMapper.java | 50 +++++++++ .../service/client/ClientDataService.java | 12 +- .../ConnectionDataServiceDatabaseImpl.java | 14 +-- .../connector/ConnectorDataService.java | 25 +++++ .../src/main/resources/application-dev.yml | 4 - .../main/resources/eventmesh-dashboard.sql | 104 +++++++++--------- ...ConnectionDataServiceDatabaseImplTest.java | 2 +- .../src/test/resources/connectiontest.sql | 14 +-- eventmesh-dashboard-service/pom.xml | 8 -- 22 files changed, 437 insertions(+), 162 deletions(-) rename eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/{EventmeshConsoleApplication.java => EventMeshDashboardApplication.java} (84%) rename eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/{entity/connection/ConnectionResponseEntity.java => dto/ConnectionResponse.java} (80%) create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/health/HealthCheckResultEntity.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/meta/MetaEntity.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/enums/KubernetesPodStatus.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/enums/health/HealthCheckDimensionEnum.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/meta/MetaMapper.java rename eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/Main.java => eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/client/ClientDataService.java (84%) create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/connector/ConnectorDataService.java diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/EventmeshConsoleApplication.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/EventMeshDashboardApplication.java similarity index 84% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/EventmeshConsoleApplication.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/EventMeshDashboardApplication.java index b82db61b..79fc03d8 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/EventmeshConsoleApplication.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/EventMeshDashboardApplication.java @@ -24,16 +24,14 @@ import lombok.extern.slf4j.Slf4j; -import lombok.extern.slf4j.Slf4j; - @Slf4j @SpringBootApplication @EnableScheduling @ComponentScan({"org.apache.eventmesh.dashboard.service", "org.apache.eventmesh.dashboard.console"}) -public class EventmeshConsoleApplication { +public class EventMeshDashboardApplication { public static void main(String[] args) { - SpringApplication.run(EventmeshConsoleApplication.class, args); - log.info("{} Successfully booted.", EventmeshConsoleApplication.class.getSimpleName()); + SpringApplication.run(EventMeshDashboardApplication.class, args); + log.info("{} Successfully booted.", EventMeshDashboardApplication.class.getSimpleName()); } } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/connection/ConnectionResponseEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/dto/ConnectionResponse.java similarity index 80% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/connection/ConnectionResponseEntity.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/dto/ConnectionResponse.java index f8fff4c7..a7d7a53f 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/connection/ConnectionResponseEntity.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/dto/ConnectionResponse.java @@ -15,17 +15,18 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.entity.connection; +package org.apache.eventmesh.dashboard.console.dto; import java.io.Serializable; import io.swagger.v3.oas.annotations.media.Schema; -public class ConnectionResponseEntity implements Serializable { - private static final long serialVersionUID = 1L; +public class ConnectionResponse implements Serializable { - @Schema(name = "id", description = "primary key") + private static final long serialVersionUID = -7317308457824435889L; + + @Schema(name = "id", description = "primary key of table connection") private Long id; @Schema(name = "sourceType", defaultValue = "connector", allowableValues = {"connector", "client"}) @@ -37,6 +38,9 @@ public class ConnectionResponseEntity implements Serializable { @Schema(name = "sourceStatus", defaultValue = "0", allowableValues = {"0", "1"}, description = "0:not active, 1:active") private Integer sourceStatus; + @Schema(name = "sourceConfigList", description = "source config list") + private List sourceConfigList; + @Schema(name = "sinkType", defaultValue = "connector", allowableValues = {"connector", "client"}) private String sinkType; @@ -46,6 +50,9 @@ public class ConnectionResponseEntity implements Serializable { @Schema(name = "sinkStatus", defaultValue = "0", allowableValues = {"0", "1"}, description = "0:not active, 1:active") private Integer sinkStatus; + @Schema(name = "sinkConfigList", description = "sink config list") + private List sinkConfigList; + private Long runtimeId; @Schema(name = "status", defaultValue = "0", allowableValues = {"0", "1"}, description = "0:not active, 1:active") diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/base/BaseEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/base/BaseEntity.java index 9bf5a8c0..14192fad 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/base/BaseEntity.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/base/BaseEntity.java @@ -28,7 +28,9 @@ @Schema(name = "BaseEntity", description = "Base entity") public class BaseEntity implements Serializable { - private Long clusterPhyId; + private static final long serialVersionUID = -2697805837923579585L; + + private Long clusterId; protected Timestamp createTime; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/client/ClientEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/client/ClientEntity.java index 019a2234..6eba6f66 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/client/ClientEntity.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/client/ClientEntity.java @@ -19,19 +19,18 @@ import org.apache.eventmesh.dashboard.console.entity.base.BaseEntity; +import java.sql.Timestamp; + import io.swagger.v3.oas.annotations.media.Schema; public class ClientEntity extends BaseEntity { - private static final long serialVersionUID = 1L; - + private static final long serialVersionUID = 8204133370609215856L; @Schema(name = "id", description = "primary key") private Long id; private String name; - private String eventmeshAddress; - private String platform; private String language; @@ -50,6 +49,10 @@ public class ClientEntity extends BaseEntity { @Schema(name = "status", defaultValue = "0", allowableValues = {"0", "1"}, description = "0:not active, 1:active") private Integer status; + private String configIds; + private String description; + + private Timestamp endTime; } \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/connection/ConnectionEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/connection/ConnectionEntity.java index f609e359..55a4f576 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/connection/ConnectionEntity.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/connection/ConnectionEntity.java @@ -19,6 +19,7 @@ import org.apache.eventmesh.dashboard.console.entity.base.BaseEntity; +import java.sql.Timestamp; import java.util.Objects; import io.swagger.v3.oas.annotations.media.Schema; @@ -32,28 +33,21 @@ @Data public class ConnectionEntity extends BaseEntity { - private static final long serialVersionUID = 1L; - + private static final long serialVersionUID = 6565578252656944905L; @Schema(name = "id", description = "primary key") private Long id; + /** + * The type of source. Possible values are "connector" or "client". + */ @Schema(name = "sourceType", defaultValue = "connector", allowableValues = {"connector", "client"}) private String sourceType; - /** - * The type of source. Possible values are "connector" and "client". - */ @Schema(name = "sourceId", description = "connectorId or clientId") private Long sourceId; /** - * 0: not active, 1: active - */ - @Schema(name = "sourceStatus", defaultValue = "0", allowableValues = {"0", "1"}, description = "0:not active, 1:active") - private Integer sourceStatus; - - /** - * The type of sink. Possible values are "connector" and "client". + * The type of sink. Possible values are "connector" or "client". */ @Schema(name = "sinkType", defaultValue = "connector", allowableValues = {"connector", "client"}) private String sinkType; @@ -61,23 +55,16 @@ public class ConnectionEntity extends BaseEntity { @Schema(name = "sinkId", description = "connectorId or clientId") private Long sinkId; - /** - * 0: not active, 1: active - */ - @Schema(name = "sinkStatus", defaultValue = "0", allowableValues = {"0", "1"}, description = "0:not active, 1:active") - private Integer sinkStatus; - private Long runtimeId; - @Schema(name = "status", defaultValue = "0", allowableValues = {"0", "1"}, description = "0:not active, 1:active") + @Schema(name = "status", defaultValue = "0", allowableValues = {"0", "1"}, description = "0:inactive, 1:active") private Integer status; - @Schema(name = "topic", description = "related topic name from storage") private String topic; private Long groupId; - private String groupName; + private Timestamp endTime; private String description; @@ -92,19 +79,13 @@ public boolean equals(Object o) { ConnectionEntity that = (ConnectionEntity) o; return Objects.equals(sourceType, that.sourceType) && Objects.equals(sourceId, that.sourceId) - && Objects.equals(sourceStatus, that.sourceStatus) && Objects.equals(sinkType, that.sinkType) && Objects.equals(sinkId, that.sinkId) - && Objects.equals(sinkStatus, that.sinkStatus) && Objects.equals(runtimeId, that.runtimeId) && Objects.equals(status, that.status) - && Objects.equals(topic, that.topic) - && Objects.equals(groupId, that.groupId) - && Objects.equals(groupName, that.groupName) - && Objects.equals(description, that.description); } } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/connector/ConnectorEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/connector/ConnectorEntity.java index 31b54fa3..26750194 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/connector/ConnectorEntity.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/connector/ConnectorEntity.java @@ -23,23 +23,25 @@ public class ConnectorEntity extends BaseEntity { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = -8226303660232951326L; @Schema(name = "id", description = "primary key") private Long id; - private Long connectClusterId; + private String name; - private String connectorName; + private String className; - private String connectorClassName; + private String type; - private String connectorType; + private String status; - private String state; - - private String topics; - - private Integer taskCount; + private Integer podState; + /** + * csv format config id list.
+ * Example value: 1,2,7
+ * This field is updated when the configuration is modified via the web API, but is not used during the configuration retrieval process. + */ + private String configIds; } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/health/HealthCheckResultEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/health/HealthCheckResultEntity.java new file mode 100644 index 00000000..1b1aa9e6 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/health/HealthCheckResultEntity.java @@ -0,0 +1,47 @@ +/* + * 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.dashboard.console.entity.health; + +import org.apache.eventmesh.dashboard.console.entity.base.BaseEntity; + +import io.swagger.v3.oas.annotations.media.Schema; + +import lombok.Data; + +@Data +@Schema(name = "HealthCheckResultEntity", description = "Health check result entity") +public class HealthCheckResultEntity extends BaseEntity { + + private static final long serialVersionUID = -7350585209577598040L; + @Schema(name = "id", description = "primary key") + private Long id; + + @Schema(description = "Dimension of Health Check;0:Unknown, 1:Cluster, 2:Runtime, 3:Topic, 4:Group", defaultValue = "0", allowableValues = {"0", + "1", "2", "3", "4"}) + private Integer dimension; + + private String configName; + + private String resName; + + private Integer passed; + + public HealthCheckResultEntity() { + } + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/meta/MetaEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/meta/MetaEntity.java new file mode 100644 index 00000000..016acc1a --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/meta/MetaEntity.java @@ -0,0 +1,56 @@ +/* + * 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.dashboard.console.entity.meta; + +import org.apache.eventmesh.dashboard.console.entity.base.BaseEntity; + +import io.swagger.v3.oas.annotations.media.Schema; + +import lombok.Data; + +@Data +public class MetaEntity extends BaseEntity { + + private static final long serialVersionUID = 7176263169716424469L; + + /** + * Primary key + */ + @Schema(name = "id", description = "Primary key") + private Long id; + + private String name; + + private String type; + + private String version; + + private Long clusterId; + + private String host; + + private Integer port; + + private String role; + + private String username; + + private String params; + + private Integer status; +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/enums/KubernetesPodStatus.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/enums/KubernetesPodStatus.java new file mode 100644 index 00000000..449e970e --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/enums/KubernetesPodStatus.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.dashboard.console.enums; + +public enum KubernetesPodStatus { + PENDING(0, "pending"), + RUNNING(1, "running"), + SUCCEEDED(2, "succeeded"), + FAILED(3, "failed"), + UNKNOWN(4, "unknown"); + + KubernetesPodStatus(Integer number, String status) { + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/enums/health/HealthCheckDimensionEnum.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/enums/health/HealthCheckDimensionEnum.java new file mode 100644 index 00000000..d59a13f0 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/enums/health/HealthCheckDimensionEnum.java @@ -0,0 +1,33 @@ +/* + * 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.dashboard.console.enums.health; + +public enum HealthCheckDimensionEnum { + UNKNOWN(0, "unknown"), + + CLUSTER(1, "cluster"), + + RUNTIME(2, "runtime"), + + TOPIC(3, "topic"), + + GROUP(4, "group"); + + HealthCheckDimensionEnum(Integer dimensionId, String dimensionName) { + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/client/ClientMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/client/ClientMapper.java index 8d4ea87b..671bd81b 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/client/ClientMapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/client/ClientMapper.java @@ -31,19 +31,29 @@ */ @Mapper public interface ClientMapper { - @Select("SELECT * FROM client WHERE id = #{id}") - ClientEntity selectById(ClientEntity clientEntity); - @Select("SELECT * FROM client WHERE cluster_phy_id = #{clusterPhyId}") - ClientEntity selectByClusterPhyId(ClientEntity clientEntity); + @Select("SELECT * FROM `client` WHERE `id` = #{id}") + ClientEntity selectById(Long id); - @Delete("DELETE FROM client WHERE id = #{id}") - void deleteById(ClientEntity clientEntity); - - @Update("UPDATE client SET status = #{status} WHERE id = #{id}") - void updateStatusById(ClientEntity clientEntity); + @Select("SELECT * FROM `client` WHERE `cluster_id` = #{clusterId}") + ClientEntity selectByClusterId(Long clusterId); @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") - @Insert("INSERT INTO client (cluster_phy_id, name, eventmesh_address, platform, language, pid, host, port, protocol, status, description) VALUES ( #{clusterPhyId}, #{name}, #{eventmeshAddress}, #{platform}, #{language}, #{pid}, #{host}, #{port}, #{protocol}, #{status}, #{description})") + @Insert( + "INSERT INTO `client` (`cluster_id`, `name`, `platform`," + + " `language`, `pid`, `host`, `port`, `protocol`," + + " `status`, `config_ids`, `description`, `end_time`) " + + "VALUES (#{clusterId}, #{name}, #{platform}," + + " #{language}, #{pid}, #{host}, #{port}, #{protocol}," + + " #{status}, #{configIds}, #{description}, #{endTime})") void insert(ClientEntity clientEntity); + + @Update("UPDATE `client` SET status = #{status}, end_time = NOW() WHERE id = #{id}") + void deActive(ClientEntity clientEntity); + + @Update("UPDATE `client` SET status = #{status} WHERE id = #{id}") + void updateStatus(ClientEntity clientEntity); + + @Delete("DELETE FROM `client` WHERE id = #{id}") + void deleteById(Long id); } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/connection/ConnectionMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/connection/ConnectionMapper.java index 5ae91273..af0a2acb 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/connection/ConnectionMapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/connection/ConnectionMapper.java @@ -24,6 +24,7 @@ import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Options; import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.annotations.Update; import java.util.List; @@ -39,25 +40,35 @@ public interface ConnectionMapper { @Select("SELECT * FROM connection") List selectAll(); - @Select("SELECT * FROM connection WHERE cluster_phy_id = #{clusterPhyId}") - List selectByClusterPhyId(ConnectionEntity connectionEntity); + @Select("SELECT * FROM connection WHERE cluster_id = #{clusterId}") + List selectByClusterId(ConnectionEntity connectionEntity); @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") - @Insert("INSERT INTO connection (cluster_phy_id, source_type, source_id, source_status, sink_type, sink_id, sink_status, runtime_id, status, topic, group_id, group_name, description) VALUES ( #{clusterPhyId}, #{sourceType}, #{sourceId}, #{sourceStatus}, #{sinkType}, #{sinkId}, #{sinkStatus}, #{runtimeId}, #{status}, #{topic}, #{groupId}, #{groupName}, #{description})") + @Insert("INSERT INTO connection (cluster_id, source_type, source_id," + + " sink_type, sink_id, runtime_id, status, topic, group_id, description)" + + " VALUES ( #{clusterId}, #{sourceType}, #{sourceId}, " + + " #{sinkType}, #{sinkId}, #{runtimeId}, #{status}, #{topic}, #{groupId}, #{description})") void insert(ConnectionEntity connectionEntity); + @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") @Insert("") void batchInsert(List connectionEntityList); + @Update("UPDATE connection SET status = #{status}, end_time = NOW() WHERE id = #{id}") + void endConnectionById(ConnectionEntity connectionEntity); - @Delete("DELETE FROM connection WHERE cluster_phy_id = #{clusterPhyId}") - void deleteAllByClusterPhyId(ConnectionEntity connectionEntity); + @Delete("DELETE FROM connection WHERE cluster_id = #{clusterId}") + void deleteAllByClusterId(ConnectionEntity connectionEntity); @Delete("DELETE FROM connection WHERE id = #{id}") void deleteById(ConnectionEntity connectionEntity); diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/connector/ConnectorMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/connector/ConnectorMapper.java index 235e84d3..995be20b 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/connector/ConnectorMapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/connector/ConnectorMapper.java @@ -19,6 +19,8 @@ import org.apache.eventmesh.dashboard.console.entity.connector.ConnectorEntity; +import java.util.List; + import org.apache.ibatis.annotations.Delete; import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Mapper; @@ -31,19 +33,50 @@ */ @Mapper public interface ConnectorMapper { + @Select("SELECT * FROM connector WHERE id = #{id}") - ConnectorEntity selecyById(Long id); + ConnectorEntity selectById(ConnectorEntity connectorEntity); + + @Select("SELECT * FROM connector WHERE cluster_id = #{clusterId}") + ConnectorEntity selectByClusterId(ConnectorEntity connectorEntity); + + @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") + @Insert("INSERT INTO connector (cluster_id, name, class_name, type, status, pod_state, config_ids) " + + "VALUES (#{connectClusterId}, #{name}, #{className}, #{type}, #{status}, #{podState}, #{configIds})") + void insert(ConnectorEntity connectorEntity); - @Select("SELECT * FROM connector WHERE connect_cluster_id = #{connectClusterId}") - ConnectorEntity selectByConnectClusterId(Long connectClusterId); + @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") + @Insert("") + void batchInsert(List connectorEntityList); + + @Update("UPDATE connector SET status = #{status} WHERE id = #{id}") + void updateStatus(ConnectorEntity connectorEntity); + + @Update("UPDATE connector SET pod_state = #{podState} WHERE id = #{id}") + void updatePodState(ConnectorEntity connectorEntity); + + @Update("UPDATE connector SET config_ids = #{configIds} WHERE id = #{id}") + void updateConfigIds(ConnectorEntity connectorEntity); @Delete("DELETE FROM connector WHERE id = #{id}") - void deleteById(Long id); + void deleteById(ConnectorEntity connectorEntity); - @Update("UPDATE connector SET state = #{state} WHERE id = #{id}") - void updateStateById(ConnectorEntity connectorEntity); + @Delete("DELETE FROM connector WHERE cluster_id = #{clusterId}") + void deleteByClusterId(ConnectorEntity connectorEntity); - @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") - @Insert("INSERT INTO connector (connect_cluster_id, connector_name, connector_class_name, connector_type, state, topics, task_count) VALUES (#{connectClusterId}, #{connectorName}, #{connectorClassName}, #{connectorType}, #{state}, #{topics}, #{taskCount})") - void insert(ConnectorEntity connectorEntity); + @Delete("") + void batchDelete(List connectorEntities); } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/meta/MetaMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/meta/MetaMapper.java new file mode 100644 index 00000000..f22bf74a --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/meta/MetaMapper.java @@ -0,0 +1,50 @@ +/* + * 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.dashboard.console.mapper.meta; + +import org.apache.eventmesh.dashboard.console.entity.meta.MetaEntity; + +import org.apache.ibatis.annotations.Delete; +import org.apache.ibatis.annotations.Insert; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Options; +import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.annotations.Update; + +/** + * Mybatis Mapper for the table of meta. + */ +@Mapper +public interface MetaMapper { + @Select("SELECT * FROM meta WHERE id = #{id}") + MetaEntity selectById(MetaEntity metaEntity); + + @Select("SELECT * FROM meta WHERE cluster_id = #{clusterId}") + MetaEntity selectByClusterId(MetaEntity metaEntity); + + @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") + @Insert("INSERT INTO meta (name, type, version, cluster_id, host, port, role, username, params, status)" + + " VALUES ( #{name}, #{type}, #{version}, #{clusterId}, #{host}, #{port}, #{role}, #{username}, #{params}, #{status})") + void insert(MetaEntity metaEntity); + + @Update("UPDATE meta SET status = #{status} WHERE id = #{id}") + void update(MetaEntity metaEntity); + + @Delete("DELETE FROM meta WHERE id = #{id}") + void deleteById(MetaEntity metaEntity); +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/Main.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/client/ClientDataService.java similarity index 84% rename from eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/Main.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/client/ClientDataService.java index 673282d6..4daa5ff1 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/Main.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/client/ClientDataService.java @@ -15,9 +15,11 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.common; +package org.apache.eventmesh.dashboard.console.service.client; -public class Main { - public static void main(String[] args) { - } -} \ No newline at end of file +/** + * Service providing data of clients. + */ +public interface ClientDataService { + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/connection/impl/ConnectionDataServiceDatabaseImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/connection/impl/ConnectionDataServiceDatabaseImpl.java index a89e1e15..780ee990 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/connection/impl/ConnectionDataServiceDatabaseImpl.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/connection/impl/ConnectionDataServiceDatabaseImpl.java @@ -38,8 +38,8 @@ public class ConnectionDataServiceDatabaseImpl implements ConnectionDataService public List getAllConnectionsByClusterId(Long clusterId) { ConnectionEntity connectionEntity = new ConnectionEntity(); - connectionEntity.setClusterPhyId(clusterId); - return connectionMapper.selectByClusterPhyId(connectionEntity); + connectionEntity.setClusterId(clusterId); + return connectionMapper.selectByClusterId(connectionEntity); } @@ -52,13 +52,13 @@ public List getAllConnections() { @Override @Transactional public void replaceAllConnections(List connectionEntityList) { - Map> connectionsGroupedByClusterPhyId = connectionEntityList.stream() - .collect(Collectors.groupingBy(ConnectionEntity::getClusterPhyId)); + Map> connectionsGroupedByClusterId = connectionEntityList.stream() + .collect(Collectors.groupingBy(ConnectionEntity::getClusterId)); - connectionsGroupedByClusterPhyId.forEach((clusterPhyId, newConnections) -> { + connectionsGroupedByClusterId.forEach((clusterId, newConnections) -> { ConnectionEntity connectionEntity = new ConnectionEntity(); - connectionEntity.setClusterPhyId(clusterPhyId); - List existingConnections = connectionMapper.selectByClusterPhyId(connectionEntity); + connectionEntity.setClusterId(clusterId); + List existingConnections = connectionMapper.selectByClusterId(connectionEntity); // Collect connections that are not in the new list List connectionsToDelete = existingConnections.stream() diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/connector/ConnectorDataService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/connector/ConnectorDataService.java new file mode 100644 index 00000000..b0b96427 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/connector/ConnectorDataService.java @@ -0,0 +1,25 @@ +/* + * 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.dashboard.console.service.connector; + +/** + * Service providing data of connectors. + */ +public interface ConnectorDataService { + +} diff --git a/eventmesh-dashboard-console/src/main/resources/application-dev.yml b/eventmesh-dashboard-console/src/main/resources/application-dev.yml index 8fcd1ca4..1c5e8400 100644 --- a/eventmesh-dashboard-console/src/main/resources/application-dev.yml +++ b/eventmesh-dashboard-console/src/main/resources/application-dev.yml @@ -44,10 +44,6 @@ spring: test-while-idle: true min-evictable-idle-time-millis: 300000 -logging: - level: - root: info - # cron job config, use cron expression cron: #health check job diff --git a/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql b/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql index a68ce457..7704ec0a 100644 --- a/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql +++ b/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql @@ -18,68 +18,67 @@ DROP TABLE IF EXISTS `client`; CREATE TABLE `client` ( - `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id', - `cluster_phy_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT '物理集群ID', - `name` varchar(192) NOT NULL DEFAULT '' COMMENT '客户端名称', - `eventmesh_address` varchar(192) NOT NULL DEFAULT '' COMMENT 'eventmesh地址', - `platform` varchar(192) NOT NULL DEFAULT '' COMMENT '客户端平台', - `language` varchar(192) NOT NULL DEFAULT '' COMMENT '客户端语言', - `pid` bigint(22) NOT NULL DEFAULT '-1' COMMENT '客户端进程ID', - `host` varchar(128) NOT NULL DEFAULT '' COMMENT '客户端地址', - `port` int(16) NOT NULL DEFAULT '-1' COMMENT '客户端端口', - `protocol` varchar(192) NOT NULL DEFAULT '' COMMENT '协议类型', - `status` int(16) unsigned NOT NULL DEFAULT '0' COMMENT '状态: 1启用,0未启用', - `description` text NOT NULL DEFAULT '' COMMENT '客户端描述', - `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `end_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '结束时间', - `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id', + `cluster_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT '物理集群ID', + `name` varchar(192) NOT NULL DEFAULT '' COMMENT '客户端名称', + `platform` varchar(192) NOT NULL DEFAULT '' COMMENT '客户端平台', + `language` varchar(192) NOT NULL DEFAULT '' COMMENT '客户端语言', + `pid` bigint(22) NOT NULL DEFAULT '-1' COMMENT '客户端进程ID', + `host` varchar(128) NOT NULL DEFAULT '' COMMENT '客户端地址', + `port` int(16) NOT NULL DEFAULT '-1' COMMENT '客户端端口', + `protocol` varchar(192) NOT NULL DEFAULT '' COMMENT '协议类型', + `status` tinyint(4) unsigned NOT NULL DEFAULT '0' COMMENT '状态: 1启用,0未启用', + `config_ids` text NOT NULL DEFAULT '' COMMENT 'csv config id list, like:1,3,7', + `description` text NOT NULL DEFAULT '' COMMENT '客户端描述', + `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `end_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '结束时间', + `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', - PRIMARY KEY (`id`) + PRIMARY KEY (`id`), + INDEX `idx_cluster_id` (`cluster_id`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8 COMMENT ='客户端信息表'; + + DROP TABLE IF EXISTS `connector`; CREATE TABLE `connector` ( - `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'id', - `cluster_phy_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT '物理集群ID', - `connect_cluster_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT 'Connect集群ID', - `connector_name` varchar(512) NOT NULL DEFAULT '' COMMENT 'Connector名称', - `connector_class_name` varchar(512) NOT NULL DEFAULT '' COMMENT 'Connector类', - `connector_type` varchar(32) NOT NULL DEFAULT '' COMMENT 'Connector类型', - `state` varchar(45) NOT NULL DEFAULT '' COMMENT '状态', - `topics` text COMMENT '访问过的Topics', - `task_count` int(11) NOT NULL DEFAULT '0' COMMENT '任务数', - `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'id', + `cluster_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT '物理集群ID', + `name` varchar(512) NOT NULL DEFAULT '' COMMENT 'Connector名称', + `class_name` varchar(512) NOT NULL DEFAULT '' COMMENT 'Connector类', + `type` varchar(32) NOT NULL DEFAULT '' COMMENT 'Connector类型', + `status` tinyint(4) unsigned NOT NULL DEFAULT '0' COMMENT '状态: 1启用,0未启用', + `pod_state` tinyint(4) unsigned NOT NULL DEFAULT '0' COMMENT 'k8s pod状态。0: pending;1: running;2: success;3: failed;4: unknown', + `config_ids` text NOT NULL DEFAULT '' COMMENT 'csv config id list, like:1,3,7', + `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', PRIMARY KEY (`id`), - UNIQUE KEY `uniq_connect_cluster_id_connector_name` (`connect_cluster_id`, `connector_name`) + INDEX `idx_cluster_id` (`cluster_id`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8 COMMENT ='Connector信息表'; DROP TABLE IF EXISTS `connection`; CREATE TABLE `connection` ( - `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id', - `cluster_phy_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT '物理集群ID', - - `source_type` varchar(64) NOT NULL DEFAULT '' COMMENT 'source类型,可以为client或source connector', + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id', + `cluster_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT '物理集群ID', + `source_type` varchar(64) NOT NULL DEFAULT '' COMMENT 'source类型,可以为client或source connector', `source_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT 'client或source connector ID', - `source_status` int(16) NOT NULL DEFAULT '0' COMMENT 'source状态: 1启用,0未创建', - `sink_type` varchar(64) NOT NULL DEFAULT '' COMMENT 'sink类型,可以为client或sink connector', + `sink_type` varchar(64) NOT NULL DEFAULT '' COMMENT 'sink类型,可以为client或sink connector', `sink_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT 'client或sink connector ID', - `sink_status` int(16) NOT NULL DEFAULT '0' COMMENT 'sink状态: 1启用,0未创建', - `runtime_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT '对应runtime id', - `status` int(16) NOT NULL DEFAULT '0' COMMENT '状态: 1启用,0未启用', - `topic` varchar(192) NOT NULL DEFAULT '' COMMENT 'topic name', - `group_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT 'GroupID', - `group_name` varchar(192) NOT NULL DEFAULT '' COMMENT 'Group名称', - `description` text NOT NULL DEFAULT '' COMMENT '客户端描述', - `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `end_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '结束时间', - `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', + `runtime_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT '对应runtime id', + `status` tinyint(4) unsigned NOT NULL DEFAULT '0' COMMENT '状态: 1启用,0未启用', + `topic` varchar(192) NOT NULL DEFAULT '' COMMENT 'topic name', + `group_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT 'GroupID', + `description` text NOT NULL DEFAULT '' COMMENT '客户端描述', + `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `end_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '结束时间', + `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', PRIMARY KEY (`id`), + INDEX `idx_cluster_id` (`cluster_id`), INDEX `idx_group_id` (`group_id`), INDEX `idx_topic` (`topic`), INDEX `idx_source_id` (`source_id`), @@ -93,13 +92,14 @@ CREATE TABLE `health_check_result` `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增id', `dimension` int(11) NOT NULL DEFAULT '0' COMMENT '检查维度(0:未知,1:Cluster,2:Runtime,3:Topic,4:Group)', `config_name` varchar(192) NOT NULL DEFAULT '' COMMENT '配置名', - `cluster_phy_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '物理集群ID', + `cluster_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '物理集群ID', `res_name` varchar(192) NOT NULL DEFAULT '' COMMENT '资源名称', `passed` tinyint(4) NOT NULL DEFAULT '0' COMMENT '检查通过(0:未通过,1:通过)', `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', PRIMARY KEY (`id`), - UNIQUE KEY `uniq_dimension_config_cluster_res` (`dimension`, `config_name`, `cluster_phy_id`, `res_name`) + INDEX `idx_cluster_id` (`cluster_id`), + UNIQUE KEY `uniq_dimension_config_cluster_res` (`dimension`, `config_name`, `cluster_id`, `res_name`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8 COMMENT ='健康检查结果'; @@ -107,13 +107,10 @@ DROP TABLE IF EXISTS `meta`; CREATE TABLE `meta` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'id', - `name` varchar(192) NOT NULL DEFAULT '' COMMENT '注册中心名称', - `type` varchar(192) NOT NULL DEFAULT '' COMMENT '注册中心类型,nacos,etcd,zookeeper', + `name` varchar(192) NOT NULL DEFAULT '' COMMENT '注册中心名称', + `type` varchar(192) NOT NULL DEFAULT '' COMMENT '注册中心类型,nacos,etcd,zookeeper', `version` varchar(128) NOT NULL DEFAULT '' COMMENT '注册中心版本', - `cluster_phy_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT '物理集群ID', - `connector_cluster_id` bigint(20) NOT NULL COMMENT '连接器集群ID', - `runtime_cluster_id` bigint(20) NOT NULL COMMENT '运行时集群ID', - `storage_cluster_id` bigint(20) NOT NULL COMMENT '存储集群ID', + `cluster_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT '集群ID', `host` varchar(128) NOT NULL DEFAULT '' COMMENT '注册中心地址', `port` int(16) NOT NULL DEFAULT '-1' COMMENT '注册中心端口', `role` varchar(16) NOT NULL DEFAULT '-1' COMMENT '角色, leader follower observer', @@ -124,7 +121,8 @@ CREATE TABLE `meta` `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', - PRIMARY KEY (`id`) + PRIMARY KEY (`id`), + INDEX `idx_cluster_id` (`cluster_id`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8 COMMENT ='注册中心信息表'; \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/service/connection/impl/ConnectionDataServiceDatabaseImplTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/service/connection/impl/ConnectionDataServiceDatabaseImplTest.java index 2559021e..4debf74f 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/service/connection/impl/ConnectionDataServiceDatabaseImplTest.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/service/connection/impl/ConnectionDataServiceDatabaseImplTest.java @@ -58,7 +58,7 @@ public void testGetAllConnections() { public void testReplaceAllConnections() { List connectionEntityList = connectionServiceDatabaseImpl.getAllConnectionsByClusterId(1L); //change ClusterId into 2 - connectionEntityList.forEach(connectionEntity -> connectionEntity.setClusterPhyId(2L)); + connectionEntityList.forEach(connectionEntity -> connectionEntity.setClusterId(2L)); connectionServiceDatabaseImpl.replaceAllConnections(connectionEntityList); assertEquals(7, connectionServiceDatabaseImpl.getAllConnections().size()); } diff --git a/eventmesh-dashboard-console/src/test/resources/connectiontest.sql b/eventmesh-dashboard-console/src/test/resources/connectiontest.sql index c06a79ec..641ea5fa 100644 --- a/eventmesh-dashboard-console/src/test/resources/connectiontest.sql +++ b/eventmesh-dashboard-console/src/test/resources/connectiontest.sql @@ -18,12 +18,12 @@ DELETE FROM `eventmesh-dashboard-test`.connection WHERE TRUE; ALTER TABLE `eventmesh-dashboard-test`.connection AUTO_INCREMENT = 1; -insert into `eventmesh-dashboard-test`.connection (id, cluster_phy_id, source_type, source_id, source_status, sink_type, sink_id, sink_status, runtime_id, status, topic, group_id, group_name, description, create_time, end_time, update_time) -values (1, 1, 'connector', 1, 0, 'connector', 1, 0, 1, 0, 'test-topic', -1, '', '', '2024-01-26 14:51:16', '2024-01-26 14:51:16', '2024-01-26 14:51:16'), - (2, 1, 'connector', 2, 1, 'connector', 2, 0, 2, 0, 'test-topic', -1, '', '', '2024-01-26 14:51:16', '2024-01-26 14:51:16', '2024-01-26 14:51:16'), - (3, 1, 'connector', 3, 0, 'connector', 3, 0, 3, 0, 'test-topic', -1, '', '', '2024-01-26 14:51:16', '2024-01-26 14:51:16', '2024-01-26 14:51:16'), - (4, 2, 'connector', 1, 0, 'connector', 1, 0, 1, 0, 'test-topic', -1, '', '', '2024-01-26 14:51:16', '2024-01-26 14:51:16', '2024-01-26 15:57:44'), - (5, 2, 'client', 5, 0, 'client', 5, 1, 5, 1, 'test-topic', -1, '', '', '2024-01-26 14:51:16', '2024-01-26 14:51:16', '2024-01-26 14:51:16'), - (6, 3, 'client', 6, 1, 'client', 6, 1, 6, 1, 'test-topic', -1, '', '', '2024-01-26 14:51:16', '2024-01-26 14:51:16', '2024-01-26 14:51:16'); +insert into `eventmesh-dashboard-test`.connection (id, cluster_id, source_type, source_id, sink_type, sink_id, runtime_id, status, topic, group_id, description, create_time, end_time, update_time) +values (1, 1, 'connector', 1, 'connector', 1, 1, 0, 'test-topic', -1, '', '2024-01-27 11:55:11', '2024-01-27 11:55:11', '2024-01-27 11:55:11'), + (2, 1, 'connector', 2, 'connector', 2, 2, 0, 'test-topic', -1, '', '2024-01-27 11:55:11', '2024-01-27 11:55:11', '2024-01-27 11:55:11'), + (3, 1, 'connector', 3, 'connector', 3, 3, 0, 'test-topic', -1, '', '2024-01-27 11:55:11', '2024-01-27 11:55:11', '2024-01-27 11:55:11'), + (4, 2, 'connector', 1, 'connector', 1, 1, 0, 'test-topic', -1, '', '2024-01-27 11:55:11', '2024-01-27 11:55:11', '2024-01-27 11:55:11'), + (5, 2, 'client', 5, 'client', 5, 5, 0, 'test-topic', -1, '', '2024-01-27 11:55:11', '2024-01-27 11:55:11', '2024-01-27 11:55:11'), + (6, 3, 'client', 6, 'client', 6, 6, 0, 'test-topic', -1, '', '2024-01-27 11:55:11', '2024-01-27 11:55:11', '2024-01-27 11:55:11'); diff --git a/eventmesh-dashboard-service/pom.xml b/eventmesh-dashboard-service/pom.xml index 65abe52a..f445adaf 100644 --- a/eventmesh-dashboard-service/pom.xml +++ b/eventmesh-dashboard-service/pom.xml @@ -18,12 +18,4 @@ UTF-8 - - - org.apache.eventmesh.dashboard.core - eventmesh-dashboard-core - 0.0.1-SNAPSHOT - - - \ No newline at end of file