From fcfa32e2f2250f3692420c46a2fa880545618484 Mon Sep 17 00:00:00 2001 From: "lambert@arch" Date: Fri, 26 Jan 2024 17:27:04 +0800 Subject: [PATCH 1/8] fixes #21 ADD: connection related code: Connection/Client/Connector: Mapper,Entity Connection: ConnectionService,ConnectionDataService others: eventmesh-dashboard.sql test resources MODIFY: pom file: remove dependency of junit, spring-boot-starter-test contains it. pom file: let service module depend on core module. --- eventmesh-dashboard-common/pom.xml | 4 - .../console/EventmeshConsoleApplication.java | 5 +- .../console/config/SchedulerConfig.java | 33 +++++ .../console/config/SpringDocConfig.java | 42 ++++++ .../dashboard/console/constant/ApiPrefix.java | 24 ++++ .../connection/ConnectionController.java | 25 ++++ .../console/entity/base/BaseEntity.java | 36 +++++ .../console/entity/client/ClientEntity.java | 55 ++++++++ .../entity/connection/ConnectionEntity.java | 110 +++++++++++++++ .../connection/ConnectionResponseEntity.java | 62 +++++++++ .../entity/connector/ConnectorEntity.java | 45 ++++++ .../console/mapper/client/ClientMapper.java | 49 +++++++ .../mapper/connection/ConnectionMapper.java | 73 ++++++++++ .../mapper/connector/ConnectorMapper.java | 49 +++++++ .../connection/ConnectionDataService.java | 31 +++++ .../service/connection/ConnectionService.java | 50 +++++++ .../ConnectionDataServiceDatabaseImpl.java | 85 ++++++++++++ .../src/main/resources/application-dev.yml | 9 +- .../main/resources/eventmesh-dashboard.sql | 130 ++++++++++++++++++ ...ConnectionDataServiceDatabaseImplTest.java | 65 +++++++++ .../src/test/resources/application-test.yml | 36 +++++ .../src/test/resources/connectiontest.sql | 29 ++++ eventmesh-dashboard-service/pom.xml | 8 ++ pom.xml | 5 + 24 files changed, 1053 insertions(+), 7 deletions(-) create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/config/SchedulerConfig.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/config/SpringDocConfig.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/constant/ApiPrefix.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/connection/ConnectionController.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/base/BaseEntity.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/client/ClientEntity.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/connection/ConnectionEntity.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/connection/ConnectionResponseEntity.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/connector/ConnectorEntity.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/client/ClientMapper.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/connection/ConnectionMapper.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/connector/ConnectorMapper.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/connection/ConnectionDataService.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/connection/ConnectionService.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/connection/impl/ConnectionDataServiceDatabaseImpl.java create mode 100644 eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql create mode 100644 eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/service/connection/impl/ConnectionDataServiceDatabaseImplTest.java create mode 100644 eventmesh-dashboard-console/src/test/resources/application-test.yml create mode 100644 eventmesh-dashboard-console/src/test/resources/connectiontest.sql diff --git a/eventmesh-dashboard-common/pom.xml b/eventmesh-dashboard-common/pom.xml index f79bd00c..52255b0a 100644 --- a/eventmesh-dashboard-common/pom.xml +++ b/eventmesh-dashboard-common/pom.xml @@ -20,10 +20,6 @@ - - junit - junit - org.projectlombok lombok 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/EventmeshConsoleApplication.java index 1e4d6dba..95314dde 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/EventmeshConsoleApplication.java @@ -17,13 +17,16 @@ package org.apache.eventmesh.dashboard.console; -import lombok.extern.slf4j.Slf4j; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.ComponentScan; +import org.springframework.scheduling.annotation.EnableScheduling; + +import lombok.extern.slf4j.Slf4j; @Slf4j @SpringBootApplication +@EnableScheduling @ComponentScan({"org.apache.eventmesh.dashboard.service", "org.apache.eventmesh.dashboard.console"}) public class EventmeshConsoleApplication { diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/config/SchedulerConfig.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/config/SchedulerConfig.java new file mode 100644 index 00000000..aba415a4 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/config/SchedulerConfig.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.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; +import org.springframework.stereotype.Component; + +@Component +public class SchedulerConfig { + + @Bean + public ThreadPoolTaskScheduler taskScheduler() { + ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler(); + taskScheduler.setPoolSize(5); + return taskScheduler; + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/config/SpringDocConfig.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/config/SpringDocConfig.java new file mode 100644 index 00000000..12d33c8b --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/config/SpringDocConfig.java @@ -0,0 +1,42 @@ +/* + * 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.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.info.License; + +@Configuration +public class SpringDocConfig { + + @Bean + public OpenAPI eventmeshDashboardConsoleOpenAPI() { + return new OpenAPI() + .info(new Info() + .title("Eventmesh Dashboard Console API") + .version("v1") + .license(new License() + .name("License: Apache 2.0") + .url("http://www.apache.org/licenses/LICENSE-2.0") + ) + ); + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/constant/ApiPrefix.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/constant/ApiPrefix.java new file mode 100644 index 00000000..e2107cbe --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/constant/ApiPrefix.java @@ -0,0 +1,24 @@ +/* + * 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.constant; + +public class ApiPrefix { + public static final String API_PREFIX = "/eventmesh-dashboard/"; + + public static final String API_V1_PREFIX = API_PREFIX + "v1/"; +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/connection/ConnectionController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/connection/ConnectionController.java new file mode 100644 index 00000000..72d407ed --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/connection/ConnectionController.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.controller.connection; + +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class ConnectionController { + +} 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 new file mode 100644 index 00000000..9bf5a8c0 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/base/BaseEntity.java @@ -0,0 +1,36 @@ +/* + * 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.base; + +import java.io.Serializable; +import java.sql.Timestamp; + +import io.swagger.v3.oas.annotations.media.Schema; + +import lombok.Data; + +@Data +@Schema(name = "BaseEntity", description = "Base entity") +public class BaseEntity implements Serializable { + + private Long clusterPhyId; + + protected Timestamp createTime; + + protected Timestamp updateTime; +} 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 new file mode 100644 index 00000000..019a2234 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/client/ClientEntity.java @@ -0,0 +1,55 @@ +/* + * 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.client; + +import org.apache.eventmesh.dashboard.console.entity.base.BaseEntity; + +import io.swagger.v3.oas.annotations.media.Schema; + +public class ClientEntity extends BaseEntity { + + private static final long serialVersionUID = 1L; + + @Schema(name = "id", description = "primary key") + private Long id; + + private String name; + + private String eventmeshAddress; + + private String platform; + + private String language; + + private Long pid; + + private String host; + + private Integer port; + + private String protocol; + + /** + * 0: not active, 1: active + */ + @Schema(name = "status", defaultValue = "0", allowableValues = {"0", "1"}, description = "0:not active, 1:active") + private Integer status; + + private String description; +} + \ 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 new file mode 100644 index 00000000..f609e359 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/connection/ConnectionEntity.java @@ -0,0 +1,110 @@ +/* + * 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.connection; + +import org.apache.eventmesh.dashboard.console.entity.base.BaseEntity; + +import java.util.Objects; + +import io.swagger.v3.oas.annotations.media.Schema; + +import lombok.Data; + + +/** + * A Connection is a link from a source to a sink. + */ +@Data +public class ConnectionEntity extends BaseEntity { + + private static final long serialVersionUID = 1L; + + @Schema(name = "id", description = "primary key") + private Long id; + + @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". + */ + @Schema(name = "sinkType", defaultValue = "connector", allowableValues = {"connector", "client"}) + private String sinkType; + + @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") + private Integer status; + + @Schema(name = "topic", description = "related topic name from storage") + private String topic; + + private Long groupId; + + private String groupName; + + private String description; + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + 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/connection/ConnectionResponseEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/connection/ConnectionResponseEntity.java new file mode 100644 index 00000000..f8fff4c7 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/connection/ConnectionResponseEntity.java @@ -0,0 +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.dashboard.console.entity.connection; + +import java.io.Serializable; + +import io.swagger.v3.oas.annotations.media.Schema; + + +public class ConnectionResponseEntity implements Serializable { + private static final long serialVersionUID = 1L; + + @Schema(name = "id", description = "primary key") + private Long id; + + @Schema(name = "sourceType", defaultValue = "connector", allowableValues = {"connector", "client"}) + private String sourceType; + + @Schema(name = "sourceId", description = "connectorId or clientId") + private Long sourceId; + + @Schema(name = "sourceStatus", defaultValue = "0", allowableValues = {"0", "1"}, description = "0:not active, 1:active") + private Integer sourceStatus; + + @Schema(name = "sinkType", defaultValue = "connector", allowableValues = {"connector", "client"}) + private String sinkType; + + @Schema(name = "sinkId", description = "connectorId or clientId") + private Long sinkId; + + @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") + private Integer status; + + @Schema(name = "topic", description = "related topic name from storage") + private String topic; + + private Long groupId; + + private String groupName; + + private String 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 new file mode 100644 index 00000000..31b54fa3 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/connector/ConnectorEntity.java @@ -0,0 +1,45 @@ +/* + * 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.connector; + +import org.apache.eventmesh.dashboard.console.entity.base.BaseEntity; + +import io.swagger.v3.oas.annotations.media.Schema; + +public class ConnectorEntity extends BaseEntity { + + private static final long serialVersionUID = 1L; + + @Schema(name = "id", description = "primary key") + private Long id; + + private Long connectClusterId; + + private String connectorName; + + private String connectorClassName; + + private String connectorType; + + private String state; + + private String topics; + + private Integer taskCount; + +} 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 new file mode 100644 index 00000000..8d4ea87b --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/client/ClientMapper.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.dashboard.console.mapper.client; + +import org.apache.eventmesh.dashboard.console.entity.client.ClientEntity; + +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 client. + */ +@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); + + @Delete("DELETE FROM client WHERE id = #{id}") + void deleteById(ClientEntity clientEntity); + + @Update("UPDATE client SET status = #{status} WHERE id = #{id}") + void updateStatusById(ClientEntity clientEntity); + + @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})") + void insert(ClientEntity clientEntity); +} 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 new file mode 100644 index 00000000..5ae91273 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/connection/ConnectionMapper.java @@ -0,0 +1,73 @@ +/* + * 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.connection; + +import org.apache.eventmesh.dashboard.console.entity.connection.ConnectionEntity; + +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 java.util.List; + +/** + * Mybatis Mapper for the table of connection. + */ +@Mapper +public interface ConnectionMapper { + + @Select("SELECT * FROM connection WHERE id = #{id}") + ConnectionEntity selectById(ConnectionEntity connectionEntity); + + @Select("SELECT * FROM connection") + List selectAll(); + + @Select("SELECT * FROM connection WHERE cluster_phy_id = #{clusterPhyId}") + List selectByClusterPhyId(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})") + void insert(ConnectionEntity connectionEntity); + + @Insert("") + void batchInsert(List connectionEntityList); + + + @Delete("DELETE FROM connection WHERE cluster_phy_id = #{clusterPhyId}") + void deleteAllByClusterPhyId(ConnectionEntity connectionEntity); + + @Delete("DELETE FROM connection WHERE id = #{id}") + void deleteById(ConnectionEntity connectionEntity); + + @Delete("") + void batchDelete(List connectionEntityList); + +} 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 new file mode 100644 index 00000000..235e84d3 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/connector/ConnectorMapper.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.dashboard.console.mapper.connector; + +import org.apache.eventmesh.dashboard.console.entity.connector.ConnectorEntity; + +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 connector. + */ +@Mapper +public interface ConnectorMapper { + @Select("SELECT * FROM connector WHERE id = #{id}") + ConnectorEntity selecyById(Long id); + + @Select("SELECT * FROM connector WHERE connect_cluster_id = #{connectClusterId}") + ConnectorEntity selectByConnectClusterId(Long connectClusterId); + + @Delete("DELETE FROM connector WHERE id = #{id}") + void deleteById(Long id); + + @Update("UPDATE connector SET state = #{state} WHERE id = #{id}") + void updateStateById(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); +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/connection/ConnectionDataService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/connection/ConnectionDataService.java new file mode 100644 index 00000000..05361eb2 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/connection/ConnectionDataService.java @@ -0,0 +1,31 @@ +/* + * 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.connection; + +import org.apache.eventmesh.dashboard.console.entity.connection.ConnectionEntity; + +import java.util.List; + +/** + * Service providing data of connections. + */ +public interface ConnectionDataService { + List getAllConnections(); + + void replaceAllConnections(List connectionEntityList); +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/connection/ConnectionService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/connection/ConnectionService.java new file mode 100644 index 00000000..3faedd68 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/connection/ConnectionService.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.service.connection; + +import org.apache.eventmesh.dashboard.console.entity.connection.ConnectionEntity; +import org.apache.eventmesh.dashboard.console.service.connection.impl.ConnectionDataServiceDatabaseImpl; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import lombok.extern.slf4j.Slf4j; + +@Slf4j +@Service +public class ConnectionService { + @Autowired + ConnectionDataService metaConnectionService; + + @Autowired + ConnectionDataServiceDatabaseImpl databaseConnectionService; + + public void syncConnection() { + try { + List connectionEntityList = metaConnectionService.getAllConnections(); + databaseConnectionService.replaceAllConnections(connectionEntityList); + } catch (Exception e) { + log.error("sync connection info from {} to {} failed for reason:{}.", + metaConnectionService.getClass().getSimpleName(), + databaseConnectionService.getClass().getSimpleName(), + e.getMessage()); + } + } +} 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 new file mode 100644 index 00000000..a89e1e15 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/connection/impl/ConnectionDataServiceDatabaseImpl.java @@ -0,0 +1,85 @@ +/* + * 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.connection.impl; + +import org.apache.eventmesh.dashboard.console.entity.connection.ConnectionEntity; +import org.apache.eventmesh.dashboard.console.mapper.connection.ConnectionMapper; +import org.apache.eventmesh.dashboard.console.service.connection.ConnectionDataService; + +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + + +@Service +public class ConnectionDataServiceDatabaseImpl implements ConnectionDataService { + + @Autowired + private ConnectionMapper connectionMapper; + + public List getAllConnectionsByClusterId(Long clusterId) { + ConnectionEntity connectionEntity = new ConnectionEntity(); + connectionEntity.setClusterPhyId(clusterId); + return connectionMapper.selectByClusterPhyId(connectionEntity); + } + + + @Override + public List getAllConnections() { + return connectionMapper.selectAll(); + } + + + @Override + @Transactional + public void replaceAllConnections(List connectionEntityList) { + Map> connectionsGroupedByClusterPhyId = connectionEntityList.stream() + .collect(Collectors.groupingBy(ConnectionEntity::getClusterPhyId)); + + connectionsGroupedByClusterPhyId.forEach((clusterPhyId, newConnections) -> { + ConnectionEntity connectionEntity = new ConnectionEntity(); + connectionEntity.setClusterPhyId(clusterPhyId); + List existingConnections = connectionMapper.selectByClusterPhyId(connectionEntity); + + // Collect connections that are not in the new list + List connectionsToDelete = existingConnections.stream() + .filter(existingConnection -> !newConnections.contains(existingConnection)) + .collect(Collectors.toList()); + + // Collect new connections that are not in the existing list + List connectionsToInsert = newConnections.stream() + .filter(connection -> !existingConnections.contains(connection)) + .collect(Collectors.toList()); + + // Delete connections in batch + if (!connectionsToDelete.isEmpty()) { + connectionMapper.batchDelete(connectionsToDelete); + } + + // Insert new connections in batch + if (!connectionsToInsert.isEmpty()) { + connectionMapper.batchInsert(connectionsToInsert); + } + }); + } +} + diff --git a/eventmesh-dashboard-console/src/main/resources/application-dev.yml b/eventmesh-dashboard-console/src/main/resources/application-dev.yml index bfe02806..8fcd1ca4 100644 --- a/eventmesh-dashboard-console/src/main/resources/application-dev.yml +++ b/eventmesh-dashboard-console/src/main/resources/application-dev.yml @@ -17,8 +17,6 @@ server: port: 9898 - servlet: - context-path: "/eventmesh" spring: servlet: @@ -46,6 +44,13 @@ 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 + health: "0/15 * * * * ? *" diff --git a/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql b/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql new file mode 100644 index 00000000..a68ce457 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql @@ -0,0 +1,130 @@ +/* + * 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. + */ + +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 '修改时间', + + PRIMARY KEY (`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 '修改时间', + PRIMARY KEY (`id`), + UNIQUE KEY `uniq_connect_cluster_id_connector_name` (`connect_cluster_id`, `connector_name`) +) 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', + `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_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 '修改时间', + + PRIMARY KEY (`id`), + INDEX `idx_group_id` (`group_id`), + INDEX `idx_topic` (`topic`), + INDEX `idx_source_id` (`source_id`), + INDEX `idx_sink_id` (`sink_id`) +) ENGINE = InnoDB + DEFAULT CHARSET = utf8 COMMENT ='client和connector连接关系,这里的client包括runtime'; + +DROP TABLE IF EXISTS `health_check_result`; +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', + `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`) +) ENGINE = InnoDB + DEFAULT CHARSET = utf8 COMMENT ='健康检查结果'; + +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', + `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', + `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', + `username` varchar(192) NOT NULL DEFAULT '' COMMENT '注册中心用户名', + `params` varchar(192) NOT NULL DEFAULT '' COMMENT '注册中心启动参数', + `status` tinyint(4) unsigned NOT NULL DEFAULT '0' COMMENT '状态: 1启用,0未启用', + + `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`) + +) 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 new file mode 100644 index 00000000..2559021e --- /dev/null +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/service/connection/impl/ConnectionDataServiceDatabaseImplTest.java @@ -0,0 +1,65 @@ +/* + * 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.connection.impl; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.apache.eventmesh.dashboard.console.entity.connection.ConnectionEntity; + +import java.util.List; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.jdbc.Sql; +import org.springframework.test.context.junit.jupiter.SpringExtension; + + + +@ExtendWith(SpringExtension.class) +@ActiveProfiles("test") +@Sql(executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, scripts = "classpath:connectiontest.sql") +@SpringBootTest +public class ConnectionDataServiceDatabaseImplTest { + + @Autowired + private ConnectionDataServiceDatabaseImpl connectionServiceDatabaseImpl; + + @Test + public void testGetAllConnectionsByClusterId() { + List connectionEntityList = connectionServiceDatabaseImpl.getAllConnectionsByClusterId(1L); + assertEquals(3, connectionEntityList.size()); + } + + @Test + public void testGetAllConnections() { + List connectionEntityList = connectionServiceDatabaseImpl.getAllConnections(); + assertEquals(6, connectionEntityList.size()); + } + + @Test + public void testReplaceAllConnections() { + List connectionEntityList = connectionServiceDatabaseImpl.getAllConnectionsByClusterId(1L); + //change ClusterId into 2 + connectionEntityList.forEach(connectionEntity -> connectionEntity.setClusterPhyId(2L)); + connectionServiceDatabaseImpl.replaceAllConnections(connectionEntityList); + assertEquals(7, connectionServiceDatabaseImpl.getAllConnections().size()); + } +} \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/test/resources/application-test.yml b/eventmesh-dashboard-console/src/test/resources/application-test.yml new file mode 100644 index 00000000..1a903d3f --- /dev/null +++ b/eventmesh-dashboard-console/src/test/resources/application-test.yml @@ -0,0 +1,36 @@ +# +# 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. +# + +spring: + datasource: + name: eventmesh-console + type: com.alibaba.druid.pool.DruidDataSource + druid: + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://localhost:3306/eventmesh-dashboard-test?useSSL=false&useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&zeroDateTimeBehavior=convertToNull&allowPublicKeyRetrieval=true + username: root + password: root + + initial-size: 1 + max-active: 50 + min-idle: 5 + max-wait: 6000 + validation-query: select 'x' + validation-query-timeout: 15 + test-on-borrow: false + test-while-idle: true + min-evictable-idle-time-millis: 300000 \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/test/resources/connectiontest.sql b/eventmesh-dashboard-console/src/test/resources/connectiontest.sql new file mode 100644 index 00000000..c06a79ec --- /dev/null +++ b/eventmesh-dashboard-console/src/test/resources/connectiontest.sql @@ -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. + */ + +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'); + + diff --git a/eventmesh-dashboard-service/pom.xml b/eventmesh-dashboard-service/pom.xml index f445adaf..65abe52a 100644 --- a/eventmesh-dashboard-service/pom.xml +++ b/eventmesh-dashboard-service/pom.xml @@ -18,4 +18,12 @@ UTF-8 + + + org.apache.eventmesh.dashboard.core + eventmesh-dashboard-core + 0.0.1-SNAPSHOT + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index ed8fd4fb..ec6bbdd1 100644 --- a/pom.xml +++ b/pom.xml @@ -103,6 +103,11 @@ mybatis-spring-boot-starter ${mybatis-spring-boot.version} + + org.mybatis.spring.boot + mybatis-spring-boot-starter-test + ${mybatis-spring-boot.version} + \ No newline at end of file From 828b8f94f2af1310aafc0f1584bb1ade03e16379 Mon Sep 17 00:00:00 2001 From: Pil0tXia Date: Fri, 26 Jan 2024 20:28:34 +0800 Subject: [PATCH 2/8] [ISSUE #23] Integrate Checkstyle into Build and CI process (#24) * integrate checkstyle * fix import order & remove excessive try-catch --- .asf.yaml | 4 +-- .github/workflows/{build.yaml => docker.yml} | 0 README.md | 2 +- .../eventmesh/dashboard/common/Main.java | 18 ++++++++++++- .../console/EventmeshConsoleApplication.java | 11 +++----- .../dashboard/core/service/Main.java | 7 ----- .../eventmesh/dashboard/observe/Main.java | 18 ++++++++++++- .../eventmesh/dashboard/service/Main.java | 18 ++++++++++++- pom.xml | 27 +++++++++++++++++++ style/checkStyle.xml | 2 +- 10 files changed, 86 insertions(+), 21 deletions(-) rename .github/workflows/{build.yaml => docker.yml} (100%) delete mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/service/Main.java diff --git a/.asf.yaml b/.asf.yaml index 9ff78571..898b57a2 100644 --- a/.asf.yaml +++ b/.asf.yaml @@ -45,9 +45,9 @@ github: dismiss_stale_reviews: true required_approving_review_count: 1 notifications: - commits: commits@eventmesh.apache.org + commits: commits@eventmesh.apache.org # Send all issue emails (new, closed, comments) to issues@ - issues: issues@eventmesh.apache.org + issues: issues@eventmesh.apache.org # Send new/closed PR notifications to dev@ pullrequests_status: dev@eventmesh.apache.org # Send individual PR comments/reviews to issues@ diff --git a/.github/workflows/build.yaml b/.github/workflows/docker.yml similarity index 100% rename from .github/workflows/build.yaml rename to .github/workflows/docker.yml diff --git a/README.md b/README.md index 5ddd5f57..bf6fbb59 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ 1. eventmesh-dashboard-console 业务模块的代码,调用service接口 2. eventmesh-dashboard-observe 监控模块的代码 -3. eventmesh-dashboard-core 对eventmesh以及相关组件的代码,提供service实现 +3. eventmesh-dashboard-core 对EventMesh Runtime, Meta以及相关组件的代码,提供service实现 4. eventmesh-dashboard-service 公用API接口,对core的抽象 5. eventmesh-dashboard-common 公共模块的代码 6. eventmesh-dashboard-view 前端代码 diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/Main.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/Main.java index a8b0ff7c..673282d6 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/Main.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/Main.java @@ -1,7 +1,23 @@ +/* + * 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.common; public class Main { public static void main(String[] args) { - System.out.println("Hello world!"); } } \ No newline at end of file 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/EventmeshConsoleApplication.java index 1e4d6dba..a048f24c 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/EventmeshConsoleApplication.java @@ -17,22 +17,19 @@ package org.apache.eventmesh.dashboard.console; -import lombok.extern.slf4j.Slf4j; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.ComponentScan; +import lombok.extern.slf4j.Slf4j; + @Slf4j @SpringBootApplication @ComponentScan({"org.apache.eventmesh.dashboard.service", "org.apache.eventmesh.dashboard.console"}) public class EventmeshConsoleApplication { public static void main(String[] args) { - try { - SpringApplication.run(EventmeshConsoleApplication.class, args); - log.info("{} Successfully booted.", EventmeshConsoleApplication.class.getSimpleName()); - } catch (Exception e) { - log.error(e.getMessage(), e); - } + SpringApplication.run(EventmeshConsoleApplication.class, args); + log.info("{} Successfully booted.", EventmeshConsoleApplication.class.getSimpleName()); } } diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/service/Main.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/service/Main.java deleted file mode 100644 index f538cd86..00000000 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/service/Main.java +++ /dev/null @@ -1,7 +0,0 @@ -package org.apache.eventmesh.dashboard.core.service; - -public class Main { - public static void main(String[] args) { - System.out.println("Hello world!"); - } -} \ No newline at end of file diff --git a/eventmesh-dashboard-observe/src/main/java/org/apache/eventmesh/dashboard/observe/Main.java b/eventmesh-dashboard-observe/src/main/java/org/apache/eventmesh/dashboard/observe/Main.java index 1a8fac32..dc40fa22 100644 --- a/eventmesh-dashboard-observe/src/main/java/org/apache/eventmesh/dashboard/observe/Main.java +++ b/eventmesh-dashboard-observe/src/main/java/org/apache/eventmesh/dashboard/observe/Main.java @@ -1,7 +1,23 @@ +/* + * 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.observe; public class Main { public static void main(String[] args) { - System.out.println("Hello world!"); } } \ No newline at end of file diff --git a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/Main.java b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/Main.java index 0927abf9..926f48c5 100644 --- a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/Main.java +++ b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/Main.java @@ -1,7 +1,23 @@ +/* + * 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.service; public class Main { public static void main(String[] args) { - System.out.println("Hello world!"); } } \ No newline at end of file diff --git a/pom.xml b/pom.xml index ed8fd4fb..e8ac69c5 100644 --- a/pom.xml +++ b/pom.xml @@ -89,6 +89,7 @@ eventmesh-dashboard-service eventmesh-dashboard-common + @@ -105,4 +106,30 @@ + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + 3.3.1 + + style/checkStyle.xml + true + true + false + config_loc=style + + + + validate + validate + + check + + + + + + \ No newline at end of file diff --git a/style/checkStyle.xml b/style/checkStyle.xml index cfa19728..897dbfa2 100644 --- a/style/checkStyle.xml +++ b/style/checkStyle.xml @@ -23,7 +23,7 @@ - + From 050cfd797d7828b0cf3763d885182ea185b1ee0e Mon Sep 17 00:00:00 2001 From: Pil0tXia Date: Fri, 26 Jan 2024 20:28:34 +0800 Subject: [PATCH 3/8] [ISSUE #23] Integrate Checkstyle into Build and CI process (#24) * integrate checkstyle * fix import order & remove excessive try-catch --- .asf.yaml | 4 +-- .github/workflows/{build.yaml => docker.yml} | 0 README.md | 2 +- .../eventmesh/dashboard/common/Main.java | 18 ++++++++++++- .../console/EventmeshConsoleApplication.java | 10 +++---- .../dashboard/core/service/Main.java | 7 ----- .../eventmesh/dashboard/observe/Main.java | 18 ++++++++++++- .../eventmesh/dashboard/service/Main.java | 18 ++++++++++++- pom.xml | 27 +++++++++++++++++++ style/checkStyle.xml | 2 +- 10 files changed, 86 insertions(+), 20 deletions(-) rename .github/workflows/{build.yaml => docker.yml} (100%) delete mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/service/Main.java diff --git a/.asf.yaml b/.asf.yaml index 9ff78571..898b57a2 100644 --- a/.asf.yaml +++ b/.asf.yaml @@ -45,9 +45,9 @@ github: dismiss_stale_reviews: true required_approving_review_count: 1 notifications: - commits: commits@eventmesh.apache.org + commits: commits@eventmesh.apache.org # Send all issue emails (new, closed, comments) to issues@ - issues: issues@eventmesh.apache.org + issues: issues@eventmesh.apache.org # Send new/closed PR notifications to dev@ pullrequests_status: dev@eventmesh.apache.org # Send individual PR comments/reviews to issues@ diff --git a/.github/workflows/build.yaml b/.github/workflows/docker.yml similarity index 100% rename from .github/workflows/build.yaml rename to .github/workflows/docker.yml diff --git a/README.md b/README.md index 5ddd5f57..bf6fbb59 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ 1. eventmesh-dashboard-console 业务模块的代码,调用service接口 2. eventmesh-dashboard-observe 监控模块的代码 -3. eventmesh-dashboard-core 对eventmesh以及相关组件的代码,提供service实现 +3. eventmesh-dashboard-core 对EventMesh Runtime, Meta以及相关组件的代码,提供service实现 4. eventmesh-dashboard-service 公用API接口,对core的抽象 5. eventmesh-dashboard-common 公共模块的代码 6. eventmesh-dashboard-view 前端代码 diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/Main.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/Main.java index a8b0ff7c..673282d6 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/Main.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/Main.java @@ -1,7 +1,23 @@ +/* + * 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.common; public class Main { public static void main(String[] args) { - System.out.println("Hello world!"); } } \ No newline at end of file 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/EventmeshConsoleApplication.java index 95314dde..b82db61b 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/EventmeshConsoleApplication.java @@ -24,6 +24,8 @@ import lombok.extern.slf4j.Slf4j; +import lombok.extern.slf4j.Slf4j; + @Slf4j @SpringBootApplication @EnableScheduling @@ -31,11 +33,7 @@ public class EventmeshConsoleApplication { public static void main(String[] args) { - try { - SpringApplication.run(EventmeshConsoleApplication.class, args); - log.info("{} Successfully booted.", EventmeshConsoleApplication.class.getSimpleName()); - } catch (Exception e) { - log.error(e.getMessage(), e); - } + SpringApplication.run(EventmeshConsoleApplication.class, args); + log.info("{} Successfully booted.", EventmeshConsoleApplication.class.getSimpleName()); } } diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/service/Main.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/service/Main.java deleted file mode 100644 index f538cd86..00000000 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/service/Main.java +++ /dev/null @@ -1,7 +0,0 @@ -package org.apache.eventmesh.dashboard.core.service; - -public class Main { - public static void main(String[] args) { - System.out.println("Hello world!"); - } -} \ No newline at end of file diff --git a/eventmesh-dashboard-observe/src/main/java/org/apache/eventmesh/dashboard/observe/Main.java b/eventmesh-dashboard-observe/src/main/java/org/apache/eventmesh/dashboard/observe/Main.java index 1a8fac32..dc40fa22 100644 --- a/eventmesh-dashboard-observe/src/main/java/org/apache/eventmesh/dashboard/observe/Main.java +++ b/eventmesh-dashboard-observe/src/main/java/org/apache/eventmesh/dashboard/observe/Main.java @@ -1,7 +1,23 @@ +/* + * 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.observe; public class Main { public static void main(String[] args) { - System.out.println("Hello world!"); } } \ No newline at end of file diff --git a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/Main.java b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/Main.java index 0927abf9..926f48c5 100644 --- a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/Main.java +++ b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/Main.java @@ -1,7 +1,23 @@ +/* + * 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.service; public class Main { public static void main(String[] args) { - System.out.println("Hello world!"); } } \ No newline at end of file diff --git a/pom.xml b/pom.xml index ec6bbdd1..59cb1874 100644 --- a/pom.xml +++ b/pom.xml @@ -89,6 +89,7 @@ eventmesh-dashboard-service eventmesh-dashboard-common + @@ -110,4 +111,30 @@ + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + 3.3.1 + + style/checkStyle.xml + true + true + false + config_loc=style + + + + validate + validate + + check + + + + + + \ No newline at end of file diff --git a/style/checkStyle.xml b/style/checkStyle.xml index cfa19728..897dbfa2 100644 --- a/style/checkStyle.xml +++ b/style/checkStyle.xml @@ -23,7 +23,7 @@ - + From 58f9ea7c1f504b16b5d2c307ca57eed1aed61448 Mon Sep 17 00:00:00 2001 From: "lambert@arch" Date: Sat, 27 Jan 2024 20:18:18 +0800 Subject: [PATCH 4/8] 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 From 378b7862e87c56c004c5d8dee8f26dcd08c16234 Mon Sep 17 00:00:00 2001 From: "lambert@arch" Date: Mon, 29 Jan 2024 14:49:27 +0800 Subject: [PATCH 5/8] fix checkstyle for ConnectorMapper --- .../dashboard/console/mapper/connector/ConnectorMapper.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 995be20b..07913275 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,8 +19,6 @@ 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; @@ -28,6 +26,8 @@ import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Update; +import java.util.List; + /** * Mybatis Mapper for the table of connector. */ From 6837150777f8a89bd29b00525e002028961720ec Mon Sep 17 00:00:00 2001 From: "lambert@arch" Date: Mon, 29 Jan 2024 17:11:48 +0800 Subject: [PATCH 6/8] fix: add StatusEnum add enum support for entity class. --- .../console/dto/ConnectionResponse.java | 8 +-- .../console/entity/client/ClientEntity.java | 37 +++++++++++ .../entity/connection/ConnectionEntity.java | 17 +++++ .../entity/connector/ConnectorEntity.java | 35 ++++++++-- .../health/HealthCheckResultEntity.java | 47 -------------- .../console/entity/meta/MetaEntity.java | 14 ++++ .../enums/KubernetesPodStatusEnum.java | 36 ++++++++++ ...bernetesPodStatus.java => StatusEnum.java} | 18 ++--- .../health/HealthCheckScheduler.java} | 17 ++--- .../main/resources/eventmesh-dashboard.sql | 8 +-- ...ConnectionDataServiceDatabaseImplTest.java | 65 ------------------- 11 files changed, 159 insertions(+), 143 deletions(-) delete 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/enums/KubernetesPodStatusEnum.java rename eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/enums/{KubernetesPodStatus.java => StatusEnum.java} (78%) rename eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/{enums/health/HealthCheckDimensionEnum.java => scheduler/health/HealthCheckScheduler.java} (72%) delete mode 100644 eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/service/connection/impl/ConnectionDataServiceDatabaseImplTest.java diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/dto/ConnectionResponse.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/dto/ConnectionResponse.java index a7d7a53f..d4062a68 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/dto/ConnectionResponse.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/dto/ConnectionResponse.java @@ -38,8 +38,8 @@ public class ConnectionResponse 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 = "sourceConfigList", description = "source config list") + // private List sourceConfigList; @Schema(name = "sinkType", defaultValue = "connector", allowableValues = {"connector", "client"}) private String sinkType; @@ -50,8 +50,8 @@ public class ConnectionResponse 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; + // @Schema(name = "sinkConfigList", description = "sink config list") + // private List sinkConfigList; private Long runtimeId; 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 6eba6f66..4da4dada 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 @@ -18,14 +18,26 @@ package org.apache.eventmesh.dashboard.console.entity.client; import org.apache.eventmesh.dashboard.console.entity.base.BaseEntity; +import org.apache.eventmesh.dashboard.console.enums.StatusEnum; import java.sql.Timestamp; import io.swagger.v3.oas.annotations.media.Schema; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor public class ClientEntity extends BaseEntity { private static final long serialVersionUID = 8204133370609215856L; + + /** + * Primary key + */ @Schema(name = "id", description = "primary key") private Long id; @@ -33,26 +45,51 @@ public class ClientEntity extends BaseEntity { private String platform; + /** + * programing language of client + */ + @Schema(name = "language", example = "java") private String language; + /** + * process id + */ + @Schema(name = "pid", description = "process id") private Long pid; private String host; private Integer port; + /** + * protocol used to connect to runtime. + */ + @Schema(name = "protocol", example = "http", allowableValues = {"http", "grpc", "tcp"}) private String protocol; /** * 0: not active, 1: active + * @see StatusEnum */ @Schema(name = "status", defaultValue = "0", allowableValues = {"0", "1"}, description = "0:not active, 1:active") private Integer status; + /** + * 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; private String description; + /** + * The time when the client is terminated. + */ private Timestamp endTime; + + public void setStatusEntity(StatusEnum status) { + this.status = status.getNumber(); + } } \ 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 55a4f576..d4d21c51 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 @@ -18,6 +18,7 @@ package org.apache.eventmesh.dashboard.console.entity.connection; import org.apache.eventmesh.dashboard.console.entity.base.BaseEntity; +import org.apache.eventmesh.dashboard.console.enums.StatusEnum; import java.sql.Timestamp; import java.util.Objects; @@ -34,6 +35,10 @@ public class ConnectionEntity extends BaseEntity { private static final long serialVersionUID = 6565578252656944905L; + + /** + * Primary key + */ @Schema(name = "id", description = "primary key") private Long id; @@ -43,6 +48,10 @@ public class ConnectionEntity extends BaseEntity { @Schema(name = "sourceType", defaultValue = "connector", allowableValues = {"connector", "client"}) private String sourceType; + /** + * The id of the source.
+ * It can be connectorId or clientId according to the sourceType. + */ @Schema(name = "sourceId", description = "connectorId or clientId") private Long sourceId; @@ -52,6 +61,10 @@ public class ConnectionEntity extends BaseEntity { @Schema(name = "sinkType", defaultValue = "connector", allowableValues = {"connector", "client"}) private String sinkType; + /** + * The id of the sink.
+ * It can be connectorId or clientId according to the sinkType. + */ @Schema(name = "sinkId", description = "connectorId or clientId") private Long sinkId; @@ -68,6 +81,10 @@ public class ConnectionEntity extends BaseEntity { private String description; + public void setStatusEnum(StatusEnum statusEnum) { + this.status = statusEnum.getNumber(); + } + @Override public boolean equals(Object o) { if (this == o) { 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 26750194..79754d92 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 @@ -18,9 +18,18 @@ package org.apache.eventmesh.dashboard.console.entity.connector; import org.apache.eventmesh.dashboard.console.entity.base.BaseEntity; +import org.apache.eventmesh.dashboard.console.enums.KubernetesPodStatusEnum; +import org.apache.eventmesh.dashboard.console.enums.StatusEnum; import io.swagger.v3.oas.annotations.media.Schema; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor public class ConnectorEntity extends BaseEntity { private static final long serialVersionUID = -8226303660232951326L; @@ -34,14 +43,32 @@ public class ConnectorEntity extends BaseEntity { private String type; - private String status; + /** + * 0: not active, 1: active + * + * @see StatusEnum + */ + @Schema(name = "status", defaultValue = "0", allowableValues = {"0", "1"}, description = "0:inactive, 1:active") + private Integer status; + /** + * @see KubernetesPodStatusEnum + */ + @Schema(name = "podState", defaultValue = "0", allowableValues = {"0", "1", "2", "3", "4", "5", + "6"}, description = "0:Pending, 1:Running, 2:Succeeded, 3:Failed, 4:Unknown, 5:Terminating, 6:Terminated") 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. + * 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; + + public void setStatusEnum(StatusEnum statusEnum) { + this.status = statusEnum.getNumber(); + } + + public void setKubernetesPodStatusEnum(KubernetesPodStatusEnum kubernetesPodStatusEnum) { + this.podState = kubernetesPodStatusEnum.getNumber(); + } } 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 deleted file mode 100644 index 1b1aa9e6..00000000 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/health/HealthCheckResultEntity.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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 index 016acc1a..2c32e284 100644 --- 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 @@ -18,12 +18,17 @@ package org.apache.eventmesh.dashboard.console.entity.meta; import org.apache.eventmesh.dashboard.console.entity.base.BaseEntity; +import org.apache.eventmesh.dashboard.console.enums.StatusEnum; import io.swagger.v3.oas.annotations.media.Schema; +import lombok.AllArgsConstructor; import lombok.Data; +import lombok.NoArgsConstructor; @Data +@NoArgsConstructor +@AllArgsConstructor public class MetaEntity extends BaseEntity { private static final long serialVersionUID = 7176263169716424469L; @@ -52,5 +57,14 @@ public class MetaEntity extends BaseEntity { private String params; + /** + * 0: not active, 1: active + * @see StatusEnum + */ + @Schema(name = "status", defaultValue = "0", allowableValues = {"0", "1"}, description = "0:inactive, 1:active") private Integer status; + + public void setStatusEnum(StatusEnum statusEnum) { + this.status = statusEnum.getNumber(); + } } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/enums/KubernetesPodStatusEnum.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/enums/KubernetesPodStatusEnum.java new file mode 100644 index 00000000..497fd3c1 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/enums/KubernetesPodStatusEnum.java @@ -0,0 +1,36 @@ +/* + * 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; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum KubernetesPodStatusEnum { + PENDING(0, "Pending"), + RUNNING(1, "Running"), + SUCCEEDED(2, "Succeeded"), + FAILED(3, "Failed"), + UNKNOWN(4, "Unknown"), + TERMINATING(5, "Terminating"), + TERMINATED(6, "Terminated"); + + private final Integer number; + private final String name; +} 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/StatusEnum.java similarity index 78% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/enums/KubernetesPodStatus.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/enums/StatusEnum.java index 449e970e..271e3f2a 100644 --- 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/StatusEnum.java @@ -17,13 +17,15 @@ 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"); +import lombok.AllArgsConstructor; +import lombok.Getter; - KubernetesPodStatus(Integer number, String status) { - } +@Getter +@AllArgsConstructor +public enum StatusEnum { + INACTIVE(0, "Inactive"), + ACTIVE(1, "Active"); + + private final Integer number; + private final String name; } 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/scheduler/health/HealthCheckScheduler.java similarity index 72% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/enums/health/HealthCheckDimensionEnum.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/scheduler/health/HealthCheckScheduler.java index d59a13f0..7263f7cd 100644 --- 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/scheduler/health/HealthCheckScheduler.java @@ -15,19 +15,14 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.enums.health; +package org.apache.eventmesh.dashboard.console.scheduler.health; -public enum HealthCheckDimensionEnum { - UNKNOWN(0, "unknown"), +import org.springframework.stereotype.Component; - CLUSTER(1, "cluster"), +import lombok.extern.slf4j.Slf4j; - RUNTIME(2, "runtime"), +@Slf4j +@Component +public class HealthCheckScheduler { - TOPIC(3, "topic"), - - GROUP(4, "group"); - - HealthCheckDimensionEnum(Integer dimensionId, String dimensionName) { - } } diff --git a/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql b/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql index 7704ec0a..8de09e77 100644 --- a/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql +++ b/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql @@ -19,7 +19,7 @@ DROP TABLE IF EXISTS `client`; CREATE TABLE `client` ( `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id', - `cluster_id` bigint(20) NOT NULL DEFAULT '-1' 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 '客户端语言', @@ -45,7 +45,7 @@ DROP TABLE IF EXISTS `connector`; CREATE TABLE `connector` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'id', - `cluster_id` bigint(20) NOT NULL DEFAULT '-1' 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类型', @@ -63,7 +63,7 @@ DROP TABLE IF EXISTS `connection`; CREATE TABLE `connection` ( `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id', - `cluster_id` bigint(20) NOT NULL DEFAULT '-1' 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', `sink_type` varchar(64) NOT NULL DEFAULT '' COMMENT 'sink类型,可以为client或sink connector', @@ -92,7 +92,7 @@ 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_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 '创建时间', 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 deleted file mode 100644 index 4debf74f..00000000 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/service/connection/impl/ConnectionDataServiceDatabaseImplTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * 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.connection.impl; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import org.apache.eventmesh.dashboard.console.entity.connection.ConnectionEntity; - -import java.util.List; - -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.jdbc.Sql; -import org.springframework.test.context.junit.jupiter.SpringExtension; - - - -@ExtendWith(SpringExtension.class) -@ActiveProfiles("test") -@Sql(executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, scripts = "classpath:connectiontest.sql") -@SpringBootTest -public class ConnectionDataServiceDatabaseImplTest { - - @Autowired - private ConnectionDataServiceDatabaseImpl connectionServiceDatabaseImpl; - - @Test - public void testGetAllConnectionsByClusterId() { - List connectionEntityList = connectionServiceDatabaseImpl.getAllConnectionsByClusterId(1L); - assertEquals(3, connectionEntityList.size()); - } - - @Test - public void testGetAllConnections() { - List connectionEntityList = connectionServiceDatabaseImpl.getAllConnections(); - assertEquals(6, connectionEntityList.size()); - } - - @Test - public void testReplaceAllConnections() { - List connectionEntityList = connectionServiceDatabaseImpl.getAllConnectionsByClusterId(1L); - //change ClusterId into 2 - connectionEntityList.forEach(connectionEntity -> connectionEntity.setClusterId(2L)); - connectionServiceDatabaseImpl.replaceAllConnections(connectionEntityList); - assertEquals(7, connectionServiceDatabaseImpl.getAllConnections().size()); - } -} \ No newline at end of file From 47f15cb6c2da0671138340e2222d2db8421e9b07 Mon Sep 17 00:00:00 2001 From: "lambert@arch" Date: Mon, 29 Jan 2024 19:56:54 +0800 Subject: [PATCH 7/8] fix: rename KubernetesPodStatus --- .../dashboard/console/entity/connector/ConnectorEntity.java | 6 +++--- ...ubernetesPodStatusEnum.java => KubernetesPodStatus.java} | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) rename eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/enums/{KubernetesPodStatusEnum.java => KubernetesPodStatus.java} (96%) 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 79754d92..1e7cb07d 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 @@ -18,7 +18,7 @@ package org.apache.eventmesh.dashboard.console.entity.connector; import org.apache.eventmesh.dashboard.console.entity.base.BaseEntity; -import org.apache.eventmesh.dashboard.console.enums.KubernetesPodStatusEnum; +import org.apache.eventmesh.dashboard.console.enums.KubernetesPodStatus; import org.apache.eventmesh.dashboard.console.enums.StatusEnum; import io.swagger.v3.oas.annotations.media.Schema; @@ -52,7 +52,7 @@ public class ConnectorEntity extends BaseEntity { private Integer status; /** - * @see KubernetesPodStatusEnum + * @see KubernetesPodStatus */ @Schema(name = "podState", defaultValue = "0", allowableValues = {"0", "1", "2", "3", "4", "5", "6"}, description = "0:Pending, 1:Running, 2:Succeeded, 3:Failed, 4:Unknown, 5:Terminating, 6:Terminated") @@ -68,7 +68,7 @@ public void setStatusEnum(StatusEnum statusEnum) { this.status = statusEnum.getNumber(); } - public void setKubernetesPodStatusEnum(KubernetesPodStatusEnum kubernetesPodStatusEnum) { + public void setKubernetesPodStatusEnum(KubernetesPodStatus kubernetesPodStatusEnum) { this.podState = kubernetesPodStatusEnum.getNumber(); } } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/enums/KubernetesPodStatusEnum.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/enums/KubernetesPodStatus.java similarity index 96% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/enums/KubernetesPodStatusEnum.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/enums/KubernetesPodStatus.java index 497fd3c1..4650316f 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/enums/KubernetesPodStatusEnum.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/enums/KubernetesPodStatus.java @@ -22,7 +22,7 @@ @Getter @AllArgsConstructor -public enum KubernetesPodStatusEnum { +public enum KubernetesPodStatus { PENDING(0, "Pending"), RUNNING(1, "Running"), SUCCEEDED(2, "Succeeded"), From 56d68e09baa1b56340363af50684af38863b778f Mon Sep 17 00:00:00 2001 From: "lambert@arch" Date: Mon, 29 Jan 2024 21:34:02 +0800 Subject: [PATCH 8/8] fix checkstyle --- .../apache/eventmesh/dashboard/common/Main.java | 0 .../core/EventMeshDashboardApplicationTest.java | 17 +++++++++++++++++ 2 files changed, 17 insertions(+) delete mode 100644 eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/Main.java diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/Main.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/Main.java deleted file mode 100644 index e69de29b..00000000 diff --git a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/EventMeshDashboardApplicationTest.java b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/EventMeshDashboardApplicationTest.java index 0007c1df..cde38a47 100644 --- a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/EventMeshDashboardApplicationTest.java +++ b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/EventMeshDashboardApplicationTest.java @@ -1,3 +1,20 @@ +/* + * 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.core; import org.springframework.boot.test.context.SpringBootTest;