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