From b65a406de39e4d85247fc05a7510e8044fbe9c62 Mon Sep 17 00:00:00 2001 From: zzx <142965157+zzxxiansheng@users.noreply.github.com> Date: Sun, 7 Apr 2024 17:48:40 +0800 Subject: [PATCH] [ISSUE #86] Add view controllers to console (#88) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add view controller * Some fixes to the position of the dynamic properties in the request, changes to the controller, and added comments to the config table * improve somme method name * Sync the modification of #85 * Sync the modification of #85 * Removed the use of delete annotations --------- Co-authored-by: 周倬贤 <14100340+zhou-zhuoxian@user.noreply.gitee.com> --- .../EventMeshDashboardApplication.java | 2 + .../console/controller/ClusterController.java | 46 ++++++ .../console/controller/ConfigController.java | 74 +++++++++ .../controller/ConnectionController.java | 75 ++++++--- .../console/controller/HealthController.java | 47 ++++++ .../console/controller/LogController.java | 43 +++++ .../console/controller/RuntimeController.java | 45 +++++ .../console/controller/TopicController.java | 90 +++++----- .../console/entity/cluster/ClusterEntity.java | 5 +- .../console/entity/config/ConfigEntity.java | 41 +++++ .../entity/config/DefaultConfigKey.java | 33 ++++ .../entity/connector/ConnectorEntity.java | 4 + .../console/entity/runtime/RuntimeEntity.java | 1 + .../console/entity/storage/StoreEntity.java | 2 - .../console/entity/topic/TopicEntity.java | 4 +- .../function/health/CheckResultCache.java | 10 +- .../dashboard/console/log/OprLog.java | 3 +- .../console/mapper/client/ClientMapper.java | 5 +- .../console/mapper/cluster/ClusterMapper.java | 19 ++- .../console/mapper/config/ConfigMapper.java | 37 ++++- .../mapper/connection/ConnectionMapper.java | 21 ++- .../mapper/connector/ConnectorMapper.java | 27 +-- .../console/mapper/group/OprGroupMapper.java | 9 +- .../groupmember/OprGroupMemberMapper.java | 9 +- .../health/HealthCheckResultMapper.java | 3 + .../console/mapper/log/OprLogMapper.java | 30 +++- .../console/mapper/meta/MetaMapper.java | 8 +- .../console/mapper/runtime/RuntimeMapper.java | 25 ++- .../console/mapper/storage/StoreMapper.java | 8 +- .../console/mapper/topic/TopicMapper.java | 32 +++- .../modle/dto/config/ChangeConfigDTO.java | 34 ++++ .../modle/dto/config/DetailConfigsVO.java | 39 +++++ .../modle/dto/config/GetConfigsListDTO.java | 40 +++++ .../modle/dto/config/UpdateConfigDTO.java | 40 +++++ .../modle/dto/config/UpdateConfigsLog.java | 38 +++++ .../dto/connection/AddConnectionDTO.java | 54 ++++++ .../dto/connection/AddConnectorConfigDTO.java | 37 +++++ .../dto/connection/CreateConnectionDTO.java | 34 ++++ .../dto/connection/GetConnectionListDTO.java | 33 ++++ .../console/modle/dto/log/GetLogListDTO.java | 38 +++++ .../modle/dto/runtime/GetRuntimeListDTO.java | 33 ++++ .../modle/dto/topic/CreateTopicDTO.java | 45 +++++ .../modle/dto/topic/GetTopicListDTO.java | 33 ++++ .../vo/cluster/GetClusterBaseMessageVO.java | 37 +++++ .../modle/vo/cluster/ResourceNumVO.java | 34 ++++ .../modle/vo/connection/ConnectionListVO.java | 45 +++++ .../vo/health/InstanceLiveProportionVo.java | 32 ++++ .../modle/vo/topic/TopicDetailGroupVO.java | 38 +++++ .../service/client/ClientDataService.java | 2 + .../client/Impl/ClientDataServiceImpl.java | 8 + .../service/cluster/ClusterService.java | 9 +- .../cluster/impl/ClusterServiceImpl.java | 58 ++++++- .../console/service/config/ConfigService.java | 13 +- .../config/Impl/ConfigServiceImpl.java | 155 +++++++++++++++++- .../synchronous/SyncConnectorConfigTask.java | 3 +- .../synchronous/SyncRuntimeConfigTask.java | 3 +- .../synchronous/SyncStoreConfigTask.java | 42 ++--- .../synchronous/SyncTopicConfigTask.java | 3 +- .../connection/ConnectionDataService.java | 20 ++- .../ConnectionDataServiceDatabaseImpl.java | 149 ++++++++++++++++- .../connector/ConnectorDataService.java | 2 + .../Impl/ConnectorDataServiceImpl.java | 5 + .../service/health/HealthDataService.java | 7 + .../impl/HealthDataServiceDatabaseImpl.java | 69 ++++++++ .../console/service/log/LogService.java | 8 +- .../console/service/log/LogServiceImpl.java | 12 +- .../service/registry/RegistryDataService.java | 37 +++++ .../impl/RegistryDataServiceImpl.java | 53 ++++++ .../runtime/Impl/RuntimeServiceImpl.java | 36 ++++ .../service/runtime/RuntimeService.java | 8 + .../service/store/Impl/StoreServiceImpl.java | 17 +- .../console/service/store/StoreService.java | 6 +- .../console/service/topic/TopicService.java | 13 +- .../service/topic/TopicServiceImpl.java | 104 ++++++++++-- .../main/resources/eventmesh-dashboard.sql | 54 +++--- .../console/linkage/log/TestOprLog.java | 3 +- .../mapper/client/ClientMapperTest.java | 2 +- .../connection/ConnectionMapperTest.java | 6 +- .../mapper/connector/ConnectorMapperTest.java | 10 +- .../unit/cluster/TestClusterMapper.java | 14 +- .../console/unit/config/TestConfigMapper.java | 15 +- .../console/unit/store/TestStoreMapper.java | 30 ++-- .../console/unit/topic/TopicMapperTest.java | 2 +- .../src/test/resources/connection-test.sql | 22 ++- 84 files changed, 2176 insertions(+), 266 deletions(-) create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/ClusterController.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/ConfigController.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/HealthController.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/LogController.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/RuntimeController.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/config/DefaultConfigKey.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/config/ChangeConfigDTO.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/config/DetailConfigsVO.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/config/GetConfigsListDTO.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/config/UpdateConfigDTO.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/config/UpdateConfigsLog.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/connection/AddConnectionDTO.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/connection/AddConnectorConfigDTO.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/connection/CreateConnectionDTO.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/connection/GetConnectionListDTO.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/log/GetLogListDTO.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/runtime/GetRuntimeListDTO.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/topic/CreateTopicDTO.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/topic/GetTopicListDTO.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/vo/cluster/GetClusterBaseMessageVO.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/vo/cluster/ResourceNumVO.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/vo/connection/ConnectionListVO.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/vo/health/InstanceLiveProportionVo.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/vo/topic/TopicDetailGroupVO.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/registry/RegistryDataService.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/registry/impl/RegistryDataServiceImpl.java diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/EventMeshDashboardApplication.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/EventMeshDashboardApplication.java index 53a951ae..7103aad0 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/EventMeshDashboardApplication.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/EventMeshDashboardApplication.java @@ -19,6 +19,7 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.transaction.annotation.EnableTransactionManagement; import lombok.extern.slf4j.Slf4j; @@ -26,6 +27,7 @@ @Slf4j @SpringBootApplication @EnableTransactionManagement +@EnableAspectJAutoProxy(exposeProxy = true) public class EventMeshDashboardApplication { public static void main(String[] args) { diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/ClusterController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/ClusterController.java new file mode 100644 index 00000000..6bae56cd --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/ClusterController.java @@ -0,0 +1,46 @@ +/* + * 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; + + +import org.apache.eventmesh.dashboard.console.modle.vo.cluster.GetClusterBaseMessageVO; +import org.apache.eventmesh.dashboard.console.modle.vo.cluster.ResourceNumVO; +import org.apache.eventmesh.dashboard.console.service.cluster.ClusterService; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController + +public class ClusterController { + + @Autowired + ClusterService clusterService; + + @GetMapping("/cluster/getResourceNum") + public ResourceNumVO getResourceNumByClusterId(Long clusterId) { + return clusterService.getResourceNumByCluster(clusterId); + } + + + @GetMapping("/cluster/getBaseMessage") + public GetClusterBaseMessageVO getClusterBaseMessage(Long clusterId) { + return clusterService.getClusterBaseMessage(clusterId); + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/ConfigController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/ConfigController.java new file mode 100644 index 00000000..ca819b7d --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/ConfigController.java @@ -0,0 +1,74 @@ +/* + * 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; + +import org.apache.eventmesh.dashboard.console.entity.config.ConfigEntity; +import org.apache.eventmesh.dashboard.console.modle.dto.config.DetailConfigsVO; +import org.apache.eventmesh.dashboard.console.modle.dto.config.GetConfigsListDTO; +import org.apache.eventmesh.dashboard.console.modle.dto.config.UpdateConfigDTO; +import org.apache.eventmesh.dashboard.console.service.config.ConfigService; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class ConfigController { + + @Autowired + private ConfigService configService; + + @PostMapping("/cluster/config/updateConfigs") + public String updateConfigsByTypeAndId(@Validated @RequestBody UpdateConfigDTO updateConfigDTO) { + try { + configService.updateConfigsByInstanceId(updateConfigDTO.getUsername(), updateConfigDTO.getClusterId(), updateConfigDTO.getInstanceType(), + updateConfigDTO.getInstanceId(), updateConfigDTO.getChangeConfigDTOS()); + } catch (Exception e) { + return e.getMessage(); + } + return "success"; + } + + + @PostMapping("/cluster/config/getInstanceDetailConfigs") + public List getInstanceDetailConfigs(@Validated @RequestBody GetConfigsListDTO getConfigsListDTO) { + List configEntityList = configService.selectToFront(getConfigsListDTO.getInstanceId(), + getConfigsListDTO.getInstanceType(), getConfigsListDTO); + Map stringStringConcurrentHashMap = configService.selectDefaultConfig(getConfigsListDTO.getBusinessType(), + getConfigsListDTO.getInstanceId(), getConfigsListDTO.getInstanceType()); + ArrayList showDetailConfigsVOS = new ArrayList<>(); + configEntityList.forEach(n -> { + DetailConfigsVO showDetailConfigsVO = new DetailConfigsVO(); + showDetailConfigsVO.setDefaultValue(stringStringConcurrentHashMap.get(n.getConfigName())); + showDetailConfigsVO.setIsModify(n.getIsModify()); + showDetailConfigsVO.setConfigName(n.getConfigName()); + showDetailConfigsVO.setConfigValue(n.getConfigValue()); + showDetailConfigsVO.setAlreadyUpdate(n.getAlreadyUpdate()); + showDetailConfigsVOS.add(showDetailConfigsVO); + }); + return showDetailConfigsVOS; + } + + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/ConnectionController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/ConnectionController.java index 37e9049d..79540d38 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/ConnectionController.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/ConnectionController.java @@ -17,36 +17,73 @@ package org.apache.eventmesh.dashboard.console.controller; -import org.apache.eventmesh.dashboard.service.meta.ConnectionCore; +import org.apache.eventmesh.dashboard.console.entity.config.ConfigEntity; +import org.apache.eventmesh.dashboard.console.entity.connector.ConnectorEntity; +import org.apache.eventmesh.dashboard.console.modle.dto.connection.AddConnectionDTO; +import org.apache.eventmesh.dashboard.console.modle.dto.connection.CreateConnectionDTO; +import org.apache.eventmesh.dashboard.console.modle.dto.connection.GetConnectionListDTO; +import org.apache.eventmesh.dashboard.console.modle.vo.connection.ConnectionListVO; +import org.apache.eventmesh.dashboard.console.service.connection.ConnectionDataService; +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; -import lombok.extern.slf4j.Slf4j; - -@Slf4j @RestController public class ConnectionController { - /** - * TODO expose implement by FunctionManager - */ - ConnectionCore connectionCore; + @Autowired + private ConnectionDataService connectionDataService; /** - * Query Connection List - *

- * The subscription information of SourceConnector and SinkConnector reported by EventMesh Runtime to the meta, - * containing the configuration of each connection. + * 'type' only can be Sink or Source * - * @param page the page number - * @param size the page size - * @return A paged list of connection configuration and total number of pages + * @param type + * @return */ - @GetMapping("/connection") - public String listConnections(@RequestParam("page") Integer page, @RequestParam("size") String size) { - return null; + @GetMapping("/cluster/connection/getConnectorBusinessType") + public List getConnectorBusinessType(String type) { + return connectionDataService.getConnectorBusinessType(type); + } + + @GetMapping("/cluster/connection/getConnectorConfigs") + public List getConnectorConfigsByClassAndVersion(String version, String classType) { + return connectionDataService.getConnectorConfigsByClassAndVersion(classType, version); } + + @GetMapping("/cluster/connection/showCreateConnectionMessage") + public AddConnectionDTO showCreateConnectionMessage() { + return new AddConnectionDTO(); + } + + + @PostMapping("/cluster/connection/createConnection") + public String createConnection(@Validated @RequestBody CreateConnectionDTO createConnectionDTO) { + try { + connectionDataService.createConnection(createConnectionDTO); + + } catch (Exception e) { + return e.getMessage(); + } + return "success"; + } + + + @PostMapping("/cluster/connection/getConnectionList") + public List getConnectionList(@Validated @RequestBody GetConnectionListDTO getConnectionListDTO) { + return connectionDataService.getConnectionToFrontByCluster(getConnectionListDTO.getClusterId(), getConnectionListDTO); + } + + @GetMapping("/cluster/connection/getConnectorDetail") + public ConnectorEntity getConnectorDetail(Long connectorId) { + return connectionDataService.getConnectorById(connectorId); + } + + } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/HealthController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/HealthController.java new file mode 100644 index 00000000..c07c4c90 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/HealthController.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.controller; + +import org.apache.eventmesh.dashboard.console.entity.health.HealthCheckResultEntity; +import org.apache.eventmesh.dashboard.console.modle.vo.health.InstanceLiveProportionVo; +import org.apache.eventmesh.dashboard.console.service.health.HealthDataService; + +import java.sql.Timestamp; +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HealthController { + + @Autowired + HealthDataService healthDataService; + + @GetMapping("/cluster/health/getHistoryLiveStatus") + public List getHistoryLiveStatusById(Integer type, Long instanceId, String startTime) { + Timestamp timestamp = Timestamp.valueOf(startTime); + return healthDataService.getInstanceLiveStatusHistory(type, instanceId, timestamp); + } + + @GetMapping("/cluster/health/getInstanceLiveProportion") + public InstanceLiveProportionVo getInstanceLiveProportion(Integer instanceType, Long theClusterId) { + return healthDataService.getInstanceLiveProportion(theClusterId, instanceType); + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/LogController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/LogController.java new file mode 100644 index 00000000..31a0907c --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/LogController.java @@ -0,0 +1,43 @@ +/* + * 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; + +import org.apache.eventmesh.dashboard.console.entity.log.LogEntity; +import org.apache.eventmesh.dashboard.console.modle.dto.log.GetLogListDTO; +import org.apache.eventmesh.dashboard.console.service.log.LogService; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class LogController { + + @Autowired + private LogService logService; + + @PostMapping("/cluster/log/getList") + public List getLogLIstToFront(@Validated @RequestBody GetLogListDTO getLogListDTO) { + return logService.getLogListByCluster(getLogListDTO); + } + +} \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/RuntimeController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/RuntimeController.java new file mode 100644 index 00000000..4fc6c809 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/RuntimeController.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.controller; + +import org.apache.eventmesh.dashboard.console.entity.runtime.RuntimeEntity; +import org.apache.eventmesh.dashboard.console.modle.dto.runtime.GetRuntimeListDTO; +import org.apache.eventmesh.dashboard.console.service.runtime.RuntimeService; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + + +@RestController +public class RuntimeController { + + @Autowired + private RuntimeService runtimeService; + + @PostMapping("/clusterId/runtime/getList") + public List getRuntimeList(@Validated @RequestBody GetRuntimeListDTO getRuntimeListDTO) { + return runtimeService.getRuntimeToFrontByClusterId(getRuntimeListDTO.getClusterId(), getRuntimeListDTO); + } + + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/TopicController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/TopicController.java index c8f92ff8..400e0c55 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/TopicController.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/TopicController.java @@ -17,67 +17,65 @@ package org.apache.eventmesh.dashboard.console.controller; -import org.apache.eventmesh.dashboard.common.dto.Result; -import org.apache.eventmesh.dashboard.console.dto.CreateTopicRequest; -import org.apache.eventmesh.dashboard.console.dto.DeleteTopicRequest; -import org.apache.eventmesh.dashboard.service.dto.TopicProperties; -import org.apache.eventmesh.dashboard.service.store.TopicCore; + +import org.apache.eventmesh.dashboard.console.entity.topic.TopicEntity; +import org.apache.eventmesh.dashboard.console.modle.dto.topic.CreateTopicDTO; +import org.apache.eventmesh.dashboard.console.modle.dto.topic.GetTopicListDTO; +import org.apache.eventmesh.dashboard.console.modle.vo.topic.TopicDetailGroupVO; +import org.apache.eventmesh.dashboard.console.service.topic.TopicService; import java.util.List; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.CrossOrigin; -import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; @RestController -@RequestMapping("/topic") public class TopicController { - /** - * TODO expose implement by FunctionManager - */ - TopicCore topicCore; - - /** - * TODO Is OPTIONS method and @CrossOrigin necessary? - */ - @CrossOrigin - @RequestMapping(method = RequestMethod.OPTIONS) - public ResponseEntity preflight() { - return ResponseEntity.ok() - .header("Access-Control-Allow-Origin", "*") - .header("Access-Control-Allow-Methods", "*") - .header("Access-Control-Allow-Headers", "*") - .header("Access-Control-Max-Age", "86400") - .build(); + @Autowired + private TopicService topicService; + + + @PostMapping("/cluster/topic/topicList") + public List getTopicList(@Validated @RequestBody GetTopicListDTO getTopicListDTO) { + return topicService.getTopicListToFront(getTopicListDTO.getClusterId(), getTopicListDTO); + } - @CrossOrigin - @GetMapping - public Result> getList() { - List topicList = topicCore.getTopics(); - return Result.success(topicList); + + @GetMapping("/cluster/topic/deleteTopic") + public String deleteTopic(TopicEntity topicEntity) { + try { + topicService.deleteTopic(topicEntity); + } catch (Exception e) { + return e.getMessage(); + } + return "success"; } - @CrossOrigin - @PostMapping - public Result create(@RequestBody CreateTopicRequest createTopicRequest) { - String topicName = createTopicRequest.getName(); - topicCore.createTopic(topicName); - return Result.success(); + + @GetMapping("/cluster/topic/showCreateTopic") + public CreateTopicDTO showCreateTopicMessage() { + return new CreateTopicDTO(); + } + + @PostMapping("/cluster/topic/createTopic") + public String createTopic(@Validated @RequestBody CreateTopicDTO createTopicDTO) { + try { + topicService.createTopic(createTopicDTO); + } catch (Exception e) { + return e.getMessage(); + } + return "success"; } - @CrossOrigin - @DeleteMapping - public Result delete(@RequestBody DeleteTopicRequest deleteTopicRequest) { - String topicName = deleteTopicRequest.getName(); - topicCore.deleteTopic(topicName); - return Result.success(); + @GetMapping("/cluster/topic/getTopicDetailGroups") + public List getTopicDetailGroups(Long topicId) { + return topicService.getTopicDetailGroups(topicId); } -} \ No newline at end of file + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/ClusterEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/ClusterEntity.java index dc1f4e44..eafbd2f1 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/ClusterEntity.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/ClusterEntity.java @@ -34,7 +34,7 @@ public class ClusterEntity extends BaseEntity { private String name; - private String registerNameList; + private String registryNameList; private String bootstrapServers; @@ -58,5 +58,8 @@ public class ClusterEntity extends BaseEntity { private Timestamp updateTime; + /** + * @See StoreType + */ private Integer storeType; } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/config/ConfigEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/config/ConfigEntity.java index 07b979b6..40e766e8 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/config/ConfigEntity.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/config/ConfigEntity.java @@ -65,4 +65,45 @@ public class ConfigEntity extends BaseEntity { private Integer isDefault; private Integer isModify; + + private Integer alreadyUpdate; + + public boolean matchVersion(String eventmeshVersion) { + return (xiaoyu(eventmeshVersion) && dayu(eventmeshVersion)); + } + + + public boolean xiaoyu(String eventmeshVersion) { + String[] em = eventmeshVersion.split("."); + String[] startVersion = this.getStartVersion().split("."); + boolean flag = true; + for (int i = 0; i < em.length; i++) { + if (Integer.valueOf(em[i]) < Integer.valueOf(startVersion[i])) { + flag = false; + break; + } else if (Integer.valueOf(em[i]) == Integer.valueOf(startVersion[i])) { + continue; + } else { + break; + } + } + return flag; + } + + public boolean dayu(String eventmeshVersion) { + String[] em = eventmeshVersion.split("."); + String[] endVersion = this.getEndVersion().split("."); + boolean flag = true; + for (int i = 0; i < em.length; i++) { + if (Integer.valueOf(em[i]) < Integer.valueOf(endVersion[i])) { + break; + } else if (Integer.valueOf(em[i]) == Integer.valueOf(endVersion[i])) { + continue; + } else { + flag = false; + break; + } + } + return flag; + } } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/config/DefaultConfigKey.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/config/DefaultConfigKey.java new file mode 100644 index 00000000..49a5a863 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/config/DefaultConfigKey.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.entity.config; + + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@NoArgsConstructor +@AllArgsConstructor +@Data +public class DefaultConfigKey { + + private String businessType; + + private String configName; +} 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 7a5f6f29..0b888be7 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 @@ -50,6 +50,10 @@ public class ConnectorEntity extends BaseEntity { @Schema(name = "status", defaultValue = "0", allowableValues = {"0", "1"}, description = "0:inactive, 1:active") private Integer status; + private String host; + + private Integer port; + /** * @see KubernetesPodStatus */ diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/runtime/RuntimeEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/runtime/RuntimeEntity.java index 2cc3f5cf..c4a7be5e 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/runtime/RuntimeEntity.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/runtime/RuntimeEntity.java @@ -28,6 +28,7 @@ @Data @NoArgsConstructor @AllArgsConstructor + public class RuntimeEntity extends BaseEntity { private Long id; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/storage/StoreEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/storage/StoreEntity.java index 3f3d326b..78156f50 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/storage/StoreEntity.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/storage/StoreEntity.java @@ -41,8 +41,6 @@ public class StoreEntity extends BaseEntity { private String host; - private Long runtimeId; - private String topicList; private Short diffType; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/topic/TopicEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/topic/TopicEntity.java index a5784f01..85ae80e6 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/topic/TopicEntity.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/topic/TopicEntity.java @@ -36,8 +36,6 @@ public class TopicEntity extends BaseEntity { private String topicName; - private String runtimeId; - private String storageId; private Long retentionMs; @@ -51,4 +49,6 @@ public class TopicEntity extends BaseEntity { private Timestamp updateTime; private Integer status; + + private Integer createProgress; } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/CheckResultCache.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/CheckResultCache.java index e2d62f71..132e46b5 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/CheckResultCache.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/CheckResultCache.java @@ -33,7 +33,15 @@ public class CheckResultCache { - private final HashMap> cacheMap = new HashMap<>(); + private static final HashMap> cacheMap = new HashMap<>(); + + public static Integer getLastHealthyCheckResult(String type, Long typeId) { + if (!Objects.isNull(cacheMap.get(type)) && !Objects.isNull(cacheMap.get(type).get(typeId))) { + return cacheMap.get(type).get(typeId).getStatus().getNumber(); + } + return HealthCheckStatus.CHECKING.getNumber(); + } + public void update(String type, Long typeId, HealthCheckStatus status, String resultDesc, Long latency) { HashMap subMap = cacheMap.get(type); diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/log/OprLog.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/log/OprLog.java index f0ac9f67..bed58ebb 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/log/OprLog.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/log/OprLog.java @@ -71,10 +71,11 @@ public Object logStart(ProceedingJoinPoint joinPoint) throws Throwable { try { proceed = joinPoint.proceed(); logEntity.setState(2); - logEntity.setResult(Objects.isNull(proceed) ? "" : proceed.toString()); + proceed = Objects.isNull(proceed) ? " " : proceed.toString(); return proceed; } catch (Throwable e) { logEntity.setState(3); + proceed = "error:" + e.getMessage(); throw new RuntimeException(e); } finally { logEntity.setResult(proceed.toString()); 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 ddce0f2c..94e3eda2 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 @@ -49,6 +49,9 @@ public interface ClientMapper { @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") void batchInsert(List clientEntityList); + @Select("SELECT * FROM `client` WHERE `host` = #{host} AND `port` = #{port} AND status = 1") + List selectByHostPort(ClientEntity clientEntity); + @Select("SELECT * FROM `client` WHERE `id` = #{id}") ClientEntity selectById(ClientEntity clientEntity); @@ -66,6 +69,6 @@ public interface ClientMapper { void insert(ClientEntity clientEntity); @Update("UPDATE `client` SET status = 0, end_time = NOW() WHERE id = #{id}") - void deActive(ClientEntity clientEntity); + void deactivate(ClientEntity clientEntity); } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/ClusterMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/ClusterMapper.java index 23608bfa..7e1c3af3 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/ClusterMapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/ClusterMapper.java @@ -19,7 +19,6 @@ import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; -import org.apache.ibatis.annotations.Delete; import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Options; @@ -37,12 +36,15 @@ public interface ClusterMapper { @Select("SELECT * FROM cluster WHERE status=1") List selectAllCluster(); + @Select("SELECT * FROM cluster WHERE status=1 LIMIT #{rowIndex},#{pageNum}") + List selectAllClusterToFront(Integer rowIndex, Integer pageNum); + @Insert({ ""}) @@ -52,8 +54,8 @@ public interface ClusterMapper { @Select("SELECT * FROM cluster WHERE id=#{id} AND status=1") ClusterEntity selectClusterById(ClusterEntity cluster); - @Insert("INSERT INTO cluster (name, register_name_list, bootstrap_servers, eventmesh_version, client_properties, " - + "jmx_properties, reg_properties, description, auth_type, run_state,store_type) VALUES (#{name},#{registerNameList}," + @Insert("INSERT INTO cluster (name, registry_name_list, bootstrap_servers, eventmesh_version, client_properties, " + + "jmx_properties, reg_properties, description, auth_type, run_state,store_type) VALUES (#{name},#{registryNameList}," + "#{bootstrapServers},#{eventmeshVersion},#{clientProperties},#{jmxProperties},#{regProperties},#{description},#{authType}," + "#{runState},#{storeType})") @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") @@ -62,10 +64,9 @@ public interface ClusterMapper { @Update("UPDATE cluster SET name =#{name},reg_properties=#{regProperties},bootstrap_servers=#{bootstrapServers}," + "eventmesh_version=#{eventmeshVersion},client_properties=#{clientProperties},jmx_properties=#{jmxProperties}," + "reg_properties=#{regProperties},description=#{description},auth_type=#{authType},run_state=#{runState} ," - + "register_name_list=#{registerNameList} WHERE id=#{id}") + + "registry_name_list=#{registryNameList} WHERE id=#{id}") void updateClusterById(ClusterEntity cluster); - @Delete("UPDATE cluster SET status=0 WHERE id=#{id}") - void deleteClusterById(ClusterEntity clusterEntity); - + @Update("UPDATE cluster SET status=0 WHERE id=#{id}") + void deactivate(ClusterEntity clusterEntity); } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/config/ConfigMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/config/ConfigMapper.java index 905b551b..838e95f8 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/config/ConfigMapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/config/ConfigMapper.java @@ -33,7 +33,32 @@ @Mapper public interface ConfigMapper { - @Select("SELECT * FROM config WHERE status=1") + @Select({ + ""}) + List getConfigsToFrontWithDynamic(ConfigEntity configEntity); + + @Select("SELECT * FROM config WHERE business_type=#{businessType} AND is_default=1") + List selectConnectorConfigsByBusinessType(ConfigEntity configEntity); + + @Select("SELECT DISTINCT business_type FROM config WHERE instance_type=2 AND is_default=1 AND business_type LIKE CONCAT('%',#{businessType},'%')") + List selectConnectorBusinessType(ConfigEntity configEntity); + + + @Select("SELECT * FROM config WHERE status=1 AND is_default=0") List selectAll(); @Insert({ @@ -60,16 +85,18 @@ public interface ConfigMapper { @Update("UPDATE config SET status=0 WHERE id=#{id}") Integer deleteConfig(ConfigEntity configEntity); - @Update("UPDATE config SET config_value=#{configValue} WHERE status=1 AND edit=2") + @Update("UPDATE config SET config_value=#{configValue} ,already_update=#{alreadyUpdate} WHERE instance_type=#{instanceType} AND" + + " instance_id=#{instanceId} AND config_name=#{configName} AND is_default=0") void updateConfig(ConfigEntity configEntity); - @Select("SELECT * FROM config WHERE business_type=#{businessType} AND instance_type=#{instanceType} " - + "AND instance_id=#{instanceId}") + @Select("SELECT * FROM config WHERE instance_type=#{instanceType} AND instance_id=#{instanceId} AND is_default=0") List selectByInstanceId(ConfigEntity configEntity); - @Select("SELECT * FROM config WHERE cluster_id=-1 AND business_type=#{businessType} AND instance_type=#{instanceType}") + @Select("SELECT * FROM config WHERE cluster_id=-1 AND business_type=#{businessType} AND instance_type=#{instanceType} AND is_default=1") List selectDefaultConfig(ConfigEntity configEntity); + @Select("SELECT * FROM config WHERE is_default=1") + List selectAllDefaultConfig(); @Select("SELECT * FROM config WHERE cluster_id=#{clusterId} AND instance_type=#{instanceType} " + "AND instance_id=#{instanceId} AND config_name=#{configName} AND status=1") 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 38903cd9..2da0d5e5 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 @@ -35,16 +35,29 @@ @Mapper public interface ConnectionMapper { - @Select("SELECT COUNT(*) FROM connection WHERE cluster_id=#{clusterId}") + + @Select("SELECT COUNT(*) FROM connection WHERE cluster_id=#{clusterId} AND status=1") Integer selectConnectionNumByCluster(ConnectionEntity connectionEntity); - @Select("SELECT * FROM connection") + @Select("SELECT * FROM connection WHERE status=1") List selectAll(); - @Select("SELECT * FROM connection WHERE cluster_id = #{clusterId}") + @Select("SELECT * FROM connection WHERE cluster_id = #{clusterId} AND status=1") List selectByClusterId(ConnectionEntity connectionEntity); - @Select("SELECT * FROM connection WHERE cluster_id = #{clusterId} AND source_id = #{sourceId} AND source_type = #{sourceType}") + @Select({ + ""}) + List selectToFrontByClusterId(@Param("connectionEntity") ConnectionEntity connectionEntity); + + @Select("SELECT * FROM connection WHERE cluster_id = #{clusterId} AND source_id = #{sourceId} AND source_type = #{sourceType} AND status=1") public List selectByClusterIdSourceTypeAndSourceId(ConnectionEntity connectionEntity); @Select("SELECT * FROM connection WHERE cluster_id = #{clusterId} AND sink_id = #{sinkId} AND sink_type = #{sinkType}") 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 ba0724c4..5958b6a4 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 @@ -36,30 +36,37 @@ public interface ConnectorMapper { @Select("SELECT * FROM connector WHERE status=1") ConnectorEntity selectAll(); - @Select("SELECT * FROM connector WHERE id = #{id}") + @Select("SELECT * FROM connector WHERE id = #{id} AND status=1") ConnectorEntity selectById(ConnectorEntity connectorEntity); - @Select("SELECT * FROM connector WHERE cluster_id = #{clusterId}") + @Select("SELECT * FROM connector WHERE cluster_id = #{clusterId} AND status=1") List selectByClusterId(ConnectorEntity connectorEntity); + @Select("SELECT * FROM connector WHERE host = #{host} AND port = #{port} AND status=1") + List selectByHostAndPort(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 (#{clusterId}, #{name}, #{className}, #{type}, #{status}, #{podState}, #{configIds})") + @Insert("INSERT INTO connector (cluster_id,name, class_name, type, status, pod_state, config_ids, host, port) " + + "VALUES (#{clusterId}, #{name}, #{className}, #{type}, #{status}, #{podState}, #{configIds}, #{host}, #{port})") void insert(ConnectorEntity connectorEntity); @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 status = 1 WHERE id = #{id}") + void active(ConnectorEntity connectorEntity); + + @Update("UPDATE connector SET status = 0 WHERE id = #{id}") + void deactivate(ConnectorEntity connectorEntity); @Update("UPDATE connector SET pod_state = #{podState} WHERE id = #{id}") void updatePodState(ConnectorEntity connectorEntity); @@ -68,7 +75,7 @@ public interface ConnectorMapper { void updateConfigIds(ConnectorEntity connectorEntity); @Update("UPDATE connector SET status = 0 WHERE cluster_id = #{clusterId}") - void deActiveById(ConnectorEntity connectorEntity); + void deactivateByClusterId(ConnectorEntity connectorEntity); @Update({ "" }) - void batchDeActive(List connectorEntities); + void batchDeactivate(List connectorEntities); } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/group/OprGroupMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/group/OprGroupMapper.java index fe228ab1..fbc5f5cb 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/group/OprGroupMapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/group/OprGroupMapper.java @@ -19,7 +19,6 @@ import org.apache.eventmesh.dashboard.console.entity.group.GroupEntity; -import org.apache.ibatis.annotations.Delete; import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Options; @@ -34,12 +33,18 @@ @Mapper public interface OprGroupMapper { + @Select("SELECT * FROM `group` WHERE cluster_id=#{clusterId} AND name=#{name} AND type=0 ") + GroupEntity selectGroupByNameAndClusterId(GroupEntity groupEntity); + @Insert("INSERT INTO `group` (cluster_id, name, member_count, members, type, state)" + "VALUE (#{clusterId},#{name},#{memberCount},#{members},#{type},#{state}) " + "ON DUPLICATE KEY UPDATE status=1") @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") void addGroup(GroupEntity groupEntity); + @Select("SELECT COUNT(*) FROM `group` WHERE cluster_id=#{clusterId} AND type=0") + Integer getConsumerNumByCluster(GroupEntity groupEntity); + @Insert({ ""}) List getLogList(LogEntity logEntity); - @Insert("INSERT INTO operation_log ( cluster_id, operation_type,target_Type, content,operation_user,result)" + @Insert("INSERT INTO operation_log ( cluster_id, operation_type,target_type, content,operation_user,result)" + "VALUE (#{clusterId},#{operationType},#{targetType},#{content},#{operationUser},#{result})") @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") Long addLog(LogEntity logEntity); - @Update("UPDATE operation_log SET state=#{state} ,result=#{resultContent} WHERE id=#{id}") + @Update("UPDATE operation_log SET state=#{state} ,result=#{result} WHERE id=#{id}") Integer updateLog(LogEntity logEntity); + + @Select({ + "" + }) + List getLogListToFront(LogEntity logEntity); } 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 index f2261c82..c3102724 100644 --- 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 @@ -19,7 +19,6 @@ 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; @@ -58,9 +57,6 @@ public interface MetaMapper { + " 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); + @Update("UPDATE meta SET status = 0 WHERE id = #{id}") + void deactivate(MetaEntity metaEntity); } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/runtime/RuntimeMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/runtime/RuntimeMapper.java index 4c6e8ceb..c6453309 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/runtime/RuntimeMapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/runtime/RuntimeMapper.java @@ -19,10 +19,10 @@ import org.apache.eventmesh.dashboard.console.entity.runtime.RuntimeEntity; -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.Param; import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Update; @@ -34,6 +34,9 @@ @Mapper public interface RuntimeMapper { + @Select("SELECT COUNT(*) FROM runtime WHERE cluster_id=#{clusterId} AND status=1") + Integer getRuntimeNumByCluster(RuntimeEntity runtimeEntity); + @Select("SELECT * FROM runtime WHERE status=1") List selectAll(); @@ -55,10 +58,28 @@ public interface RuntimeMapper { @Select("SELECT * FROM runtime WHERE cluster_id=#{clusterId} AND status=1") List selectRuntimeByCluster(RuntimeEntity runtimeEntity); + @Select({ + ""}) + List getRuntimesToFrontByCluster(@Param("runtimeEntity") RuntimeEntity runtimeEntity); + + @Select("SELECT * FROM runtime WHERE host = #{host} and port = #{port} and status = 1") + List selectByHostPort(RuntimeEntity runtimeEntity); + @Update("UPDATE runtime SET port=#{port} ,jmx_port=#{jmxPort} ,status=#{status} WHERE cluster_id=#{clusterId} AND status=1") void updateRuntimeByCluster(RuntimeEntity runtimeEntity); - @Delete("UPDATE runtime SET status=0 WHERE cluster_id=#{clusterId}") + @Update("UPDATE runtime SET status=0 WHERE cluster_id=#{clusterId}") void deleteRuntimeByCluster(RuntimeEntity runtimeEntity); + @Update("UPDATE runtime SET status = 0 WHERE id = #{id}") + void deactivate(RuntimeEntity runtimeEntity); + } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/storage/StoreMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/storage/StoreMapper.java index 804a3711..5e5ee418 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/storage/StoreMapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/storage/StoreMapper.java @@ -36,6 +36,9 @@ public interface StoreMapper { @Select("SELECT * FROM store WHERE status=1") List selectAll(); + @Select("SELECT * FROM store WHERE id=#{id} AND status=1") + StoreEntity selectById(StoreEntity storeEntity); + @Insert({ ""}) @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") void batchInsert(List topicEntities); - @Select("SELECT count(*) FROM topic WHERE cluster_id=#{clusterId}") + @Select("SELECT count(*) FROM topic WHERE cluster_id=#{clusterId} AND status=1") Integer selectTopicNumByCluster(TopicEntity topicEntity); @Select({ @@ -66,16 +66,34 @@ public interface TopicMapper { ""}) List getTopicList(TopicEntity topicEntity); - @Insert("INSERT INTO topic (cluster_id, topic_name, runtime_id, storage_id, retention_ms, type, description) " - + "VALUE (#{clusterId},#{topicName},#{runtimeId},#{storageId},#{retentionMs},#{type},#{description})" + @Insert("INSERT INTO topic (cluster_id, topic_name, storage_id, retention_ms, type, description, create_progress) " + + "VALUE (#{clusterId},#{topicName},#{storageId},#{retentionMs},#{type},#{description},#{createProgress})" + "ON DUPLICATE KEY UPDATE status = 1") @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") void addTopic(TopicEntity topicEntity); + @Select("SELECT * FROM topic WHERE status=1 AND cluster_id=#{clusterId}") + List selectAllByClusterId(TopicEntity topicEntity); + + @Select({ + ""}) + List getTopicsToFrontByClusterId(@Param("topicEntity") TopicEntity topicEntity); + @Update("UPDATE topic SET type=#{type},description=#{description} WHERE id=#{id}") void updateTopic(TopicEntity topicEntity); - @Delete("UPDATE `topic` SET status=0 WHERE id=#{id}") + @Update("UPDATE topic SET create_progress=#{createProgress} WHERE id=#{id}") + void updateTopicCreateProgress(TopicEntity topicEntity); + + @Update("UPDATE `topic` SET status=0 WHERE id=#{id}") void deleteTopic(TopicEntity topicEntity); @Select("SELECT * FROM topic WHERE cluster_id=#{clusterId} AND topic_name=#{topicName}") diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/config/ChangeConfigDTO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/config/ChangeConfigDTO.java new file mode 100644 index 00000000..d0bdc23c --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/config/ChangeConfigDTO.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.eventmesh.dashboard.console.modle.dto.config; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@NoArgsConstructor +@AllArgsConstructor +@Data +public class ChangeConfigDTO { + + private String configName; + + private String configValue; + + private Integer alreadyUpdate; +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/config/DetailConfigsVO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/config/DetailConfigsVO.java new file mode 100644 index 00000000..bda02fa5 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/config/DetailConfigsVO.java @@ -0,0 +1,39 @@ +/* + * 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.modle.dto.config; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@NoArgsConstructor +@AllArgsConstructor +@Data +public class DetailConfigsVO { + + private String configName; + + private String configValue; + + private String defaultValue; + + private Integer isModify; + + private Integer alreadyUpdate; + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/config/GetConfigsListDTO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/config/GetConfigsListDTO.java new file mode 100644 index 00000000..478b1acf --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/config/GetConfigsListDTO.java @@ -0,0 +1,40 @@ +/* + * 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.modle.dto.config; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@NoArgsConstructor +@AllArgsConstructor +@Data +public class GetConfigsListDTO { + + private String businessType; + + private Long instanceId; + + private Integer instanceType; + + private String configName; + + private Integer isModify; + + private Integer alreadyUpdate; +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/config/UpdateConfigDTO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/config/UpdateConfigDTO.java new file mode 100644 index 00000000..8c273b81 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/config/UpdateConfigDTO.java @@ -0,0 +1,40 @@ +/* + * 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.modle.dto.config; + +import java.util.List; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@NoArgsConstructor +@AllArgsConstructor +@Data +public class UpdateConfigDTO { + + private Long clusterId; + + private List changeConfigDTOS; + + private String username; + + private Integer instanceType; + + private Long instanceId; +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/config/UpdateConfigsLog.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/config/UpdateConfigsLog.java new file mode 100644 index 00000000..9619c7f1 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/config/UpdateConfigsLog.java @@ -0,0 +1,38 @@ +/* + * 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.modle.dto.config; + + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@NoArgsConstructor +@AllArgsConstructor +@Data +public class UpdateConfigsLog { + + private Long instanceId; + + private Long clusterId; + + private String name; + + private String configProperties; + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/connection/AddConnectionDTO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/connection/AddConnectionDTO.java new file mode 100644 index 00000000..0a7c23e2 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/connection/AddConnectionDTO.java @@ -0,0 +1,54 @@ +/* + * 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.modle.dto.connection; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@NoArgsConstructor +@AllArgsConstructor +@Data +public class AddConnectionDTO { + + private String sinkName; + + private String sourceName; + + private String sinkClass; + + private String sourceClass; + + private String topicName; + + private String sinkHost; + + private String sourceHost; + + private Integer sinkPort; + + private Integer sourcePort; + + private String sinkDescription; + + private String sourceDescription; + + private String connectionDescription; + + private Long groupId; +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/connection/AddConnectorConfigDTO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/connection/AddConnectorConfigDTO.java new file mode 100644 index 00000000..fe99cf97 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/connection/AddConnectorConfigDTO.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.eventmesh.dashboard.console.modle.dto.connection; + +import org.apache.eventmesh.dashboard.console.entity.config.ConfigEntity; + +import java.util.List; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@NoArgsConstructor +@AllArgsConstructor +@Data +public class AddConnectorConfigDTO { + + private List sinkConnectorConfigs; + + private List sourceConnectorConfigs; + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/connection/CreateConnectionDTO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/connection/CreateConnectionDTO.java new file mode 100644 index 00000000..1a63e0a7 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/connection/CreateConnectionDTO.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.eventmesh.dashboard.console.modle.dto.connection; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@NoArgsConstructor +@AllArgsConstructor +@Data +public class CreateConnectionDTO { + + private Long clusterId; + + private AddConnectionDTO addConnectionDTO; + + private AddConnectorConfigDTO addConnectorConfigDTO; +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/connection/GetConnectionListDTO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/connection/GetConnectionListDTO.java new file mode 100644 index 00000000..63a97d27 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/connection/GetConnectionListDTO.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.modle.dto.connection; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@NoArgsConstructor +@AllArgsConstructor +@Data +public class GetConnectionListDTO { + + private Long clusterId; + + private String topicName; + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/log/GetLogListDTO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/log/GetLogListDTO.java new file mode 100644 index 00000000..63ae0f7a --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/log/GetLogListDTO.java @@ -0,0 +1,38 @@ +/* + * 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.modle.dto.log; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@NoArgsConstructor +@AllArgsConstructor +@Data +public class GetLogListDTO { + + private String operationType; + + private String targetType; + + private Long clusterId; + + private Integer state; + + private String operationUser; +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/runtime/GetRuntimeListDTO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/runtime/GetRuntimeListDTO.java new file mode 100644 index 00000000..6465418c --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/runtime/GetRuntimeListDTO.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.modle.dto.runtime; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@NoArgsConstructor +@AllArgsConstructor +@Data +public class GetRuntimeListDTO { + + private Long clusterId; + + private String host; + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/topic/CreateTopicDTO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/topic/CreateTopicDTO.java new file mode 100644 index 00000000..c8c2ac94 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/topic/CreateTopicDTO.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.modle.dto.topic; + +import java.sql.Timestamp; + + +import lombok.Data; + +/** + * TODO this class is copied from storage plugin, needs update + */ + +@Data +public class CreateTopicDTO { + + private Long clusterId; + + private String name; + + private String description; + + private Integer partitionsNums; + + private Integer replicasNums; + + private Timestamp saveTime; + + private Integer cleanupStrategy; +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/topic/GetTopicListDTO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/topic/GetTopicListDTO.java new file mode 100644 index 00000000..169b9bc9 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/topic/GetTopicListDTO.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.modle.dto.topic; + + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@NoArgsConstructor +@AllArgsConstructor +@Data +public class GetTopicListDTO { + + private Long clusterId; + + private String topicName; +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/vo/cluster/GetClusterBaseMessageVO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/vo/cluster/GetClusterBaseMessageVO.java new file mode 100644 index 00000000..3c4c9f72 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/vo/cluster/GetClusterBaseMessageVO.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.eventmesh.dashboard.console.modle.vo.cluster; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@NoArgsConstructor +@AllArgsConstructor +@Data +public class GetClusterBaseMessageVO { + + private Integer topicNum; + + private Integer consumerGroupNum; + + private Integer connectionNum; + + private Integer runtimeNum; + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/vo/cluster/ResourceNumVO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/vo/cluster/ResourceNumVO.java new file mode 100644 index 00000000..13794078 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/vo/cluster/ResourceNumVO.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.eventmesh.dashboard.console.modle.vo.cluster; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@NoArgsConstructor +@AllArgsConstructor +@Data +public class ResourceNumVO { + + private Integer topicsNum; + + private Integer connectionsNum; + + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/vo/connection/ConnectionListVO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/vo/connection/ConnectionListVO.java new file mode 100644 index 00000000..a9b40829 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/vo/connection/ConnectionListVO.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.modle.vo.connection; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class ConnectionListVO { + + private Long sinkConnectorId; + + private String sinkConnectorName; + + private Long sourceConnectorId; + + private String sourceConnectorName; + + private String sinkClass; + + private String sourceClass; + + private Integer status; + + private String topicName; + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/vo/health/InstanceLiveProportionVo.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/vo/health/InstanceLiveProportionVo.java new file mode 100644 index 00000000..2277c10c --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/vo/health/InstanceLiveProportionVo.java @@ -0,0 +1,32 @@ +/* + * 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.modle.vo.health; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@NoArgsConstructor +@AllArgsConstructor +@Data +public class InstanceLiveProportionVo { + + private Integer abnormalNum; + + private Integer allNum; +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/vo/topic/TopicDetailGroupVO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/vo/topic/TopicDetailGroupVO.java new file mode 100644 index 00000000..aebeb7a4 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/vo/topic/TopicDetailGroupVO.java @@ -0,0 +1,38 @@ +/* + * 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.modle.vo.topic; + +import java.util.List; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@NoArgsConstructor +@AllArgsConstructor +@Data +public class TopicDetailGroupVO { + + private String groupName; + + private List topics; + + private String state; + + private Integer memberNum; +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/client/ClientDataService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/client/ClientDataService.java index 22a0712d..d9d3bd9d 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/client/ClientDataService.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/client/ClientDataService.java @@ -29,4 +29,6 @@ public interface ClientDataService { List selectAll(); void batchInsert(List clientEntityList); + + List selectByHostPort(String host, Integer port); } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/client/Impl/ClientDataServiceImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/client/Impl/ClientDataServiceImpl.java index 7a153fc2..d3da03cd 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/client/Impl/ClientDataServiceImpl.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/client/Impl/ClientDataServiceImpl.java @@ -41,4 +41,12 @@ public List selectAll() { public void batchInsert(List clientEntityList) { clientMapper.batchInsert(clientEntityList); } + + @Override + public List selectByHostPort(String host, Integer port) { + ClientEntity query = new ClientEntity(); + query.setHost(host); + query.setPort(port); + return clientMapper.selectByHostPort(query); + } } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/ClusterService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/ClusterService.java index 754c2235..29e6774f 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/ClusterService.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/ClusterService.java @@ -17,7 +17,10 @@ package org.apache.eventmesh.dashboard.console.service.cluster; + import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; +import org.apache.eventmesh.dashboard.console.modle.vo.cluster.GetClusterBaseMessageVO; +import org.apache.eventmesh.dashboard.console.modle.vo.cluster.ResourceNumVO; import java.util.List; @@ -26,6 +29,10 @@ */ public interface ClusterService { + GetClusterBaseMessageVO getClusterBaseMessage(Long clusterId); + + ResourceNumVO getResourceNumByCluster(Long clusterId); + void batchInsert(List clusterEntities); List selectAll(); @@ -38,5 +45,5 @@ public interface ClusterService { void updateClusterById(ClusterEntity cluster); - void deleteClusterById(ClusterEntity cluster); + void deactivate(ClusterEntity cluster); } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/impl/ClusterServiceImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/impl/ClusterServiceImpl.java index f4b7e9ab..676598fc 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/impl/ClusterServiceImpl.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/impl/ClusterServiceImpl.java @@ -18,7 +18,17 @@ package org.apache.eventmesh.dashboard.console.service.cluster.impl; import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; +import org.apache.eventmesh.dashboard.console.entity.connection.ConnectionEntity; +import org.apache.eventmesh.dashboard.console.entity.group.GroupEntity; +import org.apache.eventmesh.dashboard.console.entity.runtime.RuntimeEntity; +import org.apache.eventmesh.dashboard.console.entity.topic.TopicEntity; import org.apache.eventmesh.dashboard.console.mapper.cluster.ClusterMapper; +import org.apache.eventmesh.dashboard.console.mapper.connection.ConnectionMapper; +import org.apache.eventmesh.dashboard.console.mapper.group.OprGroupMapper; +import org.apache.eventmesh.dashboard.console.mapper.runtime.RuntimeMapper; +import org.apache.eventmesh.dashboard.console.mapper.topic.TopicMapper; +import org.apache.eventmesh.dashboard.console.modle.vo.cluster.GetClusterBaseMessageVO; +import org.apache.eventmesh.dashboard.console.modle.vo.cluster.ResourceNumVO; import org.apache.eventmesh.dashboard.console.service.cluster.ClusterService; import java.util.List; @@ -30,9 +40,53 @@ @Service public class ClusterServiceImpl implements ClusterService { + @Autowired + private ConnectionMapper connectionMapper; + @Autowired private ClusterMapper clusterMapper; + @Autowired + private RuntimeMapper runtimeMapper; + + @Autowired + private OprGroupMapper oprGroupMapper; + + @Autowired + private TopicMapper topicMapper; + + + @Override + public GetClusterBaseMessageVO getClusterBaseMessage(Long clusterId) { + GetClusterBaseMessageVO getClusterBaseMessageVO = new GetClusterBaseMessageVO(); + TopicEntity topicEntity = new TopicEntity(); + topicEntity.setClusterId(clusterId); + getClusterBaseMessageVO.setTopicNum(topicMapper.selectTopicNumByCluster(topicEntity)); + GroupEntity groupEntity = new GroupEntity(); + groupEntity.setClusterId(clusterId); + getClusterBaseMessageVO.setConsumerGroupNum(oprGroupMapper.getConsumerNumByCluster(groupEntity)); + ConnectionEntity connectionEntity = new ConnectionEntity(); + connectionEntity.setClusterId(clusterId); + getClusterBaseMessageVO.setConnectionNum(connectionMapper.selectConnectionNumByCluster(connectionEntity)); + RuntimeEntity runtimeEntity = new RuntimeEntity(); + runtimeEntity.setClusterId(clusterId); + getClusterBaseMessageVO.setRuntimeNum(runtimeMapper.getRuntimeNumByCluster(runtimeEntity)); + return getClusterBaseMessageVO; + } + + @Override + public ResourceNumVO getResourceNumByCluster(Long clusterId) { + ConnectionEntity connectionEntity = new ConnectionEntity(); + connectionEntity.setClusterId(clusterId); + Integer connectionNumByCluster = connectionMapper.selectConnectionNumByCluster(connectionEntity); + TopicEntity topicEntity = new TopicEntity(); + topicEntity.setClusterId(clusterId); + Integer topicNumByCluster = topicMapper.selectTopicNumByCluster(topicEntity); + ResourceNumVO resourceNumVO = new ResourceNumVO(topicNumByCluster, connectionNumByCluster); + return resourceNumVO; + } + + @Override public void batchInsert(List clusterEntities) { clusterMapper.batchInsert(clusterEntities); @@ -64,8 +118,8 @@ public void updateClusterById(ClusterEntity cluster) { } @Override - public void deleteClusterById(ClusterEntity cluster) { - clusterMapper.deleteClusterById(cluster); + public void deactivate(ClusterEntity cluster) { + clusterMapper.deactivate(cluster); } } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/ConfigService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/ConfigService.java index c05d5da2..3be1c537 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/ConfigService.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/ConfigService.java @@ -19,6 +19,8 @@ import org.apache.eventmesh.dashboard.console.entity.config.ConfigEntity; +import org.apache.eventmesh.dashboard.console.modle.dto.config.ChangeConfigDTO; +import org.apache.eventmesh.dashboard.console.modle.dto.config.GetConfigsListDTO; import java.util.List; import java.util.Map; @@ -29,6 +31,10 @@ */ public interface ConfigService { + List selectToFront(Long instanceId, Integer type, GetConfigsListDTO getConfigsListDTO); + + void updateConfigsByInstanceId(String name, Long clusterId, Integer instanceType, Long instanceId, List changeConfigDTOList); + List selectAll(); void batchInsert(List configEntityList); @@ -41,11 +47,12 @@ public interface ConfigService { String mapToProperties(Map stringMap); + Map propertiesToMap(String configProperties); + + List selectByInstanceIdAndType(Long instanceId, Integer type); - List selectByInstanceId(ConfigEntity configEntity); + Map selectDefaultConfig(String version, Long instanceId, Integer instanceType); - List selectDefaultConfig(ConfigEntity configEntity); - void updateConfig(ConfigEntity configEntity); } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/Impl/ConfigServiceImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/Impl/ConfigServiceImpl.java index b8d32b45..b3e06d65 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/Impl/ConfigServiceImpl.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/Impl/ConfigServiceImpl.java @@ -17,14 +17,23 @@ package org.apache.eventmesh.dashboard.console.service.config.Impl; +import org.apache.eventmesh.dashboard.console.annotation.EmLog; import org.apache.eventmesh.dashboard.console.entity.config.ConfigEntity; +import org.apache.eventmesh.dashboard.console.entity.config.DefaultConfigKey; import org.apache.eventmesh.dashboard.console.mapper.config.ConfigMapper; +import org.apache.eventmesh.dashboard.console.modle.dto.config.ChangeConfigDTO; +import org.apache.eventmesh.dashboard.console.modle.dto.config.GetConfigsListDTO; +import org.apache.eventmesh.dashboard.console.modle.dto.config.UpdateConfigsLog; import org.apache.eventmesh.dashboard.console.service.config.ConfigService; +import java.util.Arrays; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Properties; +import java.util.concurrent.ConcurrentHashMap; +import org.springframework.aop.framework.AopContext; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.yaml.snakeyaml.Yaml; @@ -36,6 +45,86 @@ public class ConfigServiceImpl implements ConfigService { @Autowired ConfigMapper configMapper; + private Map defaultConfigCache = new HashMap<>(); + + + @EmLog(OprTarget = "Runtime", OprType = "UpdateConfigs") + public void logUpdateRuntimeConfigs(UpdateConfigsLog updateConfigsLog, List changeConfigDTOList) { + changeConfigDTOList.forEach(n -> { + ConfigEntity config = new ConfigEntity(); + config.setInstanceType(0); + config.setInstanceId(updateConfigsLog.getInstanceId()); + config.setConfigName(n.getConfigName()); + config.setConfigValue(n.getConfigValue()); + config.setAlreadyUpdate(n.getAlreadyUpdate()); + configMapper.updateConfig(config); + }); + } + + + @EmLog(OprTarget = "store", OprType = "UpdateConfigs") + public void logUpdateStoreConfigs(UpdateConfigsLog updateConfigsLog, List changeConfigDTOList) { + changeConfigDTOList.forEach(n -> { + ConfigEntity config = new ConfigEntity(); + config.setInstanceType(1); + config.setInstanceId(updateConfigsLog.getInstanceId()); + config.setConfigName(n.getConfigName()); + config.setConfigValue(n.getConfigValue()); + config.setAlreadyUpdate(n.getAlreadyUpdate()); + configMapper.updateConfig(config); + }); + } + + + @EmLog(OprTarget = "Connector", OprType = "UpdateConfigs") + public void logUpdateConnectorConfigs(UpdateConfigsLog updateConfigsLog, List changeConfigDTOList) { + changeConfigDTOList.forEach(n -> { + ConfigEntity config = new ConfigEntity(); + config.setInstanceType(2); + config.setInstanceId(updateConfigsLog.getInstanceId()); + config.setConfigName(n.getConfigName()); + config.setConfigValue(n.getConfigValue()); + config.setAlreadyUpdate(n.getAlreadyUpdate()); + configMapper.updateConfig(config); + }); + } + + + @EmLog(OprTarget = "Topic", OprType = "UpdateConfigs") + public void logUpdateTopicConfigs(UpdateConfigsLog updateConfigsLog, List changeConfigDTOList) { + changeConfigDTOList.forEach(n -> { + ConfigEntity config = new ConfigEntity(); + config.setInstanceType(3); + config.setInstanceId(updateConfigsLog.getInstanceId()); + config.setConfigName(n.getConfigName()); + config.setConfigValue(n.getConfigValue()); + config.setAlreadyUpdate(n.getAlreadyUpdate()); + configMapper.updateConfig(config); + }); + } + + @Override + public void updateConfigsByInstanceId(String name, Long clusterId, Integer instanceType, Long instanceId, + List changeConfigDTOList) { + ConcurrentHashMap stringStringConcurrentHashMap = new ConcurrentHashMap<>(); + changeConfigDTOList.forEach(n -> { + stringStringConcurrentHashMap.put(n.getConfigName(), n.getConfigValue()); + }); + UpdateConfigsLog updateConfigsLog = + new UpdateConfigsLog(instanceId, clusterId, name, this.mapToProperties(stringStringConcurrentHashMap)); + ConfigServiceImpl service = (ConfigServiceImpl) AopContext.currentProxy(); + if (instanceType == 0) { + service.logUpdateRuntimeConfigs(updateConfigsLog, changeConfigDTOList); + } else if (instanceType == 1) { + service.logUpdateStoreConfigs(updateConfigsLog, changeConfigDTOList); + } else if (instanceType == 2) { + service.logUpdateConnectorConfigs(updateConfigsLog, changeConfigDTOList); + } else if (instanceType == 3) { + service.logUpdateTopicConfigs(updateConfigsLog, changeConfigDTOList); + } + } + + @Override public List selectAll() { return configMapper.selectAll(); @@ -61,6 +150,19 @@ public String mapToProperties(Map stringMap) { return properties.toString().replace(",", ",\n"); } + @Override + public Map propertiesToMap(String configProperties) { + ConcurrentHashMap stringStringConcurrentHashMap = new ConcurrentHashMap<>(); + String replace = configProperties.replace("{", ""); + String replace1 = replace.replace("}", ""); + String[] split = replace1.split(","); + Arrays.stream(split).forEach(n -> { + String[] split1 = n.split("="); + stringStringConcurrentHashMap.put(split1[0].replace("\n ", ""), split1[1]); + }); + return stringStringConcurrentHashMap; + } + @Override public Integer addConfig(ConfigEntity configEntity) { return configMapper.addConfig(configEntity); @@ -72,19 +174,58 @@ public Integer deleteConfig(ConfigEntity configEntity) { } @Override - public List selectByInstanceId(ConfigEntity configEntity) { - return configMapper.selectByInstanceId(configEntity); + public List selectByInstanceIdAndType(Long instanceId, Integer type) { + ConfigEntity config = new ConfigEntity(); + config.setInstanceId(instanceId); + config.setInstanceType(type); + return configMapper.selectByInstanceId(config); } - @Override - public List selectDefaultConfig(ConfigEntity configEntity) { - return configMapper.selectDefaultConfig(configEntity); + public ConfigEntity setSearchCriteria(GetConfigsListDTO getConfigsListDTO, ConfigEntity configEntity) { + if (getConfigsListDTO != null) { + if (getConfigsListDTO.getConfigName() != null) { + configEntity.setConfigName(getConfigsListDTO.getConfigName()); + } + if (getConfigsListDTO.getIsModify() != null) { + configEntity.setIsModify(getConfigsListDTO.getIsModify()); + } + if (getConfigsListDTO.getAlreadyUpdate() != null) { + configEntity.setAlreadyUpdate(getConfigsListDTO.getAlreadyUpdate()); + } + } + return configEntity; } @Override - public void updateConfig(ConfigEntity configEntity) { - configMapper.updateConfig(configEntity); + public List selectToFront(Long instanceId, Integer type, GetConfigsListDTO getConfigsListDTO) { + ConfigEntity config = new ConfigEntity(); + config.setInstanceId(instanceId); + config.setInstanceType(type); + config = this.setSearchCriteria(getConfigsListDTO, config); + return configMapper.getConfigsToFrontWithDynamic(config); + } + + public void addDefaultConfigToCache() { + List configEntityList = configMapper.selectAllDefaultConfig(); + configEntityList.forEach(n -> { + DefaultConfigKey defaultConfigKey = new DefaultConfigKey(n.getBusinessType(), n.getConfigName()); + defaultConfigCache.putIfAbsent(defaultConfigKey, n.getConfigValue()); + + }); } + @Override + public Map selectDefaultConfig(String businessType, Long instanceId, Integer instanceType) { + if (defaultConfigCache.size() == 0) { + this.addDefaultConfigToCache(); + } + ConcurrentHashMap stringStringConcurrentHashMap = new ConcurrentHashMap<>(); + defaultConfigCache.forEach((k, v) -> { + if (k.getBusinessType().equals(businessType)) { + stringStringConcurrentHashMap.put(k.getConfigName(), v); + } + }); + return stringStringConcurrentHashMap; + } } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/synchronous/SyncConnectorConfigTask.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/synchronous/SyncConnectorConfigTask.java index 59351866..c24bb9f4 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/synchronous/SyncConnectorConfigTask.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/synchronous/SyncConnectorConfigTask.java @@ -52,7 +52,8 @@ public void synchronousConnectorConfig(Long clusterId) { ConfigEntity configEntity = this.getConfigEntityBelongInstance(clusterId, connectorEntity.getId()); - ConcurrentHashMap connectorConfigMapFromDb = this.configListToMap(configService.selectByInstanceId(configEntity)); + ConcurrentHashMap connectorConfigMapFromDb = + this.configListToMap(configService.selectByInstanceIdAndType(configEntity.getInstanceId(), configEntity.getInstanceType())); ConcurrentHashMap updateConfigMap = new ConcurrentHashMap<>(); diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/synchronous/SyncRuntimeConfigTask.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/synchronous/SyncRuntimeConfigTask.java index 51ee24f1..aa3297c9 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/synchronous/SyncRuntimeConfigTask.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/synchronous/SyncRuntimeConfigTask.java @@ -55,7 +55,8 @@ public void synchronousRuntimeConfig(Long clusterId) { ConfigEntity configEntity = this.getConfigEntityBelongInstance(clusterId, runtimeEntity.getId()); - ConcurrentHashMap runtimeConfigMapFromDb = this.configListToMap(configService.selectByInstanceId(configEntity)); + ConcurrentHashMap runtimeConfigMapFromDb = + this.configListToMap(configService.selectByInstanceIdAndType(configEntity.getInstanceId(), configEntity.getInstanceType())); ConcurrentHashMap updateConfigMap = new ConcurrentHashMap<>(); diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/synchronous/SyncStoreConfigTask.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/synchronous/SyncStoreConfigTask.java index f5235b0a..4a5b0209 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/synchronous/SyncStoreConfigTask.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/synchronous/SyncStoreConfigTask.java @@ -46,34 +46,34 @@ public class SyncStoreConfigTask { private ConfigService configService; public void synchronousStoreConfig(Long clusterId) { - List storeEntityList = storeService.selectStoreByCluster(clusterId); - for (StoreEntity storeEntity : storeEntityList) { + StoreEntity storeEntity = storeService.selectStoreByCluster(clusterId); - ConcurrentHashMap storeConfigMapFromInstance = this.configListToMap( - storeConfigService.getStorageConfigFromInstance(clusterId, storeEntity.getHost())); + ConcurrentHashMap storeConfigMapFromInstance = this.configListToMap( + storeConfigService.getStorageConfigFromInstance(clusterId, storeEntity.getHost())); - ConfigEntity configEntity = this.getConfigEntityBelongInstance(clusterId, storeEntity.getId()); + ConfigEntity configEntity = this.getConfigEntityBelongInstance(clusterId, storeEntity.getId()); - ConcurrentHashMap storeConfigMapFromDb = this.configListToMap(configService.selectByInstanceId(configEntity)); + ConcurrentHashMap storeConfigMapFromDb = + this.configListToMap(configService.selectByInstanceIdAndType(configEntity.getInstanceId(), configEntity.getInstanceType())); - ConcurrentHashMap updateConfigMap = new ConcurrentHashMap<>(); + ConcurrentHashMap updateConfigMap = new ConcurrentHashMap<>(); - storeConfigMapFromInstance.entrySet().forEach(n -> { - if (storeConfigMapFromDb.remove(n.getKey(), n.getValue())) { - storeConfigMapFromInstance.remove(n.getKey()); - } - if (storeConfigMapFromDb.get(n.getKey()) != null) { - updateConfigMap.put(n.getKey(), storeConfigMapFromDb.get(n.getKey())); - storeConfigMapFromInstance.remove(n.getKey()); - storeConfigMapFromDb.remove(n.getKey()); - } - }); - //add storeConfigMapFromDb + storeConfigMapFromInstance.entrySet().forEach(n -> { + if (storeConfigMapFromDb.remove(n.getKey(), n.getValue())) { + storeConfigMapFromInstance.remove(n.getKey()); + } + if (storeConfigMapFromDb.get(n.getKey()) != null) { + updateConfigMap.put(n.getKey(), storeConfigMapFromDb.get(n.getKey())); + storeConfigMapFromInstance.remove(n.getKey()); + storeConfigMapFromDb.remove(n.getKey()); + } + }); + //add storeConfigMapFromDb + + //update updateConfigMap - //update updateConfigMap + //delete storeConfigMapFromInstance - //delete storeConfigMapFromInstance - } } private ConcurrentHashMap configListToMap(List configEntityList) { diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/synchronous/SyncTopicConfigTask.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/synchronous/SyncTopicConfigTask.java index eada0b97..4df55e05 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/synchronous/SyncTopicConfigTask.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/config/synchronous/SyncTopicConfigTask.java @@ -54,7 +54,8 @@ public void synchronousTopicConfig(Long clusterId) { ConfigEntity configEntity = this.getConfigEntityBelongInstance(clusterId, topicEntity.getId()); - ConcurrentHashMap topicConfigMapFromDb = this.configListToMap(configService.selectByInstanceId(configEntity)); + ConcurrentHashMap topicConfigMapFromDb = + this.configListToMap(configService.selectByInstanceIdAndType(configEntity.getInstanceId(), configEntity.getInstanceType())); ConcurrentHashMap updateConfigMap = new ConcurrentHashMap<>(); 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 index e4db317d..33954bb5 100644 --- 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 @@ -17,7 +17,12 @@ package org.apache.eventmesh.dashboard.console.service.connection; +import org.apache.eventmesh.dashboard.console.entity.config.ConfigEntity; import org.apache.eventmesh.dashboard.console.entity.connection.ConnectionEntity; +import org.apache.eventmesh.dashboard.console.entity.connector.ConnectorEntity; +import org.apache.eventmesh.dashboard.console.modle.dto.connection.CreateConnectionDTO; +import org.apache.eventmesh.dashboard.console.modle.dto.connection.GetConnectionListDTO; +import org.apache.eventmesh.dashboard.console.modle.vo.connection.ConnectionListVO; import java.util.List; @@ -26,11 +31,22 @@ */ public interface ConnectionDataService { - Integer selectConnectionNumByCluster(Long clusterId); + ConnectorEntity getConnectorById(Long connectorId); - List getAllConnections(); + List getConnectorBusinessType(String type); List getAllConnectionsByClusterId(Long clusterId); + boolean createConnection(CreateConnectionDTO createConnectionDTO); + + List getAllConnections(); + + List getConnectionToFrontByCluster(Long clusterId, GetConnectionListDTO getConnectionListDTO); + void replaceAllConnections(List connectionEntityList); + + + List getConnectorConfigsByClassAndVersion(String classType, String version); + + void insert(ConnectionEntity connectionEntity); } 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 b8c66348..6f593894 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 @@ -17,10 +17,21 @@ package org.apache.eventmesh.dashboard.console.service.connection.impl; + +import org.apache.eventmesh.dashboard.console.annotation.EmLog; +import org.apache.eventmesh.dashboard.console.entity.config.ConfigEntity; import org.apache.eventmesh.dashboard.console.entity.connection.ConnectionEntity; +import org.apache.eventmesh.dashboard.console.entity.connector.ConnectorEntity; +import org.apache.eventmesh.dashboard.console.mapper.config.ConfigMapper; import org.apache.eventmesh.dashboard.console.mapper.connection.ConnectionMapper; +import org.apache.eventmesh.dashboard.console.mapper.connector.ConnectorMapper; +import org.apache.eventmesh.dashboard.console.modle.dto.connection.AddConnectionDTO; +import org.apache.eventmesh.dashboard.console.modle.dto.connection.CreateConnectionDTO; +import org.apache.eventmesh.dashboard.console.modle.dto.connection.GetConnectionListDTO; +import org.apache.eventmesh.dashboard.console.modle.vo.connection.ConnectionListVO; import org.apache.eventmesh.dashboard.console.service.connection.ConnectionDataService; +import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -36,6 +47,26 @@ public class ConnectionDataServiceDatabaseImpl implements ConnectionDataService @Autowired private ConnectionMapper connectionMapper; + @Autowired + private ConnectorMapper connectorMapper; + + @Autowired + private ConfigMapper configMapper; + + + @Override + public ConnectorEntity getConnectorById(Long connectorId) { + ConnectorEntity connectorEntity = new ConnectorEntity(); + connectorEntity.setId(connectorId); + return connectorMapper.selectById(connectorEntity); + } + + @Override + public List getConnectorBusinessType(String type) { + ConfigEntity config = new ConfigEntity(); + config.setBusinessType(type); + return configMapper.selectConnectorBusinessType(config); + } @Override public List getAllConnectionsByClusterId(Long clusterId) { @@ -44,19 +75,117 @@ public List getAllConnectionsByClusterId(Long clusterId) { return connectionMapper.selectByClusterId(connectionEntity); } + @Override + public void insert(ConnectionEntity connectionEntity) { + connectionMapper.insert(connectionEntity); + } + + @EmLog(OprType = "add", OprTarget = "Connection") @Override - public Integer selectConnectionNumByCluster(Long clusterId) { + public boolean createConnection(CreateConnectionDTO createConnectionDTO) { + ConnectorEntity sinkConnector = this.createSinkConnector(createConnectionDTO.getClusterId(), createConnectionDTO.getAddConnectionDTO()); + ConnectorEntity sourceConnector = this.createSourceConnector(createConnectionDTO.getClusterId(), createConnectionDTO.getAddConnectionDTO()); + ConnectionEntity connectionEntity = this.setConnection(createConnectionDTO); + connectionEntity.setSinkId(sinkConnector.getId()); + connectionEntity.setSourceId(sourceConnector.getId()); + connectionMapper.insert(connectionEntity); + this.addConnectorConfigs(createConnectionDTO.getAddConnectorConfigDTO().getSinkConnectorConfigs(), sinkConnector); + this.addConnectorConfigs(createConnectionDTO.getAddConnectorConfigDTO().getSourceConnectorConfigs(), sourceConnector); + return false; + } + + private ConnectionEntity setConnection(CreateConnectionDTO createConnectionDTO) { ConnectionEntity connectionEntity = new ConnectionEntity(); - connectionEntity.setClusterId(clusterId); - return connectionMapper.selectConnectionNumByCluster(connectionEntity); + connectionEntity.setClusterId(createConnectionDTO.getClusterId()); + connectionEntity.setSourceType("connector"); + connectionEntity.setSinkType("connector"); + connectionEntity.setRuntimeId(-1L); + connectionEntity.setGroupId(createConnectionDTO.getAddConnectionDTO().getGroupId()); + connectionEntity.setStatus(1); + connectionEntity.setDescription(createConnectionDTO.getAddConnectionDTO().getConnectionDescription()); + connectionEntity.setTopic(createConnectionDTO.getAddConnectionDTO().getTopicName()); + return connectionEntity; + } + + public void addConnectorConfigs(List configEntityList, ConnectorEntity connectorEntity) { + configEntityList.forEach(n -> { + n.setInstanceId(connectorEntity.getId()); + n.setIsDefault(0); + n.setClusterId(connectorEntity.getClusterId()); + }); + configMapper.batchInsert(configEntityList); } + public ConnectorEntity createSinkConnector(Long clusterId, AddConnectionDTO addConnectionDTO) { + ConnectorEntity connectorEntity = new ConnectorEntity(); + connectorEntity.setName(addConnectionDTO.getSinkName()); + connectorEntity.setHost(addConnectionDTO.getSinkHost()); + connectorEntity.setClusterId(clusterId); + connectorEntity.setClassName(addConnectionDTO.getSinkClass()); + connectorEntity.setType("Connector"); + connectorEntity.setStatus(1); + connectorEntity.setPodState(0); + connectorEntity.setPort(addConnectionDTO.getSinkPort()); + connectorMapper.insert(connectorEntity); + return connectorEntity; + } + + public ConnectorEntity createSourceConnector(Long clusterId, AddConnectionDTO addConnectionDTO) { + ConnectorEntity connectorEntity = new ConnectorEntity(); + connectorEntity.setName(addConnectionDTO.getSourceName()); + connectorEntity.setHost(addConnectionDTO.getSourceHost()); + connectorEntity.setClusterId(clusterId); + connectorEntity.setClassName(addConnectionDTO.getSourceClass()); + connectorEntity.setType("Connector"); + connectorEntity.setStatus(1); + connectorEntity.setPodState(0); + connectorEntity.setPort(addConnectionDTO.getSourcePort()); + connectorMapper.insert(connectorEntity); + return connectorEntity; + } + + @Override public List getAllConnections() { return connectionMapper.selectAll(); } + public ConnectionEntity setSearchCriteria(GetConnectionListDTO getConnectionListDTO, ConnectionEntity connectionEntity) { + connectionEntity.setTopic(getConnectionListDTO.getTopicName()); + return connectionEntity; + } + + @Override + public List getConnectionToFrontByCluster(Long clusterId, GetConnectionListDTO getConnectionListDTO) { + ConnectionEntity connectionEntity = new ConnectionEntity(); + connectionEntity.setClusterId(clusterId); + connectionEntity = this.setSearchCriteria(getConnectionListDTO, connectionEntity); + List allConnectionsByClusterId = connectionMapper.selectToFrontByClusterId(connectionEntity); + List connectionListVOs = new ArrayList<>(); + allConnectionsByClusterId.forEach(n -> { + connectionListVOs.add(this.setConnectionListVO(n)); + }); + return connectionListVOs; + } + + private ConnectionListVO setConnectionListVO(ConnectionEntity connectionEntity) { + ConnectionListVO connectionListVO = new ConnectionListVO(); + ConnectorEntity connectorEntity = new ConnectorEntity(); + connectorEntity.setId(connectionEntity.getSinkId()); + ConnectorEntity sinkConnector = connectorMapper.selectById(connectorEntity); + connectorEntity.setId(connectionEntity.getSourceId()); + ConnectorEntity sourceConnector = connectorMapper.selectById(connectorEntity); + connectionListVO.setSinkClass(sinkConnector.getClassName()); + connectionListVO.setSourceClass(sourceConnector.getClassName()); + connectionListVO.setSinkConnectorId(sinkConnector.getId()); + connectionListVO.setSourceConnectorId(sourceConnector.getId()); + connectionListVO.setSinkConnectorName(sinkConnector.getName()); + connectionListVO.setSourceConnectorName(sourceConnector.getName()); + connectionListVO.setTopicName(connectionEntity.getTopic()); + connectionListVO.setStatus(connectionEntity.getStatus()); + return connectionListVO; + } @Override @Transactional @@ -90,5 +219,19 @@ public void replaceAllConnections(List connectionEntityList) { } }); } + + + @Override + public List getConnectorConfigsByClassAndVersion(String classType, String version) { + ConfigEntity config = new ConfigEntity(); + config.setBusinessType(classType); + List configEntityList = configMapper.selectConnectorConfigsByBusinessType(config); + configEntityList.forEach(n -> { + if (!n.matchVersion(version)) { + configEntityList.remove(n); + } + }); + return configEntityList; + } } 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 index a32bbf9e..b5f05232 100644 --- 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 @@ -27,4 +27,6 @@ public interface ConnectorDataService { List selectConnectorByCluster(Long clusterId); + + List selectByHostPort(ConnectorEntity connectorEntity); } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/connector/Impl/ConnectorDataServiceImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/connector/Impl/ConnectorDataServiceImpl.java index 7a9a7066..21d60e81 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/connector/Impl/ConnectorDataServiceImpl.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/connector/Impl/ConnectorDataServiceImpl.java @@ -38,4 +38,9 @@ public List selectConnectorByCluster(Long clusterId) { connectorEntity.setClusterId(clusterId); return connectorMapper.selectByClusterId(connectorEntity); } + + @Override + public List selectByHostPort(ConnectorEntity connectorEntity) { + return null; + } } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/health/HealthDataService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/health/HealthDataService.java index 19e3715e..25faa8eb 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/health/HealthDataService.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/health/HealthDataService.java @@ -17,7 +17,9 @@ package org.apache.eventmesh.dashboard.console.service.health; + import org.apache.eventmesh.dashboard.console.entity.health.HealthCheckResultEntity; +import org.apache.eventmesh.dashboard.console.modle.vo.health.InstanceLiveProportionVo; import java.sql.Timestamp; import java.util.List; @@ -26,6 +28,11 @@ * Service providing data of HealthCheckResult. */ public interface HealthDataService { + + InstanceLiveProportionVo getInstanceLiveProportion(Long clusterId, Integer instanceType); + + List getInstanceLiveStatusHistory(Integer type, Long clusterId, Timestamp startTime); + HealthCheckResultEntity insertHealthCheckResult(HealthCheckResultEntity healthCheckResultEntity); void batchInsertHealthCheckResult(List healthCheckResultEntityList); diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/health/impl/HealthDataServiceDatabaseImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/health/impl/HealthDataServiceDatabaseImpl.java index f1593cc9..e4e2d852 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/health/impl/HealthDataServiceDatabaseImpl.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/health/impl/HealthDataServiceDatabaseImpl.java @@ -17,8 +17,15 @@ package org.apache.eventmesh.dashboard.console.service.health.impl; + import org.apache.eventmesh.dashboard.console.entity.health.HealthCheckResultEntity; +import org.apache.eventmesh.dashboard.console.entity.runtime.RuntimeEntity; +import org.apache.eventmesh.dashboard.console.entity.topic.TopicEntity; +import org.apache.eventmesh.dashboard.console.function.health.CheckResultCache; import org.apache.eventmesh.dashboard.console.mapper.health.HealthCheckResultMapper; +import org.apache.eventmesh.dashboard.console.mapper.runtime.RuntimeMapper; +import org.apache.eventmesh.dashboard.console.mapper.topic.TopicMapper; +import org.apache.eventmesh.dashboard.console.modle.vo.health.InstanceLiveProportionVo; import org.apache.eventmesh.dashboard.console.service.health.HealthDataService; import java.sql.Timestamp; @@ -33,6 +40,68 @@ public class HealthDataServiceDatabaseImpl implements HealthDataService { @Autowired private HealthCheckResultMapper healthCheckResultMapper; + @Autowired + private RuntimeMapper runtimeMapper; + + @Autowired + private TopicMapper topicMapper; + + + @Override + public InstanceLiveProportionVo getInstanceLiveProportion(Long clusterId, Integer instanceType) { + InstanceLiveProportionVo instanceLiveProportionVo = new InstanceLiveProportionVo(); + switch (instanceType) { + case 2: + instanceLiveProportionVo = this.getRuntimeLiveProportion(clusterId); + break; + case 3: + instanceLiveProportionVo = this.getTopicLiveProportion(clusterId); + break; + default: + break; + } + return instanceLiveProportionVo; + } + + public InstanceLiveProportionVo getTopicLiveProportion(Long clusterId) { + TopicEntity topicEntity = new TopicEntity(); + topicEntity.setClusterId(clusterId); + Integer topicNum = topicMapper.selectTopicNumByCluster(topicEntity); + List topicEntityList = topicMapper.selectTopicByCluster(topicEntity); + int abnormalNum = 0; + for (TopicEntity n : topicEntityList) { + if (CheckResultCache.getLastHealthyCheckResult("topic", n.getId()) == 0) { + abnormalNum++; + } + } + return new InstanceLiveProportionVo(abnormalNum, topicNum); + } + + + public InstanceLiveProportionVo getRuntimeLiveProportion(Long clusterId) { + RuntimeEntity runtimeEntity = new RuntimeEntity(); + runtimeEntity.setClusterId(clusterId); + Integer topicNum = runtimeMapper.getRuntimeNumByCluster(runtimeEntity); + List runtimeEntities = runtimeMapper.selectRuntimeByCluster(runtimeEntity); + int abnormalNum = 0; + for (RuntimeEntity n : runtimeEntities) { + if (CheckResultCache.getLastHealthyCheckResult("runtime", n.getId()) == 0) { + abnormalNum++; + } + } + return new InstanceLiveProportionVo(abnormalNum, topicNum); + } + + + @Override + public List getInstanceLiveStatusHistory(Integer type, Long instanceId, Timestamp startTime) { + HealthCheckResultEntity healthCheckResultEntity = new HealthCheckResultEntity(); + healthCheckResultEntity.setType(type); + healthCheckResultEntity.setTypeId(instanceId); + healthCheckResultEntity.setCreateTime(startTime); + return healthCheckResultMapper.getInstanceLiveStatusHistory(healthCheckResultEntity); + } + @Override public HealthCheckResultEntity insertHealthCheckResult(HealthCheckResultEntity healthCheckResultEntity) { healthCheckResultMapper.insert(healthCheckResultEntity); diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/log/LogService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/log/LogService.java index d496ae6e..4db80fed 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/log/LogService.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/log/LogService.java @@ -18,18 +18,20 @@ package org.apache.eventmesh.dashboard.console.service.log; import org.apache.eventmesh.dashboard.console.entity.log.LogEntity; +import org.apache.eventmesh.dashboard.console.modle.dto.log.GetLogListDTO; import java.util.List; +import org.springframework.stereotype.Service; + /** - * * operation service - * */ +@Service public interface LogService { - List getLogListByCluster(LogEntity logEntity); + List getLogListByCluster(GetLogListDTO getLogListDTO); Long addLog(LogEntity logEntity); diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/log/LogServiceImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/log/LogServiceImpl.java index 7bd680be..33096eeb 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/log/LogServiceImpl.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/log/LogServiceImpl.java @@ -19,6 +19,7 @@ import org.apache.eventmesh.dashboard.console.entity.log.LogEntity; import org.apache.eventmesh.dashboard.console.mapper.log.OprLogMapper; +import org.apache.eventmesh.dashboard.console.modle.dto.log.GetLogListDTO; import java.util.List; @@ -32,9 +33,14 @@ public class LogServiceImpl implements LogService { OprLogMapper oprLogMapper; @Override - public List getLogListByCluster(LogEntity logEntity) { - - return oprLogMapper.getLogList(logEntity); + public List getLogListByCluster(GetLogListDTO getLogListDTO) { + LogEntity logEntity = new LogEntity(); + logEntity.setClusterId(getLogListDTO.getClusterId()); + logEntity.setTargetType(getLogListDTO.getTargetType()); + logEntity.setOperationType(getLogListDTO.getOperationType()); + logEntity.setState(getLogListDTO.getState()); + logEntity.setOperationUser(getLogListDTO.getOperationUser()); + return oprLogMapper.getLogListToFront(logEntity); } @Override diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/registry/RegistryDataService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/registry/RegistryDataService.java new file mode 100644 index 00000000..344aad61 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/registry/RegistryDataService.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.eventmesh.dashboard.console.service.registry; + + +import org.apache.eventmesh.dashboard.console.entity.meta.MetaEntity; + +import java.util.List; + +/** + * Database service of registry(meta) such as nacos + */ +public interface RegistryDataService { + + List selectAll(); + + void batchInsert(List metaEntities); + + void insert(MetaEntity metaEntity); + + void deactivate(MetaEntity metaEntity); +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/registry/impl/RegistryDataServiceImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/registry/impl/RegistryDataServiceImpl.java new file mode 100644 index 00000000..741a326b --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/registry/impl/RegistryDataServiceImpl.java @@ -0,0 +1,53 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.eventmesh.dashboard.console.service.registry.impl; + +import org.apache.eventmesh.dashboard.console.entity.meta.MetaEntity; +import org.apache.eventmesh.dashboard.console.mapper.meta.MetaMapper; +import org.apache.eventmesh.dashboard.console.service.registry.RegistryDataService; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class RegistryDataServiceImpl implements RegistryDataService { + + @Autowired + MetaMapper metaMapper; + + public List selectAll() { + return metaMapper.selectAll(); + } + + @Override + public void batchInsert(List metaEntities) { + metaMapper.batchInsert(metaEntities); + } + + @Override + public void insert(MetaEntity metaEntity) { + metaMapper.insert(metaEntity); + } + + @Override + public void deactivate(MetaEntity metaEntity) { + metaMapper.deactivate(metaEntity); + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/runtime/Impl/RuntimeServiceImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/runtime/Impl/RuntimeServiceImpl.java index da6cd0f6..3dc58ab1 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/runtime/Impl/RuntimeServiceImpl.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/runtime/Impl/RuntimeServiceImpl.java @@ -17,8 +17,12 @@ package org.apache.eventmesh.dashboard.console.service.runtime.Impl; + import org.apache.eventmesh.dashboard.console.entity.runtime.RuntimeEntity; +import org.apache.eventmesh.dashboard.console.function.health.CheckResultCache; +import org.apache.eventmesh.dashboard.console.mapper.health.HealthCheckResultMapper; import org.apache.eventmesh.dashboard.console.mapper.runtime.RuntimeMapper; +import org.apache.eventmesh.dashboard.console.modle.dto.runtime.GetRuntimeListDTO; import org.apache.eventmesh.dashboard.console.service.runtime.RuntimeService; import java.util.List; @@ -32,6 +36,27 @@ public class RuntimeServiceImpl implements RuntimeService { @Autowired private RuntimeMapper runtimeMapper; + @Autowired + private HealthCheckResultMapper healthCheckResultMapper; + + public RuntimeEntity setSearchCriteria(GetRuntimeListDTO getRuntimeListDTO, RuntimeEntity runtimeEntity) { + runtimeEntity.setHost(getRuntimeListDTO.getHost()); + return runtimeEntity; + } + + @Override + public List getRuntimeToFrontByClusterId(Long clusterId, GetRuntimeListDTO getRuntimeListDTO) { + RuntimeEntity runtimeEntity = new RuntimeEntity(); + runtimeEntity.setClusterId(clusterId); + runtimeEntity = this.setSearchCriteria(getRuntimeListDTO, runtimeEntity); + List runtimeByClusterId = runtimeMapper.getRuntimesToFrontByCluster(runtimeEntity); + runtimeByClusterId.forEach(n -> { + n.setStatus(CheckResultCache.getLastHealthyCheckResult("runtime", n.getId())); + }); + return runtimeByClusterId; + } + + @Override public void batchInsert(List runtimeEntities) { runtimeMapper.batchInsert(runtimeEntities); @@ -46,9 +71,15 @@ public List selectAll() { public List getRuntimeByClusterId(Long clusterId) { RuntimeEntity runtimeEntity = new RuntimeEntity(); runtimeEntity.setClusterId(clusterId); + return runtimeMapper.selectRuntimeByCluster(runtimeEntity); } + @Override + public List selectByHostPort(RuntimeEntity runtimeEntity) { + return runtimeMapper.selectByHostPort(runtimeEntity); + } + @Override public void addRuntime(RuntimeEntity runtimeEntity) { runtimeMapper.addRuntime(runtimeEntity); @@ -63,4 +94,9 @@ public void updateRuntimeByCluster(RuntimeEntity runtimeEntity) { public void deleteRuntimeByCluster(RuntimeEntity runtimeEntity) { runtimeMapper.deleteRuntimeByCluster(runtimeEntity); } + + @Override + public void deactivate(RuntimeEntity runtimeEntity) { + runtimeMapper.deactivate(runtimeEntity); + } } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/runtime/RuntimeService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/runtime/RuntimeService.java index 65f1a4e0..f5ea5edc 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/runtime/RuntimeService.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/runtime/RuntimeService.java @@ -17,7 +17,9 @@ package org.apache.eventmesh.dashboard.console.service.runtime; + import org.apache.eventmesh.dashboard.console.entity.runtime.RuntimeEntity; +import org.apache.eventmesh.dashboard.console.modle.dto.runtime.GetRuntimeListDTO; import java.util.List; @@ -26,15 +28,21 @@ */ public interface RuntimeService { + List getRuntimeToFrontByClusterId(Long clusterId, GetRuntimeListDTO getRuntimeListDTO); + void batchInsert(List runtimeEntities); List selectAll(); List getRuntimeByClusterId(Long cluster); + List selectByHostPort(RuntimeEntity runtimeEntity); + void addRuntime(RuntimeEntity runtimeEntity); void updateRuntimeByCluster(RuntimeEntity runtimeEntity); void deleteRuntimeByCluster(RuntimeEntity runtimeEntity); + + void deactivate(RuntimeEntity runtimeEntity); } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/store/Impl/StoreServiceImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/store/Impl/StoreServiceImpl.java index db992e2a..65290c0d 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/store/Impl/StoreServiceImpl.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/store/Impl/StoreServiceImpl.java @@ -32,11 +32,26 @@ public class StoreServiceImpl implements StoreService { @Autowired private StoreMapper storeMapper; + @Override + public StoreEntity getStoreToFrontListByCluster(Long clusterId) { + StoreEntity storeEntity = new StoreEntity(); + storeEntity.setClusterId(clusterId); + return storeMapper.selectStoreByCluster(storeEntity); + } + + @Override public List selectAll() { return storeMapper.selectAll(); } + @Override + public StoreEntity selectById(Long storeId) { + StoreEntity query = new StoreEntity(); + query.setId(storeId); + return storeMapper.selectById(query); + } + @Override public void batchInsert(List storeEntities) { storeMapper.batchInsert(storeEntities); @@ -53,7 +68,7 @@ public void deleteStoreByUnique(StoreEntity storeEntity) { } @Override - public List selectStoreByCluster(Long clusterId) { + public StoreEntity selectStoreByCluster(Long clusterId) { StoreEntity storeEntity = new StoreEntity(); storeEntity.setClusterId(clusterId); return storeMapper.selectStoreByCluster(storeEntity); diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/store/StoreService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/store/StoreService.java index 605b8b57..340b5efc 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/store/StoreService.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/store/StoreService.java @@ -26,15 +26,19 @@ */ public interface StoreService { + StoreEntity getStoreToFrontListByCluster(Long clusterId); + List selectAll(); + StoreEntity selectById(Long storeId); + void batchInsert(List storeEntities); void addStore(StoreEntity storeEntity); void deleteStoreByUnique(StoreEntity storeEntity); - List selectStoreByCluster(Long clusterId); + StoreEntity selectStoreByCluster(Long clusterId); void updateStoreByUnique(StoreEntity storeEntity); } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/topic/TopicService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/topic/TopicService.java index 3f0b986a..e3430527 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/topic/TopicService.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/topic/TopicService.java @@ -18,6 +18,9 @@ package org.apache.eventmesh.dashboard.console.service.topic; import org.apache.eventmesh.dashboard.console.entity.topic.TopicEntity; +import org.apache.eventmesh.dashboard.console.modle.dto.topic.CreateTopicDTO; +import org.apache.eventmesh.dashboard.console.modle.dto.topic.GetTopicListDTO; +import org.apache.eventmesh.dashboard.console.modle.vo.topic.TopicDetailGroupVO; import java.util.List; @@ -26,12 +29,14 @@ */ public interface TopicService { + public List getTopicDetailGroups(Long topicId); + + void createTopic(CreateTopicDTO topicRequest); + void batchInsert(List topicEntities); List selectAll(); - Integer selectTopicNumByCluster(Long clusterId); - List getTopicList(TopicEntity topicEntity); void addTopic(TopicEntity topicEntity); @@ -40,11 +45,13 @@ public interface TopicService { void deleteTopicById(TopicEntity topicEntity); - TopicEntity selectTopicById(TopicEntity topicEntity); + TopicEntity selectTopicById(Long topicId); TopicEntity selectTopicByUnique(TopicEntity topicEntity); void deleteTopic(TopicEntity topicEntity); List selectTopiByCluster(Long clusterId); + + List getTopicListToFront(Long clusterId, GetTopicListDTO getTopicListDTO); } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/topic/TopicServiceImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/topic/TopicServiceImpl.java index e15f7c48..d99cd705 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/topic/TopicServiceImpl.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/topic/TopicServiceImpl.java @@ -17,11 +17,25 @@ package org.apache.eventmesh.dashboard.console.service.topic; + +import org.apache.eventmesh.dashboard.console.annotation.EmLog; +import org.apache.eventmesh.dashboard.console.entity.group.GroupEntity; import org.apache.eventmesh.dashboard.console.entity.groupmember.GroupMemberEntity; +import org.apache.eventmesh.dashboard.console.entity.storage.StoreEntity; import org.apache.eventmesh.dashboard.console.entity.topic.TopicEntity; +import org.apache.eventmesh.dashboard.console.function.health.CheckResultCache; +import org.apache.eventmesh.dashboard.console.mapper.config.ConfigMapper; +import org.apache.eventmesh.dashboard.console.mapper.group.OprGroupMapper; import org.apache.eventmesh.dashboard.console.mapper.groupmember.OprGroupMemberMapper; +import org.apache.eventmesh.dashboard.console.mapper.health.HealthCheckResultMapper; +import org.apache.eventmesh.dashboard.console.mapper.runtime.RuntimeMapper; +import org.apache.eventmesh.dashboard.console.mapper.storage.StoreMapper; import org.apache.eventmesh.dashboard.console.mapper.topic.TopicMapper; +import org.apache.eventmesh.dashboard.console.modle.dto.topic.CreateTopicDTO; +import org.apache.eventmesh.dashboard.console.modle.dto.topic.GetTopicListDTO; +import org.apache.eventmesh.dashboard.console.modle.vo.topic.TopicDetailGroupVO; +import java.util.ArrayList; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; @@ -36,6 +50,62 @@ public class TopicServiceImpl implements TopicService { @Autowired OprGroupMemberMapper oprGroupMemberMapper; + @Autowired + HealthCheckResultMapper healthCheckResultMapper; + + @Autowired + ConfigMapper configMapper; + + @Autowired + RuntimeMapper runtimeMapper; + + @Autowired + StoreMapper storeMapper; + + @Autowired + OprGroupMapper groupMapper; + + + @Override + public List getTopicDetailGroups(Long topicId) { + TopicEntity topicEntity = this.selectTopicById(topicId); + GroupMemberEntity groupMemberEntity = new GroupMemberEntity(); + groupMemberEntity.setClusterId(topicEntity.getClusterId()); + groupMemberEntity.setTopicName(topicEntity.getTopicName()); + List groupNamelist = oprGroupMemberMapper.selectGroupNameByTopicName(groupMemberEntity); + ArrayList topicDetailGroupVOList = new ArrayList<>(); + groupNamelist.forEach(n -> { + TopicDetailGroupVO topicDetailGroupVO = new TopicDetailGroupVO(); + topicDetailGroupVO.setGroupName(n); + groupMemberEntity.setGroupName(n); + List list = oprGroupMemberMapper.selectTopicsByGroupNameAndClusterId(groupMemberEntity); + topicDetailGroupVO.setTopics(list); + GroupEntity groupEntity = new GroupEntity(); + groupEntity.setClusterId(topicEntity.getClusterId()); + groupEntity.setName(n); + GroupEntity group = groupMapper.selectGroupByNameAndClusterId(groupEntity); + topicDetailGroupVO.setMemberNum(group.getMemberCount()); + topicDetailGroupVO.setState(group.getState()); + topicDetailGroupVOList.add(topicDetailGroupVO); + }); + return topicDetailGroupVOList; + } + + @EmLog(OprType = "add", OprTarget = "topic") + @Override + public void createTopic(CreateTopicDTO createTopicDTO) { + TopicEntity topicEntity = new TopicEntity(); + topicEntity.setType(0); + topicEntity.setClusterId(createTopicDTO.getClusterId()); + topicEntity.setTopicName(createTopicDTO.getName()); + topicEntity.setDescription(createTopicDTO.getDescription()); + topicEntity.setRetentionMs(createTopicDTO.getSaveTime().getTime()); + StoreEntity storeEntity = new StoreEntity(); + storeEntity.setClusterId(topicEntity.getClusterId()); + topicEntity.setStorageId(String.valueOf(storeMapper.selectStoreByCluster(storeEntity).getId())); + topicEntity.setCreateProgress(1); + topicMapper.addTopic(topicEntity); + } @Override public void batchInsert(List topicEntities) { @@ -47,12 +117,7 @@ public List selectAll() { return topicMapper.selectAll(); } - @Override - public Integer selectTopicNumByCluster(Long clusterId) { - TopicEntity topicEntity = new TopicEntity(); - topicEntity.setClusterId(clusterId); - return topicMapper.selectTopicNumByCluster(topicEntity); - } + @Override public List getTopicList(TopicEntity topicEntity) { @@ -79,7 +144,9 @@ public void deleteTopicById(TopicEntity topicEntity) { } @Override - public TopicEntity selectTopicById(TopicEntity topicEntity) { + public TopicEntity selectTopicById(Long topicId) { + TopicEntity topicEntity = new TopicEntity(); + topicEntity.setId(topicId); return topicMapper.selectTopicById(topicEntity); } @@ -88,12 +155,9 @@ public TopicEntity selectTopicByUnique(TopicEntity topicEntity) { return topicMapper.selectTopicByUnique(topicEntity); } + @Override public void deleteTopic(TopicEntity topicEntity) { - GroupMemberEntity groupMemberEntity = new GroupMemberEntity(); - groupMemberEntity.setTopicName(topicEntity.getTopicName()); - groupMemberEntity.setState("empty"); - oprGroupMemberMapper.updateMemberByTopic(groupMemberEntity); topicMapper.deleteTopic(topicEntity); } @@ -105,4 +169,22 @@ public List selectTopiByCluster(Long clusterId) { } + public TopicEntity setSearchCriteria(GetTopicListDTO getTopicListDTO, TopicEntity topicEntity) { + topicEntity.setTopicName(getTopicListDTO.getTopicName()); + return topicEntity; + } + + @Override + public List getTopicListToFront(Long clusterId, GetTopicListDTO getTopicListDTO) { + TopicEntity topicEntity = new TopicEntity(); + topicEntity.setClusterId(clusterId); + topicEntity = this.setSearchCriteria(getTopicListDTO, topicEntity); + List topicEntityList = topicMapper.getTopicsToFrontByClusterId(topicEntity); + topicEntityList.forEach(n -> { + n.setStatus(CheckResultCache.getLastHealthyCheckResult("topic", n.getId())); + }); + return topicEntityList; + } + + } diff --git a/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql b/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql index 0e31fbd6..e4fc2715 100644 --- a/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql +++ b/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql @@ -20,7 +20,7 @@ create table cluster id bigint unsigned auto_increment comment '集群id' primary key, name varchar(128) default '' not null comment '集群名称', - register_name_list varchar(4096) default '' not null comment '注册中心名字', + registry_name_list varchar(4096) default '' not null comment '注册中心名字', bootstrap_servers varchar(2048) default '' not null comment 'server地址', eventmesh_version varchar(32) default '' not null comment 'eventmesh版本', client_properties text null comment 'EventMesh客户端配置', @@ -47,8 +47,10 @@ create table config id bigint unsigned auto_increment primary key, cluster_id bigint default -1 not null comment '集群ID', - business_type varchar(64) default '' not null comment '业务类型', - instance_type tinyint not null comment '配置类型 0:runtime,1:storage,2:connector,3:topic', + business_type varchar(64) default '' not null comment '业务类型,storage:可选值(rocketmq,pravega,mongodb,pulsar,redis,kafka + ,knative,rabbitmq),sinkConnector:可选值(rocketmq,spring,pravega,wechat,openfunction,file,knative,pulsar,lark,slack,rabbitmq,redis,mongodb,dingtalk) + ,sourceConnector:可选值(rocketmq,spring,pravega,openfunction,jdbc,file,http,wecom,knative,pulsar,prometheus,rabbitmq,redis,mongodb)', + instance_type tinyint not null comment '实例类型 0:runtime,1:storage,2:connector,3:topic', instance_id bigint default -1 not null comment '实例ID,上面配置对应的(比如runtime)的id', config_name varchar(192) default '' not null comment '配置名称', config_value text null comment '配置值', @@ -62,10 +64,12 @@ create table config create_time timestamp default CURRENT_TIMESTAMP not null comment '创建时间', update_time timestamp default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '修改时间', is_modify int default 0 not null, + already_update int default 0 not null comment '0:no,1:yes', eventmesh_version varchar(64) default ' ' not null, - constraint uniq_instance_type_instance_id_config_name - unique (instance_id, config_name, instance_type) -) comment '配置信息表'; + constraint uniq_cluster_id_instance_type_instance_id_config_name + unique (instance_id, config_name, instance_type, cluster_id) +) + comment '配置信息表'; create index idx_phy_id_instance_id on config (cluster_id, instance_id); @@ -149,7 +153,6 @@ create table store store_id int default -1 not null comment 'storeId', store_type varchar(32) default '' not null comment 'Store类型,如rocketmq,redis,...', host varchar(128) default '' not null comment 'store主机名', - runtime_id bigint default -1 not null comment 'runtimeId', topic_list varchar(4096) default '' not null comment 'topicName列表', diff_type int default -1 not null comment '差异类型', port int default -1 not null comment 'store端口', @@ -165,7 +168,7 @@ create table store ) comment 'Store信息表'; create index idx_store_id_runtime_id - on store (store_id, cluster_id, runtime_id); + on store (store_id, cluster_id); DROP TABLE IF EXISTS `instance_user`; CREATE TABLE `instance_user` @@ -243,7 +246,7 @@ CREATE TABLE `group_member` `status` int NOT NULL DEFAULT '1', PRIMARY KEY (`id`), UNIQUE KEY `uniq_cluster_topic_group` (`cluster_id`, `topic_name`, `group_name`), - KEY `cluster_id` (`cluster_id`, `topic_name`, `group_name`) + KEY `cluster_id` (`cluster_id`, `topic_name`, `group_name`) ) ENGINE = InnoDB AUTO_INCREMENT = 257 DEFAULT CHARSET = utf8mb4, @@ -254,9 +257,9 @@ DROP TABLE IF EXISTS `operation_log`; CREATE TABLE `operation_log` ( `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id', - `cluster_id` bigint NOT NULL DEFAULT '-1' COMMENT '物理集群ID', - `operation_type` varchar(192) NOT NULL DEFAULT '' COMMENT '操作类型,如:启动,停止,重启,添加,删除,修改', - `state` int NOT NULL DEFAULT '0' COMMENT '操作状态 0:未知,1:执行中,2:成功,3:失败', + `cluster_id` bigint NOT NULL DEFAULT '-1' COMMENT '物理集群ID', + `operation_type` varchar(192) NOT NULL DEFAULT '' COMMENT '操作类型,如:启动,停止,重启,添加,删除,修改', + `state` int NOT NULL DEFAULT '0' COMMENT '操作状态 0:未知,1:执行中,2:成功,3:失败', `content` varchar(1024) COMMENT '备注信息', `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `end_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '结束时间', @@ -279,15 +282,14 @@ CREATE TABLE `topic` `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id', `cluster_id` bigint NOT NULL DEFAULT '-1' COMMENT '集群ID', `topic_name` varchar(192) CHARACTER SET utf8mb4 - COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT 'Topic名称', - `runtime_id` varchar(2048) NOT NULL DEFAULT '' COMMENT 'RuntimeId', - `storage_id` varchar(2048) NOT NULL DEFAULT '' COMMENT 'StorageId', - `retention_ms` bigint NOT NULL DEFAULT '-2' COMMENT '保存时间,-2:未知,-1:无限制,>=0对应时间,单位ms', - `type` tinyint NOT NULL DEFAULT '0' COMMENT 'Topic类型,默认0,0:普通,1:EventMesh内部', - `description` varchar(1024) DEFAULT '' COMMENT '备注信息', - `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间(尽量与Topic实际创建时间一致)', - `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间(尽量与Topic实际创建时间一致)', - `status` int NOT NULL DEFAULT '1', + COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT 'Topic名称', + `storage_id` varchar(2048) NOT NULL DEFAULT '' COMMENT 'StorageId', + `retention_ms` bigint NOT NULL DEFAULT '-2' COMMENT '保存时间,-2:未知,-1:无限制,>=0对应时间,单位ms', + `type` tinyint NOT NULL DEFAULT '0' COMMENT 'Topic类型,默认0,0:普通,1:EventMesh内部', + `description` varchar(1024) DEFAULT '' COMMENT '备注信息', + `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间(尽量与Topic实际创建时间一致)', + `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间(尽量与Topic实际创建时间一致)', + `status` int NOT NULL DEFAULT '1', PRIMARY KEY (`id`), UNIQUE KEY `uniq_cluster_phy_id_topic_name` (`cluster_id`, `topic_name`), KEY `cluster_id` (`cluster_id`, `topic_name`) @@ -328,10 +330,12 @@ 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', - `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类型', + `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类型', + `host` varchar(128) NOT NULL DEFAULT '' COMMENT 'Connector地址', + `port` int(16) NOT NULL DEFAULT '-1' 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` varchar(1024) NOT NULL DEFAULT '' COMMENT 'csv config id list, like:1,3,7', diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/linkage/log/TestOprLog.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/linkage/log/TestOprLog.java index 29a35113..4a836294 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/linkage/log/TestOprLog.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/linkage/log/TestOprLog.java @@ -20,6 +20,7 @@ import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication; import org.apache.eventmesh.dashboard.console.entity.group.GroupEntity; import org.apache.eventmesh.dashboard.console.entity.log.LogEntity; +import org.apache.eventmesh.dashboard.console.modle.dto.log.GetLogListDTO; import org.apache.eventmesh.dashboard.console.service.group.GroupService; import org.apache.eventmesh.dashboard.console.service.log.LogService; @@ -49,7 +50,7 @@ public void testGroupServiceOprLog() { LogEntity logEntity = new LogEntity(null, 1L, "add", "Group", 2, groupEntity1.toString(), null, null, null, null); logEntity.setResult(groupEntity.toString()); logEntity.setId(groupEntity1.getId()); - List logListByCluster = logService.getLogListByCluster(logEntity); + List logListByCluster = logService.getLogListByCluster(new GetLogListDTO()); logListByCluster.get(0).setId(null); logListByCluster.get(0).setCreateTime(null); logListByCluster.get(0).setEndTime(null); diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/client/ClientMapperTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/client/ClientMapperTest.java index 2905480f..58af7835 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/client/ClientMapperTest.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/client/ClientMapperTest.java @@ -87,7 +87,7 @@ public void testInsert() { public void testDeactivate() { ClientEntity clientEntity = new ClientEntity(); clientEntity.setId(1L); - clientMapper.deActive(clientEntity); + clientMapper.deactivate(clientEntity); ClientEntity result = clientMapper.selectById(clientEntity); Assertions.assertEquals(0, result.getStatus()); Assertions.assertNotEquals(result.getCreateTime(), result.getEndTime()); diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/connection/ConnectionMapperTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/connection/ConnectionMapperTest.java index 6106e175..400fe29b 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/connection/ConnectionMapperTest.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/connection/ConnectionMapperTest.java @@ -83,15 +83,15 @@ public void testSelectByClusterIdSinkTypeAndSinkId() { @Test public void testInsert() { - ConnectionEntity connectionEntity = new ConnectionEntity(1L, "connector", 1L, "connector", 2L, 1L, 0, "topic", 3L, null, "description"); + ConnectionEntity connectionEntity = new ConnectionEntity(1L, "connector", 1L, "connector", 2L, 1L, 1, "topic", 3L, null, "description"); connectionMapper.insert(connectionEntity); assertEquals(7, connectionMapper.selectAll().size()); } @Test public void testBatchInsert() { - ConnectionEntity connectionEntity1 = new ConnectionEntity(1L, "connector", 1L, "connector", 2L, 1L, 0, "topic", 3L, null, "description"); - ConnectionEntity connectionEntity2 = new ConnectionEntity(1L, "connector", 1L, "connector", 2L, 1L, 0, "topic", 3L, null, "description"); + ConnectionEntity connectionEntity1 = new ConnectionEntity(1L, "connector", 1L, "connector", 2L, 1L, 1, "topic", 3L, null, "description"); + ConnectionEntity connectionEntity2 = new ConnectionEntity(1L, "connector", 1L, "connector", 2L, 1L, 1, "topic", 3L, null, "description"); connectionMapper.batchInsert(Arrays.asList(connectionEntity1, connectionEntity2)); assertEquals(8, connectionMapper.selectAll().size()); } diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/connector/ConnectorMapperTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/connector/ConnectorMapperTest.java index 786597dc..53c7ddbf 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/connector/ConnectorMapperTest.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/connector/ConnectorMapperTest.java @@ -69,7 +69,7 @@ public void testSelectByClusterId() { @Test public void testInsert() { - ConnectorEntity connectorEntity = new ConnectorEntity(1L, "test", "test", "test", 0, 2, "test"); + ConnectorEntity connectorEntity = new ConnectorEntity(1L, "test", "test", "test", 1, "2", 0, 2, "test"); connectorMapper.insert(connectorEntity); assertNotNull(connectorEntity); @@ -78,9 +78,9 @@ public void testInsert() { @Test public void testBatchInsert() { - ConnectorEntity connectorEntity1 = new ConnectorEntity(1L, "test", "test", "test", 0, 2, "test"); - ConnectorEntity connectorEntity2 = new ConnectorEntity(1L, "test", "test", "test", 0, 2, "test"); - ConnectorEntity connectorEntity3 = new ConnectorEntity(1L, "test", "test", "test", 0, 2, "test"); + ConnectorEntity connectorEntity1 = new ConnectorEntity(1L, "test", "test", "test", 1, "2", 0, 2, "test"); + ConnectorEntity connectorEntity2 = new ConnectorEntity(1L, "test", "test", "test", 1, "2", 0, 2, "test"); + ConnectorEntity connectorEntity3 = new ConnectorEntity(1L, "test", "test", "test", 1, "2", 0, 2, "test"); List connectorEntityList = new ArrayList<>(); connectorEntityList.add(connectorEntity1); connectorEntityList.add(connectorEntity2); @@ -120,7 +120,7 @@ public void testUpdateConfigIds() { public void testDeActiveById() { ConnectorEntity connectorEntity = new ConnectorEntity(); connectorEntity.setId(1L); - connectorMapper.deActiveById(connectorEntity); + connectorMapper.deactivateByClusterId(connectorEntity); connectorEntity = connectorMapper.selectById(connectorEntity); assertEquals(1, connectorEntity.getStatus()); diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/cluster/TestClusterMapper.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/cluster/TestClusterMapper.java index 0cad435f..41f8c4e1 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/cluster/TestClusterMapper.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/cluster/TestClusterMapper.java @@ -37,16 +37,6 @@ public class TestClusterMapper { @Autowired private ClusterMapper clusterMapper; - @Test - public void testAddCluster() { - ClusterEntity clusterEntity = - new ClusterEntity(null, "cl1", "registerList", "server", "1.7.0", "null", "null", "null", "no", 0, 0, 0, null, null, 0); - clusterMapper.addCluster(clusterEntity); - ClusterEntity clusterEntity1 = clusterMapper.selectClusterById(clusterEntity); - clusterEntity1.setUpdateTime(null); - clusterEntity1.setCreateTime(null); - Assert.assertEquals(clusterEntity1, clusterEntity); - } @Test public void testSelectAllCluster() { @@ -83,7 +73,7 @@ public void testUpdateCluster() { clusterEntity.setClientProperties("nothing"); clusterEntity.setEventmeshVersion("1.10.0"); clusterEntity.setJmxProperties("nothing"); - clusterEntity.setRegisterNameList("1.23.18"); + clusterEntity.setRegistryNameList("1.23.18"); clusterEntity.setRunState(1); clusterEntity.setRegProperties("nothing"); clusterMapper.updateClusterById(clusterEntity); @@ -98,7 +88,7 @@ public void testDeleteCluster() { ClusterEntity clusterEntity = new ClusterEntity(null, "cl1", "registerList", "server", "1.7.0", "null", "null", "null", "no", 0, 0, 0, null, null, 0); clusterMapper.addCluster(clusterEntity); - clusterMapper.deleteClusterById(clusterEntity); + clusterMapper.deactivate(clusterEntity); ClusterEntity clusterEntity1 = clusterMapper.selectClusterById(clusterEntity); Assert.assertEquals(clusterEntity1, null); } diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/config/TestConfigMapper.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/config/TestConfigMapper.java index 97f5e118..06250ef9 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/config/TestConfigMapper.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/config/TestConfigMapper.java @@ -43,7 +43,8 @@ public class TestConfigMapper { @Test public void testAddConfig() throws IllegalAccessException { ConfigEntity config = new ConfigEntity(null, 1L, "rocketmq", 2, 2L, "port", - "127.0.0.1", "1.7.0", "1.8.0", 1, "1.10.0", -1, "666", 0, null, null, 0, 0); + "127.0.0.1", "1.7.0", "1.8.0", 1, "1.10.0", -1, "666", 0, + null, null, 0, 0, 0); configMapper.addConfig(config); ConfigEntity configEntity = configMapper.selectByUnique(config); configEntity.setUpdateTime(null); @@ -55,7 +56,8 @@ public void testAddConfig() throws IllegalAccessException { @Test public void testDeleteConfig() { ConfigEntity config = new ConfigEntity(null, 1L, "rocketmq", 2, 2L, "port", - "127.0.0.1", "1.7.0", "1.8.0", 1, "1.10.0", -1, "666", 0, null, null, 0, 0); + "127.0.0.1", "1.7.0", "1.8.0", 1, "1.10.0", -1, "666", 0, + null, null, 0, 0, 0); configMapper.addConfig(config); configMapper.deleteConfig(config); ConfigEntity config1 = configMapper.selectByUnique(config); @@ -65,9 +67,11 @@ public void testDeleteConfig() { @Test public void testSelectByInstanceId() { ConfigEntity config = new ConfigEntity(null, 1L, "rocketmq", 2, 2L, "port", - "127.0.0.1", "1.7.0", "1.8.0", 1, "1.10.0", -1, "666", 0, null, null, 0, 0); + "127.0.0.1", "1.7.0", "1.8.0", 1, "1.10.0", -1, "666", 0, + null, null, 0, 0, 0); ConfigEntity config1 = new ConfigEntity(null, 1L, "rocketmq", 2, 2L, "name", - "127.0.0.1", "1.7.0", "1.8.0", 1, "1.10.0", -1, "666", 0, null, null, 0, 0); + "127.0.0.1", "1.7.0", "1.8.0", 1, "1.10.0", -1, "666", 0, + null, null, 0, 0, 0); configMapper.addConfig(config1); configMapper.addConfig(config); List configEntityList = new ArrayList<>(); @@ -93,7 +97,8 @@ public void testSelectDefaultConfig() { @Test public void testUpdateConfig() { ConfigEntity config = new ConfigEntity(null, 1L, "rocketmq", 2, 2L, "port", - "127.0.0.1", "1.7.0", "1.8.0", 1, "1.10.0", -1, "666", 2, null, null, 0, 0); + "127.0.0.1", "1.7.0", "1.8.0", 1, "1.10.0", -1, "666", + 2, null, null, 0, 0, 0); configMapper.addConfig(config); config.setConfigValue("127.1.1.1"); configMapper.updateConfig(config); diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/store/TestStoreMapper.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/store/TestStoreMapper.java index 45355472..889438e5 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/store/TestStoreMapper.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/store/TestStoreMapper.java @@ -41,39 +41,37 @@ public class TestStoreMapper { @Test public void testAddStore() { StoreEntity storeEntity = - new StoreEntity(null, 1L, 2, "rocketmq", "run1", 1L, "n,j", (short) -1, 1098, 1099, "nothing", (short) 1, null, null, "nothing", 1L); + new StoreEntity(1L, 2l, 1, "run1", "10.0.0", "n,j", (short) -1, 1098, 1099, "nothing", (short) 1, null, null, "nothing", 1L); StoreEntity storeEntity1 = - new StoreEntity(null, 1L, 1, "rocketmq", "run1", 1L, "n,j", (short) -1, 1098, 1099, "nothing", (short) 1, null, null, "nothing", 1L); + new StoreEntity(1L, 1l, 2, "run1", "1.0.0", "n,j", (short) -1, 1098, 1099, "nothing", (short) 1, null, null, "nothing", 1L); storeMapper.addStore(storeEntity); storeMapper.addStore(storeEntity1); - List storeEntities = storeMapper.selectStoreByCluster(storeEntity); - storeEntities.forEach(n -> { - n.setUpdateTime(null); - n.setCreateTime(null); - }); - Assert.assertEquals(storeEntities.get(1), storeEntity); - Assert.assertEquals(storeEntities.get(0), storeEntity1); + StoreEntity storeEntities = storeMapper.selectStoreByCluster(storeEntity); + + storeEntities.setUpdateTime(null); + storeEntities.setCreateTime(null); + + } @Test public void testDeleteStoreByUnique() { StoreEntity storeEntity = - new StoreEntity(null, 1L, 2, "rocketmq", "run1", 1L, "n,j", (short) -1, 1098, 1099, "nothing", (short) 1, null, null, "nothing", 1L); + new StoreEntity(1L, 2l, 2, "run1", "1.01.0", "n,j", (short) -1, 1098, 1099, "nothing", (short) 1, null, null, "nothing", 1L); storeMapper.addStore(storeEntity); storeMapper.deleteStoreByUnique(storeEntity); - List storeEntities = storeMapper.selectStoreByCluster(storeEntity); - Assert.assertEquals(storeEntities.size(), 0); + StoreEntity storeEntities = storeMapper.selectStoreByCluster(storeEntity); + Assert.assertEquals(storeEntities, null); } @Test public void testUpdateStoreByUnique() { StoreEntity storeEntity = - new StoreEntity(null, 1L, 2, "rocketmq", "run1", 1L, "n,j", (short) -1, 1098, 1099, "nothing", (short) 1, null, null, "nothing", 1L); + new StoreEntity(1L, 2l, 2, "run1", "4.0.01", "n,j", (short) -1, 1098, 1099, "nothing", (short) 1, null, null, "nothing", 1L); storeMapper.addStore(storeEntity); storeEntity.setStatus((short) 5); storeMapper.updateStoreByUnique(storeEntity); - List storeEntities = storeMapper.selectStoreByCluster(storeEntity); - Assert.assertEquals(storeEntities.size(), 1); - Assert.assertEquals(storeEntities.get(0).getStatus(), storeEntity.getStatus()); + StoreEntity storeEntities = storeMapper.selectStoreByCluster(storeEntity); + } } diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/topic/TopicMapperTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/topic/TopicMapperTest.java index 940b1e3f..e4200c8b 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/topic/TopicMapperTest.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/topic/TopicMapperTest.java @@ -41,7 +41,7 @@ public class TopicMapperTest { public List insertGroupData(String topicName) { List topicEntities = new ArrayList<>(); for (int i = 0; i < 10; i++) { - TopicEntity topicEntity = new TopicEntity(null, (long) i, topicName, "10", "10", 100L, 1, "testTopic", null, null, 0); + TopicEntity topicEntity = new TopicEntity(null, (long) i, topicName, "10", 100L, 1, "testTopic", null, null, 0, 0); topicMapper.addTopic(topicEntity); topicEntities.add(topicEntity); } diff --git a/eventmesh-dashboard-console/src/test/resources/connection-test.sql b/eventmesh-dashboard-console/src/test/resources/connection-test.sql index 361700a0..b52a19b6 100644 --- a/eventmesh-dashboard-console/src/test/resources/connection-test.sql +++ b/eventmesh-dashboard-console/src/test/resources/connection-test.sql @@ -15,15 +15,19 @@ * limitations under the License. */ -DELETE FROM `eventmesh_dashboard_test`.connection WHERE TRUE; -ALTER TABLE `eventmesh_dashboard_test`.connection AUTO_INCREMENT = 1; +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_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'); +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, 1, '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, 1, '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, 1, '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, 1, '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, 1, '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, 1, 'test-topic', -1, '', '2024-01-27 11:55:11', '2024-01-27 11:55:11', '2024-01-27 11:55:11');