From 6bc58559a15a4f36245a3116bc578449a0537fb5 Mon Sep 17 00:00:00 2001 From: jie Date: Fri, 9 May 2025 19:31:16 +0800 Subject: [PATCH 01/11] =?UTF-8?q?fix(*):=201.=20=E5=90=88=E5=B9=B6?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=EF=BC=8C=202.=20=E5=A4=84=E7=90=86=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- eventmesh-dashboard-common/pom.xml | 16 +- .../annotation/RemotingServiceMapper.java | 37 ++ .../RemotingServiceMethodMapper.java | 38 ++ .../dashboard/common/constant/ApiPrefix.java | 2 + .../dashboard/common/constant/NacosConst.java | 2 + .../common/constant/StoreTypeConstant.java | 2 + .../health/HealthCheckTypeConstant.java | 2 + .../constant/health/HealthConstant.java | 1 + .../dashboard/common/dto/Result.java | 140 ------ .../dashboard/common/enums/BusinessType.java | 2 + .../ClusterFramework.java} | 58 ++- .../common/enums/ClusterOwnType.java | 38 ++ .../common/enums/ClusterSyncMetadataEnum.java | 113 +++++ .../common/enums/ClusterTrusteeshipType.java | 115 ++++- .../dashboard/common/enums/ClusterType.java | 292 +++++++++++- .../common/enums/DeployStatusType.java | 107 +++++ .../common/enums/KubernetesPodStatus.java | 1 + .../dashboard/common/enums/MetadataType.java | 74 +++ .../common/enums/OperationRange.java | 100 ++++ .../dashboard/common/enums/RecordStatus.java | 1 + .../dashboard/common/enums/RemotingType.java | 34 +- .../common/enums/ReplicationDimension.java | 38 ++ .../common/enums/ReplicationType.java | 49 ++ .../common/enums/ResetOffsetMode.java | 22 + .../dashboard/common/enums/Status.java | 91 ---- .../dashboard/common/enums/StoreType.java | 2 + .../dashboard/common/enums/SyncErrorType.java | 13 +- .../enums/health/HealthCheckStatus.java | 26 +- ...heckType.java => HealthCheckTypeEnum.java} | 18 +- .../common/model/ClusterSyncMetadata.java | 71 +++ .../common/model/ConnectionInfo.java | 1 + .../common/model/ConvertMetaData.java | 31 ++ .../model/DatabaseAndMetadataMapper.java | 40 ++ .../model/MetadataSyncResultMetadata.java | 35 ++ .../dashboard/common/model/PortHandler.java | 12 +- .../common/model/SubscriptionInfo.java | 2 + .../common/model/base/BaseClusterIdBase.java | 57 +++ .../base/BaseOrganizationBase.java} | 53 ++- .../common/model/base/BaseRuntimeIdBase.java | 34 ++ .../common/model/base/BaseSyncBase.java | 65 +++ .../common/model/metadata/AclMetadata.java | 17 +- .../common/model/metadata/ClientMetadata.java | 10 +- .../model/metadata/ClusterMetadata.java | 16 +- .../metadata/ClusterRelationshipMetadata.java | 11 +- .../common/model/metadata/ConfigMetadata.java | 15 +- .../model/metadata/ConnectionMetadata.java | 10 +- .../model/metadata/ConnectorMetadata.java | 9 +- .../model/metadata/ConsumeOffsetMetadata.java | 35 ++ .../common/model/metadata/GroupMetadata.java | 11 +- .../model/metadata/InstanceUserMetadata.java | 7 +- .../common/model/metadata/MetadataConfig.java | 48 -- .../common/model/metadata/QueueMetadata.java | 35 ++ .../model/metadata/RegistryMetadata.java | 14 +- .../model/metadata/RuntimeMetadata.java | 27 +- .../common/model/metadata/TopicMetadata.java | 21 +- .../model/metadata/TopicOffsetMetadata.java | 44 ++ .../remoting/AbstractGlobal2Request.java | 31 ++ .../model/remoting/BaseGlobalResult.java | 1 + .../common/model/remoting/Global2Request.java | 35 ++ .../common/model/remoting/GlobalResult.java | 1 + .../common/model/remoting/RemotingAction.java | 1 + ...alRequest.java => RemotingActionType.java} | 15 +- .../model/remoting/RemotingOperate.java | 1 + .../model/remoting/acl/CreateAclRequest.java | 1 + .../model/remoting/acl/CreateAclResponse.java | 1 + .../model/remoting/acl/CreateAclResult.java | 1 + .../model/remoting/acl/DeleteAclRequest.java | 1 + .../model/remoting/acl/DeleteAclResponse.java | 1 + .../model/remoting/acl/DeleteAclResult.java | 1 + ...tAclsRequest.java => GetAcls2Request.java} | 5 +- .../model/remoting/acl/GetAclsResponse.java | 1 + .../model/remoting/acl/GetAclsResult.java | 1 + .../remoting/client/GetClientRequest.java | 1 + .../remoting/client/GetClientResponse.java | 1 + .../remoting/client/GetClientResult.java | 1 + .../remoting/config/AddConfigRequest.java | 1 + .../remoting/config/AddConfigResponse.java | 1 + .../remoting/config/AddConfigResult.java | 1 + .../model/remoting/config/ConfigType.java | 4 + .../remoting/config/DeleteConfigRequest.java | 1 + .../remoting/config/DeleteConfigResponse.java | 1 + .../remoting/config/DeleteConfigResult.java | 1 + .../remoting/config/GetConfigRequest.java | 1 + .../remoting/config/GetConfigResponse.java | 1 + .../remoting/config/GetConfigResult.java | 1 + .../remoting/config/UpdateConfigRequest.java | 1 + .../remoting/config/UpdateConfigResponse.java | 1 + .../remoting/config/UpdateConfigResult.java | 1 + .../connector/CreateConnectorRequest.java | 1 + .../connector/CreateConnectorResponse.java | 1 + .../connector/CreateConnectorResult.java | 1 + .../connector/GetConnectorRequest.java | 1 + .../connector/GetConnectorResponse.java | 1 + .../connector/GetConnectorResult.java | 1 + .../model/remoting/group/GetGroupResult.java | 3 + .../remoting/group/GetGroupsRequest.java | 1 + .../remoting/group/GetGroupsResponse.java | 1 + .../remoting/offset/GetOffsetRequest.java | 1 + .../remoting/offset/GetOffsetResponse.java | 1 + .../remoting/offset/GetOffsetResult.java | 1 + .../remoting/offset/ResetOffsetRequest.java | 6 +- .../remoting/offset/ResetOffsetResponse.java | 1 + .../remoting/offset/ResetOffsetResult.java | 1 + ...meRequest.java => GetRuntime2Request.java} | 7 +- .../remoting/runtime/GetRuntimeResponse.java | 1 + .../remoting/runtime/GetRuntimeResult.java | 3 + .../subscription/GetSubscriptionRequest.java | 1 + .../subscription/GetSubscriptionResponse.java | 1 + .../subscription/GetSubscriptionResult.java | 1 + ...cRequest.java => CreateTopic2Request.java} | 14 +- .../remoting/topic/CreateTopicResponse.java | 1 + .../remoting/topic/CreateTopicResult.java | 1 + .../remoting/topic/DeleteTopicRequest.java | 1 + .../remoting/topic/DeleteTopicResponse.java | 1 + .../remoting/topic/DeleteTopicResult.java | 1 + ...icsRequest.java => GetTopics2Request.java} | 11 +- .../remoting/topic/GetTopicsResponse.java | 1 + .../model/remoting/topic/GetTopicsResult.java | 1 + .../remoting/user/CreateUserRequest.java | 1 + .../remoting/user/CreateUserResponse.java | 1 + .../model/remoting/user/CreateUserResult.java | 1 + .../remoting/user/DeleteUserResponse.java | 1 + .../model/remoting/user/DeleteUserResult.java | 1 + .../remoting/user/DeleterUserRequest.java | 1 + .../model/remoting/user/GetUserRequest.java | 1 + .../model/remoting/user/GetUserResponse.java | 1 + .../model/remoting/user/GetUserResult.java | 1 + .../common/port/AbstractPortValidate.java | 47 ++ .../common/port/NotPortValidate.java | 48 ++ .../dashboard/common/port/PortRule.java | 38 ++ .../dashboard/common/port/PortValidate.java | 31 ++ .../common/util/ClasspathScanner.java | 136 ++++++ .../dashboard/common/util/ExceptionUtil.java | 3 + .../common/utils/ClusterTypeRelationship.java | 66 +++ eventmesh-dashboard-console/pom.xml | 49 +- .../EventMeshDashboardApplication.java | 3 +- .../dashboard/console/annotation/EmLog.java | 1 + .../config/FunctionManagerConfigs.java | 1 + .../console/config/SpringDocConfig.java | 1 + .../controller/ClusterAbitityService.java | 68 +++ .../controller/ConnectionController.java | 31 +- .../console/controller/MetricsController.java | 3 +- .../controller/SubscriptionController.java | 71 --- .../controller/cluster/AclController.java | 1 + .../cluster/ClientDataController.java | 10 +- .../controller/cluster/ClusterController.java | 95 ++-- .../ClusterRelationshipController.java | 6 +- .../controller/cluster/DetailsController.java | 57 +++ .../controller/cluster/HomeController.java | 94 ++++ .../cluster/InstanceUserController.java | 66 --- .../cluster/NetConnectionController.java | 1 + .../controller/cluster/RuntimeController.java | 51 +- .../controller/deploy/CaseController.java | 71 +++ .../deploy/ClusterCycleController.java | 192 ++++++++ .../controller/deploy/CreateCycleService.java | 272 +++++++++++ .../deploy/ResourcesConfigController.java | 53 +++ .../CreateClusterByDeployScriptHandler.java | 144 ++++++ .../CreateRuntimeByDeployScriptHandler.java | 97 ++++ .../console/controller/deploy/design.md | 157 ++++++ .../deploy/handler/UpdateHandler.java | 30 ++ .../controller/deploy/pause/PauseCluster.java | 110 +++++ .../controller/deploy/pause/PauseRuntime.java | 53 +++ .../relationship/RelationshipHandler.java | 54 +++ .../relationship/UnRelationshipHandler.java | 45 ++ .../uninstall/UninstallClusterHandler.java | 35 ++ .../uninstall/UninstallRuntimeHandler.java | 35 ++ .../controller/function/ConfigController.java | 21 +- .../controller/function/HealthController.java | 11 +- .../controller/function/LogController.java | 10 +- .../function/OverviewController.java | 6 +- .../controller/message/GroupController.java | 7 +- .../message/GroupRelationshipController.java | 1 + .../message/OffsetOperateController.java | 18 +- .../controller/message/TopicController.java | 117 ++++- .../domain/ClusterAndRuntimeDomain.java | 39 ++ .../Impl/ClusterAndRuntimeDomainImpl.java | 33 ++ .../console/domain/OperationRangeDomain.java | 146 ++++++ .../metadata/ClusterMetadataDomain.java | 447 ++++++++++++++++++ .../metadata/ClusterOperationHandler.java | 36 ++ .../domain/metadata/MetadataAllDO.java | 42 ++ .../dashboard/console/entity/BaseEntity.java | 15 +- .../console/entity/DefaultConfigKey.java | 6 + .../dashboard/console/entity/StoreEntity.java | 6 +- .../entity/base/BaseClusterIdEntity.java | 35 ++ .../console/entity/base/BaseIdEntity.java | 55 +++ .../entity/base/BaseOrganizationEntity.java | 33 ++ .../entity/base/BaseRuntimeIdEntity.java | 31 ++ .../console/entity/base/BaseSyncEntity.java | 81 ++++ .../console/entity/cases/CaseEntity.java | 43 ++ .../entity/cases/DeployScriptEntity.java | 46 ++ .../console/entity/cases/PortEntity.java | 32 ++ .../console/entity/cases/ResouceEntity.java | 32 ++ .../entity/cases/ResourcesConfigEntity.java | 38 ++ .../console/entity/cluster/AclEntity.java | 1 + .../console/entity/cluster/ClientEntity.java | 24 +- .../cluster/ClusterAndRelationshipEntity.java | 5 +- .../console/entity/cluster/ClusterEntity.java | 31 +- .../cluster/ClusterRelationshipEntity.java | 18 +- .../entity/cluster/ConnectionEntity.java | 15 +- .../entity/cluster/InstanceUserEntity.java | 9 +- .../entity/cluster/NetConnectionEntity.java | 6 +- .../console/entity/cluster/RuntimeEntity.java | 26 +- .../entity/connector/ConnectorEntity.java | 19 +- .../console/entity/function/ConfigEntity.java | 17 +- .../entity/function/ConfigGatherEntity.java | 30 ++ .../function/HealthCheckResultEntity.java | 34 +- .../console/entity/function/LogEntity.java | 11 +- .../function/MetadataSyncResultEntity.java | 48 ++ .../entity/message/ConsumeOffsetEntity.java | 39 ++ .../console/entity/message/GroupEntity.java | 15 +- ...berEntity.java => SubscriptionEntity.java} | 14 +- .../console/entity/message/TopicEntity.java | 41 +- .../entity/message/TopicOffsetEntity.java | 40 ++ .../exception/GlobalExceptionHandler.java | 63 --- .../function/health/CheckResultCache.java | 12 +- .../function/health/Health2Service.java | 272 +++++++++++ .../function/health/HealthExecutor.java | 144 ------ .../function/health/HealthService.java | 291 ------------ .../health/annotation/HealthCheckType.java | 18 +- .../health/callback/HealthCheckCallback.java | 5 +- .../check/AbstractHealthCheckService.java | 45 +- .../AbstractTopicHealthCheckService.java | 64 +++ .../check/ClusterHealthCheckService.java | 36 ++ .../health/check/HealthCheckService.java | 14 +- .../check/config/HealthCheckObjectConfig.java | 71 --- .../health/check/impl/HealthRegister.java | 30 ++ .../health/check/impl/jvm/JVMCapCheck.java | 35 ++ .../check/impl/jvm/JVMCapTopicCheck.java | 35 ++ .../health/check/impl/jvm/JVMCheck.java | 36 ++ .../health/check/impl/jvm/JVMTopicCheck.java | 36 ++ .../check/impl/meta/NacosConfigCheck.java | 56 +-- .../impl/meta/NacosNamingServiceCheck.java | 49 +- .../health/check/impl/storage/RedisCheck.java | 79 +--- .../RocketMQClusterHealthCheckService.java | 218 +++++++++ .../rocketmq4/Rocketmq4BrokerCheck.java | 76 +-- .../rocketmq4/Rocketmq4NameServerCheck.java | 79 +--- .../rocketmq4/Rocketmq4TopicCheck.java | 16 +- .../console/function/health/design.md | 19 + .../metadata/MetadataServiceWrapper.java | 57 --- .../handler/MetadataHandlerWrapper.java | 56 --- .../db/ClusterMetadataHandlerToDbImpl.java | 62 --- .../db/ConfigMetadataHandlerToDbImpl.java | 68 --- .../db/GroupMetadataHandlerToDbImpl.java | 63 --- .../db/RuntimeMetadataHandlerToDbImpl.java | 103 ---- .../db/TopicMetadataHandlerToDbImpl.java | 75 --- .../syncservice/SyncDataServiceWrapper.java | 59 --- .../dashboard/console/log/OprLog.java | 15 +- .../console/mapper/SyncDataHandlerMapper.java | 19 +- .../console/mapper/cluster/AclMapper.java | 25 +- .../console/mapper/cluster/ClientMapper.java | 78 ++- .../console/mapper/cluster/ClusterMapper.java | 120 +++-- .../cluster/ClusterRelationshipMapper.java | 79 +++- .../mapper/cluster/ConnectionMapper.java | 30 +- .../mapper/cluster/InstanceUserMapper.java | 56 --- .../mapper/cluster/NetConnectionMapper.java | 4 +- .../console/mapper/cluster/RuntimeMapper.java | 175 +++++-- .../mapper/connector/ConnectorMapper.java | 50 +- .../mapper/deploy/DeployScriptMapper.java | 62 +++ .../console/mapper/deploy/PortMapper.java | 44 ++ .../console/mapper/function/ConfigMapper.java | 73 +-- .../function/HealthCheckResultMapper.java | 63 ++- .../console/mapper/function/OprLogMapper.java | 22 +- .../mapper/message/ConsumerOffsetMapper.java | 22 +- .../{OprGroupMapper.java => GroupMapper.java} | 45 +- .../mapper/message/OprGroupMemberMapper.java | 101 ++-- .../console/mapper/message/TopicMapper.java | 70 ++- .../mapper/message/TopicOffsetMapper.java | 41 ++ .../console/mapper/storage/StoreMapper.java | 76 --- .../cluster/ClientDataControllerMapper.java | 5 +- .../cluster/ClusterControllerMapper.java | 14 +- .../cluster/GroupControllerMapper.java | 5 +- .../cluster/RuntimeControllerMapper.java | 5 +- .../CaseControllerMapper.java} | 14 +- .../deploy/ClusterCycleControllerMapper.java | 50 ++ .../ResourceConfigControllerMapper.java | 36 ++ .../message/TopicControllerMapper.java | 4 +- .../dashboard/console/modle/ClusterIdDTO.java | 7 +- ...eryRuntimeByClusterIdAndClusterTypeDO.java | 34 ++ .../QueryListByClusterIdAndTypeDO.java | 41 ++ .../QueryRuntimeByBigExpandClusterDO.java | 42 ++ .../dashboard/console/modle/IdDTO.java | 1 + .../OperateDTO.java} | 20 +- .../console/modle/OrganizationIdDTO.java | 27 ++ .../modle/cluster/ClusterHomeListVO.java | 1 + .../CreateClusterByCompleteDataDTO.java | 40 ++ ...java => CreateClusterBySimpleDataDTO.java} | 24 +- .../console/modle/cluster/VerifyNameDTO.java | 34 ++ ...DTO.java => QueryClientByUserFormDTO.java} | 8 +- .../cluster/cluster/ClusterDetailsVO.java | 7 +- ...ueryClusterByOrganizationIdAndTypeDTO.java | 37 ++ ...yRelationClusterByClusterIdAndTypeDTO.java | 33 ++ ...eRuntimeDTO.java => CreateRuntimeDTO.java} | 11 +- .../QueryRuntimeListByClusterIdDTO.java | 4 + .../runtimeCycle/CreateRuntimeDTO.java | 32 ++ .../console/modle/deploy/BaseConifgDO.java | 36 ++ .../console/modle/deploy/BaseDeployDO.java | 38 ++ .../modle/deploy/ClusterAllMetadataDO.java | 38 ++ .../console/modle/deploy/DeployClusterDO.java | 37 ++ .../console/modle/deploy/DeployFullDO.java | 36 ++ .../DeployGroupDO.java} | 13 +- .../modle/deploy/DeployMetadataDO.java | 38 ++ .../console/modle/deploy/DeployRuntimeDO.java | 30 ++ .../console/modle/deploy/DeployTopicDO.java | 33 ++ .../console/modle/deploy/GetPortsDO.java | 33 ++ .../cases/QueryCaseByObjectTypeDTO.java | 30 ++ .../create/CreateClusterByDeployScriptDO.java | 53 +++ .../create/CreateClusterByEventMesh.java | 41 ++ .../CreateEventMeshClusterByOnlyScript.java | 39 ++ .../create/CreateRuntimeByDeployScriptDO.java | 39 ++ .../CreateRuntimeByDeployScriptDTO.java | 36 ++ .../create/CreateRuntimeByOnlyDataDO.java | 57 +++ .../resouce/QueryResourceByObjectTypeDTO.java | 31 ++ .../console/modle/domain/ClusterEntityDO.java | 33 ++ .../domain/RuntimeEntityDO.java} | 19 +- .../dto/config/ChangeConfigDTO.java} | 15 +- .../modle/dto/config/DetailConfigsVO.java | 5 + .../modle/dto/config/GetConfigsListDTO.java | 5 + .../modle/dto/config/UpdateConfigDTO.java | 19 +- .../{ => dto}/config/UpdateConfigsLog.java | 7 +- .../dto/connection/AddConnectionDTO.java} | 9 +- .../connection/AddConnectorConfigDTO.java} | 9 +- .../dto/connection/CreateConnectionDTO.java | 12 +- .../dto/connection/GetConnectionListDTO.java | 5 + .../console/modle/dto/log/GetLogListDTO.java | 5 + .../console/modle/dto/meta/NewMetaDTO.java | 5 + .../modle/dto/operation/OperationBaseDTO.java | 54 +++ .../modle/dto/topic/CreateTopicDTO.java | 9 +- .../modle/dto/topic/GetTopicListDTO.java | 7 +- .../console/modle/function/OverviewDTO.java | 3 + .../console/modle/function/OverviewType.java | 1 + .../QueryOffsetByMessageMetadataDTO.java | 3 + .../modle/message/offset/ResetOffsetDTO.java | 19 +- .../console/modle/vo/RuntimeIdDTO.java | 32 ++ .../vo/cluster/GetClusterBaseMessageVO.java | 5 + .../modle/vo/cluster/ResourceNumVO.java | 5 + .../modle/vo/connection/ConnectionListVO.java | 5 + .../vo/health/InstanceLiveProportionVo.java | 5 + .../modle/vo/topic/TopicDetailGroupVO.java | 5 + .../console/service/DataServiceWrapper.java | 77 --- .../console/service/OverviewService.java | 5 +- .../console/service/cluster/AclService.java | 1 + .../service/cluster/ClientDataService.java | 12 +- .../cluster/ClusterRelationshipService.java | 8 +- .../service/cluster/ClusterService.java | 32 +- .../cluster/ConnectionDataService.java | 17 +- .../service/cluster/RuntimeService.java | 23 +- .../service/cluster/impl/AclServiceImpl.java | 1 + .../cluster/impl/ClientDataServiceImpl.java | 23 +- .../impl/ClusterRelationshipServiceImpl.java | 19 +- .../cluster/impl/ClusterServiceImpl.java | 115 ++++- .../ConnectionDataServiceDatabaseImpl.java | 231 --------- .../cluster/impl/InstanceUserServiceImpl.java | 68 --- .../cluster/impl/RuntimeServiceImpl.java | 102 +++- .../connector/ConnectorDataService.java | 3 +- .../Impl/ConnectorDataServiceImpl.java | 5 +- .../Impl/ResourcesConfigServiceImpl.java | 34 +- .../connector/ResourcesConfigService.java | 41 ++ .../service/deploy/DeployScriptService.java | 41 ++ .../console/service/deploy/PortService.java | 33 ++ .../deploy/impl/DeployScriptServiceImpl.java | 61 +++ .../service/deploy/impl/PortServiceImpl.java | 56 +++ .../service/function/ConfigService.java | 19 +- .../service/function/HealthDataService.java | 11 +- .../HealthDataServiceMemoryStorage.java | 2 + .../function/Impl/ConfigServiceImpl.java | 107 +++-- .../Impl/HealthDataServiceDatabaseImpl.java | 45 +- .../service/function/Impl/LogServiceImpl.java | 16 +- .../Impl/MetadataSyncResultServiceImpl.java | 46 ++ .../console/service/function/LogService.java | 7 +- .../MetadataSyncResultService.java} | 29 +- .../service/message/GroupMemberService.java | 21 +- .../console/service/message/GroupService.java | 18 +- .../console/service/message/TopicService.java | 17 +- .../message/impl/GroupMemberServiceImp.java | 43 +- .../message/impl/GroupServiceImpl.java | 55 +-- .../message/impl/TopicServiceImpl.java | 71 +-- .../AbstractDBDataMetadataHandler.java | 124 +++++ .../metadata/ClientDataMetadataHandler.java | 25 +- .../metadata/ConfigDataMetadataHandler.java | 38 ++ .../ConsumeOffsetDataMetadataHandler.java | 44 ++ .../metadata/GroupDataMetadataHandler.java | 44 ++ .../NetConnectionDataMetadataHandler.java | 43 ++ .../metadata/RuntimeDataMetadataHandler.java | 51 ++ .../metadata/TopicDataMetadataHandler.java | 49 ++ .../TopicOffsetDataMetadataHandler.java | 44 ++ .../service/store/Impl/StoreServiceImpl.java | 89 ---- .../spring/support/DefaultDataHandler.java | 81 ++++ .../spring/support/FunctionManage.java | 178 +++++++ .../spring/support/FunctionManager.java | 54 --- .../spring/support/FunctionManagerLoader.java | 72 --- .../support/FunctionManagerProperties.java | 38 -- .../spring/support/RuntimeDeployService.java | 422 +++++++++++++++++ .../metadata/DatabaseAndMetadataType.java | 80 ++++ .../DefaultMetadataSyncResultHandler.java | 205 ++++++++ .../convert/ClientConvertMetaData.java | 41 ++ .../convert/ClusterConvertMetaData.java | 41 ++ .../convert/ConfigConvertMetaData.java | 41 ++ .../ConsumeOffsetConvertMetaData.java} | 21 +- .../convert/GroupConvertMetaData.java | 42 ++ .../convert/RuntimeConvertMetaData.java | 43 ++ .../convert/TopicConvertMetaData.java | 41 ++ .../convert/TopicOffsetConvertMetaData.java | 40 ++ .../register/AbstractBuildMetadata.java | 74 +++ .../support/register/BuildMetadata.java} | 24 +- .../support/register/BuildMetadataManage.java | 81 ++++ .../support/register/ScriptBuildData.java | 58 +++ .../meta/AbstractMetaBuildMetadata.java | 33 ++ .../meta/RocketNameServiceBuildMetadata.java | 64 +++ .../register/meta/ZookeeperBuildMetadata.java | 50 ++ .../runtime/AbstractRuntimeBuildMetadata.java | 32 ++ .../EventMethRuntimeBuildMetadata.java | 78 +++ .../runtime/RocketMQBuildMetadata.java | 73 +++ .../dashboard/console/utils/RuntimeUtils.java | 38 ++ .../src/main/resources/RENAME.md | 38 ++ .../src/main/resources/application-dev.yml | 19 +- .../main/resources/eventmesh-dashboard.jmx | 253 ++++++++++ .../main/resources/eventmesh-dashboard.sql | 336 +++++++------ .../src/main/resources/logback.xml | 21 +- .../EventMeshDashboardApplicationTest.java | 1 + .../console/databuild/BuildFullMetadata.java | 49 ++ .../console/databuild/BuildFullSceneData.java | 395 ++++++++++++++++ .../function/health/Health2ServiceTest.java | 80 ++++ .../function/health/HealthExecutorTest.java | 186 -------- .../function/health/HealthServiceTest.java | 133 ------ .../check/impl/meta/NacosConfigCheckTest.java | 14 +- .../meta/NacosNamingServiceCheckTest.java | 18 +- .../check/impl/storage/RedisCheckTest.java | 83 ---- .../rocketmq4/Rocketmq4BrokerCheckTest.java | 9 +- .../Rocketmq4NameserverCheckTest.java | 9 +- .../rocketmq4/Rocketmq4TopicCheckTest.java | 8 +- .../db/ConfigMetadataHandlerToDbImplTest.java | 54 --- ...ConnectionMetadataHandlerToDbImplTest.java | 121 ----- .../db/GroupMetadataHandlerToDbImplTest.java | 62 --- .../RuntimeMetadataHandlerToDbImplTest.java | 122 ----- .../db/TopicMetadataHandlerToDbImplTest.java | 71 --- .../health/HealthServiceIntegrateTest.java | 75 --- .../console/linkage/log/TestOprLog.java | 9 +- .../mapper/cluster/ClusterDataMapperTest.java | 35 ++ .../cluster/ClusterEntityMapperTest.java | 133 ++++++ .../ClusterRelationshipMapperTest.java | 152 ++++++ .../cluster/RuntimeEntityMapperTest.java | 194 ++++++++ .../mapper/message/TopicEntityMapperTest.java | 106 +++++ .../domain/ClusterMetadataDomainTest.java | 218 +++++++++ .../impl/ClusterEntityServiceImplTest.java | 102 ++++ ...ConnectionDataServiceDatabaseImplTest.java | 19 +- .../support/DefaultDataHandlerTest.java | 34 ++ .../spring/support/FunctionManagerTest.java | 80 ---- .../support/RuntimeDeployServiceTest.java | 171 +++++++ .../convert/RuntimeConvertMetaDataTest.java | 40 ++ .../src/test/resources/acl-test.sql | 1 + .../src/test/resources/application-test.yml | 25 +- .../src/test/resources/client-test.sql | 1 + .../src/test/resources/connection-test.sql | 1 + .../src/test/resources/connector-test.sql | 1 + .../src/test/resources/health-test.sql | 1 + .../src/test/resources/instance-user-test.sql | 1 + .../kubernetes/EventMesh-runtime-refer.yaml | 63 +++ .../kubernetes/EventMesh-runtime.yaml | 60 +++ .../kubernetes/RocketMQ-broker-refer.yaml | 39 ++ .../resources/kubernetes/RocketMQ-broker.yaml | 39 ++ .../RocketMQ-nameservice-refer.yaml | 30 ++ .../kubernetes/RocketMQ-nameservice.yaml | 30 ++ .../src/test/resources/meta-test.sql | 1 + .../src/test/resources/runtime-test.sql | 1 + .../src/test/resources/store-test.sql | 1 + .../src/test/resources/topic-test.sql | 1 + .../src/test/resources/use-test-schema.sql | 1 + eventmesh-dashboard-core/pom.xml | 14 +- .../dashboard/core/cluster/BaseDataDO.java | 22 +- .../dashboard/core/cluster/ClusterBaseDO.java | 42 ++ .../dashboard/core/cluster/ClusterDO.java | 13 +- .../core/cluster/ClusterDoCache.java | 1 + .../dashboard/core/cluster/ColonyDO.java | 161 ++++++- .../core/cluster/MetadataBaseDO.java | 32 ++ .../dashboard/core/cluster/RuntimeBaseDO.java | 40 ++ .../dashboard/core/cluster/RuntimeDO.java | 34 ++ .../core/config/AdminProperties.java | 92 ---- .../core/function/SDK/AbstractClientInfo.java | 56 +++ .../function/SDK/AbstractSDKOperation.java | 17 +- .../SDK/ClientWrapper.java} | 14 +- .../core/function/SDK/ConfigManage.java | 56 +++ .../core/function/SDK/ProtocolType.java | 32 ++ .../core/function/SDK/SDKManage.java | 224 +++++++++ .../core/function/SDK/SDKManager.java | 164 ------- .../core/function/SDK/SDKMetadata.java | 62 +++ .../core/function/SDK/SDKOperation.java | 9 +- .../core/function/SDK/SDKTypeEnum.java | 43 +- .../SDK/config/AbstractCreateSDKConfig.java | 61 +++ .../config/AbstractMultiCreateSDKConfig.java | 100 ++++ .../config/AbstractSimpleCreateSDKConfig.java | 40 ++ .../function/SDK/config/CreateEtcdConfig.java | 18 +- .../SDK/config/CreateJvmCapConfig.java | 23 + .../function/SDK/config/CreateJvmConfig.java | 23 + .../SDK/config/CreateKafkaZkConfig.java | 23 + .../SDK/config/CreateKakfaConfig.java | 27 ++ .../SDK/config/CreateKubernetesConfig.java | 23 + .../SDK/config/CreateNacosConfig.java | 25 +- .../SDK/config/CreateRedisConfig.java | 20 +- .../SDK/config/CreateRemotingConfig.java | 23 + .../config/CreateRocketmqAdminSDKConfig.java | 14 +- .../SDK/config/CreateRocketmqConfig.java | 1 + .../CreateRocketmqConsumerSDKConfig.java | 38 ++ .../CreateRocketmqProduceSDKConfig.java | 29 ++ .../SDK/config/CreateRuntimeConfig.java | 3 +- .../function/SDK/config/CreateSDKConfig.java | 1 + .../SDK/config/CreateZookeeperConfig.java | 23 + .../core/function/SDK/config/NetAddress.java | 45 ++ .../SDK/config/NullCreateSDKConfig.java | 32 ++ .../SDK/operation/EtcdSDKOperation.java | 41 +- .../operation/NacosConfigSDKOperation.java | 64 --- .../operation/NacosNamingSDKOperation.java | 65 --- .../SDK/operation/NacosSDKOperation.java | 75 ++- .../SDK/operation/RedisSDKOperation.java | 32 +- .../function/SDK/operation/jvm/JvmAdmin.java | 40 ++ .../SDK/operation/jvm/JvmCapAdmin.java | 40 ++ .../operation/kafka/KafkaAdminOperation.java | 47 ++ .../kafka/KafkaZkAdminOperation.java | 30 +- .../kubernetes/KubernetesClientOperation.java | 47 ++ .../rocketmq/RocketMQAdminOperation.java | 31 +- .../rocketmq/RocketMQProduceSDKOperation.java | 36 +- .../RocketMQPushConsumerSDKOperation.java | 38 +- .../RocketMQRemotingSDKOperation.java | 136 +++++- .../RuntimeGrpcConsumerSDKOperation.java | 27 +- .../RuntimeGrpcProducerSDKOperation.java | 26 +- .../RuntimeHttpConsumerSDKOperation.java | 22 +- .../RuntimeHttpProducerSDKOperation.java | 24 +- .../runtime/RuntimeSDKOperation.java | 65 ++- .../RuntimeTcpCloudEventSDKOperation.java | 36 +- .../RuntimeTcpEventMeshSDKOperation.java | 35 +- .../RuntimeTcpOpenMessageSDKOperation.java | 30 +- .../operation/zookeeper/ZookeeperAdmin.java | 44 ++ .../SDK/util/RuntimeSDKOperationUtils.java | 1 + .../function/SDK/wrapper/NacosSDKWrapper.java | 1 + .../SDK/wrapper/RuntimeSDKWrapper.java | 38 +- .../core/gather/jmx/JmxConnector.java | 52 ++ .../dashboard/core/message/MessageManage.java | 112 +++++ .../message/model/AbstractMessageDTO.java | 46 ++ .../core/message/model/ConsumerDTO.java | 31 ++ .../core/message/model/ProducerDTO.java | 23 + .../dashboard/core/message/model/SendTDO.java | 8 +- .../operate/AbstractConsumerOperate.java | 44 ++ .../operate/AbstractMessageOperate.java | 32 +- .../operate/AbstractProducerOperate.java | 34 ++ .../core/message/operate/ConsumerOperate.java | 34 ++ .../core/message/operate/ProducerOperate.java | 30 ++ .../meta/connection/EtcdConnectionCore.java | 1 + .../meta/connection/NacosConnectionCore.java | 1 + .../core/meta/runtime/NacosRuntimeCore.java | 87 ---- .../subscription/NacosSubscriptionCore.java | 191 -------- .../core/metadata/DataMetadataHandler.java | 26 + .../core/metadata/FullMetadataHandler.java | 36 ++ .../core/metadata/GetMetadataHandler.java | 35 ++ .../core/metadata/MetadataHandler.java | 84 +--- .../core/metadata/MetadataSyncManage.java | 279 +++++++++++ .../core/metadata/MetadataSyncManager.java | 245 ---------- .../core/metadata/MetadataSyncWrapper.java | 176 +++++++ .../metadata/SyncMetadataCreateFactory.java | 140 ++++++ .../core/metadata/UpdateMetadataHandler.java | 73 +++ .../cluster/AbstractMetadataHandler.java | 57 --- .../cluster/AclSyncFromClusterService.java | 61 --- .../cluster/GroupSyncFromClusterService.java | 65 --- .../RuntimeSyncFromClusterService.java | 58 --- .../difference/AbstractBothDifference.java | 64 +++ .../difference/AbstractBufferDifference.java | 51 ++ .../difference/AbstractDifference.java | 75 +++ .../difference/BodyDataDifference.java | 50 ++ .../metadata/difference/BothDifference.java | 50 ++ .../metadata/difference/BufferDifference.java | 33 ++ .../core/metadata/difference/Difference.java | 29 ++ .../metadata/difference/NotDifference.java | 32 ++ .../metadata/request/RuntimeDataRequest.java | 27 ++ .../metadata/result/MetadataSyncResult.java | 48 ++ .../result/MetadataSyncResultHandler.java | 40 ++ .../remoting/AbstractRemotingService.java | 78 +-- .../core/remoting/Remoting2Manage.java | 228 +++++++++ .../core/remoting/RemotingManager.java | 391 --------------- .../remoting/RemotingProxyBatchException.java | 27 ++ .../core/remoting/RemotingResultType.java | 32 ++ .../jvm/AbstractJvmRemotingService.java | 29 ++ .../remoting/jvm/JvmAclRemotingService.java | 48 ++ .../jvm/JvmClientRemotingService.java | 35 ++ .../jvm/JvmConfigRemotingService.java} | 46 +- .../remoting/jvm/JvmGroupRemotingService.java | 40 ++ .../jvm/JvmOffsetRemotingService.java | 42 ++ .../jvm/JvmSubscriptionRemotingService.java} | 19 +- .../remoting/jvm/JvmTopicRemotingService.java | 53 +++ .../remoting/jvm/JvmUserRemotingService.java | 44 ++ .../AbstractRocketMQRemotingService.java | 85 +--- .../rocketmq/RocketMQAclRemotingService.java | 5 +- .../RocketMQClientRemotingService.java | 1 + .../RocketMQConfigRemotingService.java | 5 +- .../RocketMQGroupRemotingService.java | 8 + .../RocketMQOffsetRemotingService.java | 1 + .../RocketMQSubscriptionRemotingService.java | 1 + .../RocketMQTopicRemotingService.java | 42 +- .../rocketmq/RocketMQUserRemotingService.java | 1 + .../core/store/RocketmqTopicCore.java | 157 ------ .../core/function/SDK/SDKManageTest.java | 65 +++ .../core/function/SDK/SDKManagerTest.java | 80 ---- .../dashboard/core/function/SDK/Test1.java | 47 ++ .../operation/EtcdSDKCreateOperationTest.java | 57 --- .../NacosNamingSDKOperationTest.java | 55 --- .../SDK/operation/RedisSDKOperationTest.java | 60 --- .../RuntimeGrpcConsumerSDKOperationTest.java | 59 --- .../RuntimeGrpcProducerSDKOperationTest.java | 59 --- .../RuntimeHttpConsumerSDKOperationTest.java | 65 --- .../RuntimeHttpProducerSDKOperationTest.java | 65 --- .../operation/RuntimeSDKOperationTest.java | 76 --- .../RuntimeTcpCloudEventSDKOperationTest.java | 74 --- .../RuntimeTcpEventMeshSDKOperationTest.java | 74 --- .../meta/runtime/NacosRuntimeCoreTest.java | 49 -- .../metadata/MetadataSyncManagerTest.java | 140 +++--- .../metadata/MetadataSyncWrapperTest.java | 95 ++++ .../core/remoting/Remoting2ManageTest.java | 48 ++ .../core/remoting/RemotingManagerTest.java | 166 ------- eventmesh-dashboard-observe/pom.xml | 1 + eventmesh-dashboard-service/pom.xml | 2 +- .../service/dto/RocketmqProperties.java | 2 + .../service/dto/TopicProperties.java | 2 + .../service/meta/ConnectionCore.java | 3 +- .../connector/ConnectorOptService.java | 2 + .../connector/RuntimeOptService.java | 2 + .../service/remoting/AclRemotingService.java | 10 +- .../remoting/ClientRemotingService.java | 5 +- .../remoting/ConfigRemotingService.java | 10 +- .../remoting/ConnectorRemotingService.java | 1 + .../ConsumeOffsetRemotingService.java | 32 ++ .../remoting/GroupRemotingService.java | 9 + .../service/remoting/MetaRemotingService.java | 8 +- .../remoting/OffsetRemotingService.java | 2 + .../remoting/RemotingIntegrationService.java | 2 + .../remoting/SubscriptionRemotingService.java | 4 + ...e.java => TopicOffsetRemotingService.java} | 13 +- .../remoting/TopicRemotingService.java | 15 +- .../service/remoting/UserRemotingService.java | 6 + pom.xml | 8 +- 636 files changed, 19079 insertions(+), 8643 deletions(-) create mode 100644 eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/annotation/RemotingServiceMapper.java create mode 100644 eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/annotation/RemotingServiceMethodMapper.java delete mode 100644 eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/dto/Result.java rename eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/{constant/ConfigConst.java => enums/ClusterFramework.java} (52%) create mode 100644 eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ClusterOwnType.java create mode 100644 eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ClusterSyncMetadataEnum.java create mode 100644 eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/DeployStatusType.java create mode 100644 eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/MetadataType.java create mode 100644 eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/OperationRange.java create mode 100644 eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ReplicationDimension.java create mode 100644 eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ReplicationType.java delete mode 100644 eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/Status.java rename eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/cluster/InstanceUserFromClusterService.java => eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/SyncErrorType.java (83%) rename eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/health/{HealthCheckType.java => HealthCheckTypeEnum.java} (86%) create mode 100644 eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/ClusterSyncMetadata.java create mode 100644 eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/ConvertMetaData.java create mode 100644 eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/DatabaseAndMetadataMapper.java create mode 100644 eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/MetadataSyncResultMetadata.java rename eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/SyncRelationshipConfig.java => eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/PortHandler.java (81%) create mode 100644 eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/base/BaseClusterIdBase.java rename eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/{exception/BaseException.java => model/base/BaseOrganizationBase.java} (50%) create mode 100644 eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/base/BaseRuntimeIdBase.java create mode 100644 eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/base/BaseSyncBase.java create mode 100644 eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/ConsumeOffsetMetadata.java delete mode 100644 eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/MetadataConfig.java create mode 100644 eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/QueueMetadata.java create mode 100644 eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/TopicOffsetMetadata.java create mode 100644 eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/AbstractGlobal2Request.java create mode 100644 eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/Global2Request.java rename eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/{GlobalRequest.java => RemotingActionType.java} (90%) rename eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/{GetAclsRequest.java => GetAcls2Request.java} (84%) rename eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/runtime/{GetRuntimeRequest.java => GetRuntime2Request.java} (87%) rename eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/{CreateTopicRequest.java => CreateTopic2Request.java} (74%) rename eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/{GetTopicsRequest.java => GetTopics2Request.java} (85%) create mode 100644 eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/port/AbstractPortValidate.java create mode 100644 eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/port/NotPortValidate.java create mode 100644 eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/port/PortRule.java create mode 100644 eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/port/PortValidate.java create mode 100644 eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/util/ClasspathScanner.java create mode 100644 eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/utils/ClusterTypeRelationship.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/ClusterAbitityService.java delete mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/SubscriptionController.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/DetailsController.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/HomeController.java delete mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/InstanceUserController.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/CaseController.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/ClusterCycleController.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/CreateCycleService.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/ResourcesConfigController.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/create/CreateClusterByDeployScriptHandler.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/create/CreateRuntimeByDeployScriptHandler.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/design.md create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/handler/UpdateHandler.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/pause/PauseCluster.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/pause/PauseRuntime.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/relationship/RelationshipHandler.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/relationship/UnRelationshipHandler.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/uninstall/UninstallClusterHandler.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/uninstall/UninstallRuntimeHandler.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/domain/ClusterAndRuntimeDomain.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/domain/Impl/ClusterAndRuntimeDomainImpl.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/domain/OperationRangeDomain.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/domain/metadata/ClusterMetadataDomain.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/domain/metadata/ClusterOperationHandler.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/domain/metadata/MetadataAllDO.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/base/BaseClusterIdEntity.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/base/BaseIdEntity.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/base/BaseOrganizationEntity.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/base/BaseRuntimeIdEntity.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/base/BaseSyncEntity.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cases/CaseEntity.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cases/DeployScriptEntity.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cases/PortEntity.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cases/ResouceEntity.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cases/ResourcesConfigEntity.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/function/ConfigGatherEntity.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/function/MetadataSyncResultEntity.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/message/ConsumeOffsetEntity.java rename eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/message/{GroupMemberEntity.java => SubscriptionEntity.java} (78%) create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/message/TopicOffsetEntity.java delete mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/exception/GlobalExceptionHandler.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/Health2Service.java delete mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/HealthExecutor.java delete mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/HealthService.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/AbstractTopicHealthCheckService.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/ClusterHealthCheckService.java delete mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/config/HealthCheckObjectConfig.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/HealthRegister.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/jvm/JVMCapCheck.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/jvm/JVMCapTopicCheck.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/jvm/JVMCheck.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/jvm/JVMTopicCheck.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/RocketMQClusterHealthCheckService.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/design.md delete mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/MetadataServiceWrapper.java delete mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/MetadataHandlerWrapper.java delete mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/ClusterMetadataHandlerToDbImpl.java delete mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/ConfigMetadataHandlerToDbImpl.java delete mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/GroupMetadataHandlerToDbImpl.java delete mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/RuntimeMetadataHandlerToDbImpl.java delete mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/TopicMetadataHandlerToDbImpl.java delete mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/syncservice/SyncDataServiceWrapper.java rename eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/exception/EventMeshException.java => eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/SyncDataHandlerMapper.java (73%) delete mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/InstanceUserMapper.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/deploy/DeployScriptMapper.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/deploy/PortMapper.java rename eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/meta/SubscriptionCore.java => eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/message/ConsumerOffsetMapper.java (57%) rename eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/message/{OprGroupMapper.java => GroupMapper.java} (80%) create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/message/TopicOffsetMapper.java delete mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/storage/StoreMapper.java rename eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/{log/LogControllerMapper.java => deploy/CaseControllerMapper.java} (66%) create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/deploy/ClusterCycleControllerMapper.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/deploy/ResourceConfigControllerMapper.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/DO/QueryRuntimeByClusterIdAndClusterTypeDO.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/DO/clusterRelationship/QueryListByClusterIdAndTypeDO.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/DO/runtime/QueryRuntimeByBigExpandClusterDO.java rename eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/{entity/CreateConnectionEntity.java => modle/OperateDTO.java} (66%) create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/OrganizationIdDTO.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/CreateClusterByCompleteDataDTO.java rename eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/{CreateClusterDTO.java => CreateClusterBySimpleDataDTO.java} (82%) create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/VerifyNameDTO.java rename eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/client/{SelectByClusterIdDTO.java => QueryClientByUserFormDTO.java} (85%) rename eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/RemotingServiceType.java => eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/cluster/ClusterDetailsVO.java (88%) create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/cluster/QueryClusterByOrganizationIdAndTypeDTO.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/cluster/QueryRelationClusterByClusterIdAndTypeDTO.java rename eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/runtime/{CrateRuntimeDTO.java => CreateRuntimeDTO.java} (75%) create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/runtimeCycle/CreateRuntimeDTO.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/BaseConifgDO.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/BaseDeployDO.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/ClusterAllMetadataDO.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/DeployClusterDO.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/DeployFullDO.java rename eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/{config/ChangeConfigEntity.java => deploy/DeployGroupDO.java} (81%) create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/DeployMetadataDO.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/DeployRuntimeDO.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/DeployTopicDO.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/GetPortsDO.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/cases/QueryCaseByObjectTypeDTO.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/create/CreateClusterByDeployScriptDO.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/create/CreateClusterByEventMesh.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/create/CreateEventMeshClusterByOnlyScript.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/create/CreateRuntimeByDeployScriptDO.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/create/CreateRuntimeByDeployScriptDTO.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/create/CreateRuntimeByOnlyDataDO.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/resouce/QueryResourceByObjectTypeDTO.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/domain/ClusterEntityDO.java rename eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/{mapstruct/config/ConfigControllerMapper.java => modle/domain/RuntimeEntityDO.java} (66%) rename eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/{function/health/check/config/RocketmqConfig.java => modle/dto/config/ChangeConfigDTO.java} (82%) rename eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/{ => dto}/config/UpdateConfigsLog.java (85%) rename eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/{entity/connection/AddConnectionEntity.java => modle/dto/connection/AddConnectionDTO.java} (85%) rename eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/{entity/connection/AddConnectorConfigEntity.java => modle/dto/connection/AddConnectorConfigDTO.java} (83%) create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/operation/OperationBaseDTO.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/vo/RuntimeIdDTO.java delete mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/DataServiceWrapper.java delete mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/impl/ConnectionDataServiceDatabaseImpl.java delete mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/impl/InstanceUserServiceImpl.java rename eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/cluster/TopicSyncFromClusterService.java => eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/connector/Impl/ResourcesConfigServiceImpl.java (52%) create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/connector/ResourcesConfigService.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/deploy/DeployScriptService.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/deploy/PortService.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/deploy/impl/DeployScriptServiceImpl.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/deploy/impl/PortServiceImpl.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/Impl/MetadataSyncResultServiceImpl.java rename eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/{store/StoreService.java => function/MetadataSyncResultService.java} (56%) create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/metadata/AbstractDBDataMetadataHandler.java rename eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/meta/subscription/EtcdSubscriptionCore.java => eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/metadata/ClientDataMetadataHandler.java (59%) create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/metadata/ConfigDataMetadataHandler.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/metadata/ConsumeOffsetDataMetadataHandler.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/metadata/GroupDataMetadataHandler.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/metadata/NetConnectionDataMetadataHandler.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/metadata/RuntimeDataMetadataHandler.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/metadata/TopicDataMetadataHandler.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/metadata/TopicOffsetDataMetadataHandler.java delete mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/store/Impl/StoreServiceImpl.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/DefaultDataHandler.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/FunctionManage.java delete mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/FunctionManager.java delete mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/FunctionManagerLoader.java delete mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/FunctionManagerProperties.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/RuntimeDeployService.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/metadata/DatabaseAndMetadataType.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/metadata/DefaultMetadataSyncResultHandler.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/metadata/convert/ClientConvertMetaData.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/metadata/convert/ClusterConvertMetaData.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/metadata/convert/ConfigConvertMetaData.java rename eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/{mapstruct/connection/ConnectionControllerMapper.java => spring/support/metadata/convert/ConsumeOffsetConvertMetaData.java} (54%) create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/metadata/convert/GroupConvertMetaData.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/metadata/convert/RuntimeConvertMetaData.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/metadata/convert/TopicConvertMetaData.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/metadata/convert/TopicOffsetConvertMetaData.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/register/AbstractBuildMetadata.java rename eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/{service/cluster/InstanceUserService.java => spring/support/register/BuildMetadata.java} (58%) create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/register/BuildMetadataManage.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/register/ScriptBuildData.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/register/meta/AbstractMetaBuildMetadata.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/register/meta/RocketNameServiceBuildMetadata.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/register/meta/ZookeeperBuildMetadata.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/register/runtime/AbstractRuntimeBuildMetadata.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/register/runtime/EventMethRuntimeBuildMetadata.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/register/runtime/RocketMQBuildMetadata.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/utils/RuntimeUtils.java create mode 100644 eventmesh-dashboard-console/src/main/resources/RENAME.md create mode 100644 eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.jmx create mode 100644 eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/databuild/BuildFullMetadata.java create mode 100644 eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/databuild/BuildFullSceneData.java create mode 100644 eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/Health2ServiceTest.java delete mode 100644 eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/HealthExecutorTest.java delete mode 100644 eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/HealthServiceTest.java delete mode 100644 eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/RedisCheckTest.java delete mode 100644 eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/ConfigMetadataHandlerToDbImplTest.java delete mode 100644 eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/ConnectionMetadataHandlerToDbImplTest.java delete mode 100644 eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/GroupMetadataHandlerToDbImplTest.java delete mode 100644 eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/RuntimeMetadataHandlerToDbImplTest.java delete mode 100644 eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/TopicMetadataHandlerToDbImplTest.java delete mode 100644 eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/integration/health/HealthServiceIntegrateTest.java create mode 100644 eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/cluster/ClusterDataMapperTest.java create mode 100644 eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/cluster/ClusterEntityMapperTest.java create mode 100644 eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/cluster/ClusterRelationshipMapperTest.java create mode 100644 eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/cluster/RuntimeEntityMapperTest.java create mode 100644 eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/message/TopicEntityMapperTest.java create mode 100644 eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/model/domain/ClusterMetadataDomainTest.java create mode 100644 eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/service/cluster/impl/ClusterEntityServiceImplTest.java create mode 100644 eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/spring/support/DefaultDataHandlerTest.java delete mode 100644 eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/spring/support/FunctionManagerTest.java create mode 100644 eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/spring/support/RuntimeDeployServiceTest.java create mode 100644 eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/spring/support/metadata/convert/RuntimeConvertMetaDataTest.java create mode 100644 eventmesh-dashboard-console/src/test/resources/kubernetes/EventMesh-runtime-refer.yaml create mode 100644 eventmesh-dashboard-console/src/test/resources/kubernetes/EventMesh-runtime.yaml create mode 100644 eventmesh-dashboard-console/src/test/resources/kubernetes/RocketMQ-broker-refer.yaml create mode 100644 eventmesh-dashboard-console/src/test/resources/kubernetes/RocketMQ-broker.yaml create mode 100644 eventmesh-dashboard-console/src/test/resources/kubernetes/RocketMQ-nameservice-refer.yaml create mode 100644 eventmesh-dashboard-console/src/test/resources/kubernetes/RocketMQ-nameservice.yaml rename eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/store/TopicCore.java => eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/cluster/BaseDataDO.java (70%) create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/cluster/ClusterBaseDO.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/cluster/MetadataBaseDO.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/cluster/RuntimeBaseDO.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/cluster/RuntimeDO.java delete mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/config/AdminProperties.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/AbstractClientInfo.java rename eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/{remoting/RemotingServiceRuntimeConfig.java => function/SDK/ClientWrapper.java} (73%) create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/ConfigManage.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/ProtocolType.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/SDKManage.java delete mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/SDKManager.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/SDKMetadata.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/AbstractCreateSDKConfig.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/AbstractMultiCreateSDKConfig.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/AbstractSimpleCreateSDKConfig.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateJvmCapConfig.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateJvmConfig.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateKafkaZkConfig.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateKakfaConfig.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateKubernetesConfig.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateRemotingConfig.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateRocketmqConsumerSDKConfig.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateRocketmqProduceSDKConfig.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateZookeeperConfig.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/NetAddress.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/NullCreateSDKConfig.java delete mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/NacosConfigSDKOperation.java delete mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/NacosNamingSDKOperation.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/jvm/JvmAdmin.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/jvm/JvmCapAdmin.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/kafka/KafkaAdminOperation.java rename eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/exception/EventMeshAdminException.java => eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/kafka/KafkaZkAdminOperation.java (52%) create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/kubernetes/KubernetesClientOperation.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/zookeeper/ZookeeperAdmin.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/gather/jmx/JmxConnector.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/message/MessageManage.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/message/model/AbstractMessageDTO.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/message/model/ConsumerDTO.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/message/model/ProducerDTO.java rename eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/RemotingOperate.java => eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/message/model/SendTDO.java (87%) create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/message/operate/AbstractConsumerOperate.java rename eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/exception/MetaException.java => eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/message/operate/AbstractMessageOperate.java (56%) create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/message/operate/AbstractProducerOperate.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/message/operate/ConsumerOperate.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/message/operate/ProducerOperate.java delete mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/meta/runtime/NacosRuntimeCore.java delete mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/meta/subscription/NacosSubscriptionCore.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/DataMetadataHandler.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/FullMetadataHandler.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/GetMetadataHandler.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/MetadataSyncManage.java delete mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/MetadataSyncManager.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/MetadataSyncWrapper.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/SyncMetadataCreateFactory.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/UpdateMetadataHandler.java delete mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/cluster/AbstractMetadataHandler.java delete mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/cluster/AclSyncFromClusterService.java delete mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/cluster/GroupSyncFromClusterService.java delete mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/cluster/RuntimeSyncFromClusterService.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/difference/AbstractBothDifference.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/difference/AbstractBufferDifference.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/difference/AbstractDifference.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/difference/BodyDataDifference.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/difference/BothDifference.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/difference/BufferDifference.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/difference/Difference.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/difference/NotDifference.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/request/RuntimeDataRequest.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/result/MetadataSyncResult.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/result/MetadataSyncResultHandler.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/Remoting2Manage.java delete mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/RemotingManager.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/RemotingProxyBatchException.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/RemotingResultType.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/jvm/AbstractJvmRemotingService.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/jvm/JvmAclRemotingService.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/jvm/JvmClientRemotingService.java rename eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/{metadata/cluster/ConfigSyncFromClusterService.java => remoting/jvm/JvmConfigRemotingService.java} (50%) create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/jvm/JvmGroupRemotingService.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/jvm/JvmOffsetRemotingService.java rename eventmesh-dashboard-core/src/{test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeTcpOpenMessageSDKOperationTest.java => main/java/org/apache/eventmesh/dashboard/core/remoting/jvm/JvmSubscriptionRemotingService.java} (58%) create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/jvm/JvmTopicRemotingService.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/jvm/JvmUserRemotingService.java delete mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/store/RocketmqTopicCore.java create mode 100644 eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/SDKManageTest.java delete mode 100644 eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/SDKManagerTest.java create mode 100644 eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/Test1.java delete mode 100644 eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/EtcdSDKCreateOperationTest.java delete mode 100644 eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/NacosNamingSDKOperationTest.java delete mode 100644 eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RedisSDKOperationTest.java delete mode 100644 eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeGrpcConsumerSDKOperationTest.java delete mode 100644 eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeGrpcProducerSDKOperationTest.java delete mode 100644 eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeHttpConsumerSDKOperationTest.java delete mode 100644 eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeHttpProducerSDKOperationTest.java delete mode 100644 eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeSDKOperationTest.java delete mode 100644 eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeTcpCloudEventSDKOperationTest.java delete mode 100644 eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeTcpEventMeshSDKOperationTest.java delete mode 100644 eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/meta/runtime/NacosRuntimeCoreTest.java create mode 100644 eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/metadata/MetadataSyncWrapperTest.java create mode 100644 eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/remoting/Remoting2ManageTest.java delete mode 100644 eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/remoting/RemotingManagerTest.java create mode 100644 eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/ConsumeOffsetRemotingService.java rename eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/{RuntimeRemotingService.java => TopicOffsetRemotingService.java} (73%) diff --git a/eventmesh-dashboard-common/pom.xml b/eventmesh-dashboard-common/pom.xml index 50890fe9..806a2892 100644 --- a/eventmesh-dashboard-common/pom.xml +++ b/eventmesh-dashboard-common/pom.xml @@ -30,20 +30,17 @@ eventmesh-dashboard-common - 1.8 + 17 UTF-8 UTF-8 - - - org.springframework.boot - spring-boot-starter-web - provided + org.springframework + spring-core + 5.1.19.RELEASE - org.projectlombok @@ -54,6 +51,11 @@ commons-lang3 3.14.0 + + org.apache.commons + commons-collections4 + 4.4 + com.alibaba.fastjson2 fastjson2 diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/annotation/RemotingServiceMapper.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/annotation/RemotingServiceMapper.java new file mode 100644 index 00000000..20a278b3 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/annotation/RemotingServiceMapper.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.common.annotation; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface RemotingServiceMapper { + + + ClusterType clusterType(); + +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/annotation/RemotingServiceMethodMapper.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/annotation/RemotingServiceMethodMapper.java new file mode 100644 index 00000000..fb619f6d --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/annotation/RemotingServiceMethodMapper.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.common.annotation; + +import org.apache.eventmesh.dashboard.common.model.remoting.RemotingActionType; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * + */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface RemotingServiceMethodMapper { + + RemotingActionType[] value(); +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/constant/ApiPrefix.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/constant/ApiPrefix.java index df5f0715..a25ee55b 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/constant/ApiPrefix.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/constant/ApiPrefix.java @@ -15,8 +15,10 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.constant; +@Deprecated public class ApiPrefix { public static final String API_PREFIX = "/eventmesh-dashboard/"; diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/constant/NacosConst.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/constant/NacosConst.java index b23a8d3d..592a7e93 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/constant/NacosConst.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/constant/NacosConst.java @@ -15,8 +15,10 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.constant; +@Deprecated public class NacosConst { public static final String LOGIN_API = "/nacos/v1/auth/login"; diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/constant/StoreTypeConstant.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/constant/StoreTypeConstant.java index 665024af..455f1219 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/constant/StoreTypeConstant.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/constant/StoreTypeConstant.java @@ -15,8 +15,10 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.constant; +@Deprecated public class StoreTypeConstant { public static final String STORE_TYPE_TYPE_UNKNOWN = "unknown"; diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/constant/health/HealthCheckTypeConstant.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/constant/health/HealthCheckTypeConstant.java index 5252899e..31f095ab 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/constant/health/HealthCheckTypeConstant.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/constant/health/HealthCheckTypeConstant.java @@ -15,10 +15,12 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.constant.health; import org.apache.eventmesh.dashboard.common.constant.StoreTypeConstant; +@Deprecated public class HealthCheckTypeConstant { public static final String HEALTH_CHECK_TYPE_UNKNOWN = "unknown"; diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/constant/health/HealthConstant.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/constant/health/HealthConstant.java index dd724889..b00ea3d1 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/constant/health/HealthConstant.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/constant/health/HealthConstant.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.constant.health; public class HealthConstant { diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/dto/Result.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/dto/Result.java deleted file mode 100644 index e34fd920..00000000 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/dto/Result.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.common.dto; - -import org.apache.eventmesh.dashboard.common.enums.Status; -import org.apache.eventmesh.dashboard.common.exception.BaseException; - -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -/** - * A RESTful response DTO. - */ - -@Data -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class Result { - - private T data; - - private Integer pages; - - private StatusMessage message; - - public Result(StatusMessage statusMessage) { - this.message = statusMessage; - } - - public Result(T data, Integer pages) { - this.data = data; - this.pages = pages; - } - - /** - * The request is valid and the result is wrapped in {@link Result}. - */ - public static Result success() { - return new Result<>(new StatusMessage(Status.SUCCESS)); - } - - public static Result success(Result result) { - result.setMessage(new StatusMessage(Status.SUCCESS)); - return result; - } - - public static Result success(T data) { - return new Result<>(data, null, new StatusMessage(Status.SUCCESS)); - } - - /** - * The request is valid and the result is returned in {@link ResponseEntity}. Logic issues should use 422 Unprocessable Entity instead of 200 OK. - */ - public static ResponseEntity> ok() { - return ResponseEntity.ok(new Result<>(new StatusMessage(Status.SUCCESS))); - } - - public static ResponseEntity> ok(Result result) { - result.setMessage(new StatusMessage(Status.SUCCESS)); - return ResponseEntity.ok(result); - } - - /** - * The request is invalid. - */ - public static ResponseEntity> badRequest(String message) { - return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new Result<>(new StatusMessage(message))); - } - - /** - * The request is valid but cannot be processed due to business logic issues. - */ - public static ResponseEntity> unprocessable(String message) { - return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY).body(new Result<>(new StatusMessage(message))); - } - - /** - * Uncaught exception happened in EventMeshAdmin application. - */ - public static ResponseEntity> internalError(String message) { - return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(new Result<>(new StatusMessage(message))); - } - - /** - * Upstream service unavailable such as Meta. - */ - public static ResponseEntity> badGateway(String message) { - return ResponseEntity.status(HttpStatus.BAD_GATEWAY).body(new Result<>(new StatusMessage(message))); - } - - @Data - public static class StatusMessage { - - private String status; - - private String category; - - private String desc; - - public StatusMessage(BaseException e) { - this.status = e.getStatus().name(); - this.category = e.getStatus().getCategory().name(); - this.desc = e.getMessage(); - } - - /** - * Only recommended for returning successful results, the stack trace cannot be displayed when returning unsuccessful results. - */ - public StatusMessage(Status status) { - this.status = status.name(); - this.category = status.getCategory().name(); - this.desc = status.getDesc(); // no stack trace - } - - public StatusMessage(String desc) { - this.desc = desc; - } - } -} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/BusinessType.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/BusinessType.java index 41ca551a..2b6bfafb 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/BusinessType.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/BusinessType.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.enums; /** @@ -23,6 +24,7 @@ * 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)', */ +@Deprecated public enum BusinessType { } diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/constant/ConfigConst.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ClusterFramework.java similarity index 52% rename from eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/constant/ConfigConst.java rename to eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ClusterFramework.java index f13a40ee..0de7ccb2 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/constant/ConfigConst.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ClusterFramework.java @@ -15,26 +15,52 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.common.constant; -public class ConfigConst { +package org.apache.eventmesh.dashboard.common.enums; - // yml config - public static final String ADMIN_PROPS_PREFIX = "eventmesh"; - public static final String META_TYPE_NACOS = "nacos"; - public static final String META_TYPE_ETCD = "etcd"; - public static final String STORE_TYPE_STANDALONE = "standalone"; - public static final String STORE_TYPE_ROCKETMQ = "rocketmq"; - public static final String STORE_TYPE_KAFKA = "kafka"; +import java.util.Objects; - // Open-API - public static final String HTTP_PREFIX = "http://"; - public static final String HTTPS_PREFIX = "https://"; +public enum ClusterFramework { + + NOT, + + INDEPENDENCE, - // common /** - * colon with space + * AP 架构,的 meta 有控制行为,需要逐一通知 */ - public static final String COLON = ": "; + AP, + + CP, + + CAP, + + MAIN_SLAVE, + + PAXOS, + + RAFT, + + ZK, + ; + + public boolean isAP() { + return Objects.equals(this, AP); + } + + public boolean isCP() { + return Objects.equals(this, CP); + } + + public boolean isMainSlave() { + return Objects.equals(this, MAIN_SLAVE); + } + + public boolean isCAP() { + return Objects.equals(this, ZK) || Objects.equals(this, RAFT) || Objects.equals(this, PAXOS) || Objects.equals(this, CAP); + } -} + public boolean isNot() { + return this == NOT; + } +} \ No newline at end of file diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ClusterOwnType.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ClusterOwnType.java new file mode 100644 index 00000000..b5deee5c --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ClusterOwnType.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.common.enums; + +public enum ClusterOwnType { + + NOT, + + INDEPENDENCE, + + SHARE, + + OVERALL_SHARE, + + ORGANIZATION_SHARE, + + ; + + public boolean isIndependence() { + return this == INDEPENDENCE; + } +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ClusterSyncMetadataEnum.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ClusterSyncMetadataEnum.java new file mode 100644 index 00000000..7560b195 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ClusterSyncMetadataEnum.java @@ -0,0 +1,113 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.common.enums; + +import org.apache.eventmesh.dashboard.common.model.ClusterSyncMetadata; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.concurrent.ConcurrentHashMap; + +import lombok.Getter; + +/** + * 集群的特性 + */ +public enum ClusterSyncMetadataEnum { + + + EVENTMESH_RUNTIME( + ClusterSyncMetadata.builder().clusterFramework(ClusterFramework.INDEPENDENCE).metadataTypeList(ClusterSyncMetadata.STORAGE).build()), + + EVENTMESH_META_ETCD(ClusterSyncMetadata.builder().clusterFramework(ClusterFramework.RAFT).metadataTypeList(ClusterSyncMetadata.META).build()), + + EVENTMESH_META_NACOS(ClusterSyncMetadata.builder().clusterFramework(ClusterFramework.AP).metadataTypeList(ClusterSyncMetadata.META).build()), + + STORAGE_ROCKETMQ_NAMESERVER( + ClusterSyncMetadata.builder().clusterFramework(ClusterFramework.AP).metadataTypeList(ClusterSyncMetadata.META).build()), + + STORAGE_ROCKETMQ_BROKER_MAIN_SLAVE( + ClusterSyncMetadata.builder().clusterFramework(ClusterFramework.MAIN_SLAVE).metadataTypeList(ClusterSyncMetadata.STORAGE).build()), + + STORAGE_ROCKETMQ_BROKER_RFT( + ClusterSyncMetadata.builder().clusterFramework(ClusterFramework.RAFT).metadataTypeList(ClusterSyncMetadata.STORAGE).build()), + + STORAGE_KAFKA_ZK(ClusterSyncMetadata.builder().clusterFramework(ClusterFramework.ZK).metadataTypeList(ClusterSyncMetadata.META).build()), + + STORAGE_KAFKA_RAFT(ClusterSyncMetadata.builder().clusterFramework(ClusterFramework.RAFT).metadataTypeList(ClusterSyncMetadata.META).build()), + + STORAGE_KAFKA_BROKER( + ClusterSyncMetadata.builder().clusterFramework(ClusterFramework.CAP) + .metadataTypeList(ListWrapper.build().add(ClusterSyncMetadata.STORAGE).add(ClusterSyncMetadata.AUTH).list) + .replicationDimension(ReplicationDimension.TOPIC).build()), + + STORAGE_JVM_BROKER( + ClusterSyncMetadata.builder().clusterFramework(ClusterFramework.MAIN_SLAVE).metadataTypeList(ClusterSyncMetadata.TEST_ONE).build()), + + STORAGE_JVM_CAP_BROKER( + ClusterSyncMetadata.builder().clusterFramework(ClusterFramework.CAP).metadataTypeList(ClusterSyncMetadata.STORAGE) + .replicationDimension(ReplicationDimension.TOPIC).build()), + ; + + private static final Map SYNC_METADATA_CONCURRENT_HASH_MAP = new ConcurrentHashMap<>(); + + public static ClusterSyncMetadata getClusterSyncMetadata(ClusterType clusterType) { + ClusterSyncMetadata clusterSyncMetadata = SYNC_METADATA_CONCURRENT_HASH_MAP.get(clusterType); + try { + if (Objects.isNull(clusterSyncMetadata)) { + ClusterSyncMetadataEnum clusterSyncMetadataEnum = ClusterSyncMetadataEnum.valueOf(clusterType.toString()); + SYNC_METADATA_CONCURRENT_HASH_MAP.put(clusterType, clusterSyncMetadataEnum.getClusterSyncMetadata()); + clusterSyncMetadata = clusterSyncMetadataEnum.getClusterSyncMetadata(); + } + } catch (Exception e) { + clusterSyncMetadata = ClusterSyncMetadata.EMPTY_OBJECT; + SYNC_METADATA_CONCURRENT_HASH_MAP.put(clusterType, clusterSyncMetadata); + } + return clusterSyncMetadata; + } + + public static ClusterFramework getClusterFramework(ClusterType clusterType) { + return getClusterSyncMetadata(clusterType).getClusterFramework(); + } + + static class ListWrapper { + + static ListWrapper build() { + return new ListWrapper(); + } + + private List list = new ArrayList<>(); + + ListWrapper add(List list) { + list.addAll(list); + return this; + } + } + + @Getter + private ClusterSyncMetadata clusterSyncMetadata; + + ClusterSyncMetadataEnum(ClusterSyncMetadata clusterSyncMetadata) { + this.clusterSyncMetadata = clusterSyncMetadata; + } + + +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ClusterTrusteeshipType.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ClusterTrusteeshipType.java index 44b852d1..66daa531 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ClusterTrusteeshipType.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ClusterTrusteeshipType.java @@ -15,16 +15,123 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.enums; +import java.util.List; + +import lombok.Getter; + +/** + * + */ +@Getter public enum ClusterTrusteeshipType { - FIRE_AND_FORGET_TRUSTEESHIP, - TRUSTEESHIP, + NOT("", List.of(ClusterType.CLUSTER, ClusterType.META, ClusterType.RUNTIME, ClusterType.META_AND_RUNTIME)), + + /** + * 全托管 存储不好做全托管 RocketMQ, kafhka,都适合 + **/ + SELF("自维护", List.of(ClusterType.CLUSTER, ClusterType.META, ClusterType.RUNTIME, ClusterType.META_AND_RUNTIME)), + + /** + * + */ + TRUSTEESHIP("托管", List.of(ClusterType.CLUSTER, ClusterType.META, ClusterType.RUNTIME, ClusterType.META_AND_RUNTIME)), + + /** + * 托管,从 meta 获得 runtime 提供了 meta地址,从 meta 获得 runtime 主要用于已经存在的集群 支持: eventmesh cluster RocketMQ cluster + **/ + TRUSTEESHIP_FIND("托管且从 meta 获得 runtime,同时同步配置", List.of(ClusterType.META, ClusterType.META_AND_RUNTIME)), + + /** + * 继承 TRUSTEESHIP_FIND 能力 同时以 集群为主 + **/ + TRUSTEESHIP_FIND_REVERSE("以集群为主", List.of(ClusterType.CLUSTER, ClusterType.META, ClusterType.RUNTIME, ClusterType.META_AND_RUNTIME)), + + // 不托管 + NO_TRUSTEESHIP("不托管", List.of(ClusterType.CLUSTER, ClusterType.META, ClusterType.RUNTIME, ClusterType.META_AND_RUNTIME)); + + private List clusterTypeList; + + private final String type; + + private String name; + + private FirstToWhom firstToWhom; + + public enum FirstToWhom { + + NOT, + + DASHBOARD, + + RUNTIME, + + /** + * 等待开始 + */ + WAIT_START, + + /** + * 同步完成 + */ + COMPLETE, + + /** + * 同步中 + */ + UNDER_WAY, + + FAIL, + + ; + } + + /** + * 注册 meta, 表示需要从 meta 读取 runtime。 如果 FirstToWhom.DASHBOARD , 那么读取的 runtime 都标记为 DASHBOARD 如果 不托管 , 那么读取的 runtime 标记如 托管状态 + *

+ * 读取 runtime 的会后, 如何是 DASHBOARD , 使用 database 同步 如果是 RUNTIME , 使用 runtime 同步 执行完之后,判断 同步状态, 如果是 以 runtime 为主,使用 runtime 同步, 以 runtime 的不允许修改 + * 如果是 以 database 为主,使用 database 同步 分为第一次同步,与永久同步 + */ + @Deprecated + public enum TrusteeshipArrangeType { + + /** + * 同时注册了 meta 与 runtime + */ + META_AND_RUNTIME, + + /** + * 只注册 meta + */ + META, + + /** + * 只注册 runtime + */ + RUNTIME, + + /** + * 自维护 + */ + SELF, + + + } + + ClusterTrusteeshipType(String type, List clusterTypeList) { + this.type = type; + } - REVERSE, - NO_TRUSTEESHIP; + public boolean isSelf() { + return this == ClusterTrusteeshipType.SELF || this == ClusterTrusteeshipType.TRUSTEESHIP; + } + public boolean isReverse() { + return this == ClusterTrusteeshipType.TRUSTEESHIP_FIND || this == ClusterTrusteeshipType.TRUSTEESHIP_FIND_REVERSE; + } } diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ClusterType.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ClusterType.java index 41d918fb..f8b24519 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ClusterType.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ClusterType.java @@ -15,8 +15,11 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.enums; +import org.apache.commons.lang3.reflect.FieldUtils; + import java.util.ArrayList; import java.util.List; import java.util.Objects; @@ -25,19 +28,54 @@ public enum ClusterType { + DEFINITION(0), + DEFAULT(1), + EVENTMESH(20), + CLUSTER(1), + + META(2), + + RUNTIME(3), + + META_AND_RUNTIME(4), + + BROKER(4), + + COPY_BROKER(5), + + ZK_BROKER(6), + + RFT_BROKER(6), + STORAGE(21), + RUNTIME_CLUSTER(21), + + META_CLUSTER(22), + + STORAGE_CLUSTER(22), + DEFAULT_TYPE_NAME(1), - CLUSTER(1), - META(2), + CLUSTER_TYPE_META(1), - RUNTIME(3), + CLUSTER_TYPE_RUNTIME(1), + + CLUSTER_TYPE_STORAGE(1), + + + NODE_BY_COPY_IN_TYPE(2), + + NODE_BY_COPY_IN_TYPE_NOT_HAVE(2), + + NODE_BY_COPY_IN_TYPE_MAIN(2), + + NODE_BY_COPY_IN_TYPE_SLAVE(3), RUNTIME_EVENT_RUNTIME(ClusterType.META.code + 1), @@ -48,10 +86,13 @@ public enum ClusterType { META_TYPE_NACOS(ClusterType.META.code + 2), + META_TYPE_ZK(ClusterType.META.code + 3), + META_TYPE_ROCKETMQ_NAMESERVER(ClusterType.META.code + 31), + KUBERNETES_RUNTIME(DEFAULT, DEFAULT, CLUSTER, RUNTIME, RemotingType.KUBERNETES), - EVENTMESH_CLUSTER(EVENTMESH, EVENTMESH, CLUSTER, DEFAULT, RemotingType.EVENT_MESH_RUNTIME), + EVENTMESH_CLUSTER(EVENTMESH, EVENTMESH, CLUSTER, DEFINITION, RemotingType.EVENT_MESH_RUNTIME), EVENTMESH_RUNTIME(EVENTMESH, EVENTMESH, RUNTIME, DEFAULT, RemotingType.EVENT_MESH_RUNTIME), @@ -61,27 +102,130 @@ public enum ClusterType { STORAGE_ROCKETMQ(ClusterType.STORAGE.code + 1), - STORAGE_ROCKETMQ_CLUSTER(STORAGE, STORAGE_ROCKETMQ, CLUSTER, DEFAULT, RemotingType.ROCKETMQ), + STORAGE_ROCKETMQ_CLUSTER(STORAGE, STORAGE_ROCKETMQ, CLUSTER, DEFINITION, RemotingType.ROCKETMQ), STORAGE_ROCKETMQ_NAMESERVER(STORAGE, STORAGE_ROCKETMQ, META, DEFAULT, RemotingType.ROCKETMQ_NAMESERVER), - STORAGE_ROCKETMQ_BROKER(STORAGE, STORAGE_ROCKETMQ, RUNTIME, DEFAULT, RemotingType.ROCKETMQ); + STORAGE_ROCKETMQ_BROKER(STORAGE, STORAGE_ROCKETMQ, RUNTIME, DEFINITION, RemotingType.ROCKETMQ), + + STORAGE_ROCKETMQ_BROKER_MAIN_SLAVE(STORAGE, STORAGE_ROCKETMQ_BROKER, RUNTIME, DEFAULT, RemotingType.ROCKETMQ), + + STORAGE_ROCKETMQ_BROKER_RAFT(STORAGE, STORAGE_ROCKETMQ_BROKER, RUNTIME, DEFAULT, RemotingType.ROCKETMQ), + + + STORAGE_KAFKA(STORAGE_ROCKETMQ.code + 1), + STORAGE_KAFKA_CLUSTER(STORAGE, STORAGE_KAFKA, CLUSTER, DEFINITION, RemotingType.KAFKA), - public static final List STORAGE_TYPES = getStorage(); + STORAGE_KAFKA_ZK(STORAGE, STORAGE_KAFKA, META, META_TYPE_ZK, RemotingType.ZK), + + STORAGE_KAFKA_RAFT(STORAGE, STORAGE_KAFKA, META_AND_RUNTIME, STORAGE_KAFKA, RemotingType.KAFKA), + + STORAGE_KAFKA_BROKER(STORAGE, STORAGE_KAFKA, RUNTIME, DEFAULT, RemotingType.KAFKA), + + + STORAGE_REDIS(STORAGE_KAFKA.code + 1), + + STORAGE_REDIS_CLUSTER(STORAGE, STORAGE_REDIS, CLUSTER, DEFINITION, RemotingType.REDIS), + + STORAGE_REDIS_BROKER(STORAGE, STORAGE_REDIS, RUNTIME, DEFAULT, RemotingType.REDIS), + + STORAGE_JVM(STORAGE_REDIS.code + 1), + + STORAGE_JVM_CLUSTER(STORAGE, STORAGE_JVM, CLUSTER, DEFINITION, RemotingType.JVM), + + STORAGE_JVM_META(STORAGE, STORAGE_JVM, META, DEFAULT, RemotingType.JVM), + + STORAGE_JVM_BROKER(STORAGE, STORAGE_JVM, RUNTIME, DEFAULT, RemotingType.JVM), + + STORAGE_JVM_CAP(STORAGE_REDIS.code + 1), + + STORAGE_JVM_CAP_CLUSTER(STORAGE, STORAGE_JVM_CAP, CLUSTER, DEFINITION, RemotingType.JVM), + + STORAGE_JVM_CAP_BROKER(STORAGE, STORAGE_JVM_CAP, META_AND_RUNTIME, DEFAULT, RemotingType.JVM), + ; + + + private static final List STORAGE_MAIN_CLUSTER_TYPE_LIST = new ArrayList<>(); + + private static final List STORAGE_META_CLUSTER_TYPE_LIST = new ArrayList<>(); + + private static final List STORAGE_RUNTIME_CLUSTER_TYPE_LIST = new ArrayList<>(); + + private static final List STORAGE_META_RUNTIME_TYPE_LIST = new ArrayList<>(); + + static { + for (ClusterType clusterType : ClusterType.values()) { + if (clusterType.isStorageCluster()) { + STORAGE_MAIN_CLUSTER_TYPE_LIST.add(clusterType); + } + if (clusterType.isStorageMeta()) { + STORAGE_META_CLUSTER_TYPE_LIST.add(clusterType); + } + if (clusterType.isStorageRuntime()) { + STORAGE_RUNTIME_CLUSTER_TYPE_LIST.add(clusterType); + } + if (clusterType.isMetaAndRuntime()) { + STORAGE_META_RUNTIME_TYPE_LIST.add(clusterType); + } + } + } + + public static List getStorageCluster() { + return STORAGE_MAIN_CLUSTER_TYPE_LIST; + } + + public static List getStorageMetaCluster() { + return STORAGE_META_CLUSTER_TYPE_LIST; + } + + public static List getStorageRuntimeCluster() { + return STORAGE_RUNTIME_CLUSTER_TYPE_LIST; + } + + public static List getStorageMetaRuntimeCluster() { + return STORAGE_META_RUNTIME_TYPE_LIST; + } + + /** + * 集群在 eventmesh 集群内的 节点(集群)类型。meta集群,存储集群,runtime集群 + */ @Getter private ClusterType eventmeshNodeType; + /** + * 具体类型集群 + */ @Getter private ClusterType assemblyName; + + /** + * 这个节点在 具体集群内是什么节点 + */ @Getter private ClusterType assemblyNodeType; + + /** + * 厂商是什么类型。比如注册中心。注册中心有 etc,nacos + */ @Getter private ClusterType assemblyBusiness; + + /** + * 远程协议类型 + */ @Getter private RemotingType remotingType; + @Getter private int code; + + private List mainClusterType; + + private List metaClusterType; + + private List runtimeClusterType; + ClusterType(int code) { this.code = code; } @@ -96,29 +240,137 @@ public enum ClusterType { this.remotingType = remotingType; } - private static List getStorage() { + + /** + * 半托管状态需要 如要从 + */ + public boolean isEventMethMeta() { + return this.eventmeshNodeType.equals(EVENTMESH) && this.assemblyNodeType.equals(META); + } + + + public boolean isEventMethRuntime() { + return this == EVENTMESH_RUNTIME; + } + + public boolean isMeta() { + if (Objects.isNull(this.assemblyNodeType)) { + return false; + } + return this.assemblyNodeType.equals(META); + } + + public boolean isMetaAndRuntime() { + if (Objects.isNull(this.eventmeshNodeType)) { + return false; + } + return this.eventmeshNodeType.equals(META_AND_RUNTIME); + } + + public boolean isRuntime() { + if (Objects.isNull(this.assemblyNodeType)) { + return false; + } + return this.assemblyNodeType.equals(RUNTIME) || this.eventmeshNodeType.equals(META_AND_RUNTIME); + } + + public boolean isStorage() { + if (Objects.isNull(this.eventmeshNodeType)) { + return false; + } + return this.eventmeshNodeType.equals(STORAGE); + } + + public boolean isMainCluster() { + return Objects.equals(this, ClusterType.EVENTMESH_CLUSTER) || Objects.equals(this.assemblyNodeType, ClusterType.CLUSTER); + } + + + public boolean isHealthTopic() { + return Objects.equals(this, EVENTMESH_RUNTIME) || this.isStorageRuntime(); + } + + public boolean isStorageCluster() { + return Objects.equals(this.eventmeshNodeType, STORAGE) && Objects.equals(this.assemblyNodeType, CLUSTER); + } + + public boolean isStorageRuntime() { + return Objects.equals(this.eventmeshNodeType, STORAGE) && Objects.equals(this.assemblyNodeType, RUNTIME); + } + + public boolean isStorageMeta() { + return Objects.equals(this.eventmeshNodeType, STORAGE) && Objects.equals(this.assemblyNodeType, META); + } + + public boolean isMain() { + return Objects.equals(this, NODE_BY_COPY_IN_TYPE_MAIN); + } + + public boolean isSlave() { + return Objects.equals(this, NODE_BY_COPY_IN_TYPE_SLAVE); + } + + public boolean isDefinition() { + return Objects.equals(this.assemblyBusiness, DEFINITION); + } + + public List getMetaClusterInStorage() { List list = new ArrayList<>(); - for (ClusterType clusterType : ClusterType.values()) { - if (Objects.equals(clusterType.eventmeshNodeType, ClusterType.STORAGE) && Objects.equals(clusterType.assemblyNodeType, - ClusterType.CLUSTER)) { - list.add(clusterType); + for (ClusterType allClusterType : ClusterType.values()) { + if (Objects.equals(allClusterType.eventmeshNodeType, STORAGE) && Objects.equals(allClusterType.assemblyNodeType, META)) { + list.add(allClusterType); } } return list; } - public boolean isMainCluster() { - return Objects.equals(this, ClusterType.EVENTMESH_CLUSTER) || Objects.equals(this.assemblyNodeType, ClusterType.CLUSTER); + public List getMainClusterType() { + return this.getThisClusterType(CLUSTER, this.mainClusterType, "mainClusterType"); + } - public boolean isFirstLayer() { - return Objects.equals(this, ClusterType.EVENTMESH_META_NACOS) || Objects.equals(this, ClusterType.EVENTMESH_META_ETCD) || Objects.equals(this, - ClusterType.EVENTMESH_RUNTIME) || Objects.equals(this.getAssemblyNodeType(), ClusterType.CLUSTER); + public List getMetaClusterType() { + return this.getThisClusterType(META, this.metaClusterType, "metaClusterType"); } - public boolean isSecondFloor() { - return Objects.equals(eventmeshNodeType, ClusterType.STORAGE) ? (Objects.equals(assemblyNodeType, ClusterType.RUNTIME) || Objects.equals( - assemblyNodeType, ClusterType.META)) : false; + public List getRuntimeClusterType() { + return this.getThisClusterType(RUNTIME, this.runtimeClusterType, "runtimeClusterType"); } + + private List getThisClusterType(ClusterType assemblyNodeType, List clusterTypeList, String fieldName) { + if (Objects.equals(assemblyNodeType, this.assemblyNodeType) && !this.isDefinition()) { + return null; + } + if (Objects.nonNull(clusterTypeList)) { + return clusterTypeList; + } + clusterTypeList = new ArrayList<>(); + synchronized (this) { + for (ClusterType allClusterType : ClusterType.values()) { + if (this == allClusterType) { + continue; + } + if (Objects.equals(this.eventmeshNodeType, allClusterType.eventmeshNodeType) + && (Objects.equals(this.assemblyName, allClusterType.assemblyName) || Objects.equals(this, allClusterType.assemblyName)) + && Objects.equals(assemblyNodeType, allClusterType.assemblyNodeType)) { + clusterTypeList.add(allClusterType); + } + } + } + if (clusterTypeList.isEmpty()) { + // TODO + // String message = String.format("cluster %s assemblyNodeType is %s fieldName is %s ", this, assemblyNodeType, fieldName); + // throw new RuntimeException(message); + } + + try { + FieldUtils.writeField(this, fieldName, clusterTypeList, true); + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } + return clusterTypeList; + } + + } diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/DeployStatusType.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/DeployStatusType.java new file mode 100644 index 00000000..2e8556bb --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/DeployStatusType.java @@ -0,0 +1,107 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.common.enums; + +public enum DeployStatusType { + + + RESOURCE_APPLY, + + RESOURCE_APPLY_FAILED, + + CREATE_WAIT, + + CREATE_FULL_WAIT, + + CREATE_WAIT_TIMEOUT, + + CREATE_CAP_UPDATE_WAIT, + + CREATE_CAP_UPDATE_WAIT_TIMEOUT, + + CREATE_ING, + + CREATE_FULL_ING, + + CREATE_FAIL, + + CREATE_FULL_SUCCESS, + + CREATE_FULL_FAIL, + + CREATE_CAP_UPDATE_FAIL, + + CREATE_CAP_UPDATE_ING, + + CREATE_SUCCESS, + + CREATE_CAP_UPDATE_SUCCESS, + + UPDATE_WAIT, + + UPDATE_ING, + + UPDATE_SUCCESS, + + UPDATE_FAIL, + + UPDATE_FULL_WAIT, + + UPDATE_FULL_ING, + + UPDATE_FULL_SUCCESS, + + UPDATE_FULL_FAIL, + + + PAUSE_WAIT, + + PAUSE_ING, + + PAUSE_FULL_ING, + + PAUSE_FULL_WAIT, + + PAUSE_SUCCESS, + + PAUSE_FAIL, + + PAUSE_FULL_SUCCESS, + + PAUSE_FULL_FAIL, + + RESET_WAIT, + + RESET_ING, + + RESET_FAIL, + + RESET_SUCCESS, + + UNINSTALL, + + UNINSTALL_FAIL, + + UNINSTALL_FAILED, + + UNINSTALL_ING, + + UNINSTALL_SUCCESS, + ; +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/KubernetesPodStatus.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/KubernetesPodStatus.java index 1e6d8a0e..1a08cec1 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/KubernetesPodStatus.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/KubernetesPodStatus.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.enums; import lombok.AllArgsConstructor; diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/MetadataType.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/MetadataType.java new file mode 100644 index 00000000..42ca89d9 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/MetadataType.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.common.enums; + +import org.apache.eventmesh.dashboard.common.model.metadata.AclMetadata; +import org.apache.eventmesh.dashboard.common.model.metadata.ClientMetadata; +import org.apache.eventmesh.dashboard.common.model.metadata.ClusterMetadata; +import org.apache.eventmesh.dashboard.common.model.metadata.ConfigMetadata; +import org.apache.eventmesh.dashboard.common.model.metadata.ConnectionMetadata; +import org.apache.eventmesh.dashboard.common.model.metadata.ConsumeOffsetMetadata; +import org.apache.eventmesh.dashboard.common.model.metadata.GroupMetadata; +import org.apache.eventmesh.dashboard.common.model.metadata.RuntimeMetadata; +import org.apache.eventmesh.dashboard.common.model.metadata.TopicMetadata; +import org.apache.eventmesh.dashboard.common.model.metadata.TopicOffsetMetadata; + +import lombok.Getter; + + +@Getter +public enum MetadataType { + + CLUSTER(ClusterMetadata.class), + + CONFIG(ConfigMetadata.class), + + RUNTIME(RuntimeMetadata.class), + + TOPIC(TopicMetadata.class), + + GROUP(GroupMetadata.class), + + TOPIC_OFFSET(TopicOffsetMetadata.class, true), + + CONSUME_OFFSET(ConsumeOffsetMetadata.class, true), + + SUBSCRIBER(GroupMetadata.class), + + CLIENT(ClientMetadata.class, true), + + NET_CONNECT(ConnectionMetadata.class, true), + + USER(ConnectionMetadata.class), + + ACL(AclMetadata.class); + + private Class metadataClass; + + private boolean readOnly = false; + + MetadataType(Class metadataClass) { + this.metadataClass = metadataClass; + } + + MetadataType(Class metadataClass, boolean readOnly) { + this.metadataClass = metadataClass; + this.readOnly = readOnly; + } +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/OperationRange.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/OperationRange.java new file mode 100644 index 00000000..bfe248db --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/OperationRange.java @@ -0,0 +1,100 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.common.enums; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * 比如: 通过 topic id 修改配置。 Kafka 只需要 操作 cluster 就可以了。 RocketMQ 需要操作 broker集群,复制集群, + */ +public class OperationRange { + + private static final OperationRange operationRange = new OperationRange(); + + private static Map> operationRangeListHashMap = new HashMap<>(); + + public static OperationRange getInstance() { + return operationRange; + } + + private OperationRange() { + + } + + + private void setOperationRange(ClusterType clusterType, OperationRangeType operationRangeType) { + operationRangeListHashMap.computeIfAbsent(clusterType, k -> new ArrayList<>()).add(operationRangeType); + } + + public List getOperationRangeTypeList(ClusterType clusterType) { + return operationRangeListHashMap.get(clusterType); + } + + /** + * 依据范围查询数据 + * 集群, runtime , topic ,SUBSCRIBER , SUBSCRIBER_QUEUE + */ + public enum OperationRangeType { + + ALL(null), + + CLUSTER(null), + + ALL_RUNTIME(null), + + ONCE_CLUSTER(null), + + RANGE_CLUSTER_CAP(CLUSTER), + + MAIN_SLAVE(CLUSTER), + + RANGE_RUNTIME(MAIN_SLAVE), + + + GROUP(RANGE_RUNTIME), + + TOPIC(RANGE_RUNTIME), + + SUBSCRIBER(RANGE_RUNTIME), + + SUBSCRIBER_QUEUE(RANGE_RUNTIME), + + QUEUE(TOPIC), + + ; + + private Map> operationRangeListHashMap; + + private int index; + + OperationRangeType() { + + } + + OperationRangeType(OperationRangeType operationRangeType) { + this.index = Objects.isNull(operationRangeType) ? 0 : operationRangeType.index + 1; + } + } + + +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/RecordStatus.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/RecordStatus.java index 5ed81c75..07d026e5 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/RecordStatus.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/RecordStatus.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.enums; import lombok.AllArgsConstructor; diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/RemotingType.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/RemotingType.java index aa0ad0e8..226e14d0 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/RemotingType.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/RemotingType.java @@ -15,16 +15,24 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.enums; +import java.util.HashSet; +import java.util.Set; + public enum RemotingType { NOT, + JVM, + META, STORAGE, + REDIS, + EVENT_MESH_RUNTIME, EVENT_MESH_NACOS, @@ -32,5 +40,29 @@ public enum RemotingType { EVENT_MESH_ETCD, ROCKETMQ, - ROCKETMQ_NAMESERVER; + + ROCKETMQ_NAMESERVER, + + KAFKA, + + + ZK, + + KUBERNETES, + + ; + + private Set supportClusterType = new HashSet<>(); + + RemotingType() { + } + + RemotingType(ClusterType... clusterType) { + for (ClusterType c : clusterType) { + this.supportClusterType.add(c); + } + + } + + } diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ReplicationDimension.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ReplicationDimension.java new file mode 100644 index 00000000..67d11afd --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ReplicationDimension.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.common.enums; + +public enum ReplicationDimension { + + NOT, + + + /** + * 节点复制 复制, + */ + FULL_REPLICATION, + + TOPIC, + + /** + * 部分复制 + */ + SECTION_REPLICATION, + ; +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ReplicationType.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ReplicationType.java new file mode 100644 index 00000000..8b29f9e8 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ReplicationType.java @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.common.enums; + +public enum ReplicationType { + + NOT, + + MAIN, + + SLAVE, + + MAIN_SLAVE, + ; + + + public boolean isNot() { + return this == NOT; + } + + public boolean isMain() { + return this == MAIN; + } + + public boolean isSlave() { + return this == SLAVE; + } + + + public boolean isMainSlave() { + return this == MAIN_SLAVE; + } +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ResetOffsetMode.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ResetOffsetMode.java index 519767ae..822e260b 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ResetOffsetMode.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ResetOffsetMode.java @@ -15,15 +15,37 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.enums; public enum ResetOffsetMode { + /** + * 支持维度如下: + *

+ * event mesh cluster 。 + * RockerMQ 查出 所有的 存储集群,然后存储存储集群里面,所有子集群,以及子集群里面所有的 broker ,对每个broker 进行一次请求奥做。 + * Kkakfa 查出 所有的 存储集群,然后存储存储集群里面。 只需要对 cluster 进行一次请求操作 + *

+ * storage cluster + *

+ * storage definition cluster + *

+ * storage runtime cluster + * + * + */ CONSUME_FROM_LAST_OFFSET, CONSUME_FROM_FIRST_OFFSET, + CONSUME_FROM_TIMESTAMP, + /** + * 只有此模式支持 Queue 维度 + *

+ * 只有这个模式,传递Queue id + */ CONSUME_FROM_DESIGNATED_OFFSET } diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/Status.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/Status.java deleted file mode 100644 index 4a6036f5..00000000 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/Status.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.common.enums; - -import static org.apache.eventmesh.dashboard.common.constant.ConfigConst.COLON; - -import org.springframework.http.HttpStatus; - -import lombok.Getter; - -/** - * An error enumeration class that conforms to the RESTful specifications and custom error reporting requirements. - *

    - *
  • The 'code' field is used to return the HTTP status code using {@link HttpStatus}.
  • - *
  • The 'category' field represents the major category of the error.
  • - *
  • the 'desc' field represents the detailed subcategory and information of the error.
  • - *
- */ - -@Getter -public enum Status { - - SUCCESS(HttpStatus.OK, Category.SUCCESS, "Operation success."), - - NACOS_SDK_CONFIG_ERR(HttpStatus.INTERNAL_SERVER_ERROR, Category.SDK_CONFIG_ERR, - "Failed to create Nacos ConfigService. Please check EventMeshAdmin application configuration."), - - NACOS_GET_CONFIGS_ERR(HttpStatus.BAD_GATEWAY, Category.META_COM_ERR, "Failed to retrieve Nacos config(s)."), - - NACOS_EMPTY_RESP_ERR(HttpStatus.BAD_GATEWAY, Category.META_COM_ERR, "No result returned by Nacos. Please check Nacos."), - - NACOS_LOGIN_ERR(HttpStatus.UNAUTHORIZED, Category.META_COM_ERR, "Nacos login failed."), - - NACOS_LOGIN_EMPTY_RESP_ERR(HttpStatus.BAD_GATEWAY, Category.META_COM_ERR, "Nacos didn't return accessToken. Please check Nacos status."), - ; - - // error code - private final HttpStatus code; - - // error type - private final Category category; - - // error message - private final String desc; - - Status(HttpStatus code, Category category, String desc) { - this.code = code; - this.category = category; - this.desc = desc; - } - - @Override - public String toString() { - return name() + " of " + category + COLON + desc; - } - - @Getter - public enum Category { - - SUCCESS("Successfully received and processed"), - - SDK_CONFIG_ERR("Meta SDK config error"), - - META_COM_ERR("Network communication to Meta error"), - ; - - /** - * Helpful for understanding and not used for now - */ - private final String desc; - - Category(String desc) { - this.desc = desc; - } - } -} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/StoreType.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/StoreType.java index ed15a868..50ea1918 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/StoreType.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/StoreType.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.enums; import static org.apache.eventmesh.dashboard.common.constant.StoreTypeConstant.STORE_TYPE_KAFKA; @@ -27,6 +28,7 @@ import lombok.AllArgsConstructor; import lombok.Getter; +@Deprecated @AllArgsConstructor public enum StoreType { diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/cluster/InstanceUserFromClusterService.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/SyncErrorType.java similarity index 83% rename from eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/cluster/InstanceUserFromClusterService.java rename to eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/SyncErrorType.java index 5d6ddb81..c66626b0 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/cluster/InstanceUserFromClusterService.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/SyncErrorType.java @@ -15,11 +15,16 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.core.metadata.cluster; -import org.springframework.stereotype.Service; +package org.apache.eventmesh.dashboard.common.enums; -@Service -public class InstanceUserFromClusterService { +public enum SyncErrorType { + + NOT, + + METADATA_SYNC_ERROR, + + CHECK_SYNC_ERROR, + ; } diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/health/HealthCheckStatus.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/health/HealthCheckStatus.java index 75423765..34a5891d 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/health/HealthCheckStatus.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/health/HealthCheckStatus.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.enums.health; import lombok.AllArgsConstructor; @@ -23,12 +24,25 @@ @Getter @AllArgsConstructor public enum HealthCheckStatus { - FAILED(0, "failed"), - PASSED(1, "passed"), - CHECKING(2, "checking"), - TIMEOUT(3, "timeout"), - NOT_CONNECTED(4, "not connected"); - private final Integer number; + SUCCESS(1L, "success"), + + FAILED(0L, "failed"), + + PASSED(1L, "passed"), + + CHECKING(2L, "checking"), + + TIMEOUT(3L, "timeout"), + + NOT_CONNECTED(4L, "not connected"), + + USER_AUTHENTICATION_FAIL(5L, "user authentication fail"), + + REQUEST_AUTHENTICATION_FAIL(6L, "request authentication fail"), + ; + + private final Long number; + private final String name; } diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/health/HealthCheckType.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/health/HealthCheckTypeEnum.java similarity index 86% rename from eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/health/HealthCheckType.java rename to eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/health/HealthCheckTypeEnum.java index 54c061e4..457e65b5 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/health/HealthCheckType.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/health/HealthCheckTypeEnum.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.enums.health; import org.apache.eventmesh.dashboard.common.constant.health.HealthCheckTypeConstant; @@ -23,14 +24,23 @@ import lombok.Getter; @AllArgsConstructor -public enum HealthCheckType { +public enum HealthCheckTypeEnum { UNKNOWN(0, HealthCheckTypeConstant.HEALTH_CHECK_TYPE_UNKNOWN), + PROCESS(0, "检查进场"), + + PORT(1, "端口"), + + PING(2, "ping"), + + + TOPIC(3, HealthCheckTypeConstant.HEALTH_CHECK_TYPE_TOPIC), + + CLUSTER(1, HealthCheckTypeConstant.HEALTH_CHECK_TYPE_CLUSTER), RUNTIME(2, HealthCheckTypeConstant.HEALTH_CHECK_TYPE_RUNTIME), - TOPIC(3, HealthCheckTypeConstant.HEALTH_CHECK_TYPE_TOPIC), STORAGE(4, HealthCheckTypeConstant.HEALTH_CHECK_TYPE_STORAGE); @@ -40,7 +50,7 @@ public enum HealthCheckType { private final String name; public static Integer toNumber(String name) { - for (HealthCheckType healthCheckTypeEnum : HealthCheckType.values()) { + for (HealthCheckTypeEnum healthCheckTypeEnum : HealthCheckTypeEnum.values()) { if (healthCheckTypeEnum.name.equals(name)) { return healthCheckTypeEnum.number; } @@ -49,7 +59,7 @@ public static Integer toNumber(String name) { } public static String toName(Integer number) { - for (HealthCheckType healthCheckTypeEnum : HealthCheckType.values()) { + for (HealthCheckTypeEnum healthCheckTypeEnum : HealthCheckTypeEnum.values()) { if (healthCheckTypeEnum.number.equals(number)) { return healthCheckTypeEnum.name; } diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/ClusterSyncMetadata.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/ClusterSyncMetadata.java new file mode 100644 index 00000000..c58890d3 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/ClusterSyncMetadata.java @@ -0,0 +1,71 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.common.model; + +import org.apache.eventmesh.dashboard.common.enums.ClusterFramework; +import org.apache.eventmesh.dashboard.common.enums.MetadataType; +import org.apache.eventmesh.dashboard.common.enums.ReplicationDimension; + +import java.util.ArrayList; +import java.util.List; + +import lombok.Builder; +import lombok.Data; + +@Data +@Builder +public class ClusterSyncMetadata { + + public static final ClusterSyncMetadata EMPTY_OBJECT = new ClusterSyncMetadata(new ArrayList<>(), ReplicationDimension.NOT, ClusterFramework.NOT); + + public static List TEST_ONE = new ArrayList<>(); + + public static List META = new ArrayList<>(); + + public static List STORAGE = new ArrayList<>(); + + public static List LANTERN = new ArrayList<>(); + + public static List AUTH = new ArrayList<>(); + + static { + + TEST_ONE.add(MetadataType.TOPIC); + + META.add(MetadataType.RUNTIME); + + STORAGE.add(MetadataType.CONFIG); + STORAGE.add(MetadataType.TOPIC); + STORAGE.add(MetadataType.GROUP); + STORAGE.add(MetadataType.NET_CONNECT); + STORAGE.add(MetadataType.SUBSCRIBER); + + AUTH.add(MetadataType.USER); + AUTH.add(MetadataType.ACL); + + } + + private List metadataTypeList; + + private ReplicationDimension replicationDimension; + + private ClusterFramework clusterFramework; + + +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/ConnectionInfo.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/ConnectionInfo.java index 3934e8f6..b6d79e0c 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/ConnectionInfo.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/ConnectionInfo.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model; public class ConnectionInfo { diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/ConvertMetaData.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/ConvertMetaData.java new file mode 100644 index 00000000..c8417c90 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/ConvertMetaData.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.common.model; + +/** + * + */ +public interface ConvertMetaData { + + + E toEntity(M meta); + + M toMetaData(E entity); + +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/DatabaseAndMetadataMapper.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/DatabaseAndMetadataMapper.java new file mode 100644 index 00000000..1f89aab5 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/DatabaseAndMetadataMapper.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.common.model; + +import org.apache.eventmesh.dashboard.common.enums.MetadataType; + +import lombok.Builder; +import lombok.Data; + +@Data +@Builder +public class DatabaseAndMetadataMapper { + + + private MetadataType metaType; + + private Class databaseHandlerClass; + + private Class metadataHandlerClass; + + private ConvertMetaData convertMetaData; + + +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/MetadataSyncResultMetadata.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/MetadataSyncResultMetadata.java new file mode 100644 index 00000000..df371e75 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/MetadataSyncResultMetadata.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.common.model; + +import org.apache.eventmesh.dashboard.common.enums.ClusterTrusteeshipType; +import org.apache.eventmesh.dashboard.common.enums.MetadataType; + +@Deprecated +public class MetadataSyncResultMetadata { + + + private MetadataType metadataType; + + private ClusterTrusteeshipType clusterTrusteeshipType; + + private boolean isFast = false; + + private String resultData; +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/SyncRelationshipConfig.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/PortHandler.java similarity index 81% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/SyncRelationshipConfig.java rename to eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/PortHandler.java index 018584ab..e404672d 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/SyncRelationshipConfig.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/PortHandler.java @@ -15,13 +15,17 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.function.metadata; +package org.apache.eventmesh.dashboard.common.model; -public class SyncRelationshipConfig { +@Deprecated +public class PortHandler { - private Class metadataClass; - private Class entityClass; + private Integer port; + + private Integer jmsPort; + + private Integer mainPort; } diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/SubscriptionInfo.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/SubscriptionInfo.java index 6052d6c0..482c8e27 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/SubscriptionInfo.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/SubscriptionInfo.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model; import lombok.Builder; @@ -22,6 +23,7 @@ @Data @Builder +@Deprecated public class SubscriptionInfo { // client name diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/base/BaseClusterIdBase.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/base/BaseClusterIdBase.java new file mode 100644 index 00000000..b45c9e07 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/base/BaseClusterIdBase.java @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.common.model.base; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; + +public abstract class BaseClusterIdBase extends BaseOrganizationBase { + + private Long clusterId; + + private ClusterType clusterType; + + public Long getClusterId() { + return clusterId; + } + + public void setClusterId(Long clusterId) { + this.clusterId = clusterId; + } + + public ClusterType getClusterType() { + return clusterType; + } + + public void setClusterType(ClusterType clusterType) { + this.clusterType = clusterType; + } + + public boolean isDelete() { + return this.getStatus() == 0; + } + + public boolean isUpdate() { + return !this.isDelete() && !this.isInsert(); + } + + public boolean isInsert() { + return true; + } + +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/exception/BaseException.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/base/BaseOrganizationBase.java similarity index 50% rename from eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/exception/BaseException.java rename to eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/base/BaseOrganizationBase.java index c3364018..a4c2356c 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/exception/BaseException.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/base/BaseOrganizationBase.java @@ -15,40 +15,49 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.common.exception; -import static org.apache.eventmesh.dashboard.common.constant.ConfigConst.COLON; +package org.apache.eventmesh.dashboard.common.model.base; -import org.apache.eventmesh.dashboard.common.enums.Status; -import org.apache.eventmesh.dashboard.common.util.ExceptionUtil; -import lombok.Getter; +public abstract class BaseOrganizationBase { -/** - * Exceptions in EventMeshAdmin application - */ + private Long id; -@Getter -public class BaseException extends RuntimeException { + private Long status; - private static final long serialVersionUID = 3509261993355721168L; + private Long organizationId; - private Status status; + public Long getId() { + return id; + } - public BaseException(String message) { - super(message); + public void setId(Long id) { + this.id = id; } - /** - * Customized error reporting using enums and exceptions - */ - public BaseException(Status status, Throwable cause) { - super(ExceptionUtil.trimDesc(status.getDesc()) + COLON + cause.getMessage(), cause); - this.status = status; + public Long getOrganizationId() { + return organizationId; + } + + public void setOrganizationId(Long organizationId) { + this.organizationId = organizationId; } - public BaseException(Status status) { - super(status.getDesc()); + public Long getStatus() { + return status; + } + + public void setStatus(Long status) { this.status = status; } + + public String getUnique() { + return this.getClass().getSimpleName() + "-" + this.id.toString(); + } + + /** + * 主要用于 database 数据 与 节点数据 对比用。这个数据在node的唯一 + * @return + */ + public abstract String nodeUnique(); } diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/base/BaseRuntimeIdBase.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/base/BaseRuntimeIdBase.java new file mode 100644 index 00000000..7ceeb0b2 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/base/BaseRuntimeIdBase.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.common.model.base; + +public abstract class BaseRuntimeIdBase extends BaseClusterIdBase { + + private Long runtimeId; + + + public Long getRuntimeId() { + return runtimeId; + } + + public void setRuntimeId(Long runtimeId) { + this.runtimeId = runtimeId; + } + +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/base/BaseSyncBase.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/base/BaseSyncBase.java new file mode 100644 index 00000000..a027241c --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/base/BaseSyncBase.java @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.common.model.base; + +import org.apache.eventmesh.dashboard.common.enums.ClusterTrusteeshipType; +import org.apache.eventmesh.dashboard.common.enums.ClusterTrusteeshipType.FirstToWhom; +import org.apache.eventmesh.dashboard.common.enums.ReplicationType; +import org.apache.eventmesh.dashboard.common.enums.SyncErrorType; + +import java.time.LocalDateTime; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public abstract class BaseSyncBase extends BaseClusterIdBase { + + + private ClusterTrusteeshipType trusteeshipType; + + private FirstToWhom firstToWhom; + + private FirstToWhom firstSyncState; + + private ReplicationType replicationType; + + private SyncErrorType syncErrorType; + + private String config; + + /** + * 上线时间 + */ + private LocalDateTime onlineTimestamp; + + /** + * 下线时间 + */ + private LocalDateTime offlineTimestamp; + + + private LocalDateTime startTimestamp; + + public boolean isCluster() { + return true; + } + +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/AclMetadata.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/AclMetadata.java index 982fa5a9..729849d8 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/AclMetadata.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/AclMetadata.java @@ -15,26 +15,37 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.metadata; +import org.apache.eventmesh.dashboard.common.model.base.BaseRuntimeIdBase; + import lombok.Data; import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = true) -public class AclMetadata extends MetadataConfig { +public class AclMetadata extends BaseRuntimeIdBase { private Long clusterId; + private String principal; + private Integer operation; + private String permissionType; + private String host; + private String resourceType; + private String resourceName; + private Integer patternType; + @Override - public String getUnique() { - return null; + public String nodeUnique() { + return this.principal; } } diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/ClientMetadata.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/ClientMetadata.java index 8dd240ae..ca2491b4 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/ClientMetadata.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/ClientMetadata.java @@ -15,14 +15,17 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.metadata; +import org.apache.eventmesh.dashboard.common.model.base.BaseRuntimeIdBase; + import lombok.Data; import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = true) -public class ClientMetadata extends MetadataConfig { +public class ClientMetadata extends BaseRuntimeIdBase { private String name; @@ -47,8 +50,9 @@ public class ClientMetadata extends MetadataConfig { */ private String protocol; + @Override - public String getUnique() { - return host + ":" + port; + public String nodeUnique() { + return this.host + "-" + this.port; } } diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/ClusterMetadata.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/ClusterMetadata.java index 57f37b26..a45d68c1 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/ClusterMetadata.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/ClusterMetadata.java @@ -15,18 +15,19 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.metadata; import org.apache.eventmesh.dashboard.common.enums.ClusterTrusteeshipType; import org.apache.eventmesh.dashboard.common.enums.ClusterType; -import org.apache.eventmesh.dashboard.common.enums.StoreType; +import org.apache.eventmesh.dashboard.common.model.base.BaseSyncBase; import lombok.Data; import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = true) -public class ClusterMetadata extends MetadataConfig { +public class ClusterMetadata extends BaseSyncBase { private String clusterName; @@ -50,17 +51,12 @@ public class ClusterMetadata extends MetadataConfig { private Integer runState; - private Integer status; - - /** - * @see StoreType - */ - private StoreType storeType; private String description; + @Override - public String getUnique() { - return clusterName + "/" + registryAddress; + public String nodeUnique() { + return this.getClusterId().toString(); } } diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/ClusterRelationshipMetadata.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/ClusterRelationshipMetadata.java index 1b5d5644..d2b97598 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/ClusterRelationshipMetadata.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/ClusterRelationshipMetadata.java @@ -15,15 +15,19 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.metadata; import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.common.model.base.BaseRuntimeIdBase; import lombok.Data; +import lombok.EqualsAndHashCode; @Data -public class ClusterRelationshipMetadata extends MetadataConfig { +@EqualsAndHashCode(callSuper = true) +public class ClusterRelationshipMetadata extends BaseRuntimeIdBase { private ClusterType clusterType; @@ -31,10 +35,9 @@ public class ClusterRelationshipMetadata extends MetadataConfig { private ClusterType relationshipType; - private Integer status; @Override - public String getUnique() { - return null; + public String nodeUnique() { + return this.relationshipId + "-" + this.getClusterId(); } } diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/ConfigMetadata.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/ConfigMetadata.java index 3592010f..6a5f26d5 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/ConfigMetadata.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/ConfigMetadata.java @@ -15,8 +15,12 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.metadata; +import org.apache.eventmesh.dashboard.common.enums.MetadataType; +import org.apache.eventmesh.dashboard.common.model.base.BaseClusterIdBase; + import lombok.Data; import lombok.EqualsAndHashCode; @@ -25,21 +29,22 @@ */ @Data @EqualsAndHashCode(callSuper = true) -public class ConfigMetadata extends MetadataConfig { +public class ConfigMetadata extends BaseClusterIdBase { /** * property key */ - private String configKey; + private String configName; private String configValue; - private Integer instanceType; + private MetadataType instanceType; private Long instanceId; + @Override - public String getUnique() { - return configKey; + public String nodeUnique() { + return this.configName; } } diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/ConnectionMetadata.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/ConnectionMetadata.java index 49856ead..39f1adfd 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/ConnectionMetadata.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/ConnectionMetadata.java @@ -15,16 +15,21 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.metadata; +import org.apache.eventmesh.dashboard.common.model.base.BaseRuntimeIdBase; + import lombok.Data; +import lombok.EqualsAndHashCode; /** * when insert data to db from meta service, connection metadata operation should be called after cluster and client in order to fetch information * from them. */ @Data -public class ConnectionMetadata extends MetadataConfig { +@EqualsAndHashCode(callSuper = true) +public class ConnectionMetadata extends BaseRuntimeIdBase { /** @@ -67,8 +72,9 @@ public class ConnectionMetadata extends MetadataConfig { private String description; + @Override - public String getUnique() { + public String nodeUnique() { return getClusterId() + "/" + sourceId + "/" + sinkId + "/" + topic; } } diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/ConnectorMetadata.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/ConnectorMetadata.java index 57e2e952..2f12a473 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/ConnectorMetadata.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/ConnectorMetadata.java @@ -15,12 +15,14 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.metadata; import org.apache.eventmesh.dashboard.common.enums.KubernetesPodStatus; +import org.apache.eventmesh.dashboard.common.model.base.BaseRuntimeIdBase; -public class ConnectorMetadata extends MetadataConfig { +public class ConnectorMetadata extends BaseRuntimeIdBase { private String name; @@ -37,8 +39,9 @@ public class ConnectorMetadata extends MetadataConfig { */ private Integer podState; + @Override - public String getUnique() { - return host + ":" + port; + public String nodeUnique() { + return ""; } } diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/ConsumeOffsetMetadata.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/ConsumeOffsetMetadata.java new file mode 100644 index 00000000..a7146180 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/ConsumeOffsetMetadata.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.eventmesh.dashboard.common.model.metadata; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class ConsumeOffsetMetadata extends TopicOffsetMetadata { + + private String groupName; + + private Long consumeOffset; + + private Integer consumeRate; + + private Long delayNum; + +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/GroupMetadata.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/GroupMetadata.java index 3827f93a..e08bf8a9 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/GroupMetadata.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/GroupMetadata.java @@ -15,14 +15,17 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.metadata; +import org.apache.eventmesh.dashboard.common.model.base.BaseRuntimeIdBase; + import lombok.Data; import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = true) -public class GroupMetadata extends MetadataConfig { +public class GroupMetadata extends BaseRuntimeIdBase { private String name; @@ -32,10 +35,10 @@ public class GroupMetadata extends MetadataConfig { private Integer type; - private String state; + @Override - public String getUnique() { - return name; + public String nodeUnique() { + return this.name; } } diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/InstanceUserMetadata.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/InstanceUserMetadata.java index aaf81bad..d25661d1 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/InstanceUserMetadata.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/InstanceUserMetadata.java @@ -15,9 +15,8 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.common.model.metadata; -import org.apache.eventmesh.dashboard.common.enums.StoreType; +package org.apache.eventmesh.dashboard.common.model.metadata; import lombok.Data; @@ -28,7 +27,7 @@ public class InstanceUserMetadata { private String userName; - //service users are only store users by now - private StoreType serviceType; + + private String password; } diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/MetadataConfig.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/MetadataConfig.java deleted file mode 100644 index 09483cfd..00000000 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/MetadataConfig.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.common.model.metadata; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; - -/** - * This class is used to represent a piece of metadata, which can be used in create, update or delete operations to metadata service(eventmesh meta - * center, eventmesh runtime cluster)

follow method should be called in init block which is used to indicate the type of metadata: - * {@code this.setServiceTypeEnums(MetadataServiceTypeEnums.RUNTIME);} - */ -@Data -@AllArgsConstructor -@NoArgsConstructor -@SuperBuilder -public abstract class MetadataConfig { - - //eventmesh registry url - private String registryAddress; - //cluster id in database - private Long clusterId; - - - private Long id; - - /** - * @return A string that is unique to the source, usually a url - */ - public abstract String getUnique(); -} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/QueueMetadata.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/QueueMetadata.java new file mode 100644 index 00000000..70e869c7 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/QueueMetadata.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.common.model.metadata; + +import org.apache.eventmesh.dashboard.common.model.base.BaseRuntimeIdBase; + +public class QueueMetadata extends BaseRuntimeIdBase { + + private String topicName; + + private String queueName; + + + @Override + public String nodeUnique() { + return this.topicName + "-" + this.queueName; + } + +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/RegistryMetadata.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/RegistryMetadata.java index 890ce757..882f421e 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/RegistryMetadata.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/RegistryMetadata.java @@ -15,20 +15,15 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.metadata; import org.apache.eventmesh.dashboard.common.enums.RecordStatus; import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; @Data -@SuperBuilder -@NoArgsConstructor -@EqualsAndHashCode(callSuper = true) -public class RegistryMetadata extends MetadataConfig { +public class RegistryMetadata { private String clusterName; @@ -55,9 +50,4 @@ public class RegistryMetadata extends MetadataConfig { * @see RecordStatus */ private Integer status; - - @Override - public String getUnique() { - return host + ":" + port; - } } diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/RuntimeMetadata.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/RuntimeMetadata.java index eb88e38d..9d51ad81 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/RuntimeMetadata.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/RuntimeMetadata.java @@ -15,20 +15,17 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.metadata; -import lombok.AllArgsConstructor; +import org.apache.eventmesh.dashboard.common.model.base.BaseSyncBase; + import lombok.Data; import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; @Data -@NoArgsConstructor -@AllArgsConstructor -@SuperBuilder @EqualsAndHashCode(callSuper = true) -public class RuntimeMetadata extends MetadataConfig { +public class RuntimeMetadata extends BaseSyncBase { private String host; @@ -36,20 +33,26 @@ public class RuntimeMetadata extends MetadataConfig { private Integer jmxPort; + private Integer runtimeIndex; + private String rack; private String endpointMap; private Long storageClusterId; - private Long startTimestamp; - private String clusterName; + public String clusterUnique() { + return ClusterMetadata.class.getSimpleName() + "-" + this.getClusterId(); + } - private Integer status; + @Override + public boolean isCluster() { + return false; + } @Override - public String getUnique() { - return host + ":" + port; + public String nodeUnique() { + return this.host + "-" + this.port; } } diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/TopicMetadata.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/TopicMetadata.java index b85c346f..d5173cee 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/TopicMetadata.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/TopicMetadata.java @@ -15,25 +15,19 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.metadata; -import org.apache.eventmesh.dashboard.common.enums.StoreType; +import org.apache.eventmesh.dashboard.common.model.base.BaseRuntimeIdBase; import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; +import lombok.EqualsAndHashCode; @Data -@SuperBuilder -@NoArgsConstructor -public class TopicMetadata extends MetadataConfig { - - private StoreType storeType; +@EqualsAndHashCode(callSuper = true) +public class TopicMetadata extends BaseRuntimeIdBase { - private String storeAddress; - //rocketmq -> broker url - private String connectionUrl; private String topicName; @@ -49,8 +43,9 @@ public class TopicMetadata extends MetadataConfig { private String topicConfig; + @Override - public String getUnique() { - return topicName; + public String nodeUnique() { + return this.topicName; } } diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/TopicOffsetMetadata.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/TopicOffsetMetadata.java new file mode 100644 index 00000000..5c695065 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/TopicOffsetMetadata.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.eventmesh.dashboard.common.model.metadata; + +import org.apache.eventmesh.dashboard.common.model.base.BaseRuntimeIdBase; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class TopicOffsetMetadata extends BaseRuntimeIdBase { + + + private String offsetRecordType; + + private Long topicId; + + private String topicName; + + private Long topicOffset; + + private Integer increaseRate; + + @Override + public String nodeUnique() { + return ""; + } +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/AbstractGlobal2Request.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/AbstractGlobal2Request.java new file mode 100644 index 00000000..49912746 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/AbstractGlobal2Request.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.common.model.remoting; + + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public abstract class AbstractGlobal2Request extends Global2Request { + + private T metaData; + +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/BaseGlobalResult.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/BaseGlobalResult.java index 28d413aa..d7dbf05d 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/BaseGlobalResult.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/BaseGlobalResult.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting; public class BaseGlobalResult extends GlobalResult { diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/Global2Request.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/Global2Request.java new file mode 100644 index 00000000..14a56347 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/Global2Request.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.common.model.remoting; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; + +import lombok.Data; + +@Data +public class Global2Request { + + private Long clusterId; + + private ClusterType clusterType; + + private Long runtimeId; + + private ClusterType runtimeType; +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/GlobalResult.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/GlobalResult.java index d6866a33..2870a57c 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/GlobalResult.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/GlobalResult.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting; import lombok.AllArgsConstructor; diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/RemotingAction.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/RemotingAction.java index ce625648..fffc11cb 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/RemotingAction.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/RemotingAction.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting; import org.apache.eventmesh.dashboard.common.enums.RemotingType; diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/GlobalRequest.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/RemotingActionType.java similarity index 90% rename from eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/GlobalRequest.java rename to eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/RemotingActionType.java index 82e6c7fa..76668ddb 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/GlobalRequest.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/RemotingActionType.java @@ -15,12 +15,19 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting; -import lombok.Data; +public enum RemotingActionType { + + ADD, + + UPDATE, + + DELETE, + + QUEUE_ALL, -@Data -public class GlobalRequest { + ; - private Long clusterId; } diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/RemotingOperate.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/RemotingOperate.java index 39bda207..c6c10522 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/RemotingOperate.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/RemotingOperate.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting; public enum RemotingOperate { diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/CreateAclRequest.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/CreateAclRequest.java index e1844ce0..6e37bbd7 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/CreateAclRequest.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/CreateAclRequest.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.acl; public class CreateAclRequest { diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/CreateAclResponse.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/CreateAclResponse.java index 8e2b3a4f..f60993d1 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/CreateAclResponse.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/CreateAclResponse.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.acl; public class CreateAclResponse { diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/CreateAclResult.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/CreateAclResult.java index 4e3d6c26..4bc95273 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/CreateAclResult.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/CreateAclResult.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.acl; public class CreateAclResult { diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/DeleteAclRequest.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/DeleteAclRequest.java index 97211b1e..382573ab 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/DeleteAclRequest.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/DeleteAclRequest.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.acl; public class DeleteAclRequest { diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/DeleteAclResponse.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/DeleteAclResponse.java index f79d7f37..2bf276f9 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/DeleteAclResponse.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/DeleteAclResponse.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.acl; public class DeleteAclResponse { diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/DeleteAclResult.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/DeleteAclResult.java index db1dbfda..6d76eeef 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/DeleteAclResult.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/DeleteAclResult.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.acl; public class DeleteAclResult { diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/GetAclsRequest.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/GetAcls2Request.java similarity index 84% rename from eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/GetAclsRequest.java rename to eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/GetAcls2Request.java index 37d78ecb..6c8099f3 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/GetAclsRequest.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/GetAcls2Request.java @@ -15,11 +15,12 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.acl; -import org.apache.eventmesh.dashboard.common.model.remoting.GlobalRequest; +import org.apache.eventmesh.dashboard.common.model.remoting.AbstractGlobal2Request; -public class GetAclsRequest extends GlobalRequest { +public class GetAcls2Request extends AbstractGlobal2Request { } diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/GetAclsResponse.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/GetAclsResponse.java index 95688e2f..97d40658 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/GetAclsResponse.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/GetAclsResponse.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.acl; public class GetAclsResponse { diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/GetAclsResult.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/GetAclsResult.java index 036dcd6f..83897411 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/GetAclsResult.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/acl/GetAclsResult.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.acl; diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/client/GetClientRequest.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/client/GetClientRequest.java index 2369a241..f856b44e 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/client/GetClientRequest.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/client/GetClientRequest.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.client; public class GetClientRequest { diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/client/GetClientResponse.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/client/GetClientResponse.java index f19f9e58..17fb22af 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/client/GetClientResponse.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/client/GetClientResponse.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.client; diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/client/GetClientResult.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/client/GetClientResult.java index 340d33ac..173a5ab9 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/client/GetClientResult.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/client/GetClientResult.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.client; import java.util.concurrent.CompletableFuture; diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/AddConfigRequest.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/AddConfigRequest.java index 0f8d3de7..5519f6d1 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/AddConfigRequest.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/AddConfigRequest.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.config; import org.apache.eventmesh.dashboard.common.model.remoting.RemotingOperate; diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/AddConfigResponse.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/AddConfigResponse.java index d951a91a..e61b5254 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/AddConfigResponse.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/AddConfigResponse.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.config; public class AddConfigResponse { diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/AddConfigResult.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/AddConfigResult.java index 2af482a7..af31a02c 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/AddConfigResult.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/AddConfigResult.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.config; public class AddConfigResult { diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/ConfigType.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/ConfigType.java index 585e9328..ec465169 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/ConfigType.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/ConfigType.java @@ -15,8 +15,12 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.config; +/** + * + */ public enum ConfigType { NODE, diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/DeleteConfigRequest.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/DeleteConfigRequest.java index c6566125..0c9844b1 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/DeleteConfigRequest.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/DeleteConfigRequest.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.config; import org.apache.eventmesh.dashboard.common.model.remoting.RemotingOperate; diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/DeleteConfigResponse.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/DeleteConfigResponse.java index b580d437..138c66dc 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/DeleteConfigResponse.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/DeleteConfigResponse.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.config; public class DeleteConfigResponse { diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/DeleteConfigResult.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/DeleteConfigResult.java index 935fb4d1..b3ee9bf7 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/DeleteConfigResult.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/DeleteConfigResult.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.config; public class DeleteConfigResult extends AddConfigResult { diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/GetConfigRequest.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/GetConfigRequest.java index b24ab36b..acb2ac36 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/GetConfigRequest.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/GetConfigRequest.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.config; diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/GetConfigResponse.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/GetConfigResponse.java index c96809a5..d7b4fa77 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/GetConfigResponse.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/GetConfigResponse.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.config; diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/GetConfigResult.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/GetConfigResult.java index 3fb1053f..0086884d 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/GetConfigResult.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/GetConfigResult.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.config; import java.util.concurrent.CompletableFuture; diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/UpdateConfigRequest.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/UpdateConfigRequest.java index baae0023..17af5167 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/UpdateConfigRequest.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/UpdateConfigRequest.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.config; import org.apache.eventmesh.dashboard.common.model.remoting.RemotingOperate; diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/UpdateConfigResponse.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/UpdateConfigResponse.java index 2686df1c..7981d307 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/UpdateConfigResponse.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/UpdateConfigResponse.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.config; public class UpdateConfigResponse { diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/UpdateConfigResult.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/UpdateConfigResult.java index a3128dab..7b24a752 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/UpdateConfigResult.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/config/UpdateConfigResult.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.config; public class UpdateConfigResult extends AddConfigResult { diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/connector/CreateConnectorRequest.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/connector/CreateConnectorRequest.java index 7117dd9d..4ed6b170 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/connector/CreateConnectorRequest.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/connector/CreateConnectorRequest.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.connector; import org.apache.eventmesh.dashboard.common.model.metadata.ConnectorMetadata; diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/connector/CreateConnectorResponse.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/connector/CreateConnectorResponse.java index 4e149df3..1f12f4d2 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/connector/CreateConnectorResponse.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/connector/CreateConnectorResponse.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.connector; diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/connector/CreateConnectorResult.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/connector/CreateConnectorResult.java index e6746502..198adf3c 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/connector/CreateConnectorResult.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/connector/CreateConnectorResult.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.connector; import java.util.concurrent.CompletableFuture; diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/connector/GetConnectorRequest.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/connector/GetConnectorRequest.java index a386d7cb..81a442c8 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/connector/GetConnectorRequest.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/connector/GetConnectorRequest.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.connector; public class GetConnectorRequest { diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/connector/GetConnectorResponse.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/connector/GetConnectorResponse.java index 4de89a62..d8beee78 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/connector/GetConnectorResponse.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/connector/GetConnectorResponse.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.connector; diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/connector/GetConnectorResult.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/connector/GetConnectorResult.java index e21d2393..5ba13dd3 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/connector/GetConnectorResult.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/connector/GetConnectorResult.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.connector; import java.util.concurrent.CompletableFuture; diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/group/GetGroupResult.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/group/GetGroupResult.java index b41acc3e..d2c653ac 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/group/GetGroupResult.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/group/GetGroupResult.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.group; import org.apache.eventmesh.dashboard.common.model.remoting.GlobalResult; @@ -22,8 +23,10 @@ import java.util.concurrent.CompletableFuture; import lombok.Data; +import lombok.EqualsAndHashCode; @Data +@EqualsAndHashCode(callSuper = true) public class GetGroupResult extends GlobalResult { private CompletableFuture future; diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/group/GetGroupsRequest.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/group/GetGroupsRequest.java index 6586fe76..eb4c5893 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/group/GetGroupsRequest.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/group/GetGroupsRequest.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.group; public class GetGroupsRequest { diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/group/GetGroupsResponse.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/group/GetGroupsResponse.java index fbe90235..cecc430c 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/group/GetGroupsResponse.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/group/GetGroupsResponse.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.group; import org.apache.eventmesh.dashboard.common.model.metadata.GroupMetadata; diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/offset/GetOffsetRequest.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/offset/GetOffsetRequest.java index 96f4b691..3d62e253 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/offset/GetOffsetRequest.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/offset/GetOffsetRequest.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.offset; diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/offset/GetOffsetResponse.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/offset/GetOffsetResponse.java index 3358b894..6d76f40e 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/offset/GetOffsetResponse.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/offset/GetOffsetResponse.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.offset; public class GetOffsetResponse { diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/offset/GetOffsetResult.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/offset/GetOffsetResult.java index 2b0a4491..4516db66 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/offset/GetOffsetResult.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/offset/GetOffsetResult.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.offset; import java.util.concurrent.CompletableFuture; diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/offset/ResetOffsetRequest.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/offset/ResetOffsetRequest.java index 3fa223e4..8fc0407d 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/offset/ResetOffsetRequest.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/offset/ResetOffsetRequest.java @@ -15,15 +15,19 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.offset; import org.apache.eventmesh.dashboard.common.enums.ResetOffsetMode; +import org.apache.eventmesh.dashboard.common.model.remoting.Global2Request; import lombok.Data; +import lombok.EqualsAndHashCode; @Data -public class ResetOffsetRequest { +@EqualsAndHashCode(callSuper = true) +public class ResetOffsetRequest extends Global2Request { private Long timestamp; diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/offset/ResetOffsetResponse.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/offset/ResetOffsetResponse.java index ed1417be..3f8be3f4 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/offset/ResetOffsetResponse.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/offset/ResetOffsetResponse.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.offset; import lombok.Data; diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/offset/ResetOffsetResult.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/offset/ResetOffsetResult.java index 3f0773e7..cd64d55a 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/offset/ResetOffsetResult.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/offset/ResetOffsetResult.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.offset; import java.util.concurrent.CompletableFuture; diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/runtime/GetRuntimeRequest.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/runtime/GetRuntime2Request.java similarity index 87% rename from eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/runtime/GetRuntimeRequest.java rename to eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/runtime/GetRuntime2Request.java index de8ac0ab..f5a6f34b 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/runtime/GetRuntimeRequest.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/runtime/GetRuntime2Request.java @@ -15,14 +15,17 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.runtime; -import org.apache.eventmesh.dashboard.common.model.remoting.GlobalRequest; +import org.apache.eventmesh.dashboard.common.model.remoting.Global2Request; import lombok.Data; +import lombok.EqualsAndHashCode; @Data -public class GetRuntimeRequest extends GlobalRequest { +@EqualsAndHashCode(callSuper = true) +public class GetRuntime2Request extends Global2Request { private String registryAddress; } diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/runtime/GetRuntimeResponse.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/runtime/GetRuntimeResponse.java index 483a609f..6e741327 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/runtime/GetRuntimeResponse.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/runtime/GetRuntimeResponse.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.runtime; import org.apache.eventmesh.dashboard.common.model.metadata.RuntimeMetadata; diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/runtime/GetRuntimeResult.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/runtime/GetRuntimeResult.java index d0ec3e17..09b74eb8 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/runtime/GetRuntimeResult.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/runtime/GetRuntimeResult.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.runtime; import org.apache.eventmesh.dashboard.common.model.remoting.GlobalResult; @@ -22,8 +23,10 @@ import java.util.concurrent.CompletableFuture; import lombok.Data; +import lombok.EqualsAndHashCode; @Data +@EqualsAndHashCode(callSuper = true) public class GetRuntimeResult extends GlobalResult { private CompletableFuture future; diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/subscription/GetSubscriptionRequest.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/subscription/GetSubscriptionRequest.java index c5271ff4..15149df0 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/subscription/GetSubscriptionRequest.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/subscription/GetSubscriptionRequest.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.subscription; public class GetSubscriptionRequest { diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/subscription/GetSubscriptionResponse.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/subscription/GetSubscriptionResponse.java index 853675f5..3c2e28eb 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/subscription/GetSubscriptionResponse.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/subscription/GetSubscriptionResponse.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.subscription; public class GetSubscriptionResponse { diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/subscription/GetSubscriptionResult.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/subscription/GetSubscriptionResult.java index f5a22158..b5e89f85 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/subscription/GetSubscriptionResult.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/subscription/GetSubscriptionResult.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.subscription; import java.util.concurrent.CompletableFuture; diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/CreateTopicRequest.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/CreateTopic2Request.java similarity index 74% rename from eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/CreateTopicRequest.java rename to eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/CreateTopic2Request.java index a9eb328e..5a0e74d5 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/CreateTopicRequest.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/CreateTopic2Request.java @@ -15,27 +15,19 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.topic; import org.apache.eventmesh.dashboard.common.model.metadata.TopicMetadata; -import org.apache.eventmesh.dashboard.common.model.remoting.GlobalRequest; - -import com.alibaba.fastjson2.JSONObject; +import org.apache.eventmesh.dashboard.common.model.remoting.AbstractGlobal2Request; -import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; @Data -@NoArgsConstructor -@AllArgsConstructor @EqualsAndHashCode(callSuper = true) -public class CreateTopicRequest extends GlobalRequest { - - private TopicMetadata topicMetadata; +public class CreateTopic2Request extends AbstractGlobal2Request { - private JSONObject topicConfig; } diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/CreateTopicResponse.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/CreateTopicResponse.java index d4e4a786..244ead5a 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/CreateTopicResponse.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/CreateTopicResponse.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.topic; import lombok.AllArgsConstructor; diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/CreateTopicResult.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/CreateTopicResult.java index 9fb63277..0c19d450 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/CreateTopicResult.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/CreateTopicResult.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.topic; import org.apache.eventmesh.dashboard.common.model.remoting.GlobalResult; diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/DeleteTopicRequest.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/DeleteTopicRequest.java index b2bd2161..deecfb44 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/DeleteTopicRequest.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/DeleteTopicRequest.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.topic; diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/DeleteTopicResponse.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/DeleteTopicResponse.java index df818750..383c618f 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/DeleteTopicResponse.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/DeleteTopicResponse.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.topic; import lombok.AllArgsConstructor; diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/DeleteTopicResult.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/DeleteTopicResult.java index a340735d..a55698b8 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/DeleteTopicResult.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/DeleteTopicResult.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.topic; import org.apache.eventmesh.dashboard.common.model.remoting.GlobalResult; diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/GetTopicsRequest.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/GetTopics2Request.java similarity index 85% rename from eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/GetTopicsRequest.java rename to eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/GetTopics2Request.java index d9920d82..2178d093 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/GetTopicsRequest.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/GetTopics2Request.java @@ -15,18 +15,17 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.topic; -import org.apache.eventmesh.dashboard.common.model.remoting.GlobalRequest; +import org.apache.eventmesh.dashboard.common.model.remoting.Global2Request; -import lombok.AllArgsConstructor; import lombok.Data; -import lombok.NoArgsConstructor; +import lombok.EqualsAndHashCode; @Data -@NoArgsConstructor -@AllArgsConstructor -public class GetTopicsRequest extends GlobalRequest { +@EqualsAndHashCode(callSuper = true) +public class GetTopics2Request extends Global2Request { private String runtimeHost; diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/GetTopicsResponse.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/GetTopicsResponse.java index dfe3408d..154dd7aa 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/GetTopicsResponse.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/GetTopicsResponse.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.topic; diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/GetTopicsResult.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/GetTopicsResult.java index debdbdba..1e6c47e9 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/GetTopicsResult.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/GetTopicsResult.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.topic; import org.apache.eventmesh.dashboard.common.model.remoting.GlobalResult; diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/CreateUserRequest.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/CreateUserRequest.java index 2031153c..0a1a1a42 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/CreateUserRequest.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/CreateUserRequest.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.user; import org.apache.eventmesh.dashboard.common.model.metadata.InstanceUserMetadata; diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/CreateUserResponse.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/CreateUserResponse.java index 7d9a79bd..403af2c9 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/CreateUserResponse.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/CreateUserResponse.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.user; public class CreateUserResponse { diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/CreateUserResult.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/CreateUserResult.java index 3e187f28..24356d80 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/CreateUserResult.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/CreateUserResult.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.user; public class CreateUserResult { diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/DeleteUserResponse.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/DeleteUserResponse.java index a8c10278..02f553f0 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/DeleteUserResponse.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/DeleteUserResponse.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.user; public class DeleteUserResponse { diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/DeleteUserResult.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/DeleteUserResult.java index d6241c23..b9de0e93 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/DeleteUserResult.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/DeleteUserResult.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.user; public class DeleteUserResult { diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/DeleterUserRequest.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/DeleterUserRequest.java index 30541d7a..4771567e 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/DeleterUserRequest.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/DeleterUserRequest.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.user; public class DeleterUserRequest { diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/GetUserRequest.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/GetUserRequest.java index faccba53..e3022896 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/GetUserRequest.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/GetUserRequest.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.user; import org.apache.eventmesh.dashboard.common.enums.StoreType; diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/GetUserResponse.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/GetUserResponse.java index 8fdf0bc7..805f6c1e 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/GetUserResponse.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/GetUserResponse.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.user; diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/GetUserResult.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/GetUserResult.java index 8014118f..2b683962 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/GetUserResult.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/user/GetUserResult.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.model.remoting.user; import java.util.concurrent.CompletableFuture; diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/port/AbstractPortValidate.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/port/AbstractPortValidate.java new file mode 100644 index 00000000..2035eb1c --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/port/AbstractPortValidate.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.common.port; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; + +public abstract class AbstractPortValidate implements PortValidate { + + protected List portRules = new ArrayList<>(); + + + protected void createNotValid(List portNameList) { + AtomicInteger index = new AtomicInteger(0); + portNameList.forEach(portName -> { + PortRule portRule = PortRule.builder().valid(false).index(index.incrementAndGet()).name(portName).build(); + this.setPortRules(portRule); + }); + } + + protected void setPortRules(PortRule portRule) { + this.portRules.add(portRule); + } + + + @Override + public List portRules() { + return portRules; + } + +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/port/NotPortValidate.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/port/NotPortValidate.java new file mode 100644 index 00000000..d2a7cef3 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/port/NotPortValidate.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.eventmesh.dashboard.common.port; + +import java.util.List; + +public class NotPortValidate extends AbstractPortValidate { + + + public static NotPortValidate builder() { + return builder(1); + } + + public static NotPortValidate builder(Integer num) { + NotPortValidate notPortValidate = new NotPortValidate(); + notPortValidate.build(num); + return notPortValidate; + } + + + protected void build(Integer num) { + for (int i = 0; i < num; i++) { + PortRule rule = PortRule.builder().valid(false).build(); + this.setPortRules(rule); + } + } + + + @Override + public boolean validate(PortRule lastPortRule, Integer lastPort, PortRule current, Integer port, List portRules) { + return false; + } +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/port/PortRule.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/port/PortRule.java new file mode 100644 index 00000000..9c149954 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/port/PortRule.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.common.port; + +import lombok.Builder; +import lombok.Data; + +/** + * 目前只支持范围获得 port + */ +@Data +@Builder +public class PortRule { + + private boolean valid; + + private String name; + + private Integer index; + + private Integer spanValue; + +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/port/PortValidate.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/port/PortValidate.java new file mode 100644 index 00000000..49364779 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/port/PortValidate.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.eventmesh.dashboard.common.port; + +import java.util.List; + +/** + * + */ +public interface PortValidate { + + + List portRules(); + + boolean validate(PortRule lastPortRule, Integer lastPort, PortRule current, Integer port, List portRules); +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/util/ClasspathScanner.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/util/ClasspathScanner.java new file mode 100644 index 00000000..1ab9fc71 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/util/ClasspathScanner.java @@ -0,0 +1,136 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.common.util; + + +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.ArrayUtils; + +import java.io.IOException; +import java.lang.reflect.Modifier; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.Set; + +import org.springframework.core.io.Resource; +import org.springframework.core.io.support.PathMatchingResourcePatternResolver; +import org.springframework.util.ClassUtils; + +import lombok.Builder; +import lombok.Data; + + +@Data +@Builder +public class ClasspathScanner { + + private Class base; + + private String baseString; + + private String subPath; + + + private boolean allSubDirectory = true; + + private Set> interfaceSet; + + private String designation; + + + private Resource[] getResource() throws IOException { + PathMatchingResourcePatternResolver resourcePatternResolver = new PathMatchingResourcePatternResolver(); + return resourcePatternResolver.getResources(this.createLocationPattern()); + } + + public List> getClazz() throws Exception { + Resource[] resources = this.getResource(); + List> resourcesList = new ArrayList<>(); + for (Resource resource : resources) { + if (this.excludeTest(resource)) { + continue; + } + Class clazz = this.createClass(resource); + if (Modifier.isAbstract(clazz.getModifiers())) { + continue; + } + if (this.includeInterface(clazz)) { + resourcesList.add(clazz); + } + Class[] innerClass = clazz.getDeclaredClasses(); + if (ArrayUtils.isEmpty(innerClass)) { + continue; + } + for (Class c : innerClass) { + if (this.includeInterface(c)) { + resourcesList.add(c); + } + } + } + return resourcesList; + } + + private boolean excludeTest(Resource resource) throws IOException { + return resource.getFile().getPath().indexOf("/target/test-classes/") != -1; + } + + private Class createClass(Resource resource) throws IOException, ClassNotFoundException { + String path = resource.getURL().getPath(); + String classPath = path.substring(path.indexOf(this.baseString)).replace("/", ".").replace(".class", ""); + return Class.forName(classPath); + } + + private boolean includeInterface(Class clazz) throws Exception { + if (CollectionUtils.isEmpty(this.interfaceSet)) { + return true; + } + Set> classInterfaceSet = ClassUtils.getAllInterfacesForClassAsSet(clazz); + for (Class c : this.interfaceSet) { + if (classInterfaceSet.contains(c)) { + return true; + } + } + return false; + } + + private String createLocationPattern() { + StringBuffer stringBuffer = new StringBuffer(); + stringBuffer.append("classpath*:./"); + this.baseString = base.getPackage().getName().replace('.', '/'); + stringBuffer.append(this.baseString); + stringBuffer.append("/"); + stringBuffer.append(subPath); + if (this.allSubDirectory) { + stringBuffer.append("/**"); + } + /** + * SDK*.class + */ + if (Objects.isNull(this.designation)) { + stringBuffer.append("/*"); + } else { + stringBuffer.append("/"); + stringBuffer.append(this.designation); + } + stringBuffer.append(".class"); + return stringBuffer.toString(); + } +} + diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/util/ExceptionUtil.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/util/ExceptionUtil.java index a9bd0e08..1b37a0de 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/util/ExceptionUtil.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/util/ExceptionUtil.java @@ -15,8 +15,11 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.common.util; + +@Deprecated public class ExceptionUtil { /** diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/utils/ClusterTypeRelationship.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/utils/ClusterTypeRelationship.java new file mode 100644 index 00000000..3159cf34 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/utils/ClusterTypeRelationship.java @@ -0,0 +1,66 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.eventmesh.dashboard.common.utils; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +public class ClusterTypeRelationship { + + private static final ClusterTypeRelationship INSTANCE = new ClusterTypeRelationship(); + + public static ClusterTypeRelationship getInstance() { + return INSTANCE; + } + + + private final List storageClusterTypeList = new ArrayList<>(); + + { + ClusterType[] clusterTypes = ClusterType.values(); + for (ClusterType clusterType : clusterTypes) { + if (Objects.isNull(clusterType.getEventmeshNodeType())) { + break; + } + for (ClusterType relationshipType : clusterTypes) { + if (Objects.isNull(clusterType.getEventmeshNodeType())) { + break; + } + } + if (Objects.equals(clusterType.getEventmeshNodeType(), ClusterType.STORAGE) + && Objects.equals(clusterType.getAssemblyNodeType(), ClusterType.CLUSTER)) { + storageClusterTypeList.add(clusterType); + } + if (Objects.equals(clusterType.getEventmeshNodeType(), ClusterType.STORAGE) + && Objects.equals(clusterType.getAssemblyNodeType(), ClusterType.CLUSTER)) { + storageClusterTypeList.add(clusterType); + } + } + } + + public ClusterTypeRelationship() { + + } + + public List getStorageClusterTypeList() { + return storageClusterTypeList; + } +} diff --git a/eventmesh-dashboard-console/pom.xml b/eventmesh-dashboard-console/pom.xml index cdac182f..bfe4dc2f 100644 --- a/eventmesh-dashboard-console/pom.xml +++ b/eventmesh-dashboard-console/pom.xml @@ -16,6 +16,7 @@ ~ limitations under the License. --> + @@ -30,7 +31,7 @@ eventmesh-dashboard-console - 1.8 + 17 UTF-8 UTF-8 @@ -65,11 +66,22 @@ mybatis-dependent 0.1.4 + + com.alibaba + druid-spring-boot-starter + 1.2.21 + + com.github.pagehelper pagehelper-spring-boot-starter 2.1.0 + + org.springframework.boot + spring-boot-starter-validation + 2.6.7 + @@ -85,12 +97,12 @@ org.mapstruct mapstruct - 1.5.2.Final + 1.6.2 org.mapstruct mapstruct-processor - 1.5.2.Final + 1.6.1 @@ -110,7 +122,7 @@ cn.lampup decoration-core - 0.1.7 + 0.1.20 @@ -125,6 +137,24 @@ 4.13.2 test + + org.mockito + mockito-inline + 5.2.0 + test + + + com.h2database + h2 + 2.3.232 + test + + + org.mybatis.spring.boot + mybatis-spring-boot-starter-test + 2.3.2 + test + @@ -134,8 +164,8 @@ maven-compiler-plugin 3.13.0 - 1.8 - 1.8 + 15 + 15 UTF-8 @@ -169,5 +199,12 @@ + + + maven_central + Maven Central + https://repo.maven.apache.org/maven2/ + + \ No newline at end of file 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 7103aad0..d0d6a4f8 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 @@ -15,11 +15,11 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console; 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; @@ -27,7 +27,6 @@ @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/annotation/EmLog.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/annotation/EmLog.java index efae3a5b..46538d12 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/annotation/EmLog.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/annotation/EmLog.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.annotation; import java.lang.annotation.ElementType; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/config/FunctionManagerConfigs.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/config/FunctionManagerConfigs.java index 3b2eb777..fed7d4f7 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/config/FunctionManagerConfigs.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/config/FunctionManagerConfigs.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.config; import org.springframework.boot.context.properties.ConfigurationProperties; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/config/SpringDocConfig.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/config/SpringDocConfig.java index 12d33c8b..31014054 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/config/SpringDocConfig.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/config/SpringDocConfig.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.config; import org.springframework.context.annotation.Bean; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/ClusterAbitityService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/ClusterAbitityService.java new file mode 100644 index 00000000..112a8898 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/ClusterAbitityService.java @@ -0,0 +1,68 @@ +/* + * 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.common.enums.ClusterFramework; +import org.apache.eventmesh.dashboard.common.enums.ClusterSyncMetadataEnum; +import org.apache.eventmesh.dashboard.console.entity.base.BaseClusterIdEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; +import org.apache.eventmesh.dashboard.console.mapstruct.cluster.ClusterControllerMapper; +import org.apache.eventmesh.dashboard.console.modle.ClusterIdDTO; +import org.apache.eventmesh.dashboard.console.service.cluster.ClusterService; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +import lombok.Getter; + + +@Component +public class ClusterAbitityService { + + + @Autowired + private ClusterService clusterService; + + + @Value("${console.controller.data.merge:false}") + @Getter + private boolean merge = false; + + + /** + * + * 可以对 topic, group, config ,sub 等做到强制性.offset 无法做到强制一致性 + * + * + */ + @Value("${console.data.forceConsistent:false}") + private boolean forceConsistent = false; + + + public boolean isCAP(ClusterIdDTO clusterIdDTO) { + ClusterEntity clusterEntity = this.clusterService.queryClusterById(ClusterControllerMapper.INSTANCE.toClusterEntity(clusterIdDTO)); + return this.isCAP(clusterEntity); + } + + public boolean isCAP(BaseClusterIdEntity baseClusterIdEntity) { + ClusterFramework clusterFramework = ClusterSyncMetadataEnum.getClusterFramework(baseClusterIdEntity.getClusterType()); + return clusterFramework.isCAP(); + } +} 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 6a4eee11..7fe42b4f 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 @@ -15,13 +15,12 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.controller; +package org.apache.eventmesh.dashboard.console.controller; -import org.apache.eventmesh.dashboard.console.entity.connection.AddConnectionEntity; import org.apache.eventmesh.dashboard.console.entity.connector.ConnectorEntity; import org.apache.eventmesh.dashboard.console.entity.function.ConfigEntity; -import org.apache.eventmesh.dashboard.console.mapstruct.connection.ConnectionControllerMapper; +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; @@ -29,19 +28,16 @@ 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.PostMapping; import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController -@RequestMapping("/cluster/connection") public class ConnectionController { - @Autowired + private ConnectionDataService connectionDataService; /** @@ -50,27 +46,28 @@ public class ConnectionController { * @param type * @return */ - @GetMapping("/getConnectorBusinessType") + @GetMapping("/cluster/connection/getConnectorBusinessType") public List getConnectorBusinessType(String type) { return connectionDataService.getConnectorBusinessType(type); } - @GetMapping("/getConnectorConfigs") + @GetMapping("/cluster/connection/getConnectorConfigs") public List getConnectorConfigsByClassAndVersion(String version, String classType) { return connectionDataService.getConnectorConfigsByClassAndVersion(classType, version); } - @GetMapping("/showCreateConnectionMessage") - public AddConnectionEntity showCreateConnectionMessage() { - return new AddConnectionEntity(); + @GetMapping("/cluster/connection/showCreateConnectionMessage") + public AddConnectionDTO showCreateConnectionMessage() { + return new AddConnectionDTO(); } - @PostMapping("/createConnection") + @PostMapping("/cluster/connection/createConnection") public String createConnection(@Validated @RequestBody CreateConnectionDTO createConnectionDTO) { try { - connectionDataService.createConnection(ConnectionControllerMapper.INSTANCE.queryCreateEntityByConnection(createConnectionDTO)); + connectionDataService.createConnection(createConnectionDTO); + } catch (Exception e) { return e.getMessage(); } @@ -78,12 +75,12 @@ public String createConnection(@Validated @RequestBody CreateConnectionDTO creat } - @PostMapping("/getConnectionList") + @PostMapping("/cluster/connection/getConnectionList") public List getConnectionList(@Validated @RequestBody GetConnectionListDTO getConnectionListDTO) { - return connectionDataService.getConnectionToFrontByCluster(ConnectionControllerMapper.INSTANCE.queryEntityByConnection(getConnectionListDTO)); + return connectionDataService.getConnectionToFrontByCluster(getConnectionListDTO.getClusterId(), getConnectionListDTO); } - @GetMapping("/getConnectorDetail") + @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/MetricsController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/MetricsController.java index bedbbdd5..2bdc6fe9 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/MetricsController.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/MetricsController.java @@ -15,14 +15,15 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.controller; -import org.apache.eventmesh.dashboard.common.dto.Result; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import com.alibaba.druid.stat.DruidStatManagerFacade; +import com.alibaba.nacos.api.model.v2.Result; @RestController public class MetricsController { diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/SubscriptionController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/SubscriptionController.java deleted file mode 100644 index 871e0c53..00000000 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/SubscriptionController.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.console.controller; - -import org.apache.eventmesh.dashboard.common.dto.Result; -import org.apache.eventmesh.dashboard.common.model.SubscriptionInfo; -import org.apache.eventmesh.dashboard.service.meta.SubscriptionCore; - -import java.util.List; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@RequestMapping("/api/v1") -public class SubscriptionController { - - // the subscription dataId naming pattern of EventMesh clients: ip-protocol - private static final String CLIENT_DATA_ID_PATTERN = "*.*.*.*-*"; - /** - * TODO expose implement by FunctionManager - */ - SubscriptionCore subscriptionCore; - - /** - * Retrieve the config content of a specified config. - * - * @param dataId nacos config data id (Exact Matching) - * @param group config group (Exact Matching) - * @return config content - */ - @GetMapping("/subscription") - public Result retrieveSubscription(@RequestParam("dataId") String dataId, @RequestParam("group") String group) { - return Result.success(subscriptionCore.retrieveConfig(dataId, group)); - } - - /** - * Retrieve a list of configs. - * - * @param page page number - * @param size page size - * @param dataId nacos config data id (Fuzzy Matching) - * @param group config group (Fuzzy Matching) - * @return config properties and base64 encoded config content - */ - @GetMapping("/subscriptions") - public Result> listSubscriptions( - @RequestParam(name = "page", defaultValue = "1") Integer page, - @RequestParam(name = "size", defaultValue = "10") Integer size, - @RequestParam(name = "dataId", defaultValue = CLIENT_DATA_ID_PATTERN) String dataId, - @RequestParam(name = "group", defaultValue = "") String group) { - return Result.success(subscriptionCore.retrieveConfigs(page, size, dataId, group)); - } -} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/AclController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/AclController.java index e4947c31..a3369698 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/AclController.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/AclController.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.controller.cluster; import org.apache.eventmesh.dashboard.console.entity.cluster.AclEntity; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/ClientDataController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/ClientDataController.java index 258496ca..dbfe803c 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/ClientDataController.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/ClientDataController.java @@ -15,12 +15,12 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.controller.cluster; import org.apache.eventmesh.dashboard.console.entity.cluster.ClientEntity; -import org.apache.eventmesh.dashboard.console.mapstruct.cluster.ClientDataControllerMapper; -import org.apache.eventmesh.dashboard.console.modle.cluster.client.SelectByClusterIdDTO; +import org.apache.eventmesh.dashboard.console.modle.cluster.client.QueryClientByUserFormDTO; import org.apache.eventmesh.dashboard.console.service.cluster.ClientDataService; import java.util.List; @@ -41,8 +41,8 @@ public class ClientDataController { private ClientDataService clientDataService; - @PostMapping("selectByClusterId") - public List selectByClusterId(@RequestBody @Validated SelectByClusterIdDTO selectByClusterIdDTO) { - return clientDataService.selectByClusterId(ClientDataControllerMapper.INSTANCE.selectByClusterIdDTO(selectByClusterIdDTO)); + @PostMapping("queryClientByUserForm") + public List queryClientByUserForm(@RequestBody @Validated QueryClientByUserFormDTO queryClientByUserFormDTO) { + return clientDataService.queryClientByUserForm(queryClientByUserFormDTO); } } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/ClusterController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/ClusterController.java index 863655b0..416d6130 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/ClusterController.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/ClusterController.java @@ -15,14 +15,26 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.controller.cluster; +import org.apache.eventmesh.dashboard.console.entity.cluster.ClientEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; import org.apache.eventmesh.dashboard.console.mapstruct.cluster.ClusterControllerMapper; import org.apache.eventmesh.dashboard.console.modle.ClusterIdDTO; -import org.apache.eventmesh.dashboard.console.modle.cluster.CreateClusterDTO; +import org.apache.eventmesh.dashboard.console.modle.cluster.client.QueryClientByUserFormDTO; +import org.apache.eventmesh.dashboard.console.modle.cluster.cluster.ClusterDetailsVO; +import org.apache.eventmesh.dashboard.console.modle.cluster.cluster.QueryClusterByOrganizationIdAndTypeDTO; +import org.apache.eventmesh.dashboard.console.modle.cluster.cluster.QueryRelationClusterByClusterIdAndTypeDTO; +import org.apache.eventmesh.dashboard.console.modle.deploy.ClusterAllMetadataDO; import org.apache.eventmesh.dashboard.console.modle.vo.cluster.GetClusterBaseMessageVO; import org.apache.eventmesh.dashboard.console.service.cluster.ClusterService; +import org.apache.eventmesh.dashboard.console.service.cluster.RuntimeService; + +import java.util.List; +import java.util.concurrent.CompletableFuture; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; @@ -32,72 +44,75 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -/** - * 1. 用户首页列表 - * 2. 集群首页概要 - */ + @RestController -@RequestMapping("cluster") +@RequestMapping("user/cluster") public class ClusterController { @Autowired - ClusterService clusterService; + private ClusterService clusterService; + + @Autowired + public RuntimeService runtimeService; + @GetMapping("queryHomeClusterData") public GetClusterBaseMessageVO queryHomeClusterData(@RequestBody @Validated ClusterIdDTO clusterIdDTO) { - return clusterService.selectClusterBaseMessage(clusterIdDTO.getClusterId()); + return clusterService.getClusterBaseMessage(clusterIdDTO); } - - @PostMapping("createCluster") - public void createCluster(@RequestBody CreateClusterDTO createClusterDTO) { - this.clusterService.createCluster(ClusterControllerMapper.INSTANCE.createCluster(createClusterDTO)); + @PostMapping("queryClusterDetails") + public ClusterDetailsVO queryClusterDetails(@RequestBody @Validated ClusterIdDTO clusterIdDTO) { + ClusterEntity clusterEntity = new ClusterEntity(); + // eventmesh 集群详情 + // 基本统计信息 + // 部署信息,巡查信息 + // meta 列表, runtime 列表 存储列表 + RuntimeEntity runtimeEntity = new RuntimeEntity(); + runtimeEntity.setClusterId(clusterIdDTO.getClusterId()); + CompletableFuture completableFuture = + CompletableFuture.supplyAsync(() -> this.runtimeService.queryAllByClusterId(runtimeEntity, true, false)); + + // 存储集群详情 + // meta 集群详情 + // runtime集群详情 + ClusterDetailsVO clusterDetailsVO = new ClusterDetailsVO(); + return clusterDetailsVO; } - /** - * 那些集群可以暂停。被依赖的集群不允许暂停。暂停的含义是什么 暂停是否释放资源 - * - * @return - */ - public Integer pauseCluster() { - // 查询集群 - - // 判断集群类型 - // 查询依赖 + @PostMapping("queryClusterByUserForm") + public List queryClusterByUserForm(QueryClientByUserFormDTO queryClientByUserFormDTO) { return null; } /** - * 重新开始集群 + * 这个接口用户 cluster 对应业务的 首页,方便查询 * + * @param dto * @return */ - public Integer resumeCluster() { - // 查询集群 - - // 判断集群类型 + @PostMapping("queryVisualizationClusterByOrganizationIdAndType") + public List queryVisualizationClusterByOrganizationIdAndType(@RequestBody @Validated QueryClusterByOrganizationIdAndTypeDTO dto) { + return this.clusterService.queryClusterByOrganizationIdAndType(ClusterControllerMapper.INSTANCE.queryClusterByOrganizationIdAndType(dto)); + } - // 查询依赖 - return null; + @PostMapping("queryClusterByOrganizationIdAndType") + public List queryClusterByOrganizationIdAndType(@RequestBody @Validated QueryClusterByOrganizationIdAndTypeDTO dto) { + return this.clusterService.queryClusterByOrganizationIdAndType(ClusterControllerMapper.INSTANCE.queryClusterByOrganizationIdAndType(dto)); } /** - * 注销集群 + * 查询 cluster 的关联集群列表 * + * @param dto * @return */ - public Integer cancelCluster() { - // 查询集群 - - // 判断集群类型 - - // 查询依赖 - - // 如果是全程托管,释放k8s 集群 - return null; + @PostMapping("queryRelationClusterByClusterIdAndType") + public List queryRelationClusterByClusterIdAndType(@RequestBody @Validated QueryRelationClusterByClusterIdAndTypeDTO dto) { + return this.clusterService.queryRelationClusterByClusterIdAndType( + ClusterControllerMapper.INSTANCE.queryRelationClusterByClusterIdAndType(dto)); } - } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/ClusterRelationshipController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/ClusterRelationshipController.java index 9dba50f9..20734ebc 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/ClusterRelationshipController.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/ClusterRelationshipController.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.controller.cluster; import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterAndRelationshipEntity; @@ -37,13 +38,14 @@ public class ClusterRelationshipController { @Autowired private ClusterRelationshipService clusterRelationshipService; - + @Deprecated @PostMapping("addClusterRelationshipEntry") public void addClusterRelationshipEntry(@RequestBody ClusterRelationshipEntity clusterRelationshipEntity) { - this.clusterRelationshipService.insertClusterRelationshipEntry(clusterRelationshipEntity); + this.clusterRelationshipService.addClusterRelationshipEntry(clusterRelationshipEntity); } + @Deprecated @PostMapping("relieveRelationship") public Integer relieveRelationship(@RequestBody ClusterRelationshipEntity clusterRelationshipEntity) { return this.clusterRelationshipService.relieveRelationship(clusterRelationshipEntity); diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/DetailsController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/DetailsController.java new file mode 100644 index 00000000..ca84a3df --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/DetailsController.java @@ -0,0 +1,57 @@ +/* + * 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.cluster; + +import org.apache.eventmesh.dashboard.console.modle.ClusterIdDTO; + +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/organization/") +public class DetailsController { + + + @PostMapping("/details/eventMesh") + public void eventMeshDetails(ClusterIdDTO clusterIdDTO) { + // eventmesh 集群详情 + // 基本统计信息 + // 部署信息,巡查信息 + // meta 列表, runtime 列表 存储列表 + // 存储集群详情 + // meta 集群详情 + // runtime集群详情 + } + + @PostMapping("/details/meta") + public void metaDetails(ClusterIdDTO clusterIdDTO) { + + } + + @PostMapping("/details/storage") + public void storageDetails(ClusterIdDTO clusterIdDTO) { + + } + + @PostMapping("/details/storage/runtime") + public void storageRuntimeDetails(ClusterIdDTO clusterIdDTO) { + + } + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/HomeController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/HomeController.java new file mode 100644 index 00000000..11861dc9 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/HomeController.java @@ -0,0 +1,94 @@ +/* + * 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.cluster; + + +import org.apache.eventmesh.dashboard.console.service.cluster.ClusterService; + +public class HomeController { + + + private ClusterService clusterService; + + + + public void clusterHome(){ + // 运维事件 + + // runtime 集群 以及 + + // meta 集群 以及 + + // 存储集群 + + // kubernetes 列表。 本集群 没有或则资源不够,找上级集群。如果有多个上级 + + // 下面的是否需要展示 + // client + + // group 列表 topic 列表。是否需要在 home 展示 + + // 连接 + } + + public void runtimeHome(){ + // 在哪个 cluster + + // 在哪一个 kubernetes + + // message 统计 + + // in out 统计 + + // topic 统计数据 + + // group 统计数据 + + // client 统计数据 + + // 连接 统计数据 + + // 实例资源统计数据 + } + + + public void groupHome(){ + // cluster + + // topic + + // client + + // + } + + public void topicHome(){ + + } + + public void clientHome(){ + + } + + + public void userHome(){ + + } + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/InstanceUserController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/InstanceUserController.java deleted file mode 100644 index e95208ef..00000000 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/InstanceUserController.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.console.controller.cluster; - -import org.apache.eventmesh.dashboard.console.entity.cluster.InstanceUserEntity; -import org.apache.eventmesh.dashboard.console.service.cluster.InstanceUserService; - -import org.springframework.beans.factory.annotation.Autowired; -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.RestController; - -@RestController -@RequestMapping("/instanceUser") -public class InstanceUserController { - - @Autowired - private InstanceUserService instanceUserService; - - @PostMapping("/insertInstanceUser") - public void insertInstanceUser(@RequestBody InstanceUserEntity instanceUserEntity) { - this.instanceUserService.insert(instanceUserEntity); - } - - @PostMapping("/deleteInstanceUserByCluster") - public void deleteInstanceUserByCluster(@RequestBody InstanceUserEntity instanceUserEntity) { - this.instanceUserService.deleteInstanceUserByCluster(instanceUserEntity); - } - - @PostMapping("/updateNameById") - public void updateNameById(@RequestBody InstanceUserEntity instanceUserEntity) { - this.instanceUserService.updatePasswordById(instanceUserEntity); - } - - @PostMapping("/selectAll") - public void selectAll() { - - } - - @PostMapping("/selectById") - public void selectById(@RequestBody InstanceUserEntity instanceUserEntity) { - this.instanceUserService.selectById(instanceUserEntity); - } - - @PostMapping("/selectByName") - public void selectByName(@RequestBody InstanceUserEntity instanceUserEntity) { - this.instanceUserService.selectByName(instanceUserEntity); - } - -} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/NetConnectionController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/NetConnectionController.java index 38d3fe56..552d39c1 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/NetConnectionController.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/NetConnectionController.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.controller.cluster; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/RuntimeController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/RuntimeController.java index fe6647d6..6f7ba10e 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/RuntimeController.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/RuntimeController.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.controller.cluster; import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; @@ -44,7 +45,7 @@ public class RuntimeController { @PostMapping("/queryRuntimeListByClusterId") public List queryRuntimeListByClusterId(@Validated @RequestBody ClusterIdDTO clusterIdDTO) { List runtimeEntityList = - runtimeService.selectRuntimeToFrontByClusterId(RuntimeControllerMapper.INSTANCE.queryRuntimeListByClusterId(clusterIdDTO)); + runtimeService.queryRuntimeToFrontByClusterId(RuntimeControllerMapper.INSTANCE.queryRuntimeListByClusterId(clusterIdDTO)); runtimeEntityList.forEach(n -> { n.setStatus(CheckResultCache.getINSTANCE().getLastHealthyCheckResult("runtime", n.getId())); }); @@ -57,53 +58,5 @@ public RuntimeEntity queryRuntimeListById(@Validated @RequestBody IdDTO idDTO) { return this.runtimeService.queryRuntimeEntityById(RuntimeControllerMapper.INSTANCE.queryRuntimeListById(idDTO)); } - @PostMapping("/createRuntime") - public void crateRuntime(@Validated @RequestBody RuntimeEntity runtimeEntity) { - runtimeService.insertRuntime(runtimeEntity); - } - - /** - * 那些集群可以暂停。被依赖的集群不允许暂停。暂停的含义是什么 - * 暂停是否释放资源 - * @return - */ - public Integer pauseCluster() { - // 查询集群 - - // 判断集群类型 - - // 查询依赖 - return null; - } - - /** - * 重新开始集群 - * @return - */ - public Integer resumeCluster() { - // 查询集群 - - // 判断集群类型 - - // 查询依赖 - return null; - } - - /** - * 注销集群 - * @return - */ - public Integer cancelCluster() { - // 查询集群 - - // 判断集群类型 - - // 查询依赖 - - // 如果是全程托管,释放k8s 集群 - return null; - } - - } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/CaseController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/CaseController.java new file mode 100644 index 00000000..14b28185 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/CaseController.java @@ -0,0 +1,71 @@ +/* + * 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.deploy; + + +import org.apache.eventmesh.dashboard.console.entity.cases.CaseEntity; +import org.apache.eventmesh.dashboard.console.mapstruct.deploy.CaseControllerMapper; +import org.apache.eventmesh.dashboard.console.modle.IdDTO; +import org.apache.eventmesh.dashboard.console.modle.deploy.cases.QueryCaseByObjectTypeDTO; + +import java.util.List; + +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("case") +public class CaseController { + + + public List queryCaseByObjectType(@RequestBody QueryCaseByObjectTypeDTO queryCaseByObjectTypeDTO) { + CaseControllerMapper.INSTANCE.queryCaseByObjectType(queryCaseByObjectTypeDTO); + return null; + } + + public Integer deleteCase(@RequestBody IdDTO idDTO) { + return 0; + } + + public List queryCaseByOrganization() { + return null; + } + + + public void backups(){ + + } + + public void createCase(@RequestBody CaseEntity caseEntity) { + // 新增,状态进行中信 + + try { + // clone object 数据 + + // 标记成功 + } catch (Exception e) { + // 回滚 标记失败 + throw new RuntimeException(e); + } + + + } + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/ClusterCycleController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/ClusterCycleController.java new file mode 100644 index 00000000..c805861e --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/ClusterCycleController.java @@ -0,0 +1,192 @@ +/* + * 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.deploy; + +import org.apache.eventmesh.dashboard.common.enums.ClusterOwnType; +import org.apache.eventmesh.dashboard.common.enums.ClusterTrusteeshipType; +import org.apache.eventmesh.dashboard.common.enums.ClusterTrusteeshipType.FirstToWhom; +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.common.enums.DeployStatusType; +import org.apache.eventmesh.dashboard.console.controller.deploy.create.CreateClusterByDeployScriptHandler; +import org.apache.eventmesh.dashboard.console.controller.deploy.create.CreateRuntimeByDeployScriptHandler; +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterRelationshipEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; +import org.apache.eventmesh.dashboard.console.mapstruct.deploy.ClusterCycleControllerMapper; +import org.apache.eventmesh.dashboard.console.modle.cluster.VerifyNameDTO; +import org.apache.eventmesh.dashboard.console.modle.deploy.create.CreateClusterByDeployScriptDO; +import org.apache.eventmesh.dashboard.console.modle.deploy.create.CreateClusterByEventMesh; +import org.apache.eventmesh.dashboard.console.modle.deploy.create.CreateRuntimeByDeployScriptDTO; +import org.apache.eventmesh.dashboard.console.modle.deploy.create.CreateRuntimeByOnlyDataDO; +import org.apache.eventmesh.dashboard.console.service.cluster.ClusterService; +import org.apache.eventmesh.dashboard.console.service.cluster.RuntimeService; + +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.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + + +/** + * 1. 用户首页列表 + *

+ * 2. 集群首页概要 kubernetes 集群在 eventmesh 集群里面创建的 只属于这个集群 kubernetes在创建的时候可以设为独立集群 如果创建集群 + *

+ * 1. 全托管创建 因为全托管创建,不需要用户管理任何东西。 + *

+ * 2. 全托管共享集群 创建时绑定集群流程 + *

+ * 1.创建 kubernetes 集群 + *

+ * 2. 创建 storage 集群 + *

+ * 3. 创建 meta 集群 + *

+ * 4. 创建 runtime 集群 + *

+ * 5. 创建时 进行绑定 3. 已经 deploy config 创建,比较麻烦。这种 kubernetes 资源不会共享 + *

+ * 1. 提供 kubernetes集群配置,多个 + *

+ * 2. 选择 storage deploy config or storage id or name + *

+ * 3. 选择 meta deploy config or meta id or name + *

+ * 4. 选择 runtime deploy config or runtime idor name + *

+ * 5. 点击 创建,提供部署流程 4. 先创建,后绑定 + *

+ * 1. 直接创建 + *

+ * 2. 在内部进行绑定 5. 配置一个kubernetes集群,可以定时校验 deploy config 的效果。校验的目的是什么 创建节点的时候,先看自己生是否有 kubernetes。 然后检查上级cluster 是否有 可用的 kubernetes + */ +@RestController +@RequestMapping("organization/clusterCycleDeploy") +public class ClusterCycleController { + + @Autowired + private RuntimeService runtimeService; + + @Autowired + private ClusterService clusterService; + + @Autowired + private CreateRuntimeByDeployScriptHandler createRuntimeByDeployScriptHandler; + + + @Autowired + private CreateClusterByDeployScriptHandler createClusterByDeployScriptHandler; + + + /** + * @param verifyNameDTO + * @return + */ + public String verifyName(VerifyNameDTO verifyNameDTO) { + + return ""; + } + + @PostMapping("createRuntimeByOnlyDataHandler") + public void createRuntimeByOnlyDataHandler(@RequestBody @Validated CreateRuntimeByOnlyDataDO createRuntimeByOnlyDataDO) { + RuntimeEntity runtimeEntity = ClusterCycleControllerMapper.INSTANCE.createRuntimeByOnlyDataHandler(createRuntimeByOnlyDataDO); + runtimeService.insertRuntime(runtimeEntity); + } + + @PostMapping("createRuntimeByDeployScript") + public void createRuntimeByDeployScript(@RequestBody @Validated CreateRuntimeByDeployScriptDTO createRuntimeByDeployScriptDTO) { + this.createRuntimeByDeployScriptHandler.handler(createRuntimeByDeployScriptDTO); + } + + @PostMapping("createClusterByDeployScript") + public void createClusterByDeployScript(@RequestBody @Validated CreateClusterByDeployScriptDO createClusterByDeployScriptDO) { + this.createClusterByDeployScriptHandler.handler(createClusterByDeployScriptDO); + } + + /** + * 分 eventmesh 集群创建 + * + * @param createClusterByEventMesh + */ + @PostMapping("createEventMeshClusterByOnlyData") + public Long createEventMeshClusterByOnlyData(@RequestBody @Validated CreateClusterByEventMesh createClusterByEventMesh) { + ClusterEntity clusterEntity = ClusterCycleControllerMapper.INSTANCE.createClusterByEventMesh(createClusterByEventMesh); + clusterEntity.setClusterType(ClusterType.EVENTMESH_CLUSTER); + clusterEntity.setClusterOwnType(ClusterOwnType.NOT); + clusterEntity.setAuthType(""); + clusterEntity.setVersion(""); + clusterEntity.setRuntimeIndex(0); + clusterEntity.setTrusteeshipType(ClusterTrusteeshipType.NOT); + clusterEntity.setFirstToWhom(FirstToWhom.NOT); + clusterEntity.setDeployStatusType(DeployStatusType.CREATE_SUCCESS); + clusterEntity.setResourcesConfigId(0L); + clusterEntity.setDeployScriptId(0L); + clusterEntity.setDeployScriptName(""); + clusterEntity.setDeployScriptVersion(""); + clusterService.insertCluster(clusterEntity); + return clusterEntity.getId(); + } + + @PostMapping("createClusterByEventMesh") + public Long createClusterByEventMesh(@RequestBody @Validated CreateClusterByEventMesh createClusterByEventMesh) { + ClusterEntity clusterEntity = ClusterCycleControllerMapper.INSTANCE.createClusterByEventMesh(createClusterByEventMesh); + clusterEntity.setClusterType(ClusterType.EVENTMESH_CLUSTER); + clusterEntity.setClusterOwnType(ClusterOwnType.INDEPENDENCE); + clusterEntity.setAuthType(""); + clusterEntity.setVersion(""); + clusterEntity.setRuntimeIndex(0); + clusterEntity.setDeployStatusType(DeployStatusType.CREATE_SUCCESS); + clusterEntity.setResourcesConfigId(0L); + clusterEntity.setDeployScriptId(0L); + clusterEntity.setDeployScriptName(""); + clusterEntity.setDeployScriptVersion(""); + ClusterRelationshipEntity relationshipEntity = new ClusterRelationshipEntity(); + clusterService.insertClusterAndRelationship(clusterEntity, relationshipEntity); + return clusterEntity.getId(); + + } + + + @PostMapping("pauseCluster") + public void pauseCluster(@RequestBody @Validated CreateClusterByEventMesh createClusterByEventMesh) { + } + + @PostMapping("pauseRuntime") + public void pauseRuntime(@RequestBody @Validated CreateClusterByEventMesh createClusterByEventMesh) { + } + + @PostMapping("relationship") + public void relationship(@RequestBody @Validated CreateClusterByEventMesh createClusterByEventMesh) { + } + + @PostMapping("unrelationship") + public void unrelationship(@RequestBody @Validated CreateClusterByEventMesh createClusterByEventMesh) { + } + + @PostMapping("uninstallCluster") + public void uninstallCluster(@RequestBody @Validated CreateClusterByEventMesh createClusterByEventMesh) { + } + + @PostMapping("uninstallRuntime") + public void uninstallRuntime(@RequestBody @Validated CreateClusterByEventMesh createClusterByEventMesh) { + } + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/CreateCycleService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/CreateCycleService.java new file mode 100644 index 00000000..6345dc8f --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/CreateCycleService.java @@ -0,0 +1,272 @@ +/* + * 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.deploy; + +import org.apache.eventmesh.dashboard.common.enums.ClusterFramework; +import org.apache.eventmesh.dashboard.common.enums.ClusterSyncMetadataEnum; +import org.apache.eventmesh.dashboard.common.enums.ClusterTrusteeshipType; +import org.apache.eventmesh.dashboard.common.enums.ClusterTrusteeshipType.FirstToWhom; +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.common.enums.ReplicationType; +import org.apache.eventmesh.dashboard.common.enums.SyncErrorType; +import org.apache.eventmesh.dashboard.console.domain.metadata.ClusterMetadataDomain; +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; +import org.apache.eventmesh.dashboard.console.mapstruct.cluster.ClusterControllerMapper; +import org.apache.eventmesh.dashboard.console.modle.cluster.CreateClusterByCompleteDataDTO; +import org.apache.eventmesh.dashboard.console.modle.cluster.CreateClusterBySimpleDataDTO; +import org.apache.eventmesh.dashboard.console.service.cluster.ClusterRelationshipService; +import org.apache.eventmesh.dashboard.console.service.cluster.ClusterService; +import org.apache.eventmesh.dashboard.console.service.cluster.RuntimeService; +import org.apache.eventmesh.dashboard.console.service.connector.ResourcesConfigService; +import org.apache.eventmesh.dashboard.console.service.deploy.DeployScriptService; +import org.apache.eventmesh.dashboard.console.service.function.ConfigService; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +import lombok.extern.slf4j.Slf4j; + +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) +@Component +@Slf4j +public class CreateCycleService { + + @Autowired + private ConfigService configService; + + @Autowired + private ClusterService clusterService; + + @Autowired + private RuntimeService runtimeService; + + @Autowired + private ClusterRelationshipService clusterRelationshipService; + + @Autowired + private ResourcesConfigService resourcesConfigService; + + @Autowired + private DeployScriptService deployScriptService; + + + @Autowired + private ClusterMetadataDomain clusterMetadataDomain; + + private ClusterEntity clusterEntity; + + + private void verifyName() { + if (!this.clusterService.nameExist(this.clusterEntity)) { + // + } + } + + private void createDevOps() { + + } + + private void createCLusterEntity() { + + } + + private void createRuntimeEntity() { + + } + + private void createRuntimeConfig() { + + } + + private void persistenceData() { + + } + + private void lockPost() { + // 获得端口 + + // + } + + private void checkResource() { + + } + + private void lockResource() { + + } + + + private void createInstance() { + // 然后通知,检查 + } + + + private void createCluster(Long configGatherId) { + this.verifyName(); + this.clusterService.createCluster(clusterEntity); + if (Objects.nonNull(configGatherId)) { + this.configService.copyConfig(configGatherId, clusterEntity.getId()); + } + } + + public ClusterEntity createClusterBySimpleData(CreateClusterBySimpleDataDTO createClusterBySimpleDataDTO) { + clusterEntity = ClusterControllerMapper.INSTANCE.createCluster(createClusterBySimpleDataDTO); + this.createCluster(createClusterBySimpleDataDTO.getConfigGatherId()); + return clusterEntity; + } + + public void createClusterByCompleteData(CreateClusterByCompleteDataDTO createClusterByCompleteDataDTO) { + // 对进群进行判断,kafka broker 集群,只能有一个 + // eventmesh 集群,目前只支持一个 meta, 一个runtime, 一个存储。 + + // 创建 部署流程 + // 集群名字是否存在 + ClusterEntity clusterEntity = this.createClusterBySimpleData(createClusterByCompleteDataDTO); + ClusterFramework clusterFramework = ClusterSyncMetadataEnum.getClusterFramework(createClusterByCompleteDataDTO.getClusterType()); + if (clusterFramework.isMainSlave()) { + this.createMainSlave(createClusterByCompleteDataDTO); + } else { + this.createNotMainSlave(createClusterByCompleteDataDTO); + } + } + + public void createClusterByConfigData(CreateClusterBySimpleDataDTO createClusterBySimpleDataDTO) { + // 创建 部署流程 + // 集群名字是否存在 + // 创建 config 里面所有数据 + // 检查资源 + // 锁定资源 + // 锁定 端口 + // 组个调用 kubernetes 创建资源 + // 检查 + // 失败,释放资源,端口,删除 kubernetes内容 + } + + private void createNotMainSlave(CreateClusterByCompleteDataDTO createClusterByCompleteDataDTO) { + ClusterEntity clusterEntity = this.createClusterBySimpleData(createClusterByCompleteDataDTO); + List runtimeEntityList = new ArrayList<>(); + for (int i = 0; i < createClusterByCompleteDataDTO.getCreateNum(); i++) { + RuntimeEntity runtimeEntity = new RuntimeEntity(); + runtimeEntity.setClusterId(clusterEntity.getId()); + runtimeEntity.setClusterType(clusterEntity.getClusterType()); + runtimeEntity.setTrusteeshipType(ClusterTrusteeshipType.SELF); + runtimeEntity.setFirstToWhom(clusterEntity.getFirstToWhom()); + runtimeEntity.setFirstSyncState(clusterEntity.getFirstSyncState()); + runtimeEntity.setSyncErrorType(clusterEntity.getSyncErrorType()); + runtimeEntity.setReplicationType(ReplicationType.NOT); + runtimeEntityList.add(runtimeEntity); + } + } + + public void createMainSlave(CreateClusterByCompleteDataDTO createClusterByCompleteDataDTO) { + List clusterEntityList = new ArrayList<>(); + for (int i = 0; i < createClusterByCompleteDataDTO.getCreateNum(); i++) { + ClusterEntity newCluster = ClusterControllerMapper.INSTANCE.createCluster(createClusterByCompleteDataDTO); + newCluster.setTrusteeshipType(ClusterTrusteeshipType.SELF); + newCluster.setFirstToWhom(FirstToWhom.COMPLETE); + newCluster.setFirstSyncState(FirstToWhom.COMPLETE); + newCluster.setSyncErrorType(SyncErrorType.NOT); + newCluster.setReplicationType(ReplicationType.NOT); + clusterEntityList.add(newCluster); + } + List runtimeEntityList = new ArrayList<>(); + clusterEntityList.forEach(entity -> { + RuntimeEntity runtimeEntity = new RuntimeEntity(); + runtimeEntity.setClusterId(entity.getId()); + runtimeEntity.setClusterType(entity.getClusterType()); + runtimeEntity.setTrusteeshipType(ClusterTrusteeshipType.SELF); + runtimeEntity.setFirstToWhom(entity.getFirstToWhom()); + runtimeEntity.setFirstSyncState(entity.getFirstSyncState()); + runtimeEntity.setSyncErrorType(entity.getSyncErrorType()); + runtimeEntity.setReplicationType(ReplicationType.MAIN); + + runtimeEntityList.add(runtimeEntity); + if (Objects.equals(createClusterByCompleteDataDTO.getReplicationType(), ReplicationType.MAIN_SLAVE)) { + runtimeEntity = new RuntimeEntity(); + runtimeEntity.setClusterId(entity.getId()); + runtimeEntity.setClusterType(entity.getClusterType()); + runtimeEntity.setTrusteeshipType(entity.getTrusteeshipType()); + runtimeEntity.setFirstToWhom(entity.getFirstToWhom()); + runtimeEntity.setFirstSyncState(entity.getFirstSyncState()); + runtimeEntity.setSyncErrorType(entity.getSyncErrorType()); + runtimeEntity.setReplicationType(ReplicationType.SLAVE); + runtimeEntityList.add(runtimeEntity); + } + }); + runtimeEntityList.forEach(entity -> { + ClusterType clusterType = entity.getClusterType(); + Map portMap = new HashMap<>(); + + portMap.forEach((key, value) -> { + + }); + }); + + + } + + public void registerRuntime(RuntimeEntity runtimeEntity) { + this.runtimeService.insertRuntime(runtimeEntity); + } + + public void createRuntime() { + // 创建 部署流程 + + // 创建 runtime + + // 判断是否 有模板 + + // 获得 cluster 默认模板 + + // 创建 config 里面所有数据 + // 持久化数据 + // 检查资源 + // 锁定资源 + // 需要一个被 console 管理的端口,所以要 锁定 端口 + // + } + + + // TODO 添加修改绑定解绑 meta 集群,都需要 所有的 runtime集群。是通过事件方式处理还是立即处理? + // IP 管理 + // 配置写入, + // 可动态修改配置(可以在线修改), + // 不可能动态修改配置,修改 yaml 重新启动容器,是否支持灰度修改 + // 配置末班, a 配置 1, 变成2 + // meta deployment + // 存储 StatefulSet 暴露端口 hostIP + // 是否直接暴露端口, 是否使用 service。 每次只能穿件一个 实例 + // 1. jmx + // 2. nameservice 负载不太均匀问题 + // 3. eventmesh runtime admin + // broker + queue + // 磁盘, + + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/ResourcesConfigController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/ResourcesConfigController.java new file mode 100644 index 00000000..5fd79969 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/ResourcesConfigController.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.controller.deploy; + +import org.apache.eventmesh.dashboard.console.entity.cases.ResourcesConfigEntity; +import org.apache.eventmesh.dashboard.console.mapstruct.deploy.ResourceConfigControllerMapper; +import org.apache.eventmesh.dashboard.console.modle.IdDTO; +import org.apache.eventmesh.dashboard.console.modle.OrganizationIdDTO; +import org.apache.eventmesh.dashboard.console.modle.deploy.resouce.QueryResourceByObjectTypeDTO; + +import java.util.List; + +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("resourcesConfig") +public class ResourcesConfigController { + + + public List queryResourcesConfigByObjectType( + @RequestBody QueryResourceByObjectTypeDTO queryResourcesConfigByObjectTypeDTO) { + ResourcesConfigEntity resourcesConfigEntity = + ResourceConfigControllerMapper.INSTANCE.queryResourcesConfigByObjectType(queryResourcesConfigByObjectTypeDTO); + return null; + } + + public Integer deleteResourcesConfig(@RequestBody IdDTO idDTO) { + // 作废之前检查,是否使用过 + return 0; + } + + public List queryResourcesConfigByOrganization(OrganizationIdDTO organizationIdDTO) { + return null; + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/create/CreateClusterByDeployScriptHandler.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/create/CreateClusterByDeployScriptHandler.java new file mode 100644 index 00000000..95ef6d0b --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/create/CreateClusterByDeployScriptHandler.java @@ -0,0 +1,144 @@ +/* + * 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.deploy.create; + +import org.apache.eventmesh.dashboard.common.enums.ClusterFramework; +import org.apache.eventmesh.dashboard.common.enums.ClusterSyncMetadataEnum; +import org.apache.eventmesh.dashboard.common.enums.ClusterTrusteeshipType; +import org.apache.eventmesh.dashboard.common.enums.ClusterTrusteeshipType.FirstToWhom; +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.common.enums.DeployStatusType; +import org.apache.eventmesh.dashboard.common.enums.ReplicationType; +import org.apache.eventmesh.dashboard.console.controller.deploy.handler.UpdateHandler; +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; +import org.apache.eventmesh.dashboard.console.mapstruct.deploy.ClusterCycleControllerMapper; +import org.apache.eventmesh.dashboard.console.modle.deploy.create.CreateClusterByDeployScriptDO; +import org.apache.eventmesh.dashboard.console.service.cluster.ClusterRelationshipService; +import org.apache.eventmesh.dashboard.console.service.cluster.ClusterService; +import org.apache.eventmesh.dashboard.console.service.cluster.RuntimeService; +import org.apache.eventmesh.dashboard.console.service.function.ConfigService; + +import java.util.ArrayList; +import java.util.Deque; +import java.util.List; +import java.util.Objects; + +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + + +@Component +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) +public class CreateClusterByDeployScriptHandler implements UpdateHandler { + + private ClusterService clusterService; + + private ConfigService configService; + + private RuntimeService runtimeService; + + private ClusterRelationshipService clusterRelationshipService; + + private ClusterEntity clusterEntity; + + private ClusterFramework clusterFramework; + + private ClusterType clusterType; + + private ReplicationType replicationType; + + + private final List runtimeEntityList = new ArrayList<>(); + + @Override + public void init() { + + } + + private void handlerMetadata(ClusterEntity clusterEntity) { + this.clusterType = clusterEntity.getClusterType(); + this.replicationType = clusterEntity.getReplicationType(); + this.clusterFramework = ClusterSyncMetadataEnum.getClusterFramework(clusterEntity.getClusterType()); + } + + @Override + public void handler(CreateClusterByDeployScriptDO createClusterByDeployScriptDO) { + this.clusterEntity = ClusterCycleControllerMapper.INSTANCE.createClusterByDeployScript(createClusterByDeployScriptDO); + + this.clusterService.insertCluster(this.clusterEntity); + this.handlerMetadata(this.clusterEntity); + if (Objects.nonNull(createClusterByDeployScriptDO.getConfigGatherId())) { + configService.copyConfig(createClusterByDeployScriptDO.getConfigGatherId(), this.clusterEntity.getId()); + } + if (this.clusterFramework.isMainSlave()) { + this.mainSlaveHandler(createClusterByDeployScriptDO, this.clusterEntity); + } else { + this.ordinaryRuntime(createClusterByDeployScriptDO); + } + + this.runtimeService.batchInsert(this.runtimeEntityList); + } + + private void ordinaryRuntime(CreateClusterByDeployScriptDO createClusterByDeployScriptDO) { + Deque linkedList = null; + if (this.clusterType.isStorage()) { + clusterEntity.setRuntimeIndex(createClusterByDeployScriptDO.getCreateNum()); + linkedList = this.clusterService.getIndex(this.clusterEntity); + } + for (int i = 0; i < createClusterByDeployScriptDO.getCreateNum(); i++) { + this.createRuntimeEntity(this.clusterEntity, replicationType, + Objects.isNull(linkedList) ? Integer.valueOf(0) : linkedList.pop()); + } + } + + private void mainSlaveHandler(CreateClusterByDeployScriptDO createClusterByDeployScriptDO, ClusterEntity clusterEntity) { + List clusterEntityList = new ArrayList<>(); + for (int i = 0; i < createClusterByDeployScriptDO.getCreateNum(); i++) { + ClusterEntity newClusterEntity = ClusterCycleControllerMapper.INSTANCE.createClusterByDeployScript(createClusterByDeployScriptDO); + clusterEntityList.add(newClusterEntity); + } + this.clusterService.batchInsert(clusterEntityList, clusterEntity); + clusterEntityList.forEach(entity -> { + this.createRuntimeEntity(clusterEntity, ReplicationType.MAIN, 0); + if (createClusterByDeployScriptDO.getReplicationType().isMainSlave()) { + this.createRuntimeEntity(clusterEntity, ReplicationType.SLAVE, 1); + } + }); + } + + private void createRuntimeEntity(ClusterEntity clusterEntity, ReplicationType replicationType, int index) { + RuntimeEntity runtimeEntity = new RuntimeEntity(); + runtimeEntity.setClusterId(clusterEntity.getClusterId()); + runtimeEntity.setClusterType(clusterEntity.getClusterType()); + runtimeEntity.setDeployScriptId(clusterEntity.getDeployScriptId()); + runtimeEntity.setResourcesConfigId(clusterEntity.getResourcesConfigId()); + runtimeEntity.setFirstToWhom(FirstToWhom.NOT); + runtimeEntity.setTrusteeshipType(ClusterTrusteeshipType.SELF); + runtimeEntity.setName(clusterEntity.getName() + "_" + index); + runtimeEntity.setHost("127.0.0.1"); + runtimeEntity.setPort(8080); + runtimeEntity.setReplicationType(replicationType); + runtimeEntity.setRuntimeIndex(index); + runtimeEntity.setDeployStatusType(DeployStatusType.CREATE_FULL_WAIT); + this.runtimeEntityList.add(runtimeEntity); + } + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/create/CreateRuntimeByDeployScriptHandler.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/create/CreateRuntimeByDeployScriptHandler.java new file mode 100644 index 00000000..f0691520 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/create/CreateRuntimeByDeployScriptHandler.java @@ -0,0 +1,97 @@ +/* + * 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.deploy.create; + +import org.apache.eventmesh.dashboard.common.enums.ClusterTrusteeshipType; +import org.apache.eventmesh.dashboard.common.enums.DeployStatusType; +import org.apache.eventmesh.dashboard.common.enums.ReplicationType; +import org.apache.eventmesh.dashboard.console.controller.deploy.handler.UpdateHandler; +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; +import org.apache.eventmesh.dashboard.console.mapstruct.cluster.ClusterControllerMapper; +import org.apache.eventmesh.dashboard.console.mapstruct.deploy.ClusterCycleControllerMapper; +import org.apache.eventmesh.dashboard.console.modle.deploy.create.CreateRuntimeByDeployScriptDTO; +import org.apache.eventmesh.dashboard.console.service.cluster.ClusterService; +import org.apache.eventmesh.dashboard.console.service.cluster.RuntimeService; + +import java.util.ArrayDeque; +import java.util.Deque; +import java.util.Objects; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +@Component +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) +public class CreateRuntimeByDeployScriptHandler implements UpdateHandler { + + + @Autowired + private ClusterService clusterService; + + @Autowired + private RuntimeService runtimeService; + + @Override + public void init() { + + } + + @Override + public void handler(CreateRuntimeByDeployScriptDTO createRuntimeByDeployScriptDTO) { + ClusterEntity clusterEntity = ClusterControllerMapper.INSTANCE.toClusterEntity(createRuntimeByDeployScriptDTO); + clusterEntity = this.clusterService.queryClusterById(clusterEntity); + RuntimeEntity runtimeEntity = ClusterCycleControllerMapper.INSTANCE.createRuntimeByDeployScript(createRuntimeByDeployScriptDTO); + if (Objects.isNull(runtimeEntity.getDeployScriptId()) && Objects.isNull(clusterEntity.getDeployScriptId())) { + return; + } + + if (Objects.isNull(runtimeEntity.getResourcesConfigId()) && Objects.isNull(clusterEntity.getResourcesConfigId())) { + return; + } + if (Objects.nonNull(runtimeEntity.getDeployScriptId())) { + runtimeEntity.setDeployScriptId(createRuntimeByDeployScriptDTO.getDeployScriptId()); + } + + if (Objects.nonNull(runtimeEntity.getResourcesConfigId())) { + runtimeEntity.setResourcesConfigId(createRuntimeByDeployScriptDTO.getResourcesConfigId()); + } + ReplicationType replicationType = createRuntimeByDeployScriptDTO.getReplicationType(); + Deque linkedList = new ArrayDeque<>(); + if (!Objects.equals(replicationType, ReplicationType.SLAVE) && clusterEntity.getClusterType().isStorage()) { + clusterEntity.setRuntimeIndex(1); + linkedList = this.clusterService.getIndex(clusterEntity); + } else if (Objects.equals(replicationType, ReplicationType.SLAVE)) { + linkedList.add(1); + } else { + linkedList.add(0); + } + + runtimeEntity.setClusterType(clusterEntity.getClusterType()); + runtimeEntity.setTrusteeshipType(ClusterTrusteeshipType.SELF); + runtimeEntity.setReplicationType(replicationType); + runtimeEntity.setDeployStatusType(DeployStatusType.CREATE_WAIT); + runtimeEntity.setRuntimeIndex(linkedList.poll()); + this.runtimeService.insertRuntime(runtimeEntity); + + } + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/design.md b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/design.md new file mode 100644 index 00000000..33a7903b --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/design.md @@ -0,0 +1,157 @@ + +## +1. 存储 remote 服务 + 1. topic 创建在 cluster main runtime +2. message + 1. 发送 + 2. 查看消息 + 3. 发布订阅 + 4. console -> 抽象层 -> broker + 5. rocketmq 4.0 push(pull) 5.0 pull +3. offset +4. k8s + 1. 集群 + 2. 创建 + 3. + 2. 节点 + 3. 创建 + 4. 停用 + 5. 删除 + 2. console , docker 执行脚本 + 2. console 与 操作分开 + 3. 6c 16G + 4. eventmesh + 5. kafka + 1. 取舍问题 + 6. rocketmq + 1. 简单 + 2. 不做难得 + 3. 两个集群 + 1. 单节点 + 2. 一主已从 + 7. pulsuer + 1. 我有 +5. 数据采集快 + 1. 存储已经支持的采集 + 2. RocketMQ 实现 +6. 前端 +7. 认证与权限,介入 + 1. rocketmq 的插件 + 2. acl -> console 同步 + 2. kafka 的 插件 + 3. 修改 +8. 一键部署 +9. 巡检 +10. 告警 + + +## 部署业务模块 +> + +## 难点 + 超级难点一: + 因消息中间件架构不一样,所以处理不一样。 + Kafka是 + 1. CAP 架构,操作一个节点就可以。 + 2. 单注册中心,meta 集群决定 kafka 集群的 一致性架构 + 3. 操作性行为 + 4. 难点 复制:kafka 基于 topic 复制 + RocketMQ 是 + 1. 多子集群 + 1. 子集群主从架构。且部分功能独立 + 2. 有 raft 架构 + 3. 难点 复制:RocketMQ 是 主从复制 + 2. 多注册中心,使用 AP 架构。broker 集群架构由 broker 集群决定 + pulsar(占时不支持) 是 + 1. 多计算集群多存储集群的计算与存储分离架构 + 2. 存储使用 BookKeeper,只能通过 pulsar broker 进行操作 + 2. 多注册中心。meta 集群决定 pulsar 集群的 一致性架构 + 3. 跨集群复制 + 4. 难点 复制: 基于 BookKeeper 复制 + + 集群创建的时候,可以定义集群 一致性 架构 + broker 集群决定一致性架构 + +重置维度 +1. 最大 +2. 最小 +3. 指定 offset +4. 指定 某个时间点 +PS: RocketMQ 的 queue 与 kafka 的 partition 是一个意思。 +超级难点一: + 因消息中间件架构不一样,所以处理不一样 + kafka 的 offset 操作时 cluster行为 + RocketMQ 操作时 broker 行为 + +kafka 只需要 队列id 就行了 + 1. 按照某个维度重置 topic 下面所有 队列 + 2. 按照某个维度重置 topic 下某个队列 +RocketMQ 的重置场景 + 1. 按照某个维度重置 topic 在集群里面所有的 队列 + 2. 按照某个维度重置 topic 在集群里面某个主从节点的 队列 + 3. 按照某个维度重置 topic 在集群里面所有的 下某个队列 + 4. 按照某个维度重置 topic 在集群里面某个主从节点的 下某个队列 + PS:以上 每次操作都需要同时操作主节点与从节点 + 5. 按照某个维度重置 topic 在某个节点上的所有 队列 + 6. 按照某个维度重置 topic 在某个节点上的所有 某个队列 + + +## 数据关联 +1. 所有对 eventmesh 的操作,需要再对应的存储集群进行操作 +2. 什么状态的集群进行操作【】。读取数据的时候,需要过滤掉,不正常得节点 + +## + +## 数据创建 +1. 把导出的数据,导入 + 1. 点击 eventmesh 集群导出 or 备份 + 1. 如果 eventmesh 独立集群直接操作 + 2. 不是,检查 依赖集群是否同时进行了备份 + 1. 没有,提示某某集群 + 2. 点击 runtime 集群 + 3. 点击 meta 集群 + 4. 点击 存储 集群 + 1. 存储集群 +2. 直接点击 cluster 绑定 + 1. 定时 保存 cluster 信息 + 2. 绑定 集群架构 + 1. eventmesh cluster + 1. meta cluster 列表 + 1. runtime列表 + 2. 一份 runtime config + 2. runtime cluster 列表 + 1. runtime + 1. 每个 runtime config + 2. runtime 的 acl + 3. topic 列表 + 4. group + 3. 存储 cluster 列表 + 1. meta cluster 列表 + 1. runtime列表 + 2. 一份 runtime config + 2. runtime cluster 列表 + 1. runtime + 1. 每个 runtime config + 2. user + 3. acl + 4. topic 列表 + 5. group 列表 + 2. 绑定 集群配置 + 3. 绑定 runtime 配置 + 4. 如果没有 resource 信息是不允许绑定的 + 5. 是否可以绑定 topic信息 + 6. 是否绑定 group 信息 + 7. 是否绑定 acl 信息 +3. case 修改就是创建 +4. 在 runtime 点击编辑。TODO 不允许在在runtime编辑。 + 1. 只能 添加 resource +5. 在 deploy 模块,添加 +6. deploy + 1. 部署方案 + 2. 资源配置 + 3. 部署关系 +7. 部署信息 + 1. 每个runtime 的部署 对应一个 资源信息 + 2. cluster 第一次部署对应一个部署信息 + 1. 这次 +8. \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/handler/UpdateHandler.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/handler/UpdateHandler.java new file mode 100644 index 00000000..8d137735 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/handler/UpdateHandler.java @@ -0,0 +1,30 @@ +/* + * 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.deploy.handler; + +/** + * + */ +public interface UpdateHandler { + + void init(); + + void handler(T t); + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/pause/PauseCluster.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/pause/PauseCluster.java new file mode 100644 index 00000000..cbcd273e --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/pause/PauseCluster.java @@ -0,0 +1,110 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.console.controller.deploy.pause; + +import org.apache.eventmesh.dashboard.common.enums.DeployStatusType; +import org.apache.eventmesh.dashboard.console.controller.deploy.handler.UpdateHandler; +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterAndRelationshipEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterRelationshipEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; +import org.apache.eventmesh.dashboard.console.modle.deploy.ClusterAllMetadataDO; +import org.apache.eventmesh.dashboard.console.service.cluster.ClusterRelationshipService; +import org.apache.eventmesh.dashboard.console.service.cluster.ClusterService; +import org.apache.eventmesh.dashboard.console.service.cluster.RuntimeService; + +import java.util.ArrayList; +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class PauseCluster implements UpdateHandler { + + @Autowired + private ClusterService clusterService; + + @Autowired + private RuntimeService runtimeService; + + @Autowired + private ClusterRelationshipService clusterRelationshipService; + + + private List selfRuntimeList = new ArrayList<>(); + + private List notSelfRuntimeList = new ArrayList<>(); + + + @Override + public void init() { + + } + + /** + * 关系解除,如果 + * + * @param clusterEntity + */ + @Override + public void handler(ClusterEntity clusterEntity) { + + clusterEntity = this.clusterService.queryClusterById(clusterEntity); + + if (clusterEntity.getClusterType().isMeta()) { + // 检查 meta 集群 是否被关联,如何被关联,就禁止删除 + ClusterRelationshipEntity clusterRelationshipEntity = new ClusterRelationshipEntity(); + clusterRelationshipEntity.setClusterId(clusterEntity.getId()); + List clusterRelationshipEntityList = + this.clusterRelationshipService.queryClusterAndRelationshipEntityListByClusterId(clusterRelationshipEntity); + if (!clusterRelationshipEntityList.isEmpty()) { + // 打印结果 + return; + } + } + + RuntimeEntity runtimeEntity = new RuntimeEntity(); + runtimeEntity.setClusterId(clusterEntity.getId()); + ClusterAllMetadataDO clusterAllMetadata = this.runtimeService.queryAllByClusterId(runtimeEntity, true, true); + + clusterAllMetadata.getRuntimeEntityList().forEach(entity -> { + // TODO + if (entity.getTrusteeshipType().isSelf()) { + entity.setDeployStatusType(DeployStatusType.PAUSE_FULL_WAIT); + } else { + entity.setStatus(1L); + } + }); + + clusterAllMetadata.getClusterEntityList().forEach(entity -> { + + }); + + if (clusterEntity.getClusterType().isMeta()) { + // 得到 所有关联项目 + + // 获得 所有关联项目的 存储 cluster + + // + } + + } + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/pause/PauseRuntime.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/pause/PauseRuntime.java new file mode 100644 index 00000000..93189f96 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/pause/PauseRuntime.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.controller.deploy.pause; + +import org.apache.eventmesh.dashboard.common.enums.DeployStatusType; +import org.apache.eventmesh.dashboard.console.controller.deploy.handler.UpdateHandler; +import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; +import org.apache.eventmesh.dashboard.console.service.cluster.RuntimeService; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class PauseRuntime implements UpdateHandler { + + @Autowired + private RuntimeService runtimeService; + + + @Override + public void init() { + + } + + @Override + public void handler(RuntimeEntity runtimeEntity) { + RuntimeEntity newRuntimeEntity = this.runtimeService.queryRuntimeEntityById(runtimeEntity); + if (newRuntimeEntity.getTrusteeshipType().isSelf()) { + newRuntimeEntity.setDeployStatusType(DeployStatusType.PAUSE_WAIT); + } else { + newRuntimeEntity.setStatus(0L); + } + this.runtimeService.deactivate(runtimeEntity); + + + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/relationship/RelationshipHandler.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/relationship/RelationshipHandler.java new file mode 100644 index 00000000..82c66a83 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/relationship/RelationshipHandler.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.controller.deploy.relationship; + +import org.apache.eventmesh.dashboard.console.controller.deploy.handler.UpdateHandler; +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterRelationshipEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; +import org.apache.eventmesh.dashboard.console.service.cluster.ClusterRelationshipService; +import org.apache.eventmesh.dashboard.console.service.cluster.ClusterService; +import org.apache.eventmesh.dashboard.console.service.cluster.RuntimeService; + +public class RelationshipHandler implements UpdateHandler { + + private ClusterService clusterService; + + private ClusterRelationshipService clusterRelationshipService; + + private RuntimeService runtimeService; + + + @Override + public void init() { + + } + + @Override + public void handler(ClusterRelationshipEntity clusterRelationshipEntity) { + // 绑定 meta 集群, 那么下面所有的 runtime 集群,需要更新更新 + // 绑定 runtime 集群, main cluster 依赖的 + clusterRelationshipService.addClusterRelationshipEntry(clusterRelationshipEntity); + + if (clusterRelationshipEntity.getRelationshipType().isMeta()) { + RuntimeEntity runtimeEntity = new RuntimeEntity(); + runtimeEntity.setClusterId(clusterRelationshipEntity.getClusterId()); + //runtimeService.queryOnlyRuntimeByClusterId(runtimeEntity); + } + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/relationship/UnRelationshipHandler.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/relationship/UnRelationshipHandler.java new file mode 100644 index 00000000..485061ce --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/relationship/UnRelationshipHandler.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.deploy.relationship; + +import org.apache.eventmesh.dashboard.console.controller.deploy.handler.UpdateHandler; +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterRelationshipEntity; +import org.apache.eventmesh.dashboard.console.service.cluster.ClusterRelationshipService; +import org.apache.eventmesh.dashboard.console.service.cluster.ClusterService; +import org.apache.eventmesh.dashboard.console.service.cluster.RuntimeService; + +public class UnRelationshipHandler implements UpdateHandler { + + private ClusterService clusterService; + + private ClusterRelationshipService clusterRelationshipService; + + private RuntimeService runtimeService; + + @Override + public void init() { + + } + + @Override + public void handler(ClusterRelationshipEntity clusterRelationshipEntity) { + // 取消 runtime ,什么都不用管 + // 接触 meta ,关联 集群下 runtime 都需要管理 + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/uninstall/UninstallClusterHandler.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/uninstall/UninstallClusterHandler.java new file mode 100644 index 00000000..c6e8f90e --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/uninstall/UninstallClusterHandler.java @@ -0,0 +1,35 @@ +/* + * 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.deploy.uninstall; + +import org.apache.eventmesh.dashboard.console.controller.deploy.handler.UpdateHandler; +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; + +public class UninstallClusterHandler implements UpdateHandler { + + @Override + public void init() { + + } + + @Override + public void handler(ClusterEntity clusterEntity) { + + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/uninstall/UninstallRuntimeHandler.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/uninstall/UninstallRuntimeHandler.java new file mode 100644 index 00000000..987de5ea --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/uninstall/UninstallRuntimeHandler.java @@ -0,0 +1,35 @@ +/* + * 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.deploy.uninstall; + +import org.apache.eventmesh.dashboard.console.controller.deploy.handler.UpdateHandler; +import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; + +public class UninstallRuntimeHandler implements UpdateHandler { + + @Override + public void init() { + + } + + @Override + public void handler(RuntimeEntity runtimeEntity) { + + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/function/ConfigController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/function/ConfigController.java index 31c36e33..ef38b02e 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/function/ConfigController.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/function/ConfigController.java @@ -15,10 +15,10 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.controller.function; import org.apache.eventmesh.dashboard.console.entity.function.ConfigEntity; -import org.apache.eventmesh.dashboard.console.mapstruct.config.ConfigControllerMapper; 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; @@ -32,32 +32,27 @@ 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.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController -@RequestMapping("/cluster/config") public class ConfigController { @Autowired private ConfigService configService; - @PostMapping("/updateConfigs") + @PostMapping("/cluster/config/updateConfigs") public String updateConfigsByTypeAndId(@Validated @RequestBody UpdateConfigDTO updateConfigDTO) { - try { - configService.updateConfigsByInstanceId(updateConfigDTO.getUsername(), updateConfigDTO.getClusterId(), updateConfigDTO.getInstanceType(), - updateConfigDTO.getInstanceId(), updateConfigDTO.getChangeConfigEntities()); - } catch (Exception e) { - return e.getMessage(); - } + return "success"; } - @PostMapping("/getInstanceDetailConfigs") + @PostMapping("/cluster/config/getInstanceDetailConfigs") public List getInstanceDetailConfigs(@Validated @RequestBody GetConfigsListDTO getConfigsListDTO) { - List configEntityList = configService.selectToFront(ConfigControllerMapper.INSTANCE.queryEntityByConfig(getConfigsListDTO)); - Map stringStringConcurrentHashMap = configService.selectDefaultConfig(getConfigsListDTO.getBusinessType()); + 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(); diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/function/HealthController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/function/HealthController.java index 4a969749..f3d0b5aa 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/function/HealthController.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/function/HealthController.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.controller.function; import org.apache.eventmesh.dashboard.console.entity.function.HealthCheckResultEntity; @@ -26,23 +27,21 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController -@RequestMapping("/cluster/health") public class HealthController { @Autowired HealthDataService healthDataService; - @GetMapping("/getHistoryLiveStatus") + @GetMapping("/cluster/health/getHistoryLiveStatus") public List getHistoryLiveStatusById(Integer type, Long instanceId, String startTime) { - return healthDataService.selectInstanceLiveStatusHistory(type, instanceId, LocalDateTime.parse(startTime)); + return healthDataService.getInstanceLiveStatusHistory(type, instanceId, LocalDateTime.parse(startTime)); } - @GetMapping("/getInstanceLiveProportion") + @GetMapping("/cluster/health/getInstanceLiveProportion") public InstanceLiveProportionVo getInstanceLiveProportion(Integer instanceType, Long theClusterId) { - return healthDataService.selectInstanceLiveProportion(theClusterId, instanceType); + return healthDataService.getInstanceLiveProportion(theClusterId, instanceType); } } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/function/LogController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/function/LogController.java index 36ec3d09..525de4fd 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/function/LogController.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/function/LogController.java @@ -15,10 +15,10 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.controller.function; import org.apache.eventmesh.dashboard.console.entity.function.LogEntity; -import org.apache.eventmesh.dashboard.console.mapstruct.log.LogControllerMapper; import org.apache.eventmesh.dashboard.console.modle.dto.log.GetLogListDTO; import org.apache.eventmesh.dashboard.console.service.function.LogService; @@ -28,19 +28,17 @@ 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.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController -@RequestMapping("/cluster/log") public class LogController { @Autowired private LogService logService; - @PostMapping("/getList") + @PostMapping("/cluster/log/getList") public List getLogLIstToFront(@Validated @RequestBody GetLogListDTO getLogListDTO) { - return logService.selectLogListByCluster(LogControllerMapper.INSTANCE.queryEntityByLog(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/function/OverviewController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/function/OverviewController.java index 4667fcea..46e49209 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/function/OverviewController.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/function/OverviewController.java @@ -16,6 +16,7 @@ */ + package org.apache.eventmesh.dashboard.console.controller.function; @@ -40,8 +41,9 @@ public class OverviewController { private Map overviewServiceMap; @PostMapping("overview") - public Map overview(@RequestBody @Validated OverviewDTO overviewDTO) { + public Object overview(@RequestBody @Validated OverviewDTO overviewDTO) { + OverviewService overviewService = overviewServiceMap.get(overviewDTO.getOverviewType().name()); - return null; + return overviewService.overview(overviewDTO); } } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/message/GroupController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/message/GroupController.java index a2f8c7b0..d1d58026 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/message/GroupController.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/message/GroupController.java @@ -16,13 +16,14 @@ */ + package org.apache.eventmesh.dashboard.console.controller.message; import org.apache.eventmesh.dashboard.console.entity.message.GroupEntity; import org.apache.eventmesh.dashboard.console.mapstruct.cluster.GroupControllerMapper; -import org.apache.eventmesh.dashboard.console.modle.ClusterIdDTO; import org.apache.eventmesh.dashboard.console.modle.IdDTO; +import org.apache.eventmesh.dashboard.console.modle.vo.RuntimeIdDTO; import org.apache.eventmesh.dashboard.console.service.message.GroupService; import java.util.List; @@ -46,8 +47,8 @@ public class GroupController { private GroupService groupService; @PostMapping("queryGroupListByClusterId") - public List queryGroupListByClusterId(@RequestBody @Validated ClusterIdDTO clusterIdDTO) { - return groupService.selectGroupByClusterId(GroupControllerMapper.INSTANCE.queryGroupListByClusterId(clusterIdDTO)); + public List queryGroupListByClusterId(@RequestBody @Validated RuntimeIdDTO runtimeIdDTO) { + return groupService.getGroupByClusterId(GroupControllerMapper.INSTANCE.queryGroupListByClusterId(runtimeIdDTO)); } @PostMapping("deleteGroupById") diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/message/GroupRelationshipController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/message/GroupRelationshipController.java index f8f19441..a726dbcf 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/message/GroupRelationshipController.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/message/GroupRelationshipController.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.controller.message; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/message/OffsetOperateController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/message/OffsetOperateController.java index 366c106c..bfdddc44 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/message/OffsetOperateController.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/message/OffsetOperateController.java @@ -15,9 +15,11 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.controller.message; +import org.apache.eventmesh.dashboard.console.domain.OperationRangeDomain; import org.apache.eventmesh.dashboard.console.modle.message.offset.QueryOffsetByMessageMetadataDTO; import org.apache.eventmesh.dashboard.console.modle.message.offset.ResetOffsetDTO; import org.apache.eventmesh.dashboard.service.remoting.OffsetRemotingService; @@ -37,10 +39,13 @@ @RequestMapping("offset") public class OffsetOperateController { - @Autowired private OffsetRemotingService offsetRemotingService; + @Autowired + private OperationRangeDomain operationRangeDomain; + + public ResultObject queryOffsetByMessageMetadataDTO( @RequestBody @Validated QueryOffsetByMessageMetadataDTO queryOffsetByMessageMetadataDTO) { @@ -49,6 +54,17 @@ public ResultObject queryOffsetByMessageMetadataDTO( public ResultObject resetOffset(@RequestBody @Validated ResetOffsetDTO resetOffsetDTO) { + // 得到 订阅信息 + // 获得 runtime + + switch (resetOffsetDTO.getResetOffsetMode()) { + case CONSUME_FROM_LAST_OFFSET: + case CONSUME_FROM_FIRST_OFFSET: + case CONSUME_FROM_TIMESTAMP: + case CONSUME_FROM_DESIGNATED_OFFSET: + default: + break; + } return null; } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/message/TopicController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/message/TopicController.java index 25353a23..5a63bd12 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/message/TopicController.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/message/TopicController.java @@ -15,17 +15,25 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.controller.message; +import org.apache.eventmesh.dashboard.common.model.metadata.ClusterMetadata; +import org.apache.eventmesh.dashboard.common.model.metadata.RuntimeMetadata; +import org.apache.eventmesh.dashboard.console.controller.ClusterAbitityService; +import org.apache.eventmesh.dashboard.console.domain.metadata.ClusterMetadataDomain; +import org.apache.eventmesh.dashboard.console.domain.metadata.ClusterOperationHandler; import org.apache.eventmesh.dashboard.console.entity.message.TopicEntity; import org.apache.eventmesh.dashboard.console.mapstruct.message.TopicControllerMapper; import org.apache.eventmesh.dashboard.console.modle.IdDTO; 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.RuntimeIdDTO; import org.apache.eventmesh.dashboard.console.modle.vo.topic.TopicDetailGroupVO; import org.apache.eventmesh.dashboard.console.service.message.TopicService; +import java.util.ArrayList; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; @@ -44,24 +52,121 @@ public class TopicController { private TopicService topicService; + @Autowired + private ClusterAbitityService clusterAbitityService; + + @Autowired + private ClusterMetadataDomain clusterMetadataDomain; + + /** + * @param getTopicListDTO + * @return + */ @PostMapping("/queryTopicListByClusterId") public List queryTopicListByClusterId(@Validated @RequestBody GetTopicListDTO getTopicListDTO) { - return topicService.selectTopicListToFront(TopicControllerMapper.INSTANCE.queryTopicListByClusterId(getTopicListDTO)); + // cap 的直接查询 + if (this.clusterAbitityService.isCAP(getTopicListDTO)) { + topicService.getTopicListToFront(TopicControllerMapper.INSTANCE.queryTopicListByClusterId(getTopicListDTO)); + } + // 非 CAP 另外查询 + return topicService.getTopicListToFront(TopicControllerMapper.INSTANCE.queryTopicListByClusterId(getTopicListDTO)); } @PostMapping("queryTopicListById ") - public TopicEntity queryTopicById(@Validated @RequestBody IdDTO idDTO) { - return topicService.selectTopicById(TopicControllerMapper.INSTANCE.queryTopicListById(idDTO)); + public TopicEntity queryTopicById(@Validated @RequestBody RuntimeIdDTO runtimeIdDTO) { + TopicEntity topicEntity = topicService.selectTopicById(TopicControllerMapper.INSTANCE.queryTopicListById(runtimeIdDTO)); + if (this.clusterAbitityService.isCAP(topicEntity)) { + return topicEntity; + } + // + List queryList = new ArrayList<>(); + // 如果 是 eventmesh 集群。 得到 eventmesh 所有 runtime , 所有存储 + clusterMetadataDomain.operation(topicEntity.getClusterId(), new ClusterOperationHandler() { + + @Override + public void handler(RuntimeMetadata baseSyncBase) { + TopicEntity topicEntity = new TopicEntity(); + queryList.add(topicEntity); + topicEntity.setClusterId(baseSyncBase.getClusterId()); + topicEntity.setClusterType(baseSyncBase.getClusterType()); + topicEntity.setRuntimeId(baseSyncBase.getId()); + topicEntity.setTopicName(topicEntity.getTopicName()); + } + + @Override + public void handler(ClusterMetadata clusterDO) { + TopicEntity topicEntity = new TopicEntity(); + queryList.add(topicEntity); + topicEntity.setClusterId(clusterDO.getClusterId()); + topicEntity.setClusterType(clusterDO.getClusterType()); + topicEntity.setRuntimeId(clusterDO.getClusterId()); + topicEntity.setTopicName(topicEntity.getTopicName()); + } + }); + + + + topicService.queryRuntimeByBaseSyncEntity(queryList); + return null; } @GetMapping("deleteTopic") public Integer deleteTopic(@Validated @RequestBody IdDTO idDTO) { - return topicService.deleteTopic(TopicControllerMapper.INSTANCE.deleteTopic(idDTO)); + TopicEntity topicEntity = this.topicService.selectTopicById(TopicControllerMapper.INSTANCE.deleteTopic(idDTO)); + if (this.clusterAbitityService.isCAP(topicEntity)) { + return this.topicService.deleteTopicById(topicEntity); + } + // 通过 clusterId,runtime id, topic name 删除 + + List deleteList = new ArrayList<>(); + // 如果 是 eventmesh 集群。 得到 eventmesh 所有 runtime , 所有存储 + clusterMetadataDomain.operation(topicEntity.getClusterId(), new ClusterOperationHandler() { + + @Override + public void handler(RuntimeMetadata baseSyncBase) { + TopicEntity topicEntity = new TopicEntity(); + deleteList.add(topicEntity); + topicEntity.setClusterId(baseSyncBase.getClusterId()); + topicEntity.setClusterType(baseSyncBase.getClusterType()); + topicEntity.setRuntimeId(baseSyncBase.getId()); + } + + @Override + public void handler(ClusterMetadata clusterDO) { + TopicEntity topicEntity = new TopicEntity(); + deleteList.add(topicEntity); + topicEntity.setClusterId(clusterDO.getClusterId()); + topicEntity.setClusterType(clusterDO.getClusterType()); + } + }); + return topicService.deleteTopicByRuntimeIdAndTopicName(deleteList); } @PostMapping("createTopic") public void createTopic(@Validated @RequestBody CreateTopicDTO createTopicDTO) { - topicService.createTopic(TopicControllerMapper.INSTANCE.createTopic(createTopicDTO)); + List createTopicList = new ArrayList<>(); + // 如果 是 eventmesh 集群。 得到 eventmesh 所有 runtime , 所有存储 + clusterMetadataDomain.operation(createTopicDTO.getClusterId(), new ClusterOperationHandler() { + + @Override + public void handler(RuntimeMetadata baseSyncBase) { + TopicEntity topicEntity = TopicControllerMapper.INSTANCE.createTopic(createTopicDTO); + createTopicList.add(topicEntity); + topicEntity.setClusterId(baseSyncBase.getClusterId()); + topicEntity.setClusterType(baseSyncBase.getClusterType()); + topicEntity.setRuntimeId(baseSyncBase.getId()); + + } + + @Override + public void handler(ClusterMetadata clusterDO) { + TopicEntity topicEntity = TopicControllerMapper.INSTANCE.createTopic(createTopicDTO); + createTopicList.add(topicEntity); + topicEntity.setClusterId(clusterDO.getClusterId()); + topicEntity.setClusterType(clusterDO.getClusterType()); + } + }); + this.topicService.batchInsert(createTopicList); } /** @@ -72,7 +177,7 @@ public void createTopic(@Validated @RequestBody CreateTopicDTO createTopicDTO) { */ @GetMapping("/cluster/topic/getTopicDetailGroups") public List getTopicDetailGroups(Long topicId) { - return topicService.selectTopicDetailGroups(topicId); + return topicService.getTopicDetailGroups(topicId); } } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/domain/ClusterAndRuntimeDomain.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/domain/ClusterAndRuntimeDomain.java new file mode 100644 index 00000000..0aa12223 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/domain/ClusterAndRuntimeDomain.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.domain; + + +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; + +import java.util.List; + +/** + * + */ +public interface ClusterAndRuntimeDomain { + + + + List getClusterByCLusterId(ClusterEntity clusterEntity); + + + + + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/domain/Impl/ClusterAndRuntimeDomainImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/domain/Impl/ClusterAndRuntimeDomainImpl.java new file mode 100644 index 00000000..67fa472e --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/domain/Impl/ClusterAndRuntimeDomainImpl.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.domain.Impl; + +import org.apache.eventmesh.dashboard.console.domain.ClusterAndRuntimeDomain; +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; + +import java.util.Collections; +import java.util.List; + +public class ClusterAndRuntimeDomainImpl implements ClusterAndRuntimeDomain { + + @Override + public List getClusterByCLusterId(ClusterEntity clusterEntity) { + return Collections.emptyList(); + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/domain/OperationRangeDomain.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/domain/OperationRangeDomain.java new file mode 100644 index 00000000..e08c9fae --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/domain/OperationRangeDomain.java @@ -0,0 +1,146 @@ +/* + * 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.domain; + +import org.apache.eventmesh.dashboard.common.enums.ClusterFramework; +import org.apache.eventmesh.dashboard.common.enums.ClusterSyncMetadataEnum; +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.common.enums.MetadataType; +import org.apache.eventmesh.dashboard.console.entity.base.BaseSyncEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; +import org.apache.eventmesh.dashboard.console.modle.deploy.ClusterAllMetadataDO; +import org.apache.eventmesh.dashboard.console.modle.dto.operation.OperationBaseDTO; +import org.apache.eventmesh.dashboard.console.service.cluster.ClusterService; +import org.apache.eventmesh.dashboard.console.service.cluster.RuntimeService; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Objects; +import java.util.Set; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +/** + * 可以得到返回的数据为两种: 1. 写入数据的 2. 直接请求其他组件 + */ +@Component +@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) +public class OperationRangeDomain { + + @Autowired + private ClusterService clusterService; + + @Autowired + private RuntimeService runtimeService; + + + private OperationBaseDTO operationBaseDTO; + + private OperationRangeDomainDataHandler rangeDomainDataHandler; + + private final Set clusterTypeSet = new HashSet<>(); + + private ClusterType rangeType; + + private boolean currentType; + + + public OperationRangeDomain operationBaseDTO(OperationBaseDTO operationBaseDTO) { + this.operationBaseDTO = operationBaseDTO; + return this; + } + + + public OperationRangeDomain operationRangeDomainDataHandler(OperationRangeDomainDataHandler operationRangeDomainDataHandler) { + this.rangeDomainDataHandler = operationRangeDomainDataHandler; + return this; + } + + public OperationRangeDomain clusterType(ClusterType clusterType) { + this.clusterTypeSet.add(clusterType); + return this; + } + + public OperationRangeDomain rangeType(ClusterType rangeType) { + this.rangeType = rangeType; + return this; + } + + public T hander() { + List operationList = new ArrayList<>(); + if (Objects.equals(operationBaseDTO.getRangeType(), MetadataType.RUNTIME)) { + RuntimeEntity runtimeEntity = new RuntimeEntity(); + runtimeEntity = runtimeService.queryRuntimeEntityById(runtimeEntity); + // 直接写入 + operationList.add((T) this.rangeDomainDataHandler.handler(runtimeEntity)); + return (T) operationList; + } + ClusterEntity clusterEntity = new ClusterEntity(); + clusterEntity = this.clusterService.queryClusterById(clusterEntity); + ClusterFramework clusterFramework = ClusterSyncMetadataEnum.getClusterFramework(clusterEntity.getClusterType()); + RuntimeEntity runtimeEntity = new RuntimeEntity(); + ClusterAllMetadataDO clusterAllMetadataDO = + runtimeService.queryAllByClusterId(runtimeEntity, true, false); + clusterAllMetadataDO.getClusterEntityList().forEach((value) -> { + ClusterFramework clusterFramework1 = ClusterSyncMetadataEnum.getClusterFramework(value.getClusterType()); + if (!clusterFramework1.isCAP()) { + return; + } + + if (!clusterTypeSet.isEmpty() && !clusterTypeSet.contains(value.getClusterType())) { + return; + } + if (!Objects.equals(this.rangeType, value.getClusterType().getAssemblyNodeType())) { + return; + } + + operationList.add((T) this.rangeDomainDataHandler.handler(value)); + }); + clusterAllMetadataDO.getRuntimeEntityList().forEach((value) -> { + ClusterFramework clusterFramework1 = ClusterSyncMetadataEnum.getClusterFramework(value.getClusterType()); + if (clusterFramework1.isCAP()) { + return; + } + if (!clusterTypeSet.isEmpty() && !clusterTypeSet.contains(value.getClusterType())) { + return; + } + if (!Objects.equals(this.rangeType, value.getClusterType().getAssemblyNodeType())) { + return; + } + operationList.add((T) this.rangeDomainDataHandler.handler(value)); + }); + + return (T) operationList; + } + + /** + * + */ + public static interface OperationRangeDomainDataHandler { + + + Object handler(BaseSyncEntity baseEntity); + } + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/domain/metadata/ClusterMetadataDomain.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/domain/metadata/ClusterMetadataDomain.java new file mode 100644 index 00000000..85475d0d --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/domain/metadata/ClusterMetadataDomain.java @@ -0,0 +1,447 @@ +/* + * 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.domain.metadata; + +import org.apache.eventmesh.dashboard.common.enums.ClusterFramework; +import org.apache.eventmesh.dashboard.common.enums.ClusterSyncMetadataEnum; +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.common.model.metadata.ClusterMetadata; +import org.apache.eventmesh.dashboard.common.model.metadata.RuntimeMetadata; +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterRelationshipEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; +import org.apache.eventmesh.dashboard.console.modle.domain.ClusterEntityDO; +import org.apache.eventmesh.dashboard.console.modle.domain.RuntimeEntityDO; +import org.apache.eventmesh.dashboard.console.spring.support.metadata.convert.ClusterConvertMetaData; +import org.apache.eventmesh.dashboard.console.spring.support.metadata.convert.RuntimeConvertMetaData; +import org.apache.eventmesh.dashboard.core.cluster.ClusterBaseDO; +import org.apache.eventmesh.dashboard.core.cluster.ClusterDO; +import org.apache.eventmesh.dashboard.core.cluster.ColonyDO; +import org.apache.eventmesh.dashboard.core.cluster.RuntimeBaseDO; +import org.apache.eventmesh.dashboard.core.cluster.RuntimeDO; +import org.apache.eventmesh.dashboard.core.function.SDK.ConfigManage; +import org.apache.eventmesh.dashboard.core.function.SDK.SDKTypeEnum; +import org.apache.eventmesh.dashboard.core.function.SDK.config.AbstractMultiCreateSDKConfig; +import org.apache.eventmesh.dashboard.core.function.SDK.config.AbstractSimpleCreateSDKConfig; +import org.apache.eventmesh.dashboard.core.function.SDK.config.NetAddress; + +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.MapUtils; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; + +/** + * 直接序列化,或则 使用 mapper + */ +@SuppressWarnings({"unchecked", "rawtypes", "RedundantCast"}) +@Slf4j +public class ClusterMetadataDomain { + + private ColonyDO colonyDO; + + + private boolean coreModel = true; + + private boolean buildConfig = false; + + @Setter + private DataHandler handler; + + public void isConsoleModel() { + this.coreModel = false; + } + + public void useBuildConfig() { + this.buildConfig = true; + } + + + public ColonyDO getColonyDO(Long clusterId) { + return colonyDO.getAllColonyDO().get(clusterId); + } + + public List> getMetaColonyDO(Long clusterId) { + ColonyDO clusterDO = colonyDO.getAllColonyDO().get(clusterId); + if (Objects.isNull(clusterDO)) { + return null; + } + + // TODO + if (colonyDO.getClusterType().isMetaAndRuntime()) { + return new ArrayList<>(clusterDO.getRuntimeColonyDOMap().values()); + } + return new ArrayList<>(clusterDO.getMetaColonyDOList().values()); + } + + public void setMainCluster(ClusterEntity clusterEntity) { + this.colonyDO = ColonyDO.create(ClusterEntityDO.class, clusterEntity); + this.colonyDO.setClusterId(clusterEntity.getClusterId()); + this.colonyDO.setClusterType(clusterEntity.getClusterType()); + this.colonyDO.setSuperiorId(-0L); + } + + public void rootClusterDHO() { + this.colonyDO = ColonyDO.create(ClusterEntityDO.class, null); + this.colonyDO.setSuperiorId(-0L); + } + + public QueueCondition createQueueCondition() { + return new QueueCondition(); + } + + + public void handlerMetadata(MetadataAllDO metadataAllDO) { + Map> colonyDOMap = new HashMap<>(); + + this.setClusterEntityAndDefinitionCluster(metadataAllDO.getClusterEntityList(), metadataAllDO.getClusterRelationshipEntityList(), + colonyDOMap); + this.setRuntimeEntity(metadataAllDO.getRuntimeEntityList(), colonyDOMap); + + colonyDOMap.forEach((key, value) -> { + AbstractMultiCreateSDKConfig createSDKConfig = value.getClusterDO().getMultiCreateSDKConfig(); + if (Objects.isNull(createSDKConfig) || createSDKConfig.isNullAddress()) { + return; + } + if (!ClusterSyncMetadataEnum.getClusterFramework(value.getClusterType()).isCAP()) { + return; + } + if (Objects.nonNull(this.handler)) { + // TODO + this.handler.registerCluster(null, value.getClusterDO(), value); + //this.handler.registerCluster(value.getClusterDO().getClusterInfo(), value.getClusterDO(), value); + } + }); + } + + + public List setClusterEntityAndDefinitionCluster(List clusterEntityList, + List clusterRelationshipEntityList, + Map> colonyDOMap) { + List definitionClusteList = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(clusterEntityList)) { + clusterEntityList.forEach(v -> { + if (v.getClusterType().isDefinition()) { + definitionClusteList.add(v); + } + if (Objects.equals(v.getStatus(), 0L)) { + ColonyDO colonyDO = this.colonyDO.remove(v.getId()); + if (Objects.nonNull(this.handler)) { + this.handler.unRegisterCluster(v, colonyDO.getClusterDO(), colonyDO); + } + } else { + ClusterBaseDO clusterEntityDO = this.createClusterBaseDO(v); + ColonyDO colonyDO = this.colonyDO.register(v.getId(), v.getClusterType(), clusterEntityDO); + if (!v.getClusterType().isDefinition()) { + colonyDOMap.put(v.getId(), colonyDO); + } + } + }); + } + if (CollectionUtils.isEmpty(clusterRelationshipEntityList)) { + return definitionClusteList; + } + clusterRelationshipEntityList.forEach(v -> { + try { + if (Objects.equals(v.getStatus(), 0L)) { + this.colonyDO.unRelationship(v.getClusterId(), v.getRelationshipId()); + } else { + this.colonyDO.relationship(v.getClusterId(), v.getRelationshipId()); + } + } catch (Exception e) { + throw new RuntimeException(e); + } + }); + return definitionClusteList; + } + + public void setRuntimeEntity(List runtimeEntityList, Map> colonyDOMap) { + if (Objects.isNull(runtimeEntityList)) { + return; + } + runtimeEntityList.forEach(value -> { + NetAddress netAddress = new NetAddress(); + netAddress.setAddress(value.getHost()); + netAddress.setPort(value.getPort()); + ColonyDO colonyDO; + ClusterFramework clusterFramework = ClusterSyncMetadataEnum.getClusterFramework(value.getClusterType()); + if (Objects.equals(value.getStatus(), 0L)) { + colonyDO = this.colonyDO.removeRuntime(value.getClusterId(), value.getId(), netAddress); + if (Objects.nonNull(colonyDO) && clusterFramework.isCAP()) { + colonyDOMap.put(value.getClusterId(), colonyDO); + } else { + if (Objects.nonNull(this.handler)) { + this.handler.unRegisterRuntime(value, null, colonyDO); + } + } + } else { + RuntimeBaseDO runtimeBaseDO = this.createRuntimeDO(value); + colonyDO = this.colonyDO.register(value.getClusterId(), value.getId(), runtimeBaseDO, netAddress); + + if (Objects.isNull(colonyDO)) { + log.warn(" not queue colonyDO, runtime is {}", value); + return; + } + if (clusterFramework.isCAP()) { + colonyDOMap.put(value.getClusterId(), colonyDO); + } else { + if (Objects.nonNull(this.handler)) { + this.handler.registerRuntime(value, runtimeBaseDO, colonyDO); + } + } + } + }); + + } + + private ClusterBaseDO createClusterBaseDO(ClusterEntity clusterEntity) { + ClusterBaseDO clusterBaseDO; + ClusterType clusterType = clusterEntity.getClusterType(); + if (this.coreModel) { + clusterBaseDO = new ClusterDO(); + ClusterMetadata clusterMetadata = ClusterConvertMetaData.INSTANCE.toMetaData(clusterEntity); + clusterBaseDO.setClusterInfo(clusterMetadata); + } else { + clusterBaseDO = new ClusterEntityDO(); + clusterBaseDO.setClusterInfo(clusterEntity); + } + ClusterFramework clusterFramework = ClusterSyncMetadataEnum.getClusterFramework(clusterType); + if (this.buildConfig && !clusterType.isDefinition() && clusterFramework.isCAP()) { + AbstractMultiCreateSDKConfig config = + ConfigManage.getInstance().getMultiCreateSDKConfig(clusterEntity.getClusterType(), SDKTypeEnum.ADMIN); + config.setKey(clusterEntity.getId().toString()); + clusterBaseDO.setMultiCreateSDKConfig(config); + } + return clusterBaseDO; + } + + private RuntimeBaseDO createRuntimeDO(RuntimeEntity runtimeEntity) { + RuntimeBaseDO runtimeBaseDO; + if (this.coreModel) { + runtimeBaseDO = new RuntimeDO(); + RuntimeMetadata runtimeMetadata = RuntimeConvertMetaData.INSTANCE.toMetaData(runtimeEntity); + runtimeBaseDO.setRuntimeMetadata(runtimeMetadata); + ClusterFramework clusterFramework = ClusterSyncMetadataEnum.getClusterFramework(runtimeEntity.getClusterType()); + if (!clusterFramework.isCAP()) { + AbstractSimpleCreateSDKConfig config = + ConfigManage.getInstance().getSimpleCreateSDKConfig(runtimeEntity.getClusterType(), SDKTypeEnum.ADMIN); + config.setKey(runtimeEntity.getId().toString()); + config.setNetAddress(this.createNetAddress(runtimeEntity)); + runtimeBaseDO.setCreateSDKConfig(config); + } + } else { + runtimeBaseDO = new RuntimeEntityDO(); + runtimeBaseDO.setRuntimeMetadata(runtimeEntity); + } + return runtimeBaseDO; + } + + private NetAddress createNetAddress(RuntimeEntity runtimeEntity) { + NetAddress netAddress = new NetAddress(); + netAddress.setAddress(runtimeEntity.getHost()); + netAddress.setPort(runtimeEntity.getPort()); + return netAddress; + } + + + public void setResource() { + + } + + public void setConfigEntity() { + + } + + /** + * TODO @see OperationRangeDomain. + * @param clusterId + * @param clusterOperationHandler + */ + public void operation(Long clusterId, ClusterOperationHandler clusterOperationHandler) { + + // 需要识别最小维度 + + ColonyDO colonyDO = this.colonyDO.getAllColonyDO().get(clusterId); + ClusterType clusterType = colonyDO.getClusterType(); + if (Objects.equals(clusterType, ClusterType.EVENTMESH_RUNTIME)) { + colonyDO.getClusterDO().getRuntimeMap().forEach((key, value) -> { + clusterOperationHandler.handler(value.getRuntimeMetadata()); + }); + } else if (Objects.equals(clusterType, ClusterType.EVENTMESH_CLUSTER)) { + colonyDO.getRuntimeColonyDOMap().forEach((key, value) -> { + value.getClusterDO().getRuntimeMap().forEach((k, v) -> { + clusterOperationHandler.handler(v.getRuntimeMetadata()); + }); + }); + + } else if (clusterType.isStorage()) { + if (clusterType.isDefinition()) { + colonyDO.getStorageColonyDOMap().forEach((key, value) -> { + value.getRuntimeColonyDOMap().forEach((k, v) -> { + value.getClusterDO().getRuntimeMap().forEach((kk, vv) -> { + clusterOperationHandler.handler(vv.getRuntimeMetadata()); + }); + }); + }); + } else { + ClusterFramework clusterFramework = ClusterSyncMetadataEnum.getClusterFramework(clusterType); + if (clusterFramework.isCAP()) { + clusterOperationHandler.handler(colonyDO.getClusterDO().getClusterInfo()); + } else { + colonyDO.getClusterDO().getRuntimeMap().forEach((k, v) -> { + clusterOperationHandler.handler(v.getRuntimeMetadata()); + }); + } + } + } + } + + + public T queue(QueueCondition queueCondition) { + QueueConditionHandler queueConditionHandler = new QueueConditionHandler(); + queueConditionHandler.colonyDO = this.colonyDO.getAllColonyDO().get(queueCondition.clusterId); + queueConditionHandler.queueCondition = queueCondition; + return (T) queueConditionHandler.handler(); + } + + + /** + * + */ + @SuppressWarnings("rawtypes") + public interface DataHandler { + + /** + * TODO 只有 非 CAP 模式的 runtime调用此方法。 CAP 模式的 runtime 更新默认为 Cluster 更新 + */ + void registerRuntime(RuntimeEntity runtimeEntity, T t, ColonyDO colonyDO); + + /** + * TODO 只有 非 CAP 模式的 runtime调用此方法。 CAP 模式的 runtime 更新默认为 Cluster 更新 + */ + void unRegisterRuntime(RuntimeEntity runtimeEntity, T t, ColonyDO colonyDO); + + void registerCluster(ClusterEntity clusterEntity, C c, ColonyDO colonyDO); + + void unRegisterCluster(ClusterEntity clusterEntity, C c, ColonyDO colonyDO); + } + + @SuppressWarnings("rawtypes") + private static class QueueConditionHandler { + + private QueueCondition queueCondition; + + private ColonyDO colonyDO; + + private Map> currentColonyDOMap; + + private final List resultData = new ArrayList<>(); + + public T handler() { + this.getColonyDOMap(); + if (MapUtils.isEmpty(currentColonyDOMap)) { + return (T) resultData; + } + this.currentColonyDOMap.forEach((k, v) -> { + this.handlerData(v); + }); + return (T) this.resultData; + } + + public void getColonyDOMap() { + if (this.queueCondition.clusterType == ClusterType.META) { + this.currentColonyDOMap = this.colonyDO.getMetaColonyDOList(); + } else if (this.queueCondition.clusterType == ClusterType.RUNTIME) { + this.currentColonyDOMap = this.colonyDO.getRuntimeColonyDOMap(); + } else if (this.queueCondition.clusterType == ClusterType.STORAGE) { + this.currentColonyDOMap = this.colonyDO.getStorageColonyDOMap(); + } + } + + public void handlerData(ColonyDO colonyDO) { + if (this.queueCondition.resultType == ClusterType.CLUSTER) { + if (this.queueCondition.resultId) { + resultData.add(colonyDO.getClusterId()); + } else { + resultData.add(colonyDO.getClusterDO().getClusterInfo()); + } + } else { + Map data = colonyDO.getClusterDO().getRuntimeMap(); + resultData.add(this.queueCondition.resultId ? data.keySet() : data.values()); + } + } + + + } + + + public static class QueueCondition { + + private Long clusterId; + + /** + * + */ + private ClusterType clusterType; + + private final ClusterType resultType = ClusterType.CLUSTER; + + private boolean resultId = false; + + + public QueueCondition clusterId(Long clusterId) { + this.clusterId = clusterId; + return this; + } + + public QueueCondition clusterType(ClusterType clusterType) { + this.clusterType = clusterType; + return this; + } + + public QueueCondition meta() { + this.clusterType = ClusterType.META; + return this; + } + + public QueueCondition storage() { + this.clusterType = ClusterType.STORAGE; + return this; + } + + public QueueCondition runtime() { + this.clusterType = ClusterType.RUNTIME; + return this; + } + + public QueueCondition() { + } + + public QueueCondition resultId() { + this.resultId = true; + return this; + } + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/domain/metadata/ClusterOperationHandler.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/domain/metadata/ClusterOperationHandler.java new file mode 100644 index 00000000..75e2bca7 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/domain/metadata/ClusterOperationHandler.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.console.domain.metadata; + +import org.apache.eventmesh.dashboard.common.model.metadata.ClusterMetadata; +import org.apache.eventmesh.dashboard.common.model.metadata.RuntimeMetadata; + +/** + * + */ +public interface ClusterOperationHandler { + + + void handler(RuntimeMetadata baseSyncBase); + + + void handler(ClusterMetadata clusterDO); + + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/domain/metadata/MetadataAllDO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/domain/metadata/MetadataAllDO.java new file mode 100644 index 00000000..aa8fefa3 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/domain/metadata/MetadataAllDO.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.console.domain.metadata; + +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterRelationshipEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; +import org.apache.eventmesh.dashboard.core.function.SDK.config.AbstractMultiCreateSDKConfig; + +import java.util.List; + +import lombok.Builder; +import lombok.Data; + +@Data +@Builder +public class MetadataAllDO { + + private List clusterEntityList; + + private List clusterRelationshipEntityList; + + private List runtimeEntityList; + + private List abstractMultiCreateSDKConfigList; +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/BaseEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/BaseEntity.java index 59c0a676..874a48fd 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/BaseEntity.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/BaseEntity.java @@ -15,8 +15,11 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.entity; +import org.apache.eventmesh.dashboard.common.enums.ClusterType; + import java.io.Serializable; import java.time.LocalDateTime; @@ -27,10 +30,13 @@ /** * Base Entity provide some basic fields that every Eventmesh Dashboard Entity would have + *

+ * 12 broker -> 12 queue , 11 queue , 1broker 没有 队列。 副本,随机出现在一个 broker */ @Data -@EqualsAndHashCode(callSuper = false, exclude = {"createTime", "updateTime"}) +@EqualsAndHashCode(callSuper = false) @Schema(name = "BaseEntity", description = "Base entity") +@Deprecated public class BaseEntity implements Serializable { private static final long serialVersionUID = -2697805837923579585L; @@ -40,9 +46,16 @@ public class BaseEntity implements Serializable { @Schema(name = "id", description = "primary key") protected Long id; + /** + * 集群id,不是 eventmesh集群id。 + */ protected Long clusterId; + protected ClusterType clusterType; + protected LocalDateTime createTime; protected LocalDateTime updateTime; + + private Integer status; } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/DefaultConfigKey.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/DefaultConfigKey.java index c4f2e8cd..49d740e5 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/DefaultConfigKey.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/DefaultConfigKey.java @@ -15,12 +15,18 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.entity; +import lombok.AllArgsConstructor; import lombok.Data; +import lombok.NoArgsConstructor; +@NoArgsConstructor +@AllArgsConstructor @Data +@Deprecated public class DefaultConfigKey { private String businessType; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/StoreEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/StoreEntity.java index 78e28d4f..a8046f83 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/StoreEntity.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/StoreEntity.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.entity; @@ -22,7 +23,8 @@ import lombok.EqualsAndHashCode; @Data -@EqualsAndHashCode(callSuper = true, exclude = "status") +@EqualsAndHashCode(callSuper = true) +@Deprecated public class StoreEntity extends BaseEntity { private Long clusterId; @@ -44,8 +46,6 @@ public class StoreEntity extends BaseEntity { private String rack; - private Short status; - private String endpointMap; private Long startTimestamp; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/base/BaseClusterIdEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/base/BaseClusterIdEntity.java new file mode 100644 index 00000000..276089e5 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/base/BaseClusterIdEntity.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.console.entity.base; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; + +import lombok.Data; +import lombok.EqualsAndHashCode; + + +@Data +@EqualsAndHashCode(callSuper = true) +public abstract class BaseClusterIdEntity extends BaseOrganizationEntity { + + private Long clusterId; + + private ClusterType clusterType; + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/base/BaseIdEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/base/BaseIdEntity.java new file mode 100644 index 00000000..a4897c2e --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/base/BaseIdEntity.java @@ -0,0 +1,55 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.console.entity.base; + +import java.io.Serializable; +import java.time.LocalDateTime; + +import lombok.Data; + +@Data +public class BaseIdEntity implements Serializable { + + private Long id; + + private LocalDateTime createTime; + + private Long createUserId; + + private LocalDateTime updateTime; + + private Long updateUserId; + + /** + * 数据展示过程,操作必须是具体的行为 过程有:等待,完成,中 具体操作是一个有动词+名词的行为:停止扩容, 一个操作允许有多个过程。是否可以在过程中取消行为 集群创建中 关闭集群:停止集群的运行,可以让重启集群 删除集群: 关闭集群之后,可以备份数据,删除集群数据 扩容中, 缩容中 + * 重启前检查: 检查 集群依赖情况 检查 资源(最低集群) -> 资源上锁 + *

+ * 重启: 检查 集群依赖情况 申请资源 -> 申请失败 -> 申请成功 -> 部署A集群 -> 部署B集群 -> 部署成功 -> 测试 -> 开始心跳测试 -> 心跳测试中 -> 心跳测试成功 -> 开始数据测试 -> 数据测试中 -> 数据测试成功 等待资源释放 -> 资源释放中 -> + * 资源释放失败 -> 完成资源释放 -> 重启集群 -> -> 删除集群数据 -> 删除集群数据中 -> 完成集群数据删除 -> + *

+ * 数据状态: 集群状态: 是否与集群状态共享 启动中 运行 停运中 已停运 卸载中 完成卸载 作废 运维状态: + *

+ * 检查状态,独立一个字段。用 二进制方式 1. 心跳失败 2. 配置异常 3. + */ + private Long status; + + private Integer isDelete; + + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/base/BaseOrganizationEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/base/BaseOrganizationEntity.java new file mode 100644 index 00000000..622fe753 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/base/BaseOrganizationEntity.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.base; + + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class BaseOrganizationEntity extends BaseIdEntity { + + + private Long organizationId; + + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/base/BaseRuntimeIdEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/base/BaseRuntimeIdEntity.java new file mode 100644 index 00000000..0c89a9d5 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/base/BaseRuntimeIdEntity.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.console.entity.base; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class BaseRuntimeIdEntity extends BaseClusterIdEntity { + + private Long runtimeId; + + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/base/BaseSyncEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/base/BaseSyncEntity.java new file mode 100644 index 00000000..cf12538a --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/base/BaseSyncEntity.java @@ -0,0 +1,81 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.console.entity.base; + +import org.apache.eventmesh.dashboard.common.enums.ClusterTrusteeshipType; +import org.apache.eventmesh.dashboard.common.enums.ClusterTrusteeshipType.FirstToWhom; +import org.apache.eventmesh.dashboard.common.enums.DeployStatusType; +import org.apache.eventmesh.dashboard.common.enums.ReplicationType; +import org.apache.eventmesh.dashboard.common.enums.SyncErrorType; + +import java.time.LocalDateTime; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 此类 runtime 与 cluster 共用 + */ +@Data +@EqualsAndHashCode(callSuper = true) +public abstract class BaseSyncEntity extends BaseClusterIdEntity { + + private String name; + + private String version; + + private ClusterTrusteeshipType trusteeshipType; + + private FirstToWhom firstToWhom; + + private FirstToWhom firstSyncState; + + private ReplicationType replicationType; + + private SyncErrorType syncErrorType; + + private DeployStatusType deployStatusType; + + private Long resourcesConfigId; + + private Long deployScriptId; + + private String deployScriptName; + + private String deployScriptVersion; + + /** + * 不想加字段,这个字段作为 port 的索引,目前只支持范围获得 + */ + private Integer runtimeIndex; + + /** + * 上线时间 + */ + private LocalDateTime onlineTimestamp; + + /** + * 下线时间 + */ + private LocalDateTime offlineTimestamp; + + + private LocalDateTime startTimestamp; + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cases/CaseEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cases/CaseEntity.java new file mode 100644 index 00000000..6b6a233e --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cases/CaseEntity.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.entity.cases; + +import org.apache.eventmesh.dashboard.console.entity.base.BaseOrganizationEntity; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class CaseEntity extends BaseOrganizationEntity { + + + private String caseType; + + /** + * cluster , runtime + */ + private String objectType; + + + /** + * + */ + private String objectId; +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cases/DeployScriptEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cases/DeployScriptEntity.java new file mode 100644 index 00000000..cb1ebd30 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cases/DeployScriptEntity.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.entity.cases; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.console.entity.base.BaseOrganizationEntity; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class DeployScriptEntity extends BaseOrganizationEntity { + + private String name; + + private String version; + + private ClusterType clusterType; + + private String description; + + private String startRuntimeVersion; + + private String endRuntimeVersion; + + private String content; + + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cases/PortEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cases/PortEntity.java new file mode 100644 index 00000000..bedfe575 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cases/PortEntity.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.entity.cases; + +import org.apache.eventmesh.dashboard.console.entity.base.BaseClusterIdEntity; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class PortEntity extends BaseClusterIdEntity { + + private Integer currentPort; + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cases/ResouceEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cases/ResouceEntity.java new file mode 100644 index 00000000..b5d6b3d7 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cases/ResouceEntity.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.entity.cases; + +import org.apache.eventmesh.dashboard.console.entity.base.BaseOrganizationEntity; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class ResouceEntity extends BaseOrganizationEntity { + + + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cases/ResourcesConfigEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cases/ResourcesConfigEntity.java new file mode 100644 index 00000000..f1606faa --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cases/ResourcesConfigEntity.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.entity.cases; + + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class ResourcesConfigEntity extends CaseEntity { + + private Float cpuNum; + + private Float memNum; + + private Float diskNum; + + private Float gpuNum; + + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/AclEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/AclEntity.java index b19bbb65..b300b6d5 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/AclEntity.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/AclEntity.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.entity.cluster; import org.apache.eventmesh.dashboard.console.entity.BaseEntity; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/ClientEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/ClientEntity.java index 452805f5..823e2d17 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/ClientEntity.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/ClientEntity.java @@ -15,10 +15,10 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.entity.cluster; -import org.apache.eventmesh.dashboard.common.enums.RecordStatus; -import org.apache.eventmesh.dashboard.console.entity.BaseEntity; +import org.apache.eventmesh.dashboard.console.entity.base.BaseRuntimeIdEntity; import java.sql.Timestamp; @@ -28,17 +28,11 @@ import lombok.EqualsAndHashCode; @Data -@EqualsAndHashCode(callSuper = true, exclude = "status") -public class ClientEntity extends BaseEntity { +@EqualsAndHashCode(callSuper = true) +public class ClientEntity extends BaseRuntimeIdEntity { private static final long serialVersionUID = 8204133370609215856L; - /** - * Primary key - */ - @Schema(name = "id", description = "primary key") - private Long id; - private String name; private String platform; @@ -65,13 +59,6 @@ public class ClientEntity extends BaseEntity { @Schema(name = "protocol", example = "http", allowableValues = {"http", "grpc", "tcp"}) private String protocol; - /** - * 0: not active, 1: active - * - * @see RecordStatus - */ - @Schema(name = "status", defaultValue = "0", allowableValues = {"0", "1"}, description = "0:not active, 1:active") - private Integer status; /** * csv format config id list.
Example value: 1,2,7
This field is updated when the configuration is modified via the web API, but is not @@ -87,8 +74,5 @@ public class ClientEntity extends BaseEntity { private Timestamp endTime; - public void setStatusEntity(RecordStatus status) { - this.status = status.getNumber(); - } } \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/ClusterAndRelationshipEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/ClusterAndRelationshipEntity.java index 78b008c8..c2008142 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/ClusterAndRelationshipEntity.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/ClusterAndRelationshipEntity.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.entity.cluster; import org.apache.eventmesh.dashboard.common.enums.ClusterType; @@ -22,8 +23,10 @@ import java.time.LocalDateTime; import lombok.Data; +import lombok.EqualsAndHashCode; @Data +@EqualsAndHashCode(callSuper = true) public class ClusterAndRelationshipEntity extends ClusterEntity { private LocalDateTime relationshipTime; @@ -32,6 +35,6 @@ public class ClusterAndRelationshipEntity extends ClusterEntity { private ClusterType relationshipType; - private Integer status; + } 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 121fe8ec..76000b35 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 @@ -15,36 +15,35 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.entity.cluster; -import org.apache.eventmesh.dashboard.common.enums.ClusterTrusteeshipType; -import org.apache.eventmesh.dashboard.common.enums.ClusterType; -import org.apache.eventmesh.dashboard.console.entity.BaseEntity; +package org.apache.eventmesh.dashboard.console.entity.cluster; +import org.apache.eventmesh.dashboard.common.enums.ClusterOwnType; +import org.apache.eventmesh.dashboard.console.entity.base.BaseSyncEntity; import lombok.Data; import lombok.EqualsAndHashCode; +/** + * + */ @Data -@EqualsAndHashCode(callSuper = true, exclude = "status") -public class ClusterEntity extends BaseEntity { +@EqualsAndHashCode(callSuper = true) +public class ClusterEntity extends BaseSyncEntity { - private String name; - - private ClusterTrusteeshipType trusteeshipType; - - private ClusterType clusterType; - - private String version; private String jmxProperties; + private String config; + private String description; - private Integer authType; + private String authType; - private Integer runState; - private Integer status; + /** + * 如何解除共享 + */ + private ClusterOwnType clusterOwnType; } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/ClusterRelationshipEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/ClusterRelationshipEntity.java index c930ed1a..2b1baaeb 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/ClusterRelationshipEntity.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/ClusterRelationshipEntity.java @@ -15,22 +15,32 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.entity.cluster; import org.apache.eventmesh.dashboard.common.enums.ClusterType; -import org.apache.eventmesh.dashboard.console.entity.BaseEntity; +import org.apache.eventmesh.dashboard.console.entity.base.BaseClusterIdEntity; + +import java.time.LocalDateTime; import lombok.Data; +import lombok.EqualsAndHashCode; @Data -public class ClusterRelationshipEntity extends BaseEntity { +@EqualsAndHashCode(callSuper = true) +public class ClusterRelationshipEntity extends BaseClusterIdEntity { - private ClusterType clusterType; + /** + * + */ private Long relationshipId; private ClusterType relationshipType; - private Integer status; + private LocalDateTime relationshipTime; + + private LocalDateTime unRelationshipTime; + } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/ConnectionEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/ConnectionEntity.java index 9f8468a9..1444cf32 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/ConnectionEntity.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/ConnectionEntity.java @@ -15,10 +15,10 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.entity.cluster; -import org.apache.eventmesh.dashboard.common.enums.RecordStatus; -import org.apache.eventmesh.dashboard.console.entity.BaseEntity; +import org.apache.eventmesh.dashboard.console.entity.base.BaseRuntimeIdEntity; import java.sql.Timestamp; @@ -32,8 +32,8 @@ * A Connection is a link from a source to a sink. */ @Data -@EqualsAndHashCode(callSuper = true, exclude = {"status", "endTime"}) -public class ConnectionEntity extends BaseEntity { +@EqualsAndHashCode(callSuper = true) +public class ConnectionEntity extends BaseRuntimeIdEntity { private static final long serialVersionUID = 6565578252656944905L; @@ -69,9 +69,6 @@ public class ConnectionEntity extends BaseEntity { private Long runtimeId; - @Schema(name = "status", defaultValue = "0", allowableValues = {"0", "1"}, description = "0:inactive, 1:active") - private Integer status; - private String topic; private Long groupId; @@ -80,8 +77,4 @@ public class ConnectionEntity extends BaseEntity { private String description; - - public void setStatusEnum(RecordStatus statusEnum) { - this.status = statusEnum.getNumber(); - } } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/InstanceUserEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/InstanceUserEntity.java index 35c0fc52..89b21623 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/InstanceUserEntity.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/InstanceUserEntity.java @@ -15,17 +15,18 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.entity.cluster; -import org.apache.eventmesh.dashboard.console.entity.BaseEntity; +import org.apache.eventmesh.dashboard.console.entity.base.BaseRuntimeIdEntity; import lombok.Data; import lombok.EqualsAndHashCode; @Data -@EqualsAndHashCode(callSuper = true, exclude = "status") -public class InstanceUserEntity extends BaseEntity { +@EqualsAndHashCode(callSuper = true) +public class InstanceUserEntity extends BaseRuntimeIdEntity { private Integer instanceType; @@ -37,6 +38,4 @@ public class InstanceUserEntity extends BaseEntity { private String token; - private Integer status; - } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/NetConnectionEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/NetConnectionEntity.java index f9785fb1..e4a27b61 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/NetConnectionEntity.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/NetConnectionEntity.java @@ -15,9 +15,10 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.entity.cluster; -import org.apache.eventmesh.dashboard.console.entity.BaseEntity; +import org.apache.eventmesh.dashboard.console.entity.base.BaseRuntimeIdEntity; import java.time.LocalDateTime; @@ -26,7 +27,7 @@ @Data @EqualsAndHashCode(callSuper = true) -public class NetConnectionEntity extends BaseEntity { +public class NetConnectionEntity extends BaseRuntimeIdEntity { private Long clusterId; @@ -41,7 +42,6 @@ public class NetConnectionEntity extends BaseEntity { private Integer runtimePort; - private int status; private String description; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/RuntimeEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/RuntimeEntity.java index 750f265f..3850d0df 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/RuntimeEntity.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/RuntimeEntity.java @@ -15,11 +15,10 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.entity.cluster; -import org.apache.eventmesh.dashboard.console.entity.BaseEntity; +package org.apache.eventmesh.dashboard.console.entity.cluster; -import java.time.LocalDateTime; +import org.apache.eventmesh.dashboard.console.entity.base.BaseSyncEntity; import lombok.Data; import lombok.EqualsAndHashCode; @@ -28,23 +27,30 @@ * */ @Data -@EqualsAndHashCode(callSuper = true, exclude = "status") -public class RuntimeEntity extends BaseEntity { - - private String name; +@EqualsAndHashCode(callSuper = true) +public class RuntimeEntity extends BaseSyncEntity { private String host; + /** + * 添加的时候只需要 host 与 post eventmesh runtime 是 admin port。通过 runtime admin 获得所有的配置。 meta 需要 host 与 post store host 与 post jmxPort + */ private Integer port; private Integer jmxPort; - private LocalDateTime startTimestamp; + private Integer adminPort; private String rack; - private Integer status; - private String endpointMap; + private String createScriptContent; + + private Long kubernetesClusterId; + + private String authType; + + + } 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 5bab3fc8..416df43d 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 @@ -15,11 +15,11 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.entity.connector; import org.apache.eventmesh.dashboard.common.enums.KubernetesPodStatus; -import org.apache.eventmesh.dashboard.common.enums.RecordStatus; -import org.apache.eventmesh.dashboard.console.entity.BaseEntity; +import org.apache.eventmesh.dashboard.console.entity.base.BaseRuntimeIdEntity; import io.swagger.v3.oas.annotations.media.Schema; @@ -27,8 +27,8 @@ import lombok.EqualsAndHashCode; @Data -@EqualsAndHashCode(callSuper = true, exclude = "status") -public class ConnectorEntity extends BaseEntity { +@EqualsAndHashCode(callSuper = true) +public class ConnectorEntity extends BaseRuntimeIdEntity { private static final long serialVersionUID = -8226303660232951326L; @@ -40,14 +40,6 @@ public class ConnectorEntity extends BaseEntity { private String type; - /** - * 0: not active, 1: active - * - * @see RecordStatus - */ - @Schema(name = "status", defaultValue = "0", allowableValues = {"0", "1"}, description = "0:inactive, 1:active") - private Integer status; - private String host; private Integer port; @@ -65,9 +57,6 @@ public class ConnectorEntity extends BaseEntity { */ private String configIds; - public void setStatusEnum(RecordStatus statusEnum) { - this.status = statusEnum.getNumber(); - } public void setKubernetesPodStatusEnum(KubernetesPodStatus kubernetesPodStatusEnum) { this.podState = kubernetesPodStatusEnum.getNumber(); diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/function/ConfigEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/function/ConfigEntity.java index cdf31405..e1c23d2c 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/function/ConfigEntity.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/function/ConfigEntity.java @@ -15,30 +15,33 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.entity.function; -import org.apache.eventmesh.dashboard.console.entity.BaseEntity; +import org.apache.eventmesh.dashboard.common.enums.MetadataType; +import org.apache.eventmesh.dashboard.console.entity.base.BaseClusterIdEntity; import lombok.Data; import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = true) -public class ConfigEntity extends BaseEntity { - - private Long id; +public class ConfigEntity extends BaseClusterIdEntity { - private Long clusterId; private String businessType; + private Long retrospectId; + /** * config type 0:runtime,1:storage,2:connector,3:topic */ - private Integer instanceType; + private MetadataType instanceType; private Long instanceId; + private String configType; + private String configName; private String configValue; @@ -47,8 +50,6 @@ public class ConfigEntity extends BaseEntity { private String eventmeshVersion; - private Integer status; - private String endVersion; private Integer diffType; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/function/ConfigGatherEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/function/ConfigGatherEntity.java new file mode 100644 index 00000000..3b050285 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/function/ConfigGatherEntity.java @@ -0,0 +1,30 @@ +/* + * 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.function; + +import org.apache.eventmesh.dashboard.console.entity.BaseEntity; + +public class ConfigGatherEntity extends BaseEntity { + + + private String name; + + private String description; + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/function/HealthCheckResultEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/function/HealthCheckResultEntity.java index 657d217d..4e22de66 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/function/HealthCheckResultEntity.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/function/HealthCheckResultEntity.java @@ -15,25 +15,47 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.entity.function; -import org.apache.eventmesh.dashboard.console.entity.BaseEntity; +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.common.enums.health.HealthCheckStatus; +import org.apache.eventmesh.dashboard.common.enums.health.HealthCheckTypeEnum; +import org.apache.eventmesh.dashboard.console.entity.base.BaseRuntimeIdEntity; + +import java.time.LocalDateTime; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.EqualsAndHashCode; - +// state of a health check, 0: failed, 1: passed, 2: doing check, 3: out of time, 4: not connected @Data @EqualsAndHashCode(callSuper = true, exclude = "resultDesc") @Schema(name = "HealthCheckResultEntity", description = "Health check result entity") -public class HealthCheckResultEntity extends BaseEntity { +public class HealthCheckResultEntity extends BaseRuntimeIdEntity { private static final long serialVersionUID = -7350585209577598040L; - private Long clusterId; + private ClusterType clusterType; + + private String protocol; + + private String interfaces; + + private HealthCheckTypeEnum healthCheckTypeEnum; + + private HealthCheckStatus result; + + private String resultDesc; + + private LocalDateTime beginTime; + + private LocalDateTime finishTime; + + @Schema(description = "Type of Health Check;0:Unknown, 1:Cluster, 2:Runtime, 3:Topic, 4:Storage", defaultValue = "0", allowableValues = {"0", "1", "2", "3", "4"}) @@ -42,9 +64,5 @@ public class HealthCheckResultEntity extends BaseEntity { @Schema(description = "Instance id(database schema) of the health check object") private Long typeId; - private String resultDesc; - - @Schema(description = "state of a health check, 0: failed, 1: passed, 2: doing check, 3: out of time, 4: not connected") - private Integer state; } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/function/LogEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/function/LogEntity.java index 7a07089f..e7d855e9 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/function/LogEntity.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/function/LogEntity.java @@ -15,19 +15,24 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.entity.function; -import org.apache.eventmesh.dashboard.console.entity.BaseEntity; +import org.apache.eventmesh.dashboard.console.entity.base.BaseRuntimeIdEntity; import java.sql.Timestamp; +import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; @Data -@EqualsAndHashCode(callSuper = true, exclude = {"endTime", "operationUser", "result"}) -public class LogEntity extends BaseEntity { +@NoArgsConstructor +@AllArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class LogEntity extends BaseRuntimeIdEntity { private Long id; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/function/MetadataSyncResultEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/function/MetadataSyncResultEntity.java new file mode 100644 index 00000000..3baa5660 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/function/MetadataSyncResultEntity.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.console.entity.function; + +import org.apache.eventmesh.dashboard.common.enums.ClusterTrusteeshipType; +import org.apache.eventmesh.dashboard.common.enums.MetadataType; +import org.apache.eventmesh.dashboard.common.enums.SyncErrorType; +import org.apache.eventmesh.dashboard.console.entity.base.BaseRuntimeIdEntity; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class MetadataSyncResultEntity extends BaseRuntimeIdEntity { + + + private Long syncId; + + private MetadataType metadataType; + + private String errorType; + + private ClusterTrusteeshipType clusterTrusteeshipType; + + private boolean isFast = false; + + private SyncErrorType syncErrorType; + + private String resultData; + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/message/ConsumeOffsetEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/message/ConsumeOffsetEntity.java new file mode 100644 index 00000000..e7f3dda4 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/message/ConsumeOffsetEntity.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.entity.message; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class ConsumeOffsetEntity extends TopicOffsetEntity { + + private Long subscribeId; + + private Long groupId; + + private String groupName; + + private Long consumeOffset; + + private Integer consumeRate; + + private Long delayNum; + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/message/GroupEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/message/GroupEntity.java index b081d44d..d4ce306c 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/message/GroupEntity.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/message/GroupEntity.java @@ -15,20 +15,17 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.entity.message; -import org.apache.eventmesh.dashboard.console.entity.BaseEntity; +import org.apache.eventmesh.dashboard.console.entity.base.BaseRuntimeIdEntity; import lombok.Data; import lombok.EqualsAndHashCode; @Data -@EqualsAndHashCode(callSuper = true, exclude = "status") -public class GroupEntity extends BaseEntity { - - private Long id; - - private Long clusterId; +@EqualsAndHashCode(callSuper = true) +public class GroupEntity extends BaseRuntimeIdEntity { private String name; @@ -38,8 +35,4 @@ public class GroupEntity extends BaseEntity { private Integer type; - private String state; - - private Integer status; - } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/message/GroupMemberEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/message/SubscriptionEntity.java similarity index 78% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/message/GroupMemberEntity.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/message/SubscriptionEntity.java index 344d02d5..cfd36cfe 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/message/GroupMemberEntity.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/message/SubscriptionEntity.java @@ -15,20 +15,17 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.entity.message; -import org.apache.eventmesh.dashboard.console.entity.BaseEntity; +import org.apache.eventmesh.dashboard.console.entity.base.BaseRuntimeIdEntity; import lombok.Data; import lombok.EqualsAndHashCode; @Data -@EqualsAndHashCode(callSuper = true, exclude = "status") -public class GroupMemberEntity extends BaseEntity { - - private Long id; - - private Long clusterId; +@EqualsAndHashCode(callSuper = true) +public class SubscriptionEntity extends BaseRuntimeIdEntity { private String topicName; @@ -36,7 +33,4 @@ public class GroupMemberEntity extends BaseEntity { private String eventMeshUser; - private String state; - - private Integer status; } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/message/TopicEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/message/TopicEntity.java index 9b70bf80..699a9700 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/message/TopicEntity.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/message/TopicEntity.java @@ -15,9 +15,10 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.entity.message; -import org.apache.eventmesh.dashboard.console.entity.BaseEntity; +import org.apache.eventmesh.dashboard.console.entity.base.BaseRuntimeIdEntity; import io.swagger.v3.oas.annotations.media.Schema; @@ -25,30 +26,44 @@ import lombok.EqualsAndHashCode; @Data -@EqualsAndHashCode(callSuper = true, exclude = "status") -public class TopicEntity extends BaseEntity { +@EqualsAndHashCode(callSuper = true) +public class TopicEntity extends BaseRuntimeIdEntity { - private Long id; - private Long clusterId; + private String topicType; private String topicName; - private Long storageId; - @Schema(description = "time to live in milliseconds, -2 unknown, -1 no limit;", example = "1000") - private Long retentionMs; + /** + * + */ + private Long numQueue; /** - * topic type, 0: normal, 1: EventMesh internal; + * 副本个数 */ - @Schema(description = "topic type, 0: normal, 1: EventMesh internal;", example = "0") - private Integer type; + private Integer replicationFactor; + + /** + * topic 拦截器类型 + */ + private String topicFilterType; + + /** + * 不确定参数 + */ + private String attributes; + + private String order; + + @Schema(description = "time to live in milliseconds, -2 unknown, -1 no limit;", example = "1000") + private Long retentionMs; + private String description; - private Integer status; private Integer createProgress; - + } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/message/TopicOffsetEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/message/TopicOffsetEntity.java new file mode 100644 index 00000000..04d38451 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/message/TopicOffsetEntity.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.entity.message; + +import org.apache.eventmesh.dashboard.console.entity.base.BaseRuntimeIdEntity; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class TopicOffsetEntity extends BaseRuntimeIdEntity { + + private String offsetRecordType; + + private Long topicId; + + private String topicName; + + private Long topicOffset; + + private Integer increaseRate; + + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/exception/GlobalExceptionHandler.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/exception/GlobalExceptionHandler.java deleted file mode 100644 index f61431fc..00000000 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/exception/GlobalExceptionHandler.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.console.exception; - -import org.apache.eventmesh.dashboard.common.dto.Result; -import org.apache.eventmesh.dashboard.common.dto.Result.StatusMessage; -import org.apache.eventmesh.dashboard.common.enums.Status; -import org.apache.eventmesh.dashboard.common.exception.BaseException; - -import javax.servlet.http.HttpServletRequest; - -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.RestControllerAdvice; - -import lombok.extern.slf4j.Slf4j; - -/** - * This class, in conjunction with {@linkplain Status Status} and {@link BaseException}, collectively implements customized error reporting. - */ - -@Slf4j -@RestControllerAdvice -public class GlobalExceptionHandler { - - @ExceptionHandler(BaseException.class) - public ResponseEntity> baseHandler(BaseException e, HttpServletRequest request) { - String uri = request.getRequestURI(); - log.error("RESTful API {} service error occurred, name: {}, category: {}", - uri, e.getStatus().name(), e.getStatus().getCategory().name(), e); - return ResponseEntity.status(e.getStatus().getCode()).body(new Result<>(new StatusMessage(e))); - } - - @ExceptionHandler(RuntimeException.class) - public ResponseEntity> runtimeHandler(RuntimeException e, HttpServletRequest request) { - String uri = request.getRequestURI(); - log.error("RESTful API {} runtime error occurred.", uri, e); - return Result.internalError(e.getMessage()); - } - - @ExceptionHandler(Exception.class) - public ResponseEntity> exceptionHandler(Exception e, HttpServletRequest request) { - String uri = request.getRequestURI(); - log.error("RESTful API {} unknown error occurred.", uri, e); - return Result.internalError(e.getMessage()); - } - -} 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 512ea12b..90e63bad 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 @@ -15,11 +15,11 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.function.health; import org.apache.eventmesh.dashboard.common.constant.health.HealthConstant; import org.apache.eventmesh.dashboard.common.enums.health.HealthCheckStatus; -import org.apache.eventmesh.dashboard.console.function.health.check.config.HealthCheckObjectConfig; import java.time.LocalDateTime; import java.util.Collections; @@ -41,7 +41,7 @@ public class CheckResultCache { private CheckResultCache() { } - public Integer getLastHealthyCheckResult(String type, Long typeId) { + public Long 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(); } @@ -61,17 +61,17 @@ public void update(String type, Long typeId, HealthCheckStatus status, String re } description += " Latency: " + latency.toString() + "ms"; CheckResult result = new CheckResult(status, description, LocalDateTime.now(), - latency, oldResult.getConfig()); + latency); subMap.put(typeId, result); } - public void update(String type, Long typeId, HealthCheckStatus status, String resultDesc, Long latency, HealthCheckObjectConfig config) { + public void update1(String type, Long typeId, HealthCheckStatus status, String resultDesc, Long latency) { HashMap subMap = cacheMap.get(type); if (Objects.isNull(subMap)) { subMap = new HashMap<>(); cacheMap.put(type, subMap); } - subMap.put(typeId, new CheckResult(status, resultDesc, LocalDateTime.now(), latency, config)); + subMap.put(typeId, new CheckResult(status, resultDesc, LocalDateTime.now(), latency)); } public Map> getCacheMap() { @@ -101,7 +101,5 @@ public class CheckResult { * latency of a health check, for example ping latency. */ private Long latencyMilliSeconds; - - private HealthCheckObjectConfig config; } } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/Health2Service.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/Health2Service.java new file mode 100644 index 00000000..5c938fcb --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/Health2Service.java @@ -0,0 +1,272 @@ +/* + * 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.function.health; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.common.enums.health.HealthCheckStatus; +import org.apache.eventmesh.dashboard.common.enums.health.HealthCheckTypeEnum; +import org.apache.eventmesh.dashboard.common.model.base.BaseSyncBase; +import org.apache.eventmesh.dashboard.common.util.ClasspathScanner; +import org.apache.eventmesh.dashboard.console.entity.function.HealthCheckResultEntity; +import org.apache.eventmesh.dashboard.console.function.health.annotation.HealthCheckType; +import org.apache.eventmesh.dashboard.console.function.health.callback.HealthCheckCallback; +import org.apache.eventmesh.dashboard.console.function.health.check.AbstractHealthCheckService; +import org.apache.eventmesh.dashboard.console.function.health.check.ClusterHealthCheckService; +import org.apache.eventmesh.dashboard.console.function.health.check.HealthCheckService; +import org.apache.eventmesh.dashboard.console.service.function.HealthDataService; +import org.apache.eventmesh.dashboard.core.function.SDK.SDKManage; + +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.LinkedBlockingDeque; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; + +import lombok.Data; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; + +@Slf4j +public class Health2Service { + + private static final Map> HEALTH_PING_CHECK_CLASS_CACHE = new HashMap<>(); + + private static final Map> HEALTH_TOPIC_CHECK_CLASS_CACHE = new HashMap<>(); + + static { + Set> interfaceSet = new HashSet<>(); + interfaceSet.add(HealthCheckService.class); + ClasspathScanner classpathScanner = + ClasspathScanner.builder().base(Health2Service.class).subPath("/check/impl/**").interfaceSet(interfaceSet).build(); + try { + List> classList = classpathScanner.getClazz(); + classList.forEach(Health2Service::setClassCache); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + + private static void setClassCache(Class clazz) { + HealthCheckType checkType = clazz.getAnnotation(HealthCheckType.class); + if (Objects.isNull(checkType)) { + return; + } + Map> map = + Objects.equals(checkType.healthType(), HealthCheckTypeEnum.PING) ? HEALTH_PING_CHECK_CLASS_CACHE : HEALTH_TOPIC_CHECK_CLASS_CACHE; + + for (ClusterType clusterType : checkType.clusterType()) { + map.put(clusterType, clazz); + } + } + + + private final Map checkServiceMap = new ConcurrentHashMap<>(); + + @Deprecated + private final Map clusterHealthCheckServiceMap = new ConcurrentHashMap<>(); + + + private final ThreadPoolExecutor threadPoolExecutor = + new ThreadPoolExecutor(32, 32, 5, TimeUnit.SECONDS, new LinkedBlockingDeque<>(), new ThreadFactory() { + final AtomicInteger counter = new AtomicInteger(0); + + @Override + public Thread newThread(Runnable r) { + return new Thread(r, "health-manager-" + counter.incrementAndGet()); + } + }); + + @Setter + private HealthDataService dataService; + + + public void register(BaseSyncBase baseSyncBase) { + try { + this.createHealthCheckWrapper(baseSyncBase, HealthCheckTypeEnum.PING); + if (baseSyncBase.getClusterType().isHealthTopic()) { + this.createHealthCheckWrapper(baseSyncBase, HealthCheckTypeEnum.TOPIC); + } + } catch (Exception e) { + log.error(e.getMessage(), e); + } + } + + + public void unRegister(BaseSyncBase baseSyncBase) { + ClusterHealthCheckService clusterHealthCheckService = this.clusterHealthCheckServiceMap.remove(baseSyncBase.getClusterId()); + if (Objects.nonNull(clusterHealthCheckService)) { + clusterHealthCheckService.unRegister(baseSyncBase); + } + this.checkServiceMap.remove(getKey(baseSyncBase, HealthCheckTypeEnum.PING)); + this.checkServiceMap.remove(getKey(baseSyncBase, HealthCheckTypeEnum.TOPIC)); + } + + @Deprecated + public void unRegisterCluster(Long clusterId) { + this.clusterHealthCheckServiceMap.remove(clusterId); + } + + + void createHealthCheckWrapper(BaseSyncBase baseSyncBase, HealthCheckTypeEnum healthCheckTypeEnum) { + Map> map = + Objects.equals(healthCheckTypeEnum, HealthCheckTypeEnum.PING) ? HEALTH_PING_CHECK_CLASS_CACHE : HEALTH_TOPIC_CHECK_CLASS_CACHE; + Class clazz = map.get(baseSyncBase.getClusterType()); + AbstractHealthCheckService abstractHealthCheckService = SDKManage.getInstance().createAbstractClientInfo(clazz, baseSyncBase); + HealthCheckWrapper healthCheckWrapper = + this.createHealthCheckWrapper(baseSyncBase, abstractHealthCheckService, healthCheckTypeEnum); + this.checkServiceMap.put(healthCheckWrapper.getKey(), healthCheckWrapper); + } + + private HealthCheckWrapper createHealthCheckWrapper(BaseSyncBase baseSyncBase, + AbstractHealthCheckService healthCheckService, HealthCheckTypeEnum healthCheckTypeEnum) { + HealthCheckWrapper healthCheckWrapper = new HealthCheckWrapper(); + healthCheckWrapper.setHealthCheckTypeEnum(healthCheckTypeEnum); + healthCheckWrapper.setBaseSyncBase(baseSyncBase); + healthCheckWrapper.setCheckService(healthCheckService); + + HealthCheckResultEntity healthCheckResultEntity = new HealthCheckResultEntity(); + + healthCheckWrapper.setHealthCheckResultEntity(healthCheckResultEntity); + return healthCheckWrapper; + } + + public void executeAll() { + long startTime = System.currentTimeMillis(); + List healthCheckResultEntityList = new ArrayList<>(); + CountDownLatch countDownLatch = new CountDownLatch(this.checkServiceMap.size()); + this.checkServiceMap.forEach((k, wrapper) -> { + healthCheckResultEntityList.add(wrapper.createHealthCheckResultEntity()); + DefaultHealthCheckCallback healthExecutor = new DefaultHealthCheckCallback(); + healthExecutor.healthCheckWrapper = wrapper; + healthExecutor.countDownLatch = countDownLatch; + healthExecutor.healthCheckResultEntity = wrapper.getHealthCheckResultEntity(); + + threadPoolExecutor.execute(() -> { + try { + wrapper.checkService.check(healthExecutor); + } catch (Exception e) { + healthExecutor.onFail(e); + } + }); + }); + try { + dataService.batchInsertHealthCheckResult(healthCheckResultEntityList); + } catch (Exception e) { + log.error("batchInsertHealthCheckResult failed", e); + } + try { + boolean await = countDownLatch.await(3, TimeUnit.SECONDS); + log.info("await ia {} downLatch count {}", await, countDownLatch.getCount()); + log.info(" startup cost {} ms", System.currentTimeMillis() - startTime); + } catch (Exception e) { + log.error(e.getMessage(), e); + } finally { + try { + dataService.batchUpdateCheckResultByClusterIdAndTypeAndTypeId(healthCheckResultEntityList); + } catch (Exception e) { + log.error("batchUpdateCheckResultByClusterIdAndTypeAndTypeId failed", e); + } + } + } + + + public String getKey(BaseSyncBase baseSyncBase, HealthCheckTypeEnum healthCheckTypeEnum) { + return healthCheckTypeEnum.toString() + "-" + baseSyncBase.getId(); + } + + static class DefaultHealthCheckCallback implements HealthCheckCallback { + + private HealthCheckWrapper healthCheckWrapper; + + private CountDownLatch countDownLatch; + + private HealthCheckResultEntity healthCheckResultEntity; + + @Override + public void onSuccess() { + healthCheckResultEntity.setResult(HealthCheckStatus.SUCCESS); + healthCheckResultEntity.setFinishTime(LocalDateTime.now()); + countDownLatch.countDown(); + } + + @Override + public void onFail(Exception e) { + healthCheckResultEntity.setResult(HealthCheckStatus.FAILED); + healthCheckResultEntity.setResultDesc(e.getMessage()); + healthCheckResultEntity.setFinishTime(LocalDateTime.now()); + countDownLatch.countDown(); + log.error("healthCheckCallback onFail Id: ", e); + } + } + + @Data + class HealthCheckWrapper { + + private BaseSyncBase baseSyncBase; + + private AbstractHealthCheckService checkService; + + + private HealthCheckResultEntity healthCheckResultEntity = new HealthCheckResultEntity(); + + + private HealthCheckTypeEnum healthCheckTypeEnum; + + + private HealthCheckResultEntity createHealthCheckResultEntity() { + HealthCheckResultEntity healthCheckResultEntity = new HealthCheckResultEntity(); + healthCheckResultEntity.setClusterId(this.baseSyncBase.getClusterId()); + healthCheckResultEntity.setInterfaces(this.baseSyncBase.getId().toString()); + healthCheckResultEntity.setHealthCheckTypeEnum(this.healthCheckTypeEnum); + healthCheckResultEntity.setClusterType(this.baseSyncBase.getClusterType()); + healthCheckResultEntity.setBeginTime(LocalDateTime.now()); + this.healthCheckResultEntity = healthCheckResultEntity; + return healthCheckResultEntity; + } + + @Override + public boolean equals(Object object) { + if (object instanceof HealthCheckWrapper) { + HealthCheckWrapper wrapper = (HealthCheckWrapper) object; + return this.baseSyncBase.getId().equals(wrapper.getBaseSyncBase().getId()) && this.baseSyncBase.getClusterType() + .equals(wrapper.getBaseSyncBase().getClusterType()); + } + return false; + } + + + public String getKey() { + return Health2Service.this.getKey(this.baseSyncBase, this.healthCheckTypeEnum); + } + + } + + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/HealthExecutor.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/HealthExecutor.java deleted file mode 100644 index 267bf8b7..00000000 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/HealthExecutor.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.console.function.health; - -import org.apache.eventmesh.dashboard.common.enums.health.HealthCheckStatus; -import org.apache.eventmesh.dashboard.common.enums.health.HealthCheckType; -import org.apache.eventmesh.dashboard.console.entity.function.HealthCheckResultEntity; -import org.apache.eventmesh.dashboard.console.function.health.CheckResultCache.CheckResult; -import org.apache.eventmesh.dashboard.console.function.health.callback.HealthCheckCallback; -import org.apache.eventmesh.dashboard.console.function.health.check.AbstractHealthCheckService; -import org.apache.eventmesh.dashboard.console.service.function.HealthDataService; - -import java.util.ArrayList; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - -import lombok.Getter; -import lombok.Setter; -import lombok.extern.slf4j.Slf4j; - -@Slf4j -public class HealthExecutor { - - private final ExecutorService executorService = Executors.newCachedThreadPool(); - @Setter - private HealthDataService dataService; - /** - * memory cache is used to store real-time health check result. - */ - @Getter - @Setter - private CheckResultCache memoryCache; - - /** - * execute function is where health check services work. - * - * @param service The health check service to be executed. - */ - - public void execute(AbstractHealthCheckService service) { - final long startTime = System.currentTimeMillis(); - //TODO: execute is called by a ScheduledThreadPoolExecutor, - // when called, it should check if current service should doCheck(check service check rate can be dynamically configured). - try { - memoryCache.update(service.getConfig().getHealthCheckResourceType(), service.getConfig().getInstanceId(), HealthCheckStatus.CHECKING, "", - null, service.getConfig()); - //The callback interface is used to pass the processing methods for checking success and failure. - executorService.submit(() -> service.doCheck(new HealthCheckCallback() { - @Override - public void onSuccess() { - //when the health check is successful, the result is updated to the memory cache. - Long latency = System.currentTimeMillis() - startTime; - HealthCheckStatus status = - latency > service.getConfig().getRequestTimeoutMillis() ? HealthCheckStatus.TIMEOUT : HealthCheckStatus.PASSED; - memoryCache.update(service.getConfig().getHealthCheckResourceType(), service.getConfig().getInstanceId(), - status, "Health check succeed.", latency - ); - } - - @Override - public void onFail(Exception e) { - //when the health check fails, the result is updated to the memory cache, passing in the exception message. - log.error("Health check failed for reason: {}. Service config is {}", e, service.getConfig()); - memoryCache.update(service.getConfig().getHealthCheckResourceType(), service.getConfig().getInstanceId(), - HealthCheckStatus.FAILED, e.getMessage(), - System.currentTimeMillis() - startTime); - } - })); - - } catch (Exception e) { - log.error("Health check failed for reason: {}. Service config is {}", e, service.getConfig()); - memoryCache.update(service.getConfig().getHealthCheckResourceType(), service.getConfig().getInstanceId(), HealthCheckStatus.FAILED, - e.getMessage(), - System.currentTimeMillis() - startTime); - } - } - - /** - * this function should be called before any actual execute behaviour.

It will check the execution result of the last check cycle in the memory - * cache, set tasks that haven't finished status to time out and update the database. - */ - public void startExecute() { - ArrayList resultList = new ArrayList<>(); - memoryCache.getCacheMap().forEach((type, subMap) -> { - subMap.forEach((instanceId, result) -> { - if (result.getStatus() == HealthCheckStatus.CHECKING) { - result.setStatus(HealthCheckStatus.TIMEOUT); - } - addToResultList(result, resultList); - }); - }); - if (!resultList.isEmpty()) { - dataService.batchUpdateCheckResultByClusterIdAndTypeAndTypeId(resultList); - } - } - - /** - * this function should be called after all actual execute behaviour.

It will insert the result of this check cycle into the database. At this - * point the status of the tasks may be CHECKING, they will be updated on the next startExecute. - */ - public void endExecute() { - ArrayList resultList = new ArrayList<>(); - memoryCache.getCacheMap().forEach((type, subMap) -> { - subMap.forEach((instanceId, result) -> { - addToResultList(result, resultList); - }); - }); - dataService.batchInsertHealthCheckResult(resultList); - } - - /** - * Helper function to add a CheckResult to the resultList. - * - * @param result memory cached result object. - * @param resultList entity list to be inserted into the database. - */ - private void addToResultList(CheckResult result, ArrayList resultList) { - HealthCheckResultEntity newEntity = new HealthCheckResultEntity(); - - newEntity.setClusterId(result.getConfig().getClusterId()); - newEntity.setType(HealthCheckType.toNumber(result.getConfig().getHealthCheckResourceType())); - newEntity.setTypeId(result.getConfig().getInstanceId()); - newEntity.setResultDesc(result.getResultDesc()); - newEntity.setState(result.getStatus().getNumber()); - - resultList.add(newEntity); - } - -} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/HealthService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/HealthService.java deleted file mode 100644 index a28b0e37..00000000 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/HealthService.java +++ /dev/null @@ -1,291 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.console.function.health; - -import org.apache.eventmesh.dashboard.common.constant.health.HealthCheckTypeConstant; -import org.apache.eventmesh.dashboard.common.enums.StoreType; -import org.apache.eventmesh.dashboard.console.entity.StoreEntity; -import org.apache.eventmesh.dashboard.console.entity.function.HealthCheckResultEntity; -import org.apache.eventmesh.dashboard.console.function.health.CheckResultCache.CheckResult; -import org.apache.eventmesh.dashboard.console.function.health.annotation.HealthCheckType; -import org.apache.eventmesh.dashboard.console.function.health.check.AbstractHealthCheckService; -import org.apache.eventmesh.dashboard.console.function.health.check.config.HealthCheckObjectConfig; -import org.apache.eventmesh.dashboard.console.function.health.check.impl.storage.RedisCheck; -import org.apache.eventmesh.dashboard.console.function.health.check.impl.storage.rocketmq4.Rocketmq4BrokerCheck; -import org.apache.eventmesh.dashboard.console.function.health.check.impl.storage.rocketmq4.Rocketmq4NameServerCheck; -import org.apache.eventmesh.dashboard.console.service.DataServiceWrapper; -import org.apache.eventmesh.dashboard.console.service.function.HealthDataService; - -import java.lang.reflect.Constructor; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Objects; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ScheduledThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - -import javax.validation.constraints.NotNull; - -import lombok.extern.slf4j.Slf4j; - -/** - * HealthService is the manager of all health check services. It is responsible for creating, deleting and executing health check services.

In this - * class there is a {@link HealthExecutor} which is used to execute health check services, and also a map to store all health check services. when the - * function executeAll is called, health check service will be executed by {@link HealthExecutor}. - */ -@Slf4j -public class HealthService { - - /** - * class cache used to build healthCheckService instance.

key: HealthCheckObjectConfig.SimpleClassName value: HealthCheckService - * - * @see HealthCheckObjectConfig - */ - private static final Map> HEALTH_CHECK_CLASS_CACHE = new HashMap<>(); - - static { - setClassCache(RedisCheck.class); - setClassCache(Rocketmq4BrokerCheck.class); - setClassCache(Rocketmq4NameServerCheck.class); - } - - /** - * This map is used to store HealthExecutor.

Outside key is Type(runtime, storage etc.), inside key is the id of type instance(runtimeId, - * storageId etc.). - * - * @see AbstractHealthCheckService - */ - private final Map> checkServiceMap = new ConcurrentHashMap<>(); - private HealthExecutor healthExecutor; - private ScheduledThreadPoolExecutor scheduledExecutor; - - private static void setClassCache(Class clazz) { - HEALTH_CHECK_CLASS_CACHE.put(clazz.getSimpleName(), clazz); - } - - public Map> getCheckResultCacheMap() { - return healthExecutor.getMemoryCache().getCacheMap(); - } - - public void insertCheckService(List configList) { - configList.forEach(this::insertCheckService); - } - - public void insertCheckService(HealthCheckObjectConfig config) { - AbstractHealthCheckService healthCheckService = null; - - try { - if (Objects.nonNull(config.getSimpleClassName())) { - Class clazz = HEALTH_CHECK_CLASS_CACHE.get(config.getSimpleClassName()); - healthCheckService = createCheckService(clazz, config); - // you can pass an object to create a HealthCheckService(not commonly used) - } else if (Objects.nonNull(config.getCheckClass())) { - healthCheckService = createCheckService(config.getCheckClass(), config); - //if simpleClassName and CheckClass are both null, use type(storage) and subType(redis) to create healthCheckService - //This is the default create method. - //healthCheckService is annotated with @HealthCheckType(type = "storage", subType = "redis") - } else if (Objects.nonNull(config.getHealthCheckResourceType()) && Objects.nonNull( - config.getHealthCheckResourceSubType())) { - for (Entry> entry : HEALTH_CHECK_CLASS_CACHE.entrySet()) { - Class clazz = entry.getValue(); - HealthCheckType annotation = clazz.getAnnotation(HealthCheckType.class); - if (Objects.isNull(annotation)) { - continue; - } - if (annotation.type().equals(config.getHealthCheckResourceType()) && annotation.subType() - .equals(config.getHealthCheckResourceSubType())) { - healthCheckService = createCheckService(clazz, config); - } - } - } - // if all above creation method failed - if (Objects.isNull(healthCheckService)) { - throw new RuntimeException("No construct method of Health Check Service is found, config is {}" + config); - } - insertCheckService(healthCheckService); - } catch (Exception e) { - log.error("create healthCheckService failed, healthCheckObjectConfig:{}", config, e); - } - } - - public void insertCheckService(AbstractHealthCheckService checkService) { - Map subMap = checkServiceMap.computeIfAbsent(checkService.getConfig().getHealthCheckResourceType(), - k -> new ConcurrentHashMap<>()); - subMap.put(checkService.getConfig().getInstanceId(), checkService); - } - - public void deleteCheckService(String resourceType, Long resourceId) { - Map subMap = checkServiceMap.get(resourceType); - if (Objects.isNull(subMap)) { - return; - } - subMap.get(resourceId).destroy(); - subMap.remove(resourceId); - if (subMap.isEmpty()) { - checkServiceMap.remove(resourceType); - } - } - - public void replaceCheckService(List configList) { - checkServiceMap.clear(); - insertCheckService(configList); - } - - public void createExecutor(HealthDataService dataService, CheckResultCache cache) { - healthExecutor = new HealthExecutor(); - healthExecutor.setDataService(dataService); - healthExecutor.setMemoryCache(cache); - } - - public void executeAll() { - try { - - healthExecutor.startExecute(); - - checkServiceMap.forEach((type, subMap) -> { - subMap.forEach((typeId, healthCheckService) -> { - healthExecutor.execute(healthCheckService); - }); - }); - } catch (Exception e) { - log.error("execute health check failed", e); - } - - healthExecutor.endExecute(); - } - - @NotNull - private AbstractHealthCheckService createCheckService(Class clazz, HealthCheckObjectConfig config) { - try { - Constructor constructor = clazz.getConstructor(HealthCheckObjectConfig.class); - return (AbstractHealthCheckService) constructor.newInstance(config); - } catch (Exception e) { - throw new RuntimeException("createCheckService failed", e); - } - } - - /** - * start scheduled execution of health check services - * - * @param initialDelay unit is second - * @param period unit is second - */ - public void startScheduledExecution(long initialDelay, int period) { - if (scheduledExecutor == null) { - scheduledExecutor = new ScheduledThreadPoolExecutor(2); - } - scheduledExecutor.scheduleAtFixedRate(this::executeAll, initialDelay, period, TimeUnit.SECONDS); - } - - public void startScheduledUpdateConfig(int initialDelay, int period, DataServiceWrapper dataServiceWrapper) { - if (scheduledExecutor == null) { - scheduledExecutor = new ScheduledThreadPoolExecutor(2); - } - scheduledExecutor.scheduleAtFixedRate(() -> this.updateHealthCheckConfigs(dataServiceWrapper), initialDelay, - period, TimeUnit.SECONDS); - } - - public void stopScheduledExecution() { - if (scheduledExecutor != null) { - scheduledExecutor.shutdown(); - } - } - - public void updateHealthCheckConfigs(DataServiceWrapper dataServiceWrapper) { - try { - List checkConfigs = new ArrayList<>(); - List checkResultEntities = new ArrayList<>(); - //TODO add health check service, only storage check is usable for now - - // List clusters = properties.getDataServiceContainer().getClusterDataService().selectAll(); - // for (ClusterEntity cluster : clusters) { - // checkConfigs.add(HealthCheckObjectConfig.builder() - // .instanceId(cluster.getId()) - // .healthCheckResourceType(HealthCheckTypeConstant.HEALTH_CHECK_TYPE_CLUSTER) - // .connectUrl(cluster.getRegistryAddress()) - // .build()); - // checkResultEntities.add(HealthCheckResultEntity.builder() - // .clusterId(cluster.getId()) - // .type(1) - // .typeId(cluster.getId()) - // .state(4) - // .resultDesc("initializing check client") - // .build()); - // } - // - // List runtimes = properties.getDataServiceContainer().getRuntimeDataService().selectAll(); - // for (RuntimeEntity runtime : runtimes) { - // checkConfigs.add(HealthCheckObjectConfig.builder() - // .instanceId(runtime.getId()) - // .healthCheckResourceType(HealthCheckTypeConstant.HEALTH_CHECK_TYPE_RUNTIME) - // .connectUrl(runtime.getHost() + ":" + runtime.getPort()) - // .build()); - // checkResultEntities.add(HealthCheckResultEntity.builder() - // .clusterId(runtime.getClusterId()) - // .type(2) - // .typeId(runtime.getId()) - // .state(4) - // .resultDesc("initializing check client") - // .build()); - // } - // - // List topics = properties.getDataServiceContainer().getTopicDataService().selectAll(); - // for (TopicEntity topic : topics) { - // checkConfigs.add(HealthCheckObjectConfig.builder() - // .instanceId(topic.getId()) - // .healthCheckResourceType(HealthCheckTypeConstant.HEALTH_CHECK_TYPE_TOPIC) - // .build()); - // checkResultEntities.add(HealthCheckResultEntity.builder() - // .clusterId(topic.getClusterId()) - // .type(3) - // .typeId(topic.getId()) - // .state(4) - // .resultDesc("initializing check client") - // .build()); - // } - - List stores = dataServiceWrapper.getStoreDataService().selectAll(); - for (StoreEntity store : stores) { - checkConfigs.add(HealthCheckObjectConfig.builder() - .instanceId(store.getId()) - .clusterId(store.getClusterId()) - .healthCheckResourceType(HealthCheckTypeConstant.HEALTH_CHECK_TYPE_STORAGE) - .healthCheckResourceSubType( - StoreType.fromNumber(store.getStoreType()).toString()) - .host(store.getHost()) - .port(store.getPort()) - .build()); - HealthCheckResultEntity healthCheckResultEntity = new HealthCheckResultEntity(); - healthCheckResultEntity.setClusterId(store.getClusterId()); - healthCheckResultEntity.setType(4); - healthCheckResultEntity.setTypeId(store.getId()); - healthCheckResultEntity.setState(4); - healthCheckResultEntity.setResultDesc("initializing check client"); - checkResultEntities.add(healthCheckResultEntity); - } - - dataServiceWrapper.getHealthDataService().batchInsertNewCheckResult(checkResultEntities); - this.replaceCheckService(checkConfigs); - } catch (Exception e) { - log.error("updateHealthCheckConfigs error", e); - } - } -} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/annotation/HealthCheckType.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/annotation/HealthCheckType.java index 43de45cc..6e293608 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/annotation/HealthCheckType.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/annotation/HealthCheckType.java @@ -15,8 +15,12 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.function.health.annotation; +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.common.enums.health.HealthCheckTypeEnum; + import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -25,19 +29,15 @@ /** * This annotation is used to mark the type of health check service implement. * - * @see org.apache.eventmesh.dashboard.common.enums.health.HealthCheckType + * @see HealthCheckTypeEnum */ @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) public @interface HealthCheckType { - /** - * type of resource. runtime, topic etc. - */ - String type(); - /** - * subtype of resource. For resource storage, it can be redis, rocketmq etc. - */ - String subType() default ""; + ClusterType[] clusterType(); + + + HealthCheckTypeEnum healthType() default HealthCheckTypeEnum.PING; } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/callback/HealthCheckCallback.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/callback/HealthCheckCallback.java index 1229b234..5d4b8c0a 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/callback/HealthCheckCallback.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/callback/HealthCheckCallback.java @@ -15,14 +15,11 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.function.health.callback; -import org.apache.eventmesh.dashboard.console.function.health.HealthExecutor; +package org.apache.eventmesh.dashboard.console.function.health.callback; /** - * Callback used by HealthService.doCheck to notify the caller of the result of the health check.

* - * @see HealthExecutor */ public interface HealthCheckCallback { diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/AbstractHealthCheckService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/AbstractHealthCheckService.java index 3a3ab99d..6123866b 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/AbstractHealthCheckService.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/AbstractHealthCheckService.java @@ -15,9 +15,12 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.function.health.check; -import org.apache.eventmesh.dashboard.console.function.health.check.config.HealthCheckObjectConfig; +import org.apache.eventmesh.dashboard.console.function.health.callback.HealthCheckCallback; +import org.apache.eventmesh.dashboard.core.function.SDK.AbstractClientInfo; +import org.apache.eventmesh.dashboard.core.function.SDK.SDKTypeEnum; import lombok.Getter; @@ -25,13 +28,43 @@ * extends */ @Getter -public abstract class AbstractHealthCheckService implements HealthCheckService { +public abstract class AbstractHealthCheckService extends AbstractClientInfo implements HealthCheckService { + + + private volatile boolean endCheck = true; + - private final HealthCheckObjectConfig config; + public SDKTypeEnum getSDKTypeEnum() { + return SDKTypeEnum.PING; + } + + public void check(HealthCheckCallback callback) throws Exception { + this.endCheck = false; + try { + this.doCheck(callback); + } catch (Exception e) { + this.endCheck = true; + callback.onFail(e); + } - public AbstractHealthCheckService(HealthCheckObjectConfig healthCheckObjectConfig) { - this.config = healthCheckObjectConfig; - this.init(); } + public abstract void doCheck(HealthCheckCallback callback) throws Exception; + + public void setEndCheck() { + this.endCheck = true; + } + + protected boolean isEndCheck() { + return this.endCheck; + } + + @Override + public void init() throws Exception { + } + + @Override + public void destroy() throws Exception{ + + } } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/AbstractTopicHealthCheckService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/AbstractTopicHealthCheckService.java new file mode 100644 index 00000000..0d93191b --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/AbstractTopicHealthCheckService.java @@ -0,0 +1,64 @@ +/* + * 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.function.health.check; + +import java.util.Objects; +import java.util.concurrent.atomic.AtomicLong; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; + +import lombok.Getter; +import lombok.Setter; + +public abstract class AbstractTopicHealthCheckService extends AbstractHealthCheckService { + + @Setter + @Getter + private Integer offset = 0; + + @Setter + @Getter + private Integer queue = 0; + + private AtomicLong atomicLong = new AtomicLong(); + + protected byte[] messageContext() { + return ("{ 'uid': " + atomicLong.incrementAndGet() + "}").getBytes(); + } + + protected boolean isCurrentValue(String context) { + if (Objects.isNull(context)) { + return false; + } + JSONObject json = JSON.parseObject(context); + if (Objects.isNull(json.get("uid"))) { + return false; + } + return Objects.equals(Integer.valueOf(json.get("uid").toString()), atomicLong.get()); + } + + protected boolean isCurrentValue(byte[] context) { + if (Objects.isNull(context)) { + return false; + } + return this.isCurrentValue(new String(context)); + } + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/ClusterHealthCheckService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/ClusterHealthCheckService.java new file mode 100644 index 00000000..4ce938db --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/ClusterHealthCheckService.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.console.function.health.check; + +import org.apache.eventmesh.dashboard.common.model.base.BaseSyncBase; + +/** + * + */ +public interface ClusterHealthCheckService { + + + + + AbstractTopicHealthCheckService register(BaseSyncBase baseSyncBase); + + + void unRegister(BaseSyncBase baseSyncBase); + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/HealthCheckService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/HealthCheckService.java index 98f666f5..185b539c 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/HealthCheckService.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/HealthCheckService.java @@ -15,9 +15,9 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.function.health.check; -import org.apache.eventmesh.dashboard.console.function.health.HealthExecutor; import org.apache.eventmesh.dashboard.console.function.health.callback.HealthCheckCallback; /** @@ -27,15 +27,11 @@ */ public interface HealthCheckService { - /** - * Do the health check.

To implement a new check service, add the necessary logic to call the success and fail functions of the callback. - * - * @param callback The behaviour of the callback is defined as a lambda function when used. Please refer to {@link HealthExecutor} for usage. - */ - public void doCheck(HealthCheckCallback callback); - public void init(); + void check(HealthCheckCallback callback) throws Exception; + + void init() throws Exception; - public void destroy(); + void destroy() throws Exception; } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/config/HealthCheckObjectConfig.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/config/HealthCheckObjectConfig.java deleted file mode 100644 index 5ca93091..00000000 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/config/HealthCheckObjectConfig.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.console.function.health.check.config; - -import java.util.Properties; - -import lombok.AllArgsConstructor; -import lombok.Builder.Default; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; - -@Data -@NoArgsConstructor -@AllArgsConstructor -@SuperBuilder -public class HealthCheckObjectConfig { - - private Long instanceId; - - private String healthCheckResourceType; - - @Default - private String healthCheckResourceSubType = ""; - - private String simpleClassName; - - private Class checkClass; - - private Properties eventmeshProperties; - - private Long clusterId; - - //Prioritize passing in this field for a url. - //redis, nacos - private String connectUrl; - - //redis - private String host; - - private Integer port; - - private String username; - - private String password; - - //mysql, redis - private String database; - - @Default - private Long requestTimeoutMillis = 100000L; - - @Default - private RocketmqConfig rocketmqConfig = new RocketmqConfig(); - -} \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/HealthRegister.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/HealthRegister.java new file mode 100644 index 00000000..55757960 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/HealthRegister.java @@ -0,0 +1,30 @@ +/* + * 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.function.health.check.impl; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.console.function.health.annotation.HealthCheckType; + +public @interface HealthRegister { + + ClusterType clusterType(); + + HealthCheckType healthCheckType(); + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/jvm/JVMCapCheck.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/jvm/JVMCapCheck.java new file mode 100644 index 00000000..71ce0e45 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/jvm/JVMCapCheck.java @@ -0,0 +1,35 @@ +/* + * 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.function.health.check.impl.jvm; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.common.enums.health.HealthCheckTypeEnum; +import org.apache.eventmesh.dashboard.console.function.health.annotation.HealthCheckType; +import org.apache.eventmesh.dashboard.console.function.health.callback.HealthCheckCallback; +import org.apache.eventmesh.dashboard.console.function.health.check.AbstractHealthCheckService; +import org.apache.eventmesh.dashboard.core.function.SDK.wrapper.NacosSDKWrapper; + +@HealthCheckType(clusterType = {ClusterType.STORAGE_JVM_CAP_BROKER}, healthType = HealthCheckTypeEnum.PING) +public class JVMCapCheck extends AbstractHealthCheckService { + + @Override + public void doCheck(HealthCheckCallback callback) throws Exception { + + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/jvm/JVMCapTopicCheck.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/jvm/JVMCapTopicCheck.java new file mode 100644 index 00000000..e4ba2adf --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/jvm/JVMCapTopicCheck.java @@ -0,0 +1,35 @@ +/* + * 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.function.health.check.impl.jvm; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.common.enums.health.HealthCheckTypeEnum; +import org.apache.eventmesh.dashboard.console.function.health.annotation.HealthCheckType; +import org.apache.eventmesh.dashboard.console.function.health.callback.HealthCheckCallback; +import org.apache.eventmesh.dashboard.console.function.health.check.AbstractHealthCheckService; +import org.apache.eventmesh.dashboard.core.function.SDK.wrapper.NacosSDKWrapper; + +@HealthCheckType(clusterType = {ClusterType.STORAGE_JVM_CAP_BROKER}, healthType = HealthCheckTypeEnum.TOPIC) +public class JVMCapTopicCheck extends AbstractHealthCheckService { + + @Override + public void doCheck(HealthCheckCallback callback) throws Exception { + + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/jvm/JVMCheck.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/jvm/JVMCheck.java new file mode 100644 index 00000000..acaf8475 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/jvm/JVMCheck.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.console.function.health.check.impl.jvm; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.common.enums.health.HealthCheckTypeEnum; +import org.apache.eventmesh.dashboard.console.function.health.annotation.HealthCheckType; +import org.apache.eventmesh.dashboard.console.function.health.callback.HealthCheckCallback; +import org.apache.eventmesh.dashboard.console.function.health.check.AbstractHealthCheckService; +import org.apache.eventmesh.dashboard.core.function.SDK.wrapper.NacosSDKWrapper; + +@HealthCheckType(clusterType = {ClusterType.STORAGE_JVM_BROKER}, healthType = HealthCheckTypeEnum.PING) +public class JVMCheck extends AbstractHealthCheckService { + + @Override + public void doCheck(HealthCheckCallback callback) throws Exception { + Thread.sleep(2000); + callback.onSuccess(); + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/jvm/JVMTopicCheck.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/jvm/JVMTopicCheck.java new file mode 100644 index 00000000..cfe8c762 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/jvm/JVMTopicCheck.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.console.function.health.check.impl.jvm; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.common.enums.health.HealthCheckTypeEnum; +import org.apache.eventmesh.dashboard.console.function.health.annotation.HealthCheckType; +import org.apache.eventmesh.dashboard.console.function.health.callback.HealthCheckCallback; +import org.apache.eventmesh.dashboard.console.function.health.check.AbstractHealthCheckService; +import org.apache.eventmesh.dashboard.core.function.SDK.wrapper.NacosSDKWrapper; + +@HealthCheckType(clusterType = {ClusterType.STORAGE_JVM_BROKER}, healthType = HealthCheckTypeEnum.TOPIC) +public class JVMTopicCheck extends AbstractHealthCheckService { + + @Override + public void doCheck(HealthCheckCallback callback) throws Exception { + Thread.sleep(2000); + callback.onSuccess(); + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/meta/NacosConfigCheck.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/meta/NacosConfigCheck.java index 850738b7..37616061 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/meta/NacosConfigCheck.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/meta/NacosConfigCheck.java @@ -15,24 +15,21 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.function.health.check.impl.meta; -import static org.apache.eventmesh.dashboard.common.constant.health.HealthCheckTypeConstant.HEALTH_CHECK_SUBTYPE_NACOS_CONFIG; -import static org.apache.eventmesh.dashboard.common.constant.health.HealthCheckTypeConstant.HEALTH_CHECK_TYPE_META; import static org.apache.eventmesh.dashboard.common.constant.health.HealthConstant.NACOS_CHECK_CONTENT; import static org.apache.eventmesh.dashboard.common.constant.health.HealthConstant.NACOS_CHECK_DATA_ID; import static org.apache.eventmesh.dashboard.common.constant.health.HealthConstant.NACOS_CHECK_GROUP; +import org.apache.eventmesh.dashboard.common.enums.ClusterType; import org.apache.eventmesh.dashboard.console.function.health.annotation.HealthCheckType; import org.apache.eventmesh.dashboard.console.function.health.callback.HealthCheckCallback; import org.apache.eventmesh.dashboard.console.function.health.check.AbstractHealthCheckService; -import org.apache.eventmesh.dashboard.console.function.health.check.config.HealthCheckObjectConfig; +import org.apache.eventmesh.dashboard.core.function.SDK.wrapper.NacosSDKWrapper; -import java.util.Properties; import java.util.concurrent.CompletableFuture; -import com.alibaba.nacos.api.NacosFactory; -import com.alibaba.nacos.api.config.ConfigService; import com.alibaba.nacos.api.exception.NacosException; import lombok.extern.slf4j.Slf4j; @@ -41,20 +38,15 @@ * Interface to check the state of nacos */ @Slf4j -@HealthCheckType(type = HEALTH_CHECK_TYPE_META, subType = HEALTH_CHECK_SUBTYPE_NACOS_CONFIG) -public class NacosConfigCheck extends AbstractHealthCheckService { - - private ConfigService configService; +@HealthCheckType(clusterType = {ClusterType.EVENTMESH_META_NACOS}) +public class NacosConfigCheck extends AbstractHealthCheckService { - public NacosConfigCheck(HealthCheckObjectConfig healthCheckObjectConfig) { - super(healthCheckObjectConfig); - } @Override public void doCheck(HealthCheckCallback callback) { CompletableFuture.runAsync(() -> { try { - String content = configService.getConfig(NACOS_CHECK_DATA_ID, NACOS_CHECK_GROUP, getConfig().getRequestTimeoutMillis()); + String content = this.getClient().getConfigService().getConfig(NACOS_CHECK_DATA_ID, NACOS_CHECK_GROUP, 3000); if (NACOS_CHECK_CONTENT.equals(content)) { callback.onSuccess(); } else { @@ -66,40 +58,4 @@ public void doCheck(HealthCheckCallback callback) { }); } - @Override - public void init() { - //create a config - try { - Properties properties = new Properties(); - properties.put("serverAddr", getConfig().getConnectUrl()); - ConfigService configService = NacosFactory.createConfigService(properties); - boolean isPublishOk = configService.publishConfig(NACOS_CHECK_DATA_ID, NACOS_CHECK_GROUP, - NACOS_CHECK_CONTENT); - if (!isPublishOk) { - log.error("NacosCheck init failed caused by crate config failed"); - } - } catch (NacosException e) { - log.error("NacosCheck init failed caused by {}", e.getErrMsg()); - } - - try { - Properties properties = new Properties(); - properties.put("serverAddr", getConfig().getConnectUrl()); - configService = NacosFactory.createConfigService(properties); - } catch (NacosException e) { - log.error("NacosCheck init failed caused by {}", e.getErrMsg()); - } - } - - @Override - public void destroy() { - if (configService != null) { - try { - configService.removeConfig(NACOS_CHECK_DATA_ID, NACOS_CHECK_GROUP); - } catch (NacosException e) { - log.error("NacosCheck destroy failed caused by {}", e.getErrMsg()); - } - - } - } } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/meta/NacosNamingServiceCheck.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/meta/NacosNamingServiceCheck.java index 0313cee9..39e198b8 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/meta/NacosNamingServiceCheck.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/meta/NacosNamingServiceCheck.java @@ -15,24 +15,19 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.function.health.check.impl.meta; -import static org.apache.eventmesh.dashboard.common.constant.health.HealthCheckTypeConstant.HEALTH_CHECK_SUBTYPE_NACOS_REGISTRY; -import static org.apache.eventmesh.dashboard.common.constant.health.HealthCheckTypeConstant.HEALTH_CHECK_TYPE_META; -import static org.apache.eventmesh.dashboard.common.constant.health.HealthConstant.NACOS_CHECK_SERVICE_CLUSTER_NAME; import static org.apache.eventmesh.dashboard.common.constant.health.HealthConstant.NACOS_CHECK_SERVICE_NAME; +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.common.enums.health.HealthCheckTypeEnum; import org.apache.eventmesh.dashboard.console.function.health.annotation.HealthCheckType; import org.apache.eventmesh.dashboard.console.function.health.callback.HealthCheckCallback; import org.apache.eventmesh.dashboard.console.function.health.check.AbstractHealthCheckService; -import org.apache.eventmesh.dashboard.console.function.health.check.config.HealthCheckObjectConfig; - -import java.util.Properties; -import java.util.concurrent.CompletableFuture; +import org.apache.eventmesh.dashboard.core.function.SDK.wrapper.NacosSDKWrapper; import com.alibaba.nacos.api.exception.NacosException; -import com.alibaba.nacos.api.naming.NamingFactory; -import com.alibaba.nacos.api.naming.NamingService; import com.alibaba.nacos.api.naming.pojo.Instance; import lombok.extern.slf4j.Slf4j; @@ -42,20 +37,15 @@ */ @Slf4j -@HealthCheckType(type = HEALTH_CHECK_TYPE_META, subType = HEALTH_CHECK_SUBTYPE_NACOS_REGISTRY) -public class NacosNamingServiceCheck extends AbstractHealthCheckService { +@HealthCheckType(clusterType = {ClusterType.EVENTMESH_META_NACOS}, healthType = HealthCheckTypeEnum.PING) +public class NacosNamingServiceCheck extends AbstractHealthCheckService { - private NamingService namingService; - - public NacosNamingServiceCheck(HealthCheckObjectConfig healthCheckObjectConfig) { - super(healthCheckObjectConfig); - } @Override public void doCheck(HealthCheckCallback callback) { - CompletableFuture.runAsync(() -> { + this.completableFuture(() -> { try { - Instance result = namingService.selectOneHealthyInstance(NACOS_CHECK_SERVICE_NAME); + Instance result = this.getClient().getNamingService().selectOneHealthyInstance(NACOS_CHECK_SERVICE_NAME); if (result.isHealthy()) { callback.onSuccess(); } else { @@ -63,30 +53,7 @@ public void doCheck(HealthCheckCallback callback) { } } catch (NacosException e) { callback.onFail(e); - } finally { - destroy(); } }); } - - @Override - public void init() { - try { - Properties properties = new Properties(); - properties.put("serverAddr", getConfig().getConnectUrl()); - namingService = NamingFactory.createNamingService(properties); - namingService.registerInstance(NACOS_CHECK_SERVICE_NAME, "11.11.11.11", 8888, NACOS_CHECK_SERVICE_CLUSTER_NAME); - } catch (NacosException e) { - log.error("NacosRegistryCheck init failed", e); - } - } - - @Override - public void destroy() { - try { - namingService.deregisterInstance(NACOS_CHECK_SERVICE_NAME, "11.11.11.11", 8888, NACOS_CHECK_SERVICE_CLUSTER_NAME); - } catch (NacosException e) { - log.error("NacosRegistryCheck destroy failed", e); - } - } } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/RedisCheck.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/RedisCheck.java index 3cad4553..505583e2 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/RedisCheck.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/RedisCheck.java @@ -15,84 +15,37 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.function.health.check.impl.storage; -import org.apache.eventmesh.dashboard.common.constant.health.HealthCheckTypeConstant; +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.common.enums.health.HealthCheckTypeEnum; import org.apache.eventmesh.dashboard.console.function.health.annotation.HealthCheckType; import org.apache.eventmesh.dashboard.console.function.health.callback.HealthCheckCallback; import org.apache.eventmesh.dashboard.console.function.health.check.AbstractHealthCheckService; -import org.apache.eventmesh.dashboard.console.function.health.check.config.HealthCheckObjectConfig; -import org.apache.eventmesh.dashboard.core.function.SDK.SDKManager; -import org.apache.eventmesh.dashboard.core.function.SDK.SDKTypeEnum; -import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateRedisConfig; - -import java.time.Duration; -import java.util.Objects; -import io.lettuce.core.RedisURI; -import io.lettuce.core.RedisURI.Builder; import io.lettuce.core.api.StatefulRedisConnection; import io.lettuce.core.api.async.RedisAsyncCommands; import lombok.extern.slf4j.Slf4j; @Slf4j -@HealthCheckType(type = HealthCheckTypeConstant.HEALTH_CHECK_TYPE_STORAGE, subType = HealthCheckTypeConstant.HEALTH_CHECK_SUBTYPE_REDIS) -public class RedisCheck extends AbstractHealthCheckService { - - private CreateRedisConfig sdkConfig; - - public RedisCheck(HealthCheckObjectConfig healthCheckObjectConfig) { - super(healthCheckObjectConfig); - } - - @Override - public void doCheck(HealthCheckCallback callback) { - try { - StatefulRedisConnection connection = (StatefulRedisConnection) SDKManager.getInstance() - .getClient(SDKTypeEnum.STORAGE_REDIS, sdkConfig.getUniqueKey()); - RedisAsyncCommands commands = connection.async(); - commands.ping().thenAccept(result -> { - callback.onSuccess(); - }).exceptionally(e -> { - if (e instanceof Exception) { - callback.onFail((Exception) e); - } else { - callback.onFail(new RuntimeException("RedisCheck failed.")); - } - return null; - }); - } catch (Exception e) { - log.error(e.toString()); - callback.onFail(e); - } - } +@HealthCheckType(clusterType = {ClusterType.STORAGE_REDIS_BROKER}, healthType = HealthCheckTypeEnum.PING) +public class RedisCheck extends AbstractHealthCheckService> { @Override - public void init() { - String redisUrl; - sdkConfig = new CreateRedisConfig(); - if (Objects.nonNull(getConfig().getConnectUrl()) && !getConfig().getConnectUrl().isEmpty()) { - redisUrl = getConfig().getConnectUrl(); - } else { - Builder builder = RedisURI.Builder.redis(getConfig().getHost(), getConfig().getPort()); - if (Objects.nonNull(getConfig().getUsername()) && Objects.nonNull(getConfig().getPassword())) { - builder.withAuthentication(getConfig().getUsername(), getConfig().getPassword()); - } - if (Objects.nonNull(getConfig().getRequestTimeoutMillis())) { - builder.withTimeout(Duration.ofMillis(getConfig().getRequestTimeoutMillis())); + public void doCheck(HealthCheckCallback callback) throws Exception { + RedisAsyncCommands commands = this.getClient().async(); + commands.ping().thenAccept(result -> { + callback.onSuccess(); + }).exceptionally(e -> { + if (e instanceof Exception) { + callback.onFail((Exception) e); + } else { + callback.onFail(new RuntimeException("RedisCheck failed.")); } - if (Objects.nonNull(getConfig().getDatabase())) { - builder.withDatabase(Integer.parseInt(getConfig().getDatabase())); - } - redisUrl = builder.build().toString(); - } - sdkConfig.setRedisUrl(redisUrl); - SDKManager.getInstance().createClient(SDKTypeEnum.STORAGE_REDIS, sdkConfig); + return null; + }); } - @Override - public void destroy() { - SDKManager.getInstance().deleteClient(SDKTypeEnum.STORAGE_REDIS, sdkConfig.getUniqueKey()); - } } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/RocketMQClusterHealthCheckService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/RocketMQClusterHealthCheckService.java new file mode 100644 index 00000000..04909c20 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/RocketMQClusterHealthCheckService.java @@ -0,0 +1,218 @@ +/* + * 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.function.health.check.impl.storage.rocketmq4; + +import org.apache.eventmesh.dashboard.common.constant.health.HealthConstant; +import org.apache.eventmesh.dashboard.console.function.health.callback.HealthCheckCallback; +import org.apache.eventmesh.dashboard.console.function.health.check.AbstractTopicHealthCheckService; +import org.apache.eventmesh.dashboard.core.function.SDK.operation.rocketmq.RocketMQRemotingSDKOperation.DefaultRemotingClient; + +import org.apache.rocketmq.client.exception.MQBrokerException; +import org.apache.rocketmq.client.exception.MQClientException; +import org.apache.rocketmq.common.TopicFilterType; +import org.apache.rocketmq.common.constant.PermName; +import org.apache.rocketmq.common.message.Message; +import org.apache.rocketmq.remoting.InvokeCallback; +import org.apache.rocketmq.remoting.exception.RemotingConnectException; +import org.apache.rocketmq.remoting.exception.RemotingException; +import org.apache.rocketmq.remoting.exception.RemotingSendRequestException; +import org.apache.rocketmq.remoting.exception.RemotingTimeoutException; +import org.apache.rocketmq.remoting.netty.ResponseFuture; +import org.apache.rocketmq.remoting.protocol.RemotingCommand; +import org.apache.rocketmq.remoting.protocol.RemotingSerializable; +import org.apache.rocketmq.remoting.protocol.RequestCode; +import org.apache.rocketmq.remoting.protocol.ResponseCode; +import org.apache.rocketmq.remoting.protocol.header.CreateTopicRequestHeader; +import org.apache.rocketmq.remoting.protocol.header.GetTopicConfigRequestHeader; +import org.apache.rocketmq.remoting.protocol.header.PullMessageRequestHeader; +import org.apache.rocketmq.remoting.protocol.header.SendMessageRequestHeader; +import org.apache.rocketmq.remoting.protocol.statictopic.TopicConfigAndQueueMapping; + +import java.util.Objects; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.atomic.AtomicBoolean; + +import lombok.extern.slf4j.Slf4j; + + +@Slf4j +public class RocketMQClusterHealthCheckService extends AbstractTopicHealthCheckService { + + + private volatile boolean checkTopic = false; + + + public void doCheck(HealthCheckCallback callback) throws Exception { + if (!RocketMQClusterHealthCheckService.this.checkTopic) { + this.getTopicConfig(); + return; + } + try { + if (this.getBaseSyncBase().getReplicationType().isSlave()) { + this.sendMessage(callback); + } else { + this.consume(callback); + } + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + private void sendMessage(HealthCheckCallback callback) throws RemotingException, InterruptedException, MQClientException { + if (this.getBaseSyncBase().getReplicationType().isSlave()) { + return; + } + SendMessageRequestHeader requestHeader = new SendMessageRequestHeader(); + requestHeader.setProducerGroup(HealthConstant.ROCKETMQ_CHECK_PRODUCER_GROUP); + requestHeader.setTopic(HealthConstant.ROCKETMQ_CHECK_TOPIC); + requestHeader.setDefaultTopic(HealthConstant.ROCKETMQ_CHECK_TOPIC); + requestHeader.setDefaultTopicQueueNums(1); + requestHeader.setQueueId(1); + //requestHeader.setSysFlag(1); + requestHeader.setBornTimestamp(System.currentTimeMillis()); + //requestHeader.setFlag(msg.getFlag()); + requestHeader.setReconsumeTimes(0); + requestHeader.setUnitMode(false); + requestHeader.setBatch(false); + requestHeader.setBrokerName("127.0.0.1:9876"); + Message message = new Message(); + message.setTags(HealthConstant.ROCKETMQ_CHECK_TOPIC); + message.setBody(this.messageContext()); + RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.SEND_MESSAGE, requestHeader); + request.setBody(message.getBody()); + this.getClient().invokeAsync( + request, + 1000, + new InvokeCallback() { + + @Override + public void operationComplete(ResponseFuture responseFuture) { + + } + + public void operationSucceed(RemotingCommand response) { + if (Objects.equals(response.getCode(), ResponseCode.SUCCESS)) { + try { + consume(callback); + } catch (Exception e) { + callback.onFail(new RuntimeException(e)); + } + + } else { + callback.onFail(new RuntimeException("")); + } + } + + public void operationFail(Throwable throwable) { + callback.onFail(new RuntimeException(throwable)); + } + }); + + } + + private void consume(HealthCheckCallback callback) throws Exception { + PullMessageRequestHeader requestHeader = new PullMessageRequestHeader(); + requestHeader.setConsumerGroup(HealthConstant.GROUP); + requestHeader.setTopic(HealthConstant.ROCKETMQ_CHECK_TOPIC); + this.getClient().invokeAsync(null, 1000, new InvokeCallback() { + @Override + public void operationComplete(ResponseFuture responseFuture) { + + } + + @Override + public void operationSucceed(final RemotingCommand response) { + AtomicBoolean isSuccess = new AtomicBoolean(false); + if (isSuccess.get()) { + return; + } + try { + consume(callback); + } catch (Exception ex) { + callback.onFail(new RuntimeException(ex)); + } + } + + @Override + public void operationFail(final Throwable throwable) { + if (!isEndCheck()) { + try { + consume(callback); + } catch (Exception ex) { + callback.onFail(new RuntimeException(ex)); + } + } else { + callback.onFail(new RuntimeException(throwable)); + } + } + }); + } + + @Override + public void init() throws Exception { + this.getTopicConfig(); + } + + private void getTopicConfig() throws InterruptedException, + RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException, MQBrokerException { + GetTopicConfigRequestHeader header = new GetTopicConfigRequestHeader(); + header.setTopic(HealthConstant.ROCKETMQ_CHECK_TOPIC); + header.setLo(true); + RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_TOPIC_CONFIG, header); + RemotingCommand response = this.getClient().invokeSync(request, 3000); + assert response != null; + if (Objects.equals(response.getCode(), ResponseCode.SUCCESS)) { + TopicConfigAndQueueMapping topicConfigAndQueueMapping = + RemotingSerializable.decode(response.getBody(), TopicConfigAndQueueMapping.class); + ConcurrentMap queue = topicConfigAndQueueMapping.getMappingDetail().getCurrIdMap(); + if (queue.size() == 1) { + queue.forEach((k, value) -> { + this.setOffset(value); + this.setQueue(k); + }); + return; + } + RocketMQClusterHealthCheckService.this.checkTopic = true; + // 删除 topic + } + if (this.getBaseSyncBase().getReplicationType().isSlave()) { + return; + } + this.createTopic(); + } + + private void createTopic() throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException { + CreateTopicRequestHeader requestHeader = new CreateTopicRequestHeader(); + requestHeader.setTopic(HealthConstant.ROCKETMQ_CHECK_TOPIC); + requestHeader.setTopicFilterType(TopicFilterType.SINGLE_TAG.name()); + requestHeader.setReadQueueNums(1); + requestHeader.setWriteQueueNums(1); + requestHeader.setPerm(PermName.PERM_READ | PermName.PERM_WRITE); + RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.UPDATE_AND_CREATE_TOPIC, requestHeader); + RemotingCommand response = + this.getClient().invokeSync(request, 1000); + if (!Objects.equals(response.getCode(), ResponseCode.SUCCESS)) { + RocketMQClusterHealthCheckService.this.checkTopic = true; + } + } + + + ; + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/Rocketmq4BrokerCheck.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/Rocketmq4BrokerCheck.java index 58c144cd..bb1a6a4e 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/Rocketmq4BrokerCheck.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/Rocketmq4BrokerCheck.java @@ -15,84 +15,40 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.function.health.check.impl.storage.rocketmq4; import org.apache.eventmesh.dashboard.console.function.health.callback.HealthCheckCallback; import org.apache.eventmesh.dashboard.console.function.health.check.AbstractHealthCheckService; -import org.apache.eventmesh.dashboard.console.function.health.check.config.HealthCheckObjectConfig; -import org.apache.eventmesh.dashboard.core.function.SDK.SDKManager; -import org.apache.eventmesh.dashboard.core.function.SDK.SDKTypeEnum; import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateRocketmqConfig; +import org.apache.eventmesh.dashboard.core.function.SDK.operation.rocketmq.RocketMQRemotingSDKOperation.DefaultRemotingClient; import org.apache.rocketmq.remoting.InvokeCallback; -import org.apache.rocketmq.remoting.RemotingClient; import org.apache.rocketmq.remoting.netty.ResponseFuture; import org.apache.rocketmq.remoting.protocol.RemotingCommand; import org.apache.rocketmq.remoting.protocol.RequestCode; -import java.util.Objects; - import lombok.extern.slf4j.Slf4j; @Slf4j -public class Rocketmq4BrokerCheck extends AbstractHealthCheckService { +public class Rocketmq4BrokerCheck extends AbstractHealthCheckService { private CreateRocketmqConfig config; - public Rocketmq4BrokerCheck(HealthCheckObjectConfig healthCheckObjectConfig) { - super(healthCheckObjectConfig); - } - @Override - public void doCheck(HealthCheckCallback callback) { - try { - RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_BROKER_RUNTIME_INFO, null); - RemotingClient client = (RemotingClient) SDKManager.getInstance().getClient(SDKTypeEnum.STORAGE_ROCKETMQ_REMOTING, config.getUniqueKey()); - client.invokeAsync(getConfig().getRocketmqConfig().getBrokerUrl(), request, getConfig().getRequestTimeoutMillis(), - new InvokeCallback() { - @Override - public void operationComplete(ResponseFuture responseFuture) { - if (responseFuture.isSendRequestOK()) { - callback.onSuccess(); - } else { - callback.onFail(new RuntimeException("RocketmqNameServerCheck failed caused by " + responseFuture.getCause())); - } - } - - }); - } catch (Exception e) { - log.error("RocketmqCheck failed.", e); - callback.onFail(e); - } + public void doCheck(HealthCheckCallback callback) throws Exception { + RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_BROKER_RUNTIME_INFO, null); + this.getClient().invokeAsync(request, 3000, new InvokeCallback() { + @Override + public void operationComplete(ResponseFuture responseFuture) { + if (responseFuture.isSendRequestOK()) { + callback.onSuccess(); + } else { + callback.onFail(new RuntimeException("RocketmqNameServerCheck failed caused by " + responseFuture.getCause())); + } + } + }); } - @Override - public void init() { - setBrokerUrl(); - - config = new CreateRocketmqConfig(); - config.setBrokerUrl(getConfig().getRocketmqConfig().getBrokerUrl()); - SDKManager.getInstance().createClient(SDKTypeEnum.STORAGE_ROCKETMQ_REMOTING, config); - } - - private void setBrokerUrl() { - if (Objects.nonNull(getConfig().getRocketmqConfig()) && Objects.nonNull(getConfig().getRocketmqConfig().getBrokerUrl())) { - return; - } - if (Objects.nonNull(getConfig().getConnectUrl()) && !getConfig().getConnectUrl().isEmpty()) { - getConfig().getRocketmqConfig().setBrokerUrl(getConfig().getConnectUrl()); - return; - } - if (Objects.nonNull(getConfig().getHost()) && Objects.nonNull(getConfig().getPort())) { - getConfig().getRocketmqConfig().setBrokerUrl(getConfig().getHost() + ":" + getConfig().getPort()); - return; - } - throw new RuntimeException("RocketmqNameServerCheck init failed, brokerUrl is empty"); - } - - @Override - public void destroy() { - SDKManager.getInstance().deleteClient(SDKTypeEnum.STORAGE_ROCKETMQ_REMOTING, config.getUniqueKey()); - } -} +} \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/Rocketmq4NameServerCheck.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/Rocketmq4NameServerCheck.java index 3c26a06d..ace3f0aa 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/Rocketmq4NameServerCheck.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/Rocketmq4NameServerCheck.java @@ -15,86 +15,43 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.function.health.check.impl.storage.rocketmq4; -import org.apache.eventmesh.dashboard.common.constant.health.HealthCheckTypeConstant; +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.common.enums.health.HealthCheckTypeEnum; import org.apache.eventmesh.dashboard.console.function.health.annotation.HealthCheckType; import org.apache.eventmesh.dashboard.console.function.health.callback.HealthCheckCallback; import org.apache.eventmesh.dashboard.console.function.health.check.AbstractHealthCheckService; -import org.apache.eventmesh.dashboard.console.function.health.check.config.HealthCheckObjectConfig; -import org.apache.eventmesh.dashboard.core.function.SDK.SDKManager; -import org.apache.eventmesh.dashboard.core.function.SDK.SDKTypeEnum; -import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateRocketmqConfig; +import org.apache.eventmesh.dashboard.core.function.SDK.operation.rocketmq.RocketMQRemotingSDKOperation.DefaultRemotingClient; import org.apache.rocketmq.remoting.InvokeCallback; -import org.apache.rocketmq.remoting.RemotingClient; import org.apache.rocketmq.remoting.netty.ResponseFuture; import org.apache.rocketmq.remoting.protocol.RemotingCommand; import org.apache.rocketmq.remoting.protocol.RequestCode; -import java.util.Objects; - import lombok.extern.slf4j.Slf4j; @Slf4j -@HealthCheckType(type = HealthCheckTypeConstant.HEALTH_CHECK_TYPE_STORAGE, subType = HealthCheckTypeConstant.HEALTH_CHECK_SUBTYPE_ROCKETMQ) -public class Rocketmq4NameServerCheck extends AbstractHealthCheckService { +@HealthCheckType(clusterType = {ClusterType.STORAGE_ROCKETMQ_NAMESERVER}, healthType = HealthCheckTypeEnum.PING) +public class Rocketmq4NameServerCheck extends AbstractHealthCheckService { - private CreateRocketmqConfig config; - - public Rocketmq4NameServerCheck(HealthCheckObjectConfig healthCheckObjectConfig) { - super(healthCheckObjectConfig); - } @Override - public void doCheck(HealthCheckCallback callback) { - try { - RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_NAMESRV_CONFIG, null); - RemotingClient client = (RemotingClient) SDKManager.getInstance().getClient(SDKTypeEnum.STORAGE_ROCKETMQ_REMOTING, config.getUniqueKey()); - client.invokeAsync(getConfig().getRocketmqConfig().getNameServerUrl(), request, getConfig().getRequestTimeoutMillis(), - new InvokeCallback() { - @Override - public void operationComplete(ResponseFuture responseFuture) { - if (responseFuture.isSendRequestOK()) { - callback.onSuccess(); - } else { - callback.onFail(new RuntimeException("RocketmqNameServerCheck failed caused by " + responseFuture.getCause())); - } + public void doCheck(HealthCheckCallback callback) throws Exception { + RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_NAMESRV_CONFIG, null); + getClient().invokeAsync(request, 3000, + new InvokeCallback() { + @Override + public void operationComplete(ResponseFuture responseFuture) { + if (responseFuture.isSendRequestOK()) { + callback.onSuccess(); + } else { + callback.onFail(new RuntimeException("RocketmqNameServerCheck failed caused by " + responseFuture.getCause())); } + } - }); - } catch (Exception e) { - log.error("RocketmqCheck failed.", e); - callback.onFail(e); - } + }); } - @Override - public void init() { - setNameServerUrl(); - - config = new CreateRocketmqConfig(); - config.setNameServerUrl(getConfig().getRocketmqConfig().getNameServerUrl()); - SDKManager.getInstance().createClient(SDKTypeEnum.STORAGE_ROCKETMQ_REMOTING, config); - } - - private void setNameServerUrl() { - if (Objects.nonNull(getConfig().getRocketmqConfig().getNameServerUrl())) { - return; - } - if (Objects.nonNull(getConfig().getConnectUrl()) && !getConfig().getConnectUrl().isEmpty()) { - getConfig().getRocketmqConfig().setNameServerUrl(getConfig().getConnectUrl()); - return; - } - if (Objects.nonNull(getConfig().getHost()) && Objects.nonNull(getConfig().getPort())) { - getConfig().getRocketmqConfig().setNameServerUrl(getConfig().getHost() + ":" + getConfig().getPort()); - return; - } - throw new RuntimeException("RocketmqNameServerCheck init failed, NameServerUrl is empty"); - } - - @Override - public void destroy() { - - } } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/Rocketmq4TopicCheck.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/Rocketmq4TopicCheck.java index 3e7c4337..97d8e798 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/Rocketmq4TopicCheck.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/Rocketmq4TopicCheck.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.function.health.check.impl.storage.rocketmq4; import static org.apache.rocketmq.client.producer.SendStatus.SEND_OK; @@ -22,7 +23,7 @@ import org.apache.eventmesh.dashboard.common.constant.health.HealthConstant; import org.apache.eventmesh.dashboard.console.function.health.callback.HealthCheckCallback; import org.apache.eventmesh.dashboard.console.function.health.check.AbstractHealthCheckService; -import org.apache.eventmesh.dashboard.console.function.health.check.config.HealthCheckObjectConfig; +import org.apache.eventmesh.dashboard.core.function.SDK.operation.rocketmq.RocketMQRemotingSDKOperation.DefaultRemotingClient; import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer; import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext; @@ -55,7 +56,7 @@ import lombok.extern.slf4j.Slf4j; @Slf4j -public class Rocketmq4TopicCheck extends AbstractHealthCheckService { +public class Rocketmq4TopicCheck extends AbstractHealthCheckService { private RemotingClient remotingClient; @@ -67,9 +68,6 @@ public class Rocketmq4TopicCheck extends AbstractHealthCheckService { private BlockingQueue consumedMessages = new LinkedBlockingQueue<>(); - public Rocketmq4TopicCheck(HealthCheckObjectConfig healthCheckObjectConfig) { - super(healthCheckObjectConfig); - } @Override public void doCheck(HealthCheckCallback callback) { @@ -109,7 +107,7 @@ public void onException(Throwable e) { private synchronized void consume(HealthCheckCallback callback, String uuid) { try { - while (System.currentTimeMillis() - startTime < getConfig().getRequestTimeoutMillis()) { + while (System.currentTimeMillis() - startTime < 3000) { Message message = consumedMessages.poll(System.currentTimeMillis() - startTime, TimeUnit.MILLISECONDS); if (message != null) { log.debug("RocketmqTopicCheck consume message:{}", new String(message.getBody())); @@ -144,7 +142,7 @@ public void init() { requestHeader.setWriteQueueNums(8); requestHeader.setPerm(PermName.PERM_READ | PermName.PERM_WRITE); RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.UPDATE_AND_CREATE_TOPIC, requestHeader); - Object result = remotingClient.invokeSync(getConfig().getRocketmqConfig().getBrokerUrl(), request, getConfig().getRequestTimeoutMillis()); + Object result = this.getClient().invokeSync(request, 3000); log.info(result.toString()); } catch (Exception e) { log.error("RocketmqTopicCheck init failed when examining topic stats.", e); @@ -153,13 +151,13 @@ public void init() { try { producer = new DefaultMQProducer(HealthConstant.ROCKETMQ_CHECK_PRODUCER_GROUP); - producer.setNamesrvAddr(getConfig().getRocketmqConfig().getNameServerUrl()); + //producer.setNamesrvAddr(getConfig().getRocketmqConfig().getNameServerUrl()); producer.setCompressMsgBodyOverHowmuch(16); producer.start(); consumer = new DefaultMQPushConsumer(HealthConstant.ROCKETMQ_CHECK_CONSUMER_GROUP); consumer.setMessageModel(MessageModel.CLUSTERING); - consumer.setNamesrvAddr(getConfig().getRocketmqConfig().getNameServerUrl()); + //consumer.setNamesrvAddr(getConfig().getRocketmqConfig().getNameServerUrl()); consumer.subscribe(HealthConstant.ROCKETMQ_CHECK_TOPIC, "*"); consumer.registerMessageListener(new MessageListenerConcurrently() { @Override diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/design.md b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/design.md new file mode 100644 index 00000000..29d331a0 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/design.md @@ -0,0 +1,19 @@ + +## health +> 心跳分为 服务(runtime)心跳,topic心跳 + + + +## topic 心跳 +> 通过 topic 的读写,确认 存储节点的主功能正常。同时需要验证复制是否正常。验证复制是否监控的同时,可以验证 节点是否可以读写 + +#### 问题是:每个 存储的topic 方式不一样 ,同时 同步方式也不一样 +1. RocketMQ 使用主从集群。同时使用 raft 集群 +2. Kafka 集群使用同样节点 +3. pulusr 使用 book 作为存储,只能检查book +4. redis 会用主从集群。 raft 集群 +5. MySQL 主从 +6. eventmesh 是代理。需要每个 runtime 都发送,获得一次吗? + 1. 只需要从一个节点得到所有数据就行了。如果节点有问题。怎么办? + 2. 请求所有节点确认所有数据是正确的 +7. \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/MetadataServiceWrapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/MetadataServiceWrapper.java deleted file mode 100644 index 0c8656ef..00000000 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/MetadataServiceWrapper.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.console.function.metadata; - -import org.apache.eventmesh.dashboard.core.metadata.MetadataHandler; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Builder.Default; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -public class MetadataServiceWrapper { - - private SingleMetadataServiceWrapper dbToService; - - private SingleMetadataServiceWrapper serviceToDb; - - private Long cacheId; - - @Data - @AllArgsConstructor - @NoArgsConstructor - @Builder - public static class SingleMetadataServiceWrapper { - - /** - * true -> incremental updates false -> full volume updates - * - * @See MetadataManager - */ - @Default - private Boolean cache = true; - - - /** - * handler is the target of metadata, it will process the metadata from syncService - */ - private MetadataHandler handler; - } -} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/MetadataHandlerWrapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/MetadataHandlerWrapper.java deleted file mode 100644 index dce04d7c..00000000 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/MetadataHandlerWrapper.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.console.function.metadata.handler; - -import org.apache.eventmesh.dashboard.console.function.metadata.handler.db.ClusterMetadataHandlerToDbImpl; -import org.apache.eventmesh.dashboard.console.function.metadata.handler.db.ConfigMetadataHandlerToDbImpl; -import org.apache.eventmesh.dashboard.console.function.metadata.handler.db.GroupMetadataHandlerToDbImpl; -import org.apache.eventmesh.dashboard.console.function.metadata.handler.db.RuntimeMetadataHandlerToDbImpl; -import org.apache.eventmesh.dashboard.console.function.metadata.handler.db.TopicMetadataHandlerToDbImpl; -import org.apache.eventmesh.dashboard.console.spring.support.FunctionManagerLoader; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import lombok.Getter; - -/** - * MetadataHandlerWrapper is a wrapper class for all metadata handlers. It is used to inject all metadata handlers. - * - * @see FunctionManagerLoader - */ -@Getter -@Component -public class MetadataHandlerWrapper { - - @Autowired - private ClusterMetadataHandlerToDbImpl clusterMetadataHandlerToDb; - - @Autowired - private ConfigMetadataHandlerToDbImpl configMetadataHandlerToDb; - - @Autowired - private GroupMetadataHandlerToDbImpl groupMetadataHandlerToDb; - - - @Autowired - private RuntimeMetadataHandlerToDbImpl runtimeMetadataHandlerToDb; - - @Autowired - private TopicMetadataHandlerToDbImpl topicMetadataHandlerToDb; -} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/ClusterMetadataHandlerToDbImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/ClusterMetadataHandlerToDbImpl.java deleted file mode 100644 index f9a27432..00000000 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/ClusterMetadataHandlerToDbImpl.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.console.function.metadata.handler.db; - -import org.apache.eventmesh.dashboard.common.model.metadata.ClusterMetadata; -import org.apache.eventmesh.dashboard.common.model.remoting.GlobalRequest; -import org.apache.eventmesh.dashboard.console.service.cluster.ClusterService; -import org.apache.eventmesh.dashboard.core.metadata.MetadataHandler; - -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -@Service -public class ClusterMetadataHandlerToDbImpl implements MetadataHandler { - - @Autowired - private ClusterService clusterService; - - @Override - public void addMetadata(ClusterMetadata meta) { - //clusterService.addCluster(new ClusterEntity(meta)); - } - - @Override - public void addMetadata(List metadataList) { - /* List entityList = metadataList.stream() - .map(ClusterEntity::new) - .collect(Collectors.toList()); - clusterService.batchInsert(entityList);*/ - } - - @Override - public void deleteMetadata(ClusterMetadata meta) { - } - - @Override - public List getData() { - return null; - } - - @Override - public List getData(GlobalRequest globalRequest) { - return null; - } -} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/ConfigMetadataHandlerToDbImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/ConfigMetadataHandlerToDbImpl.java deleted file mode 100644 index 75494832..00000000 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/ConfigMetadataHandlerToDbImpl.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.console.function.metadata.handler.db; - -import org.apache.eventmesh.dashboard.common.model.metadata.ConfigMetadata; -import org.apache.eventmesh.dashboard.common.model.remoting.GlobalRequest; -import org.apache.eventmesh.dashboard.console.service.function.ConfigService; -import org.apache.eventmesh.dashboard.core.metadata.MetadataHandler; - -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import lombok.extern.slf4j.Slf4j; - -@Slf4j -@Service -public class ConfigMetadataHandlerToDbImpl implements MetadataHandler { - - @Autowired - private ConfigService configService; - - - @Override - public void addMetadata(ConfigMetadata meta) { - //configService.addConfig(new ConfigEntity(meta)); - } - - @Override - public void addMetadata(List meta) { - /* List entityList = meta.stream() - .map(ConfigEntity::new) - .collect(Collectors.toList());*/ - //configService.batchInsert(entityList); - } - - @Override - public void deleteMetadata(ConfigMetadata meta) { - //configService.deleteConfig(new ConfigEntity(meta)); - } - - @Override - public List getData() { - return null; - } - - @Override - public List getData(GlobalRequest globalRequest) { - return null; - } -} - diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/GroupMetadataHandlerToDbImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/GroupMetadataHandlerToDbImpl.java deleted file mode 100644 index 963c005a..00000000 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/GroupMetadataHandlerToDbImpl.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.console.function.metadata.handler.db; - -import org.apache.eventmesh.dashboard.common.model.metadata.GroupMetadata; -import org.apache.eventmesh.dashboard.common.model.remoting.GlobalRequest; -import org.apache.eventmesh.dashboard.console.service.message.GroupService; -import org.apache.eventmesh.dashboard.core.metadata.MetadataHandler; - -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -@Service -public class GroupMetadataHandlerToDbImpl implements MetadataHandler { - - @Autowired - GroupService groupService; - - @Override - public void addMetadata(GroupMetadata meta) { - /* meta.setMemberCount(0); - GroupEntity groupEntity = new GroupEntity(meta); - groupService.addGroup(groupEntity);*/ - } - - @Override - public void addMetadata(List metadata) { - /*List entityList = metadata.stream().map(GroupEntity::new).collect(Collectors.toList()); - groupService.batchInsert(entityList);*/ - } - - @Override - public void deleteMetadata(GroupMetadata meta) { - - } - - @Override - public List getData() { - return null; - } - - @Override - public List getData(GlobalRequest globalRequest) { - return null; - } -} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/RuntimeMetadataHandlerToDbImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/RuntimeMetadataHandlerToDbImpl.java deleted file mode 100644 index c8c064e9..00000000 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/RuntimeMetadataHandlerToDbImpl.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.console.function.metadata.handler.db; - -import org.apache.eventmesh.dashboard.common.enums.ClusterTrusteeshipType; -import org.apache.eventmesh.dashboard.common.enums.ClusterType; -import org.apache.eventmesh.dashboard.common.model.metadata.RuntimeMetadata; -import org.apache.eventmesh.dashboard.common.model.remoting.GlobalRequest; -import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; -import org.apache.eventmesh.dashboard.console.service.cluster.ClusterService; -import org.apache.eventmesh.dashboard.console.service.cluster.RuntimeService; -import org.apache.eventmesh.dashboard.core.metadata.MetadataHandler; - -import java.util.List; -import java.util.Objects; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import lombok.extern.slf4j.Slf4j; - -@Slf4j -@Service -public class RuntimeMetadataHandlerToDbImpl implements MetadataHandler { - - @Autowired - RuntimeService runtimeService; - - @Autowired - ClusterService clusterService; - - @Override - public void addMetadata(RuntimeMetadata meta) { - ClusterEntity cluster = null; - if (Objects.isNull(cluster)) { - log.info("new cluster detected syncing runtime, adding cluster to db, cluster:{}", meta.getClusterName()); - ClusterEntity clusterEntity = new ClusterEntity(); - clusterEntity.setId(0L); - clusterEntity.setClusterType(ClusterType.EVENTMESH_CLUSTER); - clusterEntity.setTrusteeshipType(ClusterTrusteeshipType.TRUSTEESHIP); - clusterEntity.setName(meta.getClusterName()); - clusterEntity.setVersion(""); - clusterEntity.setJmxProperties(""); - clusterEntity.setDescription(""); - clusterEntity.setAuthType(0); - clusterEntity.setRunState(0); - clusterService.insertCluster(clusterEntity); - } else { - cluster.setName(meta.getClusterName()); - clusterService.insertCluster(cluster); - } - if (Objects.isNull(meta.getClusterId())) { - //meta.setClusterId(ClusterCache.getINSTANCE().getClusterByName(meta.getClusterName()).getId()); - } - //runtimeService.addRuntime(new RuntimeEntity(meta)); - //RuntimeCache.getInstance().addRuntime(new RuntimeEntity(meta)); - - // 集群存在且不过时。 直接同步就可以。 - - // 集群不存在 or 集群存在且过时。那么需要全部读出来,整理 - - // 创建 cluster do cache - - // 在一个事务中,从 runtime 同步 元数据 - - // 读取 config , topic , acl ,user , group,订阅关系, - - // 同步成功修改 状态,同步成功,修改状态 - - // - } - - @Override - public void deleteMetadata(RuntimeMetadata meta) { - //runtimeService.deactivate(new RuntimeEntity(meta)); - - } - - @Override - public List getData() { - return null; - } - - @Override - public List getData(GlobalRequest globalRequest) { - return null; - } -} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/TopicMetadataHandlerToDbImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/TopicMetadataHandlerToDbImpl.java deleted file mode 100644 index ec86ca65..00000000 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/TopicMetadataHandlerToDbImpl.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.console.function.metadata.handler.db; - -import org.apache.eventmesh.dashboard.common.model.metadata.TopicMetadata; -import org.apache.eventmesh.dashboard.common.model.remoting.GlobalRequest; -import org.apache.eventmesh.dashboard.console.entity.StoreEntity; -import org.apache.eventmesh.dashboard.console.service.message.TopicService; -import org.apache.eventmesh.dashboard.console.service.store.StoreService; -import org.apache.eventmesh.dashboard.core.metadata.MetadataHandler; - -import java.net.URI; -import java.util.List; -import java.util.Objects; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import lombok.extern.slf4j.Slf4j; - -@Slf4j -@Service -public class TopicMetadataHandlerToDbImpl implements MetadataHandler { - - @Autowired - private TopicService topicService; - - @Autowired - private StoreService storeService; - - @Override - public void addMetadata(TopicMetadata meta) { - if (Objects.nonNull(meta.getConnectionUrl())) { - URI uri = URI.create(meta.getConnectionUrl()); - if (Objects.nonNull(uri.getHost()) && uri.getPort() != -1) { - StoreEntity store = storeService.selectByHostPort(uri.getHost(), uri.getPort()); - if (Objects.nonNull(store)) { - meta.setStorageId(store.getId()); - } - } - } - - //topicService.addTopic(new TopicEntity(meta)); - } - - @Override - public void deleteMetadata(TopicMetadata meta) { - topicService.deleteTopic(null); - } - - @Override - public List getData() { - return null; - } - - @Override - public List getData(GlobalRequest globalRequest) { - return null; - } -} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/syncservice/SyncDataServiceWrapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/syncservice/SyncDataServiceWrapper.java deleted file mode 100644 index 7b52922c..00000000 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/metadata/syncservice/SyncDataServiceWrapper.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.console.function.metadata.syncservice; - -import org.apache.eventmesh.dashboard.console.spring.support.FunctionManagerLoader; -import org.apache.eventmesh.dashboard.core.metadata.cluster.AclSyncFromClusterService; -import org.apache.eventmesh.dashboard.core.metadata.cluster.ConfigSyncFromClusterService; -import org.apache.eventmesh.dashboard.core.metadata.cluster.GroupSyncFromClusterService; -import org.apache.eventmesh.dashboard.core.metadata.cluster.InstanceUserFromClusterService; -import org.apache.eventmesh.dashboard.core.metadata.cluster.RuntimeSyncFromClusterService; -import org.apache.eventmesh.dashboard.core.metadata.cluster.TopicSyncFromClusterService; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import lombok.Getter; - -/** - * SyncDataServiceWrapper is a wrapper class for all sync services. It is used to inject all sync services. - * - * @see FunctionManagerLoader - */ -@Getter -@Component -public class SyncDataServiceWrapper { - - @Autowired - private AclSyncFromClusterService aclSyncFromClusterService; - - @Autowired - private ConfigSyncFromClusterService configSyncFromClusterService; - - @Autowired - private GroupSyncFromClusterService groupSyncFromClusterService; - - @Autowired - private RuntimeSyncFromClusterService runtimeSyncFromClusterService; - - @Autowired - private InstanceUserFromClusterService instanceUserFromClusterService; - - @Autowired - private TopicSyncFromClusterService topicSyncFromClusterService; -} 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 bd61b8d1..dedbc2d6 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 @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.log; import org.apache.eventmesh.dashboard.console.annotation.EmLog; @@ -35,6 +36,7 @@ import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; +import org.springframework.context.support.AbstractApplicationContext; import org.springframework.core.Ordered; import org.springframework.stereotype.Service; import org.springframework.util.ClassUtils; @@ -47,7 +49,7 @@ public class OprLog implements Ordered, ApplicationContextAware { private LogService logService; - private ApplicationContext applicationContext; + private AbstractApplicationContext applicationContext; @Pointcut("within(org.apache.eventmesh.dashboard.console.service..*)") @@ -57,16 +59,17 @@ public void pointCut() { @Around("pointCut()") public Object logStart(ProceedingJoinPoint joinPoint) throws Throwable { - if (Objects.isNull(this.logService)) { - this.logService = applicationContext.getBean(LogService.class); - } + EmLog declaredAnnotation = this.getTargetEmlog(joinPoint); //Get the Emlog annotation on the method if (Objects.isNull(declaredAnnotation)) { return joinPoint.proceed(); } + if (Objects.isNull(this.logService) && applicationContext.isActive()) { + this.logService = applicationContext.getBean(LogService.class); + } LogEntity logEntity = this.productLoEntity(declaredAnnotation, joinPoint); - logService.insertLog(logEntity); + logService.addLog(logEntity); logEntity.setEndTime(new Timestamp(System.currentTimeMillis())); Object proceed = null; try { @@ -119,6 +122,6 @@ public int getOrder() { @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { - this.applicationContext = applicationContext; + this.applicationContext = (AbstractApplicationContext) applicationContext; } } diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/exception/EventMeshException.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/SyncDataHandlerMapper.java similarity index 73% rename from eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/exception/EventMeshException.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/SyncDataHandlerMapper.java index 444e5301..967afb23 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/exception/EventMeshException.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/SyncDataHandlerMapper.java @@ -15,17 +15,22 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.common.exception; + +package org.apache.eventmesh.dashboard.console.mapper; + +import java.util.List; /** - * EventMesh Runtime side exception + * */ +public interface SyncDataHandlerMapper { + + void syncInsert(List entityList); + + void syncUpdate(List entityList); -public class EventMeshException extends BaseException { + void syncDelete(List entityList); - private static final long serialVersionUID = 5648256502005456586L; + List syncGet(T topicEntity); - public EventMeshException(String message) { - super(message); - } } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/AclMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/AclMapper.java index 92332df7..2a4cc923 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/AclMapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/AclMapper.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.mapper.cluster; import org.apache.eventmesh.dashboard.console.entity.cluster.AclEntity; @@ -33,18 +34,6 @@ @Mapper public interface AclMapper { - @Select("SELECT * FROM acl WHERE id=#{id}") - AclEntity selectById(AclEntity aclEntity); - - @Select("SELECT * FROM acl") - List selectAll(); - - @Update("UPDATE acl SET resource_type=#{resourceType} WHERE id=#{id}") - void updateResourceTypeById(AclEntity aclEntity); - - @Update("UPDATE acl SET status=0 WHERE id=#{id}") - void deleteById(AclEntity aclEntity); - @Insert({ ""}) @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") - Integer batchInsert(List aclEntities); + void batchInsert(List aclEntities); @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") @Insert("INSERT INTO acl (cluster_id, pattern, operation, permission_type, host, resource_type, resource_name, pattern_type)" + "VALUE (#{clusterId}, #{pattern}, #{operation}, #{permissionType}, #{host}, #{resourceType}, #{resourceName}, #{patternType})") void insert(AclEntity aclEntity); + @Update("UPDATE acl SET status=0 WHERE id=#{id}") + void deleteById(AclEntity aclEntity); + + @Update("UPDATE acl SET resource_type=#{resourceType} WHERE id=#{id}") + void updateResourceTypeById(AclEntity aclEntity); + @Select("SELECT * FROM acl") + List selectAll(); + + @Select("SELECT * FROM acl WHERE id=#{id}") + AclEntity selectById(AclEntity aclEntity); } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/ClientMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/ClientMapper.java index d75f78f0..7011ba4e 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/ClientMapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/ClientMapper.java @@ -15,9 +15,12 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.mapper.cluster; import org.apache.eventmesh.dashboard.console.entity.cluster.ClientEntity; +import org.apache.eventmesh.dashboard.console.mapper.SyncDataHandlerMapper; +import org.apache.eventmesh.dashboard.console.modle.cluster.client.QueryClientByUserFormDTO; import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Mapper; @@ -32,23 +35,8 @@ * Mybatis Mapper for the table of client. */ @Mapper -public interface ClientMapper { - - - @Select("SELECT * FROM `client` WHERE `host` = #{host} AND `port` = #{port} AND status = 1") - List selectByHostPort(ClientEntity clientEntity); +public interface ClientMapper extends SyncDataHandlerMapper { - @Select("SELECT * FROM `client` WHERE `id` = #{id}") - ClientEntity selectById(ClientEntity clientEntity); - - @Select("SELECT * FROM `client` WHERE `cluster_id` = #{clusterId}") - List selectByClusterId(ClientEntity clientEntity); - - @Update("UPDATE `client` SET status = 0, end_time = NOW() WHERE id = #{id}") - Integer deactivate(ClientEntity clientEntity); - - @Update("UPDATE `client` SET status = 0, end_time = NOW() WHERE `host` = #{host} AND `port` = #{port}") - Integer deActiveByHostPort(ClientEntity clientEntity); @Select({ ""}) @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") - Integer batchInsert(List clientEntityList); + void batchInsert(List clientEntityList); + + + @Select({""" + + """}) + List queryClientByUserForm(QueryClientByUserFormDTO queryClientByUserFormDTO); + + @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); + + @Select("SELECT * FROM `client` WHERE `cluster_id` = #{clusterId}") + List selectByClusterId(ClientEntity clientEntity); @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") @Insert( "INSERT INTO `client` (`cluster_id`, `name`, `platform`," - + "`language`, `pid`, `host`, `port`, `protocol`," - + "`status`, `config_ids`, `description`) " - + "VALUES (#{clusterId}, #{name}, #{platform}," - + "#{language}, #{pid}, #{host}, #{port}, #{protocol}," - + "#{status}, #{configIds}, #{description})" - + "ON DUPLICATE KEY UPDATE `status` = 1, `pid` = #{pid}, `config_ids` = #{configIds}, `host` = #{host}, `port` = #{port}") - void insert(ClientEntity clientEntity); + + "`language`, `pid`, `host`, `port`, `protocol`," + + "`status`, `config_ids`, `description`) " + + "VALUES (#{clusterId}, #{name}, #{platform}," + + "#{language}, #{pid}, #{host}, #{port}, #{protocol}," + + "#{status}, #{configIds}, #{description})" + + "ON DUPLICATE KEY UPDATE `status` = 1, `pid` = #{pid}, `config_ids` = #{configIds}, `host` = #{host}, `port` = #{port}") + Long insert(ClientEntity clientEntity); + + @Update("UPDATE `client` SET status = 0, end_time = NOW() WHERE id = #{id}") + void deactivate(ClientEntity clientEntity); + + @Update("UPDATE `client` SET status = 0, end_time = NOW() WHERE `host` = #{host} AND `port` = #{port}") + void deActiveByHostPort(ClientEntity clientEntity); + + + void syncInsert(List entityList); + + void syncUpdate(List entityList); + void syncDelete(List entityList); + List syncGet(ClientEntity topicEntity); } 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 a59c1a74..76ee9728 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 @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.mapper.cluster; import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; @@ -32,52 +33,115 @@ /** * cluster table operation - * */ - @Mapper public interface ClusterMapper { @Select("select * from cluster where id=#{id} and status=1") - ClusterEntity selectClusterById(ClusterEntity cluster); + ClusterEntity queryByClusterId(ClusterEntity cluster); + + + @Select(""" + select * from cluster where organization_id =#{organizationId} and cluster_type=#{clusterType} + """) + List queryClusterByOrganizationIdAndType(ClusterEntity clusterEntity); + + + @Select(""" + + """) + List queryRelationClusterByClusterIdAndType(ClusterEntity clusterEntity); + + + @Select(""" + + """) + List queryRelationshipClusterByClusterIdAndType(List clusterEntityList); @Select("select * from cluster where status=1") - List selectAllCluster(); + List queryAllCluster(); @Select("SELECT * FROM cluster where update_time > #{updateTime}") List selectClusterByUpdate(@Param("updateTime") long updateTime); - @Select({ - "" - }) + + + + @Select(""" + + """) Map queryHomeClusterData(ClusterIdDTO clusterIdDTO); - @Update({"update cluster set name=#{name},jmx_properties=#{jmxProperties},description=#{description},auth_type=#{authType},run_state=#{runState}", - " where id=#{id}" - }) + @Insert(""" + + """) + @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") + Integer batchInsert(List clusterEntities); + + + @Insert(""" + insert into cluster( organization_id, name ,cluster_type,version,trusteeship_type,first_to_whom,replication_type, + deploy_status_type,cluster_own_type,resources_config_id,deploy_script_id,description, + config,auth_type,jmx_properties) + values(#{organizationId}, #{name},#{clusterType},#{version},#{trusteeshipType},#{firstToWhom},#{replicationType}, + #{deployStatusType},#{clusterOwnType},#{resourcesConfigId},#{deployScriptId},#{description}, + #{config},#{authType},#{jmxProperties}) + """) + @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") + Integer insertCluster(ClusterEntity cluster); + + @Update(""" + + """) Integer updateClusterById(ClusterEntity cluster); @Update("UPDATE cluster SET status=0 WHERE id=#{id}") Integer deactivate(ClusterEntity clusterEntity); - @Insert({ - ""}) - @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") - Integer batchInsert(List clusterEntities); - @Insert({ - "insert into cluster(name,trusteeship_type,cluster_type,version,jmx_properties,description,auth_type)values", - "(#{name},#{c.trusteeshipType},#{c.clusterType},#{c.version},#{jmxProperties},#{regProperties},#{description},#{authType})" - }) - @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") - void insertCluster(ClusterEntity cluster); + @Select(""" + select * from cluster where id=#{id} for update + """) + ClusterEntity lockByClusterId(ClusterEntity clusterEntity); + + @Update(""" + update cluster set runtime_index= runtime_index + #{runtimeIndex} where id=#{id} + """) + Integer updateNumByClusterId(ClusterEntity clusterEntity); + } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/ClusterRelationshipMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/ClusterRelationshipMapper.java index a0ea6c2e..d5dac2f2 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/ClusterRelationshipMapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/ClusterRelationshipMapper.java @@ -15,13 +15,16 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.mapper.cluster; import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterAndRelationshipEntity; import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterRelationshipEntity; +import org.apache.eventmesh.dashboard.console.modle.DO.clusterRelationship.QueryListByClusterIdAndTypeDO; import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Options; import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Update; @@ -33,6 +36,43 @@ @Mapper public interface ClusterRelationshipMapper { + + @Select(""" + + """) + List queryClusterRelationshipEntityListByClusterId(QueryListByClusterIdAndTypeDO data); + + @Select(""" + + """) + List queryListByClusterIdAndType(QueryListByClusterIdAndTypeDO data); + + @Select({ " + """) + Integer batchClusterRelationshipEntry(List clusterRelationshipEntity); + @Insert(""" + insert into cluster_relationship (organization_id , cluster_type,cluster_id,relationship_type,relationship_id) + values(#{organizationId}, #{clusterType},#{clusterId},#{relationshipType},#{relationshipId}) + """) + @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") + Integer insertClusterRelationshipEntry(ClusterRelationshipEntity clusterRelationshipEntity); } - diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/ConnectionMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/ConnectionMapper.java index c9bab4cc..0cf2f3b5 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/ConnectionMapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/ConnectionMapper.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.mapper.cluster; import org.apache.eventmesh.dashboard.console.entity.cluster.ConnectionEntity; @@ -73,24 +74,12 @@ public List selectByClusterIdSourceTypeAndSourceIdAndCreateTim public List selectByClusterIdSinkTypeAndSinkIdAndCreateTimeRange(ConnectionEntity connectionEntity, @Param("startTime") Timestamp startTime, @Param("endTime") Timestamp endTime); - @Update("UPDATE connection SET status = 1, end_time = NOW() WHERE id = #{id}") - Integer endConnectionById(ConnectionEntity connectionEntity); - - //batch end - @Update({ - ""}) - Integer batchEndConnectionById(List connectionEntityList); - @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") @Insert("INSERT INTO connection (cluster_id, source_type, source_id," + " sink_type, sink_id, runtime_id, status, topic, group_id, description)" + " VALUES ( #{clusterId}, #{sourceType}, #{sourceId}, " + " #{sinkType}, #{sinkId}, #{runtimeId}, 1, #{topic}, #{groupId}, #{description})" + "ON DUPLICATE KEY UPDATE status = 1") - void insert(ConnectionEntity connectionEntity); + Long insert(ConnectionEntity connectionEntity); @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") @Insert({ @@ -104,7 +93,18 @@ public List selectByClusterIdSinkTypeAndSinkIdAndCreateTimeRan " ", "ON DUPLICATE KEY UPDATE status = 1", ""}) - Integer batchInsert(List connectionEntityList); + void batchInsert(List connectionEntityList); + + @Update("UPDATE connection SET status = 1, end_time = NOW() WHERE id = #{id}") + void endConnectionById(ConnectionEntity connectionEntity); + //batch end + @Update({ + ""}) + void batchEndConnectionById(List connectionEntityList); -} +} \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/InstanceUserMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/InstanceUserMapper.java deleted file mode 100644 index f9d8ff85..00000000 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/InstanceUserMapper.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.console.mapper.cluster; - -import org.apache.eventmesh.dashboard.console.entity.cluster.InstanceUserEntity; - -import org.apache.ibatis.annotations.Insert; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Options; -import org.apache.ibatis.annotations.Select; -import org.apache.ibatis.annotations.Update; - -import java.util.List; - -/** - * Mybatis Mapper for the table of instanceuser. - */ -@Mapper -public interface InstanceUserMapper { - - @Select("select * from instance_user where status=1") - List selectAll(); - - @Select("SELECT * FROM instance_user WHERE id=#{id} AND status=1") - InstanceUserEntity selectById(InstanceUserEntity instanceuserEntity); - - @Select("SELECT * FROM instance_user WHERE name=#{name} AND status=1") - List selectByName(InstanceUserEntity instanceuserEntity); - - @Update("UPDATE instance_user SET status=0 WHERE id=#{clusterId}") - Integer deleteInstanceUserById(InstanceUserEntity instanceuserEntity); - - @Update("UPDATE instance_user SET password=#{password} WHERE id=#{id}") - Integer updatePasswordById(InstanceUserEntity instanceuserentity); - - @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") - @Insert("INSERT INTO instance_user (id, instance_type, password, cluster_id, name, token, status) " - + "VALUES (#{id}, #{instanceType}, #{password}, #{clusterId}, #{name}, #{token},1)") - void insert(InstanceUserEntity instanceuserEntity); - -} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/NetConnectionMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/NetConnectionMapper.java index 865b8954..ea1b06a2 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/NetConnectionMapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/NetConnectionMapper.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.mapper.cluster; import org.apache.eventmesh.dashboard.console.entity.cluster.NetConnectionEntity; @@ -28,14 +29,13 @@ * 1. 添加 and 修改。没有控制层接口 * 2. 按照 cluster or runtime id and client(host and port) 查询 * 3. 按照时间进行统计 - * */ @Mapper public interface NetConnectionMapper { - List queryNetConnectionEntityListByFrom(NetConnectionEntity netConnectionEntity); Integer batchInsert(List netConnectionEntityList); + List queryNetConnectionEntityListByFrom(NetConnectionEntity netConnectionEntity); } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/RuntimeMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/RuntimeMapper.java index ed451265..f2f7a3fb 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/RuntimeMapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/RuntimeMapper.java @@ -15,9 +15,13 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.mapper.cluster; +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; +import org.apache.eventmesh.dashboard.console.mapper.SyncDataHandlerMapper; +import org.apache.eventmesh.dashboard.console.modle.DO.runtime.QueryRuntimeByBigExpandClusterDO; import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Mapper; @@ -32,59 +36,146 @@ * runtime table operation */ @Mapper -public interface RuntimeMapper { - - @Select("SELECT COUNT(*) FROM runtime WHERE cluster_id=#{clusterId} AND status=1") - Integer selectRuntimeNumByCluster(RuntimeEntity runtimeEntity); +public interface RuntimeMapper extends SyncDataHandlerMapper { + + @Select(""" + + """) + List getRuntimesToFrontByCluster(@Param("runtimeEntity") RuntimeEntity runtimeEntity); + + @Select(""" + + """) + /** + * 查询 子集群的主集群中的某个类型的集群。 + */ + List queryClusterRuntimeOnClusterSpecifyByClusterId(QueryRuntimeByBigExpandClusterDO queryRuntimeByBigExpandClusterDO); + + /** + * TODO 如何设计动态查询 + * 通过 本集群 查询 主集群中 特定依赖集群中 的 特定依赖集群的 runtime + *

比如 eventmesh runtime 得到所有存储的 meta集群信息

+ *
    + *
  1. 通过 eventmesh runtime id 以及 eventmesh cluster type 得到 eventmesh cluster id
  2. + *
  3. 通过 eventmesh cluster id 以及 storage cluster type(列表) or storage type 得到 storage cluster id
  4. + *
  5. 通过 storage cluster id 以及 storage meta type 列表) or meta type 得到 meta cluster id
  6. + *
  7. 通过 meta cluster id 得到 runtime
  8. + *
+ */ + @Select(""" + + """) + List queryRuntimeByBigExpandCluster(QueryRuntimeByBigExpandClusterDO queryRuntimeByBigExpandClusterDO); + + + @Select(""" + + """) + List queryRuntimeByClusterId(List clusterEntityList); - @Select("SELECT * FROM runtime WHERE status=1") - List selectAll(); @Select("select * from runtime where cluster_id=#{clusterid} and status=1") List selectRuntimeByCluster(RuntimeEntity runtimeEntity); + @Select("select COUNT(*) from runtime where cluster_id=#{clusterId} AND status=1") + Integer getRuntimeNumByCluster(RuntimeEntity runtimeEntity); + + @Select("select * from runtime where update_time = #{updateTime} and status=1") + List queryByUpdateTime(RuntimeEntity runtimeEntity); + + @Select("select * from runtime where id=#{id} and status=1") RuntimeEntity queryRuntimeEntityById(RuntimeEntity runtimeEntity); - @Select({ - ""}) - List selectRuntimesToFrontByCluster(@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") - Integer updateRuntimeByCluster(RuntimeEntity runtimeEntity); - - @Update("UPDATE runtime SET status=0 WHERE cluster_id=#{clusterId}") - Integer deleteRuntimeByCluster(RuntimeEntity runtimeEntity); - - @Update("UPDATE runtime SET status = 0 WHERE id = #{id}") - Integer deactivate(RuntimeEntity runtimeEntity); - - @Insert({ - ""}) + @Select("select * from runtime where status=1") + List queryAll(); + + @Update("UPDATE runtime SET port=#{port} ,jmx_port=#{jmxPort} ,status=#{status} where cluster_id=#{clusterId} AND status=1") + void updateRuntimeByCluster(RuntimeEntity runtimeEntity); + + @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); + + + @Insert(""" + + """) @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") - Integer batchInsert(List runtimeEntities); - - @Insert("INSERT INTO runtime (cluster_id, host, storage_cluster_id, port, jmx_port, start_timestamp, rack, status, " - + "endpoint_map) VALUES(#{clusterId},#{host},#{storageClusterId},#{port},#{jmxPort},NOW(),#{rack},#{status},#{endpointMap})" - + " ON DUPLICATE KEY UPDATE status=1,start_timestamp = now()") + void batchInsert(List runtimeEntities); + + @Insert(""" + insert into runtime( organization_id , cluster_id , name , cluster_type ,version ,host ,port ,trusteeship_type,first_to_whom, + replication_type, deploy_status_type, resources_config_id,deploy_script_id,create_script_content ,auth_type,jmx_port) + values(#{organizationId}, #{clusterId}, #{name}, #{clusterType},#{version},#{host},#{port},#{trusteeshipType},#{firstToWhom}, + #{replicationType}, #{deployStatusType},#{resourcesConfigId},#{deployScriptId},'',#{authType},#{jmxPort}) + ON DUPLICATE KEY UPDATE status=1,online_timestamp = now() + """) @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") void insertRuntime(RuntimeEntity runtimeEntity); + void syncInsert(List runtimeEntities); + + void syncUpdate(List runtimeEntities); + + void syncDelete(List runtimeEntities); + + + List syncGet(RuntimeEntity topicEntity); } 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 1c9d7be1..3ae4011a 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 @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.mapper.connector; import org.apache.eventmesh.dashboard.console.entity.connector.ConnectorEntity; @@ -45,20 +46,38 @@ public interface ConnectorMapper { @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, host, port) " + + "VALUES (#{clusterId}, #{name}, #{className}, #{type}, #{status}, #{podState}, #{configIds}, #{host}, #{port})" + + "ON DUPLICATE KEY UPDATE status = 1, pod_state = #{podState}, config_ids = #{configIds}, host = #{host}, port = #{port}") + Long insert(ConnectorEntity connectorEntity); + + @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") + @Insert({ + ""}) + void batchInsert(List connectorEntityList); + @Update("UPDATE connector SET status = 1 WHERE id = #{id}") - Integer active(ConnectorEntity connectorEntity); + void active(ConnectorEntity connectorEntity); @Update("UPDATE connector SET status = 0 WHERE id = #{id}") - Integer deActive(ConnectorEntity connectorEntity); + void deActive(ConnectorEntity connectorEntity); @Update("UPDATE connector SET pod_state = #{podState} WHERE id = #{id}") - Integer updatePodState(ConnectorEntity connectorEntity); + void updatePodState(ConnectorEntity connectorEntity); @Update("UPDATE connector SET config_ids = #{configIds} WHERE id = #{id}") - Integer updateConfigIds(ConnectorEntity connectorEntity); + void updateConfigIds(ConnectorEntity connectorEntity); @Update("UPDATE connector SET status = 0 WHERE cluster_id = #{clusterId}") - Integer deactivateByClusterId(ConnectorEntity connectorEntity); + void deactivateByClusterId(ConnectorEntity connectorEntity); @Update({ "" }) - Integer batchDeactivate(List connectorEntities); - - @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") - @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})" - + "ON DUPLICATE KEY UPDATE status = 1, pod_state = #{podState}, config_ids = #{configIds}, host = #{host}, port = #{port}") - void insert(ConnectorEntity connectorEntity); - - @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") - @Insert({ - ""}) - Integer batchInsert(List connectorEntityList); - + void batchDeactivate(List connectorEntities); } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/deploy/DeployScriptMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/deploy/DeployScriptMapper.java new file mode 100644 index 00000000..7b96b6e7 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/deploy/DeployScriptMapper.java @@ -0,0 +1,62 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.console.mapper.deploy; + +import org.apache.eventmesh.dashboard.console.entity.cases.DeployScriptEntity; + +import org.apache.ibatis.annotations.Insert; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.annotations.Update; + +/** + * + */ +@Mapper +public interface DeployScriptMapper { + + + @Insert(""" + insert into deploy_script () values() + """) + void insert(DeployScriptEntity deployScriptEntity); + + + @Update(""" + update deploy_script set description=#{description} content=#{content} where id=#{id}")" + """) + void update(DeployScriptEntity deployScriptEntity); + + + @Update(""" + update deploy_script set status = 1 where id=#{id}")" + """) + void deleteById(DeployScriptEntity deployScriptEntity); + + + @Select(""" + + """) + void queryByName(DeployScriptEntity deployScriptEntity); +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/deploy/PortMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/deploy/PortMapper.java new file mode 100644 index 00000000..50fe1758 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/deploy/PortMapper.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.console.mapper.deploy; + +import org.apache.eventmesh.dashboard.console.entity.cases.PortEntity; + +import org.apache.ibatis.annotations.Insert; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.annotations.Update; + +/** + * + */ +@Mapper +public interface PortMapper { + + + @Insert("insert into port(cluster_id, current_port)values (#{clusterId},#{currentPort})") + void insertPort(PortEntity portEntity); + + + @Select(" select * from port where cluster_id = #{clusterId} for update") + PortEntity lockPort(PortEntity portEntity); + + @Update(" update port set current_port = current_port + #{currentPort} where cluster_id=#{clusterId}") + void updatePort(PortEntity portEntity); +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/function/ConfigMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/function/ConfigMapper.java index 119c5aea..ce1542d6 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/function/ConfigMapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/function/ConfigMapper.java @@ -15,13 +15,16 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.mapper.function; import org.apache.eventmesh.dashboard.console.entity.function.ConfigEntity; +import org.apache.eventmesh.dashboard.console.mapper.SyncDataHandlerMapper; 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; @@ -31,7 +34,7 @@ * config table operation */ @Mapper -public interface ConfigMapper { +public interface ConfigMapper extends SyncDataHandlerMapper { @Select({ ""}) - List selectConfigsToFrontWithDynamic(ConfigEntity configEntity); + List getConfigsToFrontWithDynamic(ConfigEntity configEntity); @Select("SELECT * FROM config WHERE business_type=#{businessType} AND is_default=1") List selectConnectorConfigsByBusinessType(ConfigEntity configEntity); @@ -57,32 +60,13 @@ public interface ConfigMapper { @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(); @Select("SELECT * FROM config WHERE instance_type=#{instanceType} AND instance_id=#{instanceId}") List selectConfigsByInstance(ConfigEntity configEntity); - @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} 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") - ConfigEntity selectByUnique(ConfigEntity configEntity); - - @Update("UPDATE config SET status=0 WHERE id=#{id}") - Integer deleteConfig(ConfigEntity configEntity); - - @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") - Integer updateConfig(ConfigEntity configEntity); - @Insert({ ""}) @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") - Integer batchInsert(List configEntityList); + void batchInsert(List configEntityList); + + + @Insert("insert into config () select *,#{targetId} as cluster_id from config where clster where cluster_id = #{sourceId}") + void copyConfig(@Param("sourceId") Long sourceId, @Param("targetId") Long targetId); @Insert("INSERT INTO config (cluster_id, business_type, instance_type, instance_id, config_name, config_value, " - + "status, is_default, diff_type, description, edit, is_modify,start_version," - + "eventmesh_version,end_version) VALUE " - + "(#{clusterId},#{businessType},#{instanceType},#{instanceId},#{configName}," - + "#{configValue},#{status},#{isDefault},#{diffType},#{description},#{edit},#{isModify}," - + "#{startVersion},#{eventmeshVersion},#{endVersion})") + + "status, is_default, diff_type, description, edit, is_modify,start_version," + + "eventmesh_version,end_version) VALUE " + + "(#{clusterId},#{businessType},#{instanceType},#{instanceId},#{configName}," + + "#{configValue},#{status},#{isDefault},#{diffType},#{description},#{edit},#{isModify}," + + "#{startVersion},#{eventmeshVersion},#{endVersion})") @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") - void insertConfig(ConfigEntity configEntity); + Integer addConfig(ConfigEntity configEntity); + + @Update("UPDATE config SET status=0 WHERE id=#{id}") + Integer deleteConfig(ConfigEntity configEntity); + + @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 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} 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") + ConfigEntity selectByUnique(ConfigEntity configEntity); + + void syncInsert(List entityList); + + void syncUpdate(List entityList); + + void syncDelete(List entityList); + List syncGet(ConfigEntity topicEntity); } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/function/HealthCheckResultMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/function/HealthCheckResultMapper.java index bdb15875..f955fee6 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/function/HealthCheckResultMapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/function/HealthCheckResultMapper.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.mapper.function; import org.apache.eventmesh.dashboard.console.entity.function.HealthCheckResultEntity; @@ -54,38 +55,6 @@ public interface HealthCheckResultMapper { List selectByClusterIdAndCreateTimeRange(@Param("clusterId") Long clusterId, @Param("startTime") Timestamp startTime, @Param("endTime") Timestamp endTime); - @Select({ - "" - }) - List selectIdsNeedToBeUpdateByClusterIdAndTypeAndTypeId(List healthCheckResultEntityList); - - @Update("UPDATE health_check_result SET state = #{state}, result_desc = #{resultDesc} WHERE id = #{id}") - Integer update(HealthCheckResultEntity healthCheckResultEntity); - - @Update({ - ""}) - Integer batchUpdate(List healthCheckResultEntityList); - - /** - * TODO 未同步修改调用方法^ - * @param healthCheckResultEntity - */ - @Options(useGeneratedKeys = true, keyProperty = "id") @Insert("INSERT INTO health_check_result(type,type_id, cluster_id, state,result_desc)" + " VALUES( #{type}, #{typeId}, #{clusterId}, #{state}, #{resultDesc})") @@ -106,7 +75,7 @@ List selectByClusterIdAndCreateTimeRange(@Param("cluste " ", "" }) - Integer batchInsert(List healthCheckResultEntityList); + void batchInsert(List healthCheckResultEntityList); @Insert({ "" }) - Integer insertNewChecks(List healthCheckResultEntityList); + void insertNewChecks(List healthCheckResultEntityList); + + @Update("UPDATE health_check_result SET state = #{state}, result_desc = #{resultDesc} WHERE id = #{id}") + void update(HealthCheckResultEntity healthCheckResultEntity); + + @Update({ + ""}) + void batchUpdate(List healthCheckResultEntityList); + @Select({ + "" + }) + List getIdsNeedToBeUpdateByClusterIdAndTypeAndTypeId(List healthCheckResultEntityList); } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/function/OprLogMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/function/OprLogMapper.java index 6452a48b..0779e317 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/function/OprLogMapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/function/OprLogMapper.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.mapper.function; import org.apache.eventmesh.dashboard.console.entity.function.LogEntity; @@ -49,7 +50,15 @@ public interface OprLogMapper { " AND is_delete=0", " ", ""}) - List selectLogList(LogEntity logEntity); + List getLogList(LogEntity logEntity); + + @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=#{result} WHERE id=#{id}") + Integer updateLog(LogEntity logEntity); @Select({ "" }) - List selectLogListToFront(LogEntity logEntity); - - @Update("UPDATE operation_log SET state=#{state} ,result=#{result} WHERE id=#{id}") - Integer updateLog(LogEntity logEntity); - - @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") - void insertLog(LogEntity logEntity); - + List getLogListToFront(LogEntity logEntity); } diff --git a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/meta/SubscriptionCore.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/message/ConsumerOffsetMapper.java similarity index 57% rename from eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/meta/SubscriptionCore.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/message/ConsumerOffsetMapper.java index e27974f7..465efc26 100644 --- a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/meta/SubscriptionCore.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/message/ConsumerOffsetMapper.java @@ -15,21 +15,27 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.service.meta; +package org.apache.eventmesh.dashboard.console.mapper.message; -import org.apache.eventmesh.dashboard.common.dto.Result; -import org.apache.eventmesh.dashboard.common.model.SubscriptionInfo; +import org.apache.eventmesh.dashboard.console.entity.message.ConsumeOffsetEntity; +import org.apache.eventmesh.dashboard.console.mapper.SyncDataHandlerMapper; + +import org.apache.ibatis.annotations.Mapper; import java.util.List; /** - * "Subscription" refers to the traditional MQ producer-consumer topic subscription relationship, emphasizing the subscription relationship between - * EventMesh clients (including SDK and connectors) and topics, reported by the EventMesh runtime. + * */ +@Mapper +public interface ConsumerOffsetMapper extends SyncDataHandlerMapper { + + + void syncInsert(List entityList); -public interface SubscriptionCore { + void syncUpdate(List entityList); - String retrieveConfig(String dataId, String group); + void syncDelete(List entityList); - Result> retrieveConfigs(Integer page, Integer size, String dataId, String group); + List syncGet(ConsumeOffsetEntity topicOffsetEntity); } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/message/OprGroupMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/message/GroupMapper.java similarity index 80% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/message/OprGroupMapper.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/message/GroupMapper.java index ae196ecf..8b6130d0 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/message/OprGroupMapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/message/GroupMapper.java @@ -15,9 +15,11 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.mapper.message; import org.apache.eventmesh.dashboard.console.entity.message.GroupEntity; +import org.apache.eventmesh.dashboard.console.mapper.SyncDataHandlerMapper; import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Mapper; @@ -31,19 +33,28 @@ * operate Group mapper **/ @Mapper -public interface OprGroupMapper { +public interface GroupMapper extends SyncDataHandlerMapper { @Select("SELECT * FROM `group` WHERE cluster_id=#{clusterId} AND name=#{name} AND type=0 ") GroupEntity selectGroupByNameAndClusterId(GroupEntity groupEntity); @Select("SELECT COUNT(*) FROM `group` WHERE cluster_id=#{clusterId} AND type=0") - Integer selectConsumerNumByCluster(GroupEntity groupEntity); + Integer getConsumerNumByCluster(GroupEntity groupEntity); @Select("SELECT * FROM `group` WHERE status=1") List selectAll(); + @Update("UPDATE `group` SET member_count=#{memberCount}," + + "members=#{members},type=#{type},state=#{state} WHERE id=#{id}") + @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") + Integer updateGroup(GroupEntity groupEntity); + + @Update("UPDATE `group` SET status=1 WHERE id=#{id}") + @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") + Integer deleteGroup(GroupEntity groupEntity); + @Select("SELECT * FROM `group` WHERE cluster_id=#{clusterId} AND name=#{name} AND status=1") GroupEntity selectGroupByUnique(GroupEntity groupEntity); @@ -65,15 +76,6 @@ public interface OprGroupMapper { ""}) List selectGroup(GroupEntity groupEntity); - @Update("UPDATE `group` SET member_count=#{memberCount}," - + "members=#{members},type=#{type},state=#{state} WHERE id=#{id}") - @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") - Integer updateGroup(GroupEntity groupEntity); - - @Update("UPDATE `group` SET status=1 WHERE id=#{id}") - @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") - Integer deleteGroup(GroupEntity groupEntity); - @Insert({ ""}) @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") - Integer batchInsert(List groupEntities); + void batchInsert(List groupEntities); @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") + + "VALUE (#{clusterId},#{name},#{memberCount},#{members},#{type},#{state}) " + + "ON DUPLICATE KEY UPDATE status=1") @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") - void insertGroup(GroupEntity groupEntity); + void addGroup(GroupEntity groupEntity); + + + @Override + void syncInsert(List entityList); + + @Override + void syncUpdate(List entityList); + + @Override + void syncDelete(List entityList); + + @Override + List syncGet(GroupEntity topicEntity); } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/message/OprGroupMemberMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/message/OprGroupMemberMapper.java index 79f6b1a2..0e81b136 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/message/OprGroupMemberMapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/message/OprGroupMemberMapper.java @@ -15,10 +15,11 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.mapper.message; -import org.apache.eventmesh.dashboard.console.entity.message.GroupMemberEntity; +import org.apache.eventmesh.dashboard.console.entity.message.SubscriptionEntity; import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Mapper; @@ -35,68 +36,78 @@ @Mapper public interface OprGroupMemberMapper { - @Select("SELECT topic_name FROM group_member WHERE cluster_id=#{clusterId} AND group_name=#{groupName}") - List selectTopicsByGroupNameAndClusterId(GroupMemberEntity groupMemberEntity); - @Select("SELECT DISTINCT (group_name) FROM group_member WHERE cluster_id=#{clusterId} AND topic_name=#{topicName}") - List selectGroupNameByTopicName(GroupMemberEntity groupMemberEntity); + @Deprecated + @Select("select topic_name from group_member where cluster_id=#{clusterId} and group_name=#{groupName}") + List selectTopicsByGroupNameAndClusterId(SubscriptionEntity subscriptionEntity); - @Select("SELECT * FROM group_member WHERE status=1") - List selectAll(); + @Deprecated + @Select("select DISTINCT (group_name) from group_member where cluster_id=#{clusterId} and topic_name=#{topicName}") + List selectGroupNameByTopicName(SubscriptionEntity subscriptionEntity); - @Select("SELECT * FROM group_member WHERE cluster_id=#{clusterId} AND group_name=#{groupName} AND topic_name=#{topicName} AND status=1") - GroupMemberEntity selectGroupMemberByUnique(GroupMemberEntity groupMemberEntity); + @Select("select * from group_member where status=1") + List selectAll(); - @Select("SELECT * FROM group_member WHERE id=#{id} AND status=1") - GroupMemberEntity selectGroupMemberById(GroupMemberEntity groupMemberEntity); - @Select({ - ""}) - List selectMember(GroupMemberEntity groupMemberEntity); + @Deprecated + @Select("select * from group_member where cluster_id=#{clusterId} and status=1") + List getGroupByClusterId(SubscriptionEntity subscriptionEntity); - @Select("SELECT * FROM group_member WHERE cluster_id=#{clusterId} AND status=1") - List selectGroupByClusterId(GroupMemberEntity groupMemberEntity); - @Update("UPDATE group_member SET state=#{state} WHERE id=#{id}") - @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") - Integer updateGroupMember(GroupMemberEntity groupMemberEntity); + @Deprecated + @Select("select * from group_member where cluster_id=#{clusterId} and group_name=#{groupName} and topic_name=#{topicName} and status=1") + SubscriptionEntity selectGroupMemberByUnique(SubscriptionEntity subscriptionEntity); + + @Select(""" + + """) + List selectMember(SubscriptionEntity subscriptionEntity); - @Update("UPDATE group_member SET status=0 WHERE id=#{id} ") - @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") - Integer deleteGroupMember(GroupMemberEntity groupMemberEntity); - @Update("UPDATE group_member SET state=#{state} WHERE topic_name=#{topicName}") - Integer updateMemberByTopic(GroupMemberEntity groupMemberEntity); + @Select("select * from group_member where id=#{id} and status=1") + SubscriptionEntity selectGroupMemberById(SubscriptionEntity subscriptionEntity); + + @Update("UPDATE group_member SET state=#{state} where id=#{id}") + void updateGroupMember(SubscriptionEntity subscriptionEntity); + + @Deprecated + @Update("UPDATE group_member SET state=#{state} where topic_name=#{topicName}") + void updateMemberByTopic(SubscriptionEntity subscriptionEntity); + + + @Update("UPDATE group_member SET status=0 where id=#{id} ") + @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") + SubscriptionEntity deleteGroupMember(SubscriptionEntity subscriptionEntity); @Insert({ ""}) @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") - Integer batchInsert(List groupMemberEntities); + void batchInsert(List groupMemberEntities); + - @Insert("INSERT INTO group_member (cluster_id, topic_name, group_name, eventmesh_user,state)" - + " VALUE (#{clusterId},#{topicName},#{groupName},#{eventMeshUser},#{state})" - + "ON DUPLICATE KEY UPDATE status=0") + @Insert("insert into group_member (cluster_id, topic_name, group_name, eventmesh_user,state)" + + " values (#{clusterId},#{topicName},#{groupName},#{eventMeshUser},#{state})" + + "ON DUPLICATE KEY UPDATE status=0") @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") - void insertGroupMember(GroupMemberEntity groupMemberEntity); + void addGroupMember(SubscriptionEntity subscriptionEntity); -} +} \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/message/TopicMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/message/TopicMapper.java index 5a98d9bc..50703e74 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/message/TopicMapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/message/TopicMapper.java @@ -15,10 +15,12 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.mapper.message; import org.apache.eventmesh.dashboard.console.entity.message.TopicEntity; +import org.apache.eventmesh.dashboard.console.mapper.SyncDataHandlerMapper; import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Mapper; @@ -33,7 +35,7 @@ * operate Topic mapper **/ @Mapper -public interface TopicMapper { +public interface TopicMapper extends SyncDataHandlerMapper { @Select("SELECT count(*) FROM topic WHERE cluster_id=#{clusterId} AND status=1") @@ -51,38 +53,70 @@ public interface TopicMapper { ""}) List queryTopicsToFrontByClusterId(@Param("topicEntity") TopicEntity topicEntity); + @Select("SELECT * FROM topic WHERE cluster_id=#{clusterId} and status = 1") List selectTopicByCluster(TopicEntity topicEntity); + @Select("SELECT * FROM topic WHERE status=1") List selectAll(); @Select("SELECT * FROM topic WHERE id=#{id}") - TopicEntity selectTopicById(TopicEntity topicEntity); + TopicEntity queryTopicById(TopicEntity topicEntity); + - @Update("UPDATE topic SET type=#{type},description=#{description} WHERE id=#{id}") - Integer updateTopic(TopicEntity topicEntity); + @Update("UPDATE topic SET topic_type=#{topicType},description=#{description} WHERE id=#{id}") + void updateTopic(TopicEntity topicEntity); @Update("UPDATE topic SET create_progress=#{createProgress} WHERE id=#{id}") - Integer updateTopicCreateProgress(TopicEntity topicEntity); + void updateTopicCreateProgress(TopicEntity topicEntity); - @Update("UPDATE `topic` SET status=0 WHERE id=#{id}") - Integer deleteTopic(TopicEntity topicEntity); + @Update(""" + + """) + Integer deleteTopicByIds(List topicEntity); - @Insert({ - ""}) + + @Update("UPDATE `topic` SET status=0 WHERE id=#{id}") + Integer deleteTopicById(TopicEntity topicEntity); + + @Insert(""" + + """) @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") void batchInsert(List topicEntities); - @Insert("INSERT INTO topic (cluster_id, topic_name, retention_ms, type, description, create_progress) " - + "VALUE (#{clusterId},#{topicName},#{storageId},#{retentionMs},#{type},#{description},#{createProgress})" - + "ON DUPLICATE KEY UPDATE status = 1") + @Insert(""" + insert into topic (cluster_id , topic_name , retention_ms , topic_type , description, create_progress) + values (#{clusterId} ,#{topicName},#{retentionMs},#{topicType},#{description},#{createProgress}) + on duplicate key update status = 1 + """) @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") void insertTopic(TopicEntity topicEntity); -} + + @Override + void syncInsert(List entityList); + + @Override + void syncUpdate(List entityList); + + @Override + void syncDelete(List entityList); + + @Override + List syncGet(TopicEntity topicEntity); + +} \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/message/TopicOffsetMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/message/TopicOffsetMapper.java new file mode 100644 index 00000000..915813e2 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/message/TopicOffsetMapper.java @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.eventmesh.dashboard.console.mapper.message; + +import org.apache.eventmesh.dashboard.console.entity.message.TopicOffsetEntity; +import org.apache.eventmesh.dashboard.console.mapper.SyncDataHandlerMapper; + +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * + */ +@Mapper +public interface TopicOffsetMapper extends SyncDataHandlerMapper { + + + void syncInsert(List entityList); + + void syncUpdate(List entityList); + + void syncDelete(List entityList); + + List syncGet(TopicOffsetEntity topicOffsetEntity); +} 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 deleted file mode 100644 index 9aaa07c3..00000000 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/storage/StoreMapper.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.console.mapper.storage; - -import org.apache.eventmesh.dashboard.console.entity.StoreEntity; - -import org.apache.ibatis.annotations.Insert; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Options; -import org.apache.ibatis.annotations.Select; -import org.apache.ibatis.annotations.Update; - -import java.util.List; - -/** - * store table operation - */ -@Mapper -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); - - @Select("SELECT * FROM store WHERE host=#{host} AND port=#{port} AND status=1 LIMIT 1") - StoreEntity selectByHostPort(StoreEntity storeEntity); - - @Select("SELECT * FROM store WHERE cluster_id=#{clusterId} AND status=1") - StoreEntity selectStoreByCluster(StoreEntity storeEntity); - - @Update("UPDATE store SET status=0 WHERE cluster_id=#{clusterId} AND store_id=#{storeId}") - Integer deleteStoreByUnique(StoreEntity storeEntity); - - @Update("UPDATE store SET status=#{status} WHERE cluster_id=#{clusterId} AND store_id=#{storeId}") - Integer updateStoreByUnique(StoreEntity storeEntity); - - @Update("UPDATE store SET topic_list=#{topicList} WHERE cluster_id=#{clusterId}") - Integer updateTopicListByCluster(StoreEntity storeEntity); - - @Insert({ - ""}) - @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") - Integer batchInsert(List storeEntities); - - @Insert("INSERT INTO store (cluster_id, store_id, store_type, host, runtime_id, topic_list, diff_type" - + ", port, jmx_port, start_timestamp, rack, status, endpoint_map ) VALUES (" - + "#{clusterId},#{storeId},#{storeType},#{host},#{runtimeId},#{topicList},#{diffType},#{port},#{jmxPort}" - + ",#{startTimestamp},#{rack},#{status},#{endpointMap})") - @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") - void insertStore(StoreEntity storeEntity); - -} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/cluster/ClientDataControllerMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/cluster/ClientDataControllerMapper.java index 2de3f0b5..b1594887 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/cluster/ClientDataControllerMapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/cluster/ClientDataControllerMapper.java @@ -15,10 +15,8 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.mapstruct.cluster; -import org.apache.eventmesh.dashboard.console.entity.cluster.ClientEntity; -import org.apache.eventmesh.dashboard.console.modle.cluster.client.SelectByClusterIdDTO; +package org.apache.eventmesh.dashboard.console.mapstruct.cluster; import org.mapstruct.factory.Mappers; @@ -30,6 +28,5 @@ public interface ClientDataControllerMapper { ClientDataControllerMapper INSTANCE = Mappers.getMapper(ClientDataControllerMapper.class); - ClientEntity selectByClusterIdDTO(SelectByClusterIdDTO selectByClusterIdDTO); } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/cluster/ClusterControllerMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/cluster/ClusterControllerMapper.java index 08ca20c4..82d59894 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/cluster/ClusterControllerMapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/cluster/ClusterControllerMapper.java @@ -15,10 +15,14 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.mapstruct.cluster; import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; -import org.apache.eventmesh.dashboard.console.modle.cluster.CreateClusterDTO; +import org.apache.eventmesh.dashboard.console.modle.ClusterIdDTO; +import org.apache.eventmesh.dashboard.console.modle.cluster.CreateClusterBySimpleDataDTO; +import org.apache.eventmesh.dashboard.console.modle.cluster.cluster.QueryClusterByOrganizationIdAndTypeDTO; +import org.apache.eventmesh.dashboard.console.modle.cluster.cluster.QueryRelationClusterByClusterIdAndTypeDTO; import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; @@ -32,6 +36,12 @@ public interface ClusterControllerMapper { ClusterControllerMapper INSTANCE = Mappers.getMapper(ClusterControllerMapper.class); - ClusterEntity createCluster(CreateClusterDTO createClusterDTO); + ClusterEntity queryClusterByOrganizationIdAndType(QueryClusterByOrganizationIdAndTypeDTO dto); + + ClusterEntity queryRelationClusterByClusterIdAndType(QueryRelationClusterByClusterIdAndTypeDTO dto); + + ClusterEntity createCluster(CreateClusterBySimpleDataDTO createClusterBySimpleDataDTO); + + ClusterEntity toClusterEntity(ClusterIdDTO clusterIdDTO); } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/cluster/GroupControllerMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/cluster/GroupControllerMapper.java index 1b2eab83..402692bf 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/cluster/GroupControllerMapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/cluster/GroupControllerMapper.java @@ -15,11 +15,12 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.mapstruct.cluster; import org.apache.eventmesh.dashboard.console.entity.message.GroupEntity; -import org.apache.eventmesh.dashboard.console.modle.ClusterIdDTO; import org.apache.eventmesh.dashboard.console.modle.IdDTO; +import org.apache.eventmesh.dashboard.console.modle.vo.RuntimeIdDTO; import org.mapstruct.factory.Mappers; @@ -31,7 +32,7 @@ public interface GroupControllerMapper { GroupControllerMapper INSTANCE = Mappers.getMapper(GroupControllerMapper.class); - GroupEntity queryGroupListByClusterId(ClusterIdDTO clusterId); + GroupEntity queryGroupListByClusterId(RuntimeIdDTO runtimeIdDTO); GroupEntity deleteGroupById(IdDTO idDTO); diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/cluster/RuntimeControllerMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/cluster/RuntimeControllerMapper.java index eccf8508..731fb6bd 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/cluster/RuntimeControllerMapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/cluster/RuntimeControllerMapper.java @@ -15,12 +15,13 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.mapstruct.cluster; import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; import org.apache.eventmesh.dashboard.console.modle.ClusterIdDTO; import org.apache.eventmesh.dashboard.console.modle.IdDTO; -import org.apache.eventmesh.dashboard.console.modle.cluster.runtime.CrateRuntimeDTO; +import org.apache.eventmesh.dashboard.console.modle.cluster.runtime.CreateRuntimeDTO; import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; @@ -38,7 +39,7 @@ public interface RuntimeControllerMapper { RuntimeEntity queryRuntimeListById(IdDTO idDTO); - RuntimeEntity crateRuntime(CrateRuntimeDTO crateRuntimeDTO); + RuntimeEntity crateRuntime(CreateRuntimeDTO crateRuntimeDTO); } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/log/LogControllerMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/deploy/CaseControllerMapper.java similarity index 66% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/log/LogControllerMapper.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/deploy/CaseControllerMapper.java index 03c5302a..bda96014 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/log/LogControllerMapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/deploy/CaseControllerMapper.java @@ -15,24 +15,22 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.mapstruct.log; -import org.apache.eventmesh.dashboard.console.entity.function.LogEntity; -import org.apache.eventmesh.dashboard.console.modle.dto.log.GetLogListDTO; +package org.apache.eventmesh.dashboard.console.mapstruct.deploy; +import org.apache.eventmesh.dashboard.console.entity.cases.CaseEntity; +import org.apache.eventmesh.dashboard.console.modle.deploy.cases.QueryCaseByObjectTypeDTO; -import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; /** * */ -@Mapper -public interface LogControllerMapper { +public interface CaseControllerMapper { - LogControllerMapper INSTANCE = Mappers.getMapper(LogControllerMapper.class); + CaseControllerMapper INSTANCE = Mappers.getMapper(CaseControllerMapper.class); - LogEntity queryEntityByLog(GetLogListDTO getLogListDTO); + CaseEntity queryCaseByObjectType(QueryCaseByObjectTypeDTO queryCaseByObjectTypeDTO); } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/deploy/ClusterCycleControllerMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/deploy/ClusterCycleControllerMapper.java new file mode 100644 index 00000000..b78bfd70 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/deploy/ClusterCycleControllerMapper.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.console.mapstruct.deploy; + +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; +import org.apache.eventmesh.dashboard.console.modle.deploy.create.CreateClusterByDeployScriptDO; +import org.apache.eventmesh.dashboard.console.modle.deploy.create.CreateClusterByEventMesh; +import org.apache.eventmesh.dashboard.console.modle.deploy.create.CreateRuntimeByDeployScriptDTO; +import org.apache.eventmesh.dashboard.console.modle.deploy.create.CreateRuntimeByOnlyDataDO; + +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +/** + * + */ +@Mapper +public interface ClusterCycleControllerMapper { + + ClusterCycleControllerMapper INSTANCE = Mappers.getMapper(ClusterCycleControllerMapper.class); + + + RuntimeEntity createRuntimeByOnlyDataHandler(CreateRuntimeByOnlyDataDO createRuntimeByOnlyDataDO); + + + ClusterEntity createClusterByEventMesh(CreateClusterByEventMesh createClusterByEventMesh); + + + ClusterEntity createClusterByDeployScript(CreateClusterByDeployScriptDO createClusterByDeployScriptDO); + + RuntimeEntity createRuntimeByDeployScript(CreateRuntimeByDeployScriptDTO createRuntimeByDeployScriptDTO); + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/deploy/ResourceConfigControllerMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/deploy/ResourceConfigControllerMapper.java new file mode 100644 index 00000000..037806af --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/deploy/ResourceConfigControllerMapper.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.console.mapstruct.deploy; + +import org.apache.eventmesh.dashboard.console.entity.cases.ResourcesConfigEntity; +import org.apache.eventmesh.dashboard.console.modle.deploy.resouce.QueryResourceByObjectTypeDTO; + +import org.mapstruct.factory.Mappers; + +/** + * + */ +public interface ResourceConfigControllerMapper { + + ResourceConfigControllerMapper INSTANCE = Mappers.getMapper(ResourceConfigControllerMapper.class); + + + ResourcesConfigEntity queryResourcesConfigByObjectType(QueryResourceByObjectTypeDTO queryResourceByObjectTypeDTO); + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/message/TopicControllerMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/message/TopicControllerMapper.java index 6f44f3b7..19bfd5bf 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/message/TopicControllerMapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/message/TopicControllerMapper.java @@ -15,12 +15,14 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.mapstruct.message; import org.apache.eventmesh.dashboard.console.entity.message.TopicEntity; import org.apache.eventmesh.dashboard.console.modle.IdDTO; 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.RuntimeIdDTO; import org.mapstruct.factory.Mappers; @@ -34,7 +36,7 @@ public interface TopicControllerMapper { TopicEntity queryTopicListByClusterId(GetTopicListDTO getTopicListDTO); - TopicEntity queryTopicListById(IdDTO idDTO); + TopicEntity queryTopicListById(RuntimeIdDTO runtimeIdDTO); TopicEntity deleteTopic(IdDTO idDTO); diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/ClusterIdDTO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/ClusterIdDTO.java index d6f008a5..760561d5 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/ClusterIdDTO.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/ClusterIdDTO.java @@ -15,16 +15,21 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.modle; import javax.validation.constraints.NotNull; import lombok.Data; +import lombok.EqualsAndHashCode; @Data -public class ClusterIdDTO { +@EqualsAndHashCode(callSuper = false) +public class ClusterIdDTO extends OrganizationIdDTO { @NotNull private Long clusterId; + + } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/DO/QueryRuntimeByClusterIdAndClusterTypeDO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/DO/QueryRuntimeByClusterIdAndClusterTypeDO.java new file mode 100644 index 00000000..37e179e0 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/DO/QueryRuntimeByClusterIdAndClusterTypeDO.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.DO; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; + +import java.util.ArrayList; +import java.util.List; + +import lombok.Data; + +@Data +public class QueryRuntimeByClusterIdAndClusterTypeDO { + + private List clusterTypeList = new ArrayList<>(); + + private List clusterIdList = new ArrayList<>(); + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/DO/clusterRelationship/QueryListByClusterIdAndTypeDO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/DO/clusterRelationship/QueryListByClusterIdAndTypeDO.java new file mode 100644 index 00000000..794861e2 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/DO/clusterRelationship/QueryListByClusterIdAndTypeDO.java @@ -0,0 +1,41 @@ +/* + * 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.DO.clusterRelationship; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; + +import java.util.List; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class QueryListByClusterIdAndTypeDO { + + private Long clusterId; + + private List clusterTypeList; + + private List relationshipTypeList; + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/DO/runtime/QueryRuntimeByBigExpandClusterDO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/DO/runtime/QueryRuntimeByBigExpandClusterDO.java new file mode 100644 index 00000000..6104ffb7 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/DO/runtime/QueryRuntimeByBigExpandClusterDO.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.eventmesh.dashboard.console.modle.DO.runtime; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; + +import java.util.List; + +import lombok.Builder; +import lombok.Data; + +@Data +@Builder +public class QueryRuntimeByBigExpandClusterDO { + + private Long followClusterId; + + private ClusterType mainClusterType; + + private List storageClusterTypeList; + + private List storageMetaClusterTypeList; + + + private List queryClusterTypeList; + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/IdDTO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/IdDTO.java index adc36993..a6e38089 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/IdDTO.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/IdDTO.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.modle; import lombok.Data; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/CreateConnectionEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/OperateDTO.java similarity index 66% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/CreateConnectionEntity.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/OperateDTO.java index 1f453fea..77d86fc4 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/CreateConnectionEntity.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/OperateDTO.java @@ -15,19 +15,25 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.entity; -import org.apache.eventmesh.dashboard.console.entity.connection.AddConnectionEntity; -import org.apache.eventmesh.dashboard.console.entity.connection.AddConnectorConfigEntity; +package org.apache.eventmesh.dashboard.console.modle; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.common.enums.OperationRange.OperationRangeType; import lombok.Data; +import lombok.EqualsAndHashCode; +/** + * + */ @Data -public class CreateConnectionEntity { +@EqualsAndHashCode(callSuper = true) +public class OperateDTO extends IdDTO { + - private Long clusterId; + private OperationRangeType operationRangeType; - private AddConnectionEntity addConnectionEntity; + private ClusterType clusterType; - private AddConnectorConfigEntity addConnectorConfigEntity; } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/OrganizationIdDTO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/OrganizationIdDTO.java new file mode 100644 index 00000000..7d03e62e --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/OrganizationIdDTO.java @@ -0,0 +1,27 @@ +/* + * 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; + +import lombok.Data; + +@Data +public class OrganizationIdDTO { + + private String organizationId; +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/ClusterHomeListVO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/ClusterHomeListVO.java index 3eaa45b0..e3fccc11 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/ClusterHomeListVO.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/ClusterHomeListVO.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.modle.cluster; import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/CreateClusterByCompleteDataDTO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/CreateClusterByCompleteDataDTO.java new file mode 100644 index 00000000..8ee206ce --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/CreateClusterByCompleteDataDTO.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.cluster; + +import org.apache.eventmesh.dashboard.common.enums.ReplicationType; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@EqualsAndHashCode(callSuper = true) +@Data +public class CreateClusterByCompleteDataDTO extends CreateClusterBySimpleDataDTO { + + + private Long k8sClusterId; + + private Long deployScriptId; + + private Long resourcesId; + + private Long createNum; + + private ReplicationType replicationType; +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/CreateClusterDTO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/CreateClusterBySimpleDataDTO.java similarity index 82% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/CreateClusterDTO.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/CreateClusterBySimpleDataDTO.java index 2102c5c5..66b9b1c5 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/CreateClusterDTO.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/CreateClusterBySimpleDataDTO.java @@ -15,36 +15,38 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.modle.cluster; import org.apache.eventmesh.dashboard.common.enums.ClusterTrusteeshipType; import org.apache.eventmesh.dashboard.common.enums.ClusterType; -import javax.validation.constraints.NotNull; - import lombok.Data; +/** + * + */ @Data -public class CreateClusterDTO { +public class CreateClusterBySimpleDataDTO { - @NotNull private String name; - @NotNull + private Long currentClusterId; + + private Long configGatherId; + private ClusterTrusteeshipType trusteeshipType; - @NotNull private ClusterType clusterType; - @NotNull private String version; + private String jmxProperties; - private String jmxProperties = ""; - - private String description = ""; + private String description; + private Integer authType; - private Integer authType = 0; + private Integer runState; } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/VerifyNameDTO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/VerifyNameDTO.java new file mode 100644 index 00000000..2f4a4bc1 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/VerifyNameDTO.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.cluster; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; + +import lombok.Data; + +@Data +public class VerifyNameDTO { + + + private Integer organizationId; + + private ClusterType clusterType; + + private String clusterName; +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/client/SelectByClusterIdDTO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/client/QueryClientByUserFormDTO.java similarity index 85% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/client/SelectByClusterIdDTO.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/client/QueryClientByUserFormDTO.java index 268aeacd..401feaad 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/client/SelectByClusterIdDTO.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/client/QueryClientByUserFormDTO.java @@ -15,11 +15,17 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.modle.cluster.client; import org.apache.eventmesh.dashboard.console.modle.ClusterIdDTO; -public class SelectByClusterIdDTO extends ClusterIdDTO { +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class QueryClientByUserFormDTO extends ClusterIdDTO { } diff --git a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/RemotingServiceType.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/cluster/ClusterDetailsVO.java similarity index 88% rename from eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/RemotingServiceType.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/cluster/ClusterDetailsVO.java index 2da47e62..003bab77 100644 --- a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/RemotingServiceType.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/cluster/ClusterDetailsVO.java @@ -15,9 +15,12 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.service.remoting; -public enum RemotingServiceType { +package org.apache.eventmesh.dashboard.console.modle.cluster.cluster; + +public class ClusterDetailsVO { + + } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/cluster/QueryClusterByOrganizationIdAndTypeDTO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/cluster/QueryClusterByOrganizationIdAndTypeDTO.java new file mode 100644 index 00000000..31c34c48 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/cluster/QueryClusterByOrganizationIdAndTypeDTO.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.cluster.cluster; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.console.modle.ClusterIdDTO; + +import javax.validation.constraints.NotNull; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class QueryClusterByOrganizationIdAndTypeDTO extends ClusterIdDTO { + + @NotNull + private ClusterType clusterType; + + private String clusterName; +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/cluster/QueryRelationClusterByClusterIdAndTypeDTO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/cluster/QueryRelationClusterByClusterIdAndTypeDTO.java new file mode 100644 index 00000000..345f0b50 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/cluster/QueryRelationClusterByClusterIdAndTypeDTO.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.cluster.cluster; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.console.modle.ClusterIdDTO; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class QueryRelationClusterByClusterIdAndTypeDTO extends ClusterIdDTO { + + + private ClusterType clusterType; +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/runtime/CrateRuntimeDTO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/runtime/CreateRuntimeDTO.java similarity index 75% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/runtime/CrateRuntimeDTO.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/runtime/CreateRuntimeDTO.java index c08eeb7b..a027cd7a 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/runtime/CrateRuntimeDTO.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/runtime/CreateRuntimeDTO.java @@ -15,16 +15,21 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.modle.cluster.runtime; +import org.apache.eventmesh.dashboard.common.enums.ClusterTrusteeshipType.FirstToWhom; +import org.apache.eventmesh.dashboard.common.enums.ClusterType; import org.apache.eventmesh.dashboard.console.modle.ClusterIdDTO; import java.time.LocalDateTime; import lombok.Data; +import lombok.EqualsAndHashCode; @Data -public class CrateRuntimeDTO extends ClusterIdDTO { +@EqualsAndHashCode(callSuper = true) +public class CreateRuntimeDTO extends ClusterIdDTO { private String name; @@ -39,4 +44,8 @@ public class CrateRuntimeDTO extends ClusterIdDTO { private String rack = ""; private String endpointMap; + + private FirstToWhom firstToWhom = FirstToWhom.DASHBOARD; + + private ClusterType trusteeshipArrangeType = ClusterType.RUNTIME; } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/runtime/QueryRuntimeListByClusterIdDTO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/runtime/QueryRuntimeListByClusterIdDTO.java index 5cccc897..b53e4cae 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/runtime/QueryRuntimeListByClusterIdDTO.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/runtime/QueryRuntimeListByClusterIdDTO.java @@ -15,13 +15,17 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.modle.cluster.runtime; import org.apache.eventmesh.dashboard.console.modle.ClusterIdDTO; import lombok.Data; +import lombok.EqualsAndHashCode; + @Data +@EqualsAndHashCode(callSuper = true) public class QueryRuntimeListByClusterIdDTO extends ClusterIdDTO { private String host; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/runtimeCycle/CreateRuntimeDTO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/runtimeCycle/CreateRuntimeDTO.java new file mode 100644 index 00000000..ee981f7a --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/runtimeCycle/CreateRuntimeDTO.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.cluster.runtimeCycle; + +import org.apache.eventmesh.dashboard.console.modle.ClusterIdDTO; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class CreateRuntimeDTO extends ClusterIdDTO { + + private int runtimeNum; + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/BaseConifgDO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/BaseConifgDO.java new file mode 100644 index 00000000..55859729 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/BaseConifgDO.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.console.modle.deploy; + +import org.apache.eventmesh.dashboard.console.entity.function.ConfigEntity; + +import java.util.List; + +import lombok.Data; + +@Data +public class BaseConifgDO { + + + private List configList; + + + + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/BaseDeployDO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/BaseDeployDO.java new file mode 100644 index 00000000..009a2827 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/BaseDeployDO.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.deploy; + +import org.apache.eventmesh.dashboard.console.entity.cases.ResouceEntity; + +import java.util.List; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class BaseDeployDO extends BaseConifgDO { + + + private List topicList; + + private ResouceEntity resource; + + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/ClusterAllMetadataDO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/ClusterAllMetadataDO.java new file mode 100644 index 00000000..5e8573e2 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/ClusterAllMetadataDO.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.deploy; + +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterRelationshipEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; + +import java.util.List; + +import lombok.Data; + +@Data +public class ClusterAllMetadataDO { + + private List clusterEntityList; + + private List runtimeEntityList; + + private List clusterRelationshipEntityList; + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/DeployClusterDO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/DeployClusterDO.java new file mode 100644 index 00000000..a93eccff --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/DeployClusterDO.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.deploy; + +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; + +import java.util.List; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class DeployClusterDO extends BaseDeployDO { + + private ClusterEntity cluster; + + private List deployRuntimeDOList; + + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/DeployFullDO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/DeployFullDO.java new file mode 100644 index 00000000..b94ba0d6 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/DeployFullDO.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.console.modle.deploy; + +import org.apache.eventmesh.dashboard.console.entity.cases.DeployScriptEntity; + +import java.util.List; + +import lombok.Data; + +@Data +public class DeployFullDO { + + private List deployClusterDOList; + + + private List kubernetesList; + + private List deployScriptEntityList; +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/config/ChangeConfigEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/DeployGroupDO.java similarity index 81% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/config/ChangeConfigEntity.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/DeployGroupDO.java index bf167b1e..4f0cec47 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/config/ChangeConfigEntity.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/DeployGroupDO.java @@ -15,16 +15,15 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.modle.config; -import lombok.Data; +package org.apache.eventmesh.dashboard.console.modle.deploy; -@Data -public class ChangeConfigEntity { - private String configName; +import lombok.Data; +import lombok.EqualsAndHashCode; - private String configValue; +@Data +@EqualsAndHashCode(callSuper = true) +public class DeployGroupDO extends BaseConifgDO { - private Integer alreadyUpdate; } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/DeployMetadataDO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/DeployMetadataDO.java new file mode 100644 index 00000000..b62784c3 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/DeployMetadataDO.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.deploy; + +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterRelationshipEntity; + +import java.util.List; + +import lombok.Data; + + +@Data +public class DeployMetadataDO { + + + private List deployClusterDOList; + + private List relationshipList; + + private List kubernetesList; + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/DeployRuntimeDO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/DeployRuntimeDO.java new file mode 100644 index 00000000..444c2d92 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/DeployRuntimeDO.java @@ -0,0 +1,30 @@ +/* + * 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.deploy; + +import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; + +public class DeployRuntimeDO extends BaseDeployDO { + + private RuntimeEntity runtime; + + + + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/DeployTopicDO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/DeployTopicDO.java new file mode 100644 index 00000000..e0f8f091 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/DeployTopicDO.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.deploy; + +import org.apache.eventmesh.dashboard.console.entity.message.TopicEntity; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class DeployTopicDO extends BaseConifgDO { + + private TopicEntity topic; + + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/GetPortsDO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/GetPortsDO.java new file mode 100644 index 00000000..fb1af802 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/GetPortsDO.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.deploy; + +import org.apache.eventmesh.dashboard.console.modle.ClusterIdDTO; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class GetPortsDO extends ClusterIdDTO { + + private Integer portNum; + + private String kubernetesPortModel; +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/cases/QueryCaseByObjectTypeDTO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/cases/QueryCaseByObjectTypeDTO.java new file mode 100644 index 00000000..b8885902 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/cases/QueryCaseByObjectTypeDTO.java @@ -0,0 +1,30 @@ +/* + * 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.deploy.cases; + +import lombok.Data; + +@Data +public class QueryCaseByObjectTypeDTO { + + + private String objectType; + + private String objectId; +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/create/CreateClusterByDeployScriptDO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/create/CreateClusterByDeployScriptDO.java new file mode 100644 index 00000000..3235e3f6 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/create/CreateClusterByDeployScriptDO.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.modle.deploy.create; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class CreateClusterByDeployScriptDO extends CreateRuntimeByDeployScriptDO { + + + private String name; + + private Long configGatherId; + + private ClusterType clusterType; + + private String version; + + private String jmxProperties; + + private String description; + + private Integer authType; + + private Integer runState; + + private Long k8sClusterId; + + private Long deployScriptId; + + private Long resourcesConfigId; + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/create/CreateClusterByEventMesh.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/create/CreateClusterByEventMesh.java new file mode 100644 index 00000000..cf891f34 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/create/CreateClusterByEventMesh.java @@ -0,0 +1,41 @@ +/* + * 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.deploy.create; + +import org.apache.eventmesh.dashboard.console.modle.OrganizationIdDTO; + +import javax.validation.constraints.NotNull; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class CreateClusterByEventMesh extends OrganizationIdDTO { + + @NotNull + private String name; + + + @NotNull + private String description; + + + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/create/CreateEventMeshClusterByOnlyScript.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/create/CreateEventMeshClusterByOnlyScript.java new file mode 100644 index 00000000..0b7e65b5 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/create/CreateEventMeshClusterByOnlyScript.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.deploy.create; + +import org.apache.eventmesh.dashboard.console.modle.OrganizationIdDTO; + +import javax.validation.constraints.NotNull; + +import lombok.Data; +import lombok.EqualsAndHashCode; + + +@Data +@EqualsAndHashCode(callSuper = true) +public class CreateEventMeshClusterByOnlyScript extends OrganizationIdDTO { + + + @NotNull + private String name; + + + @NotNull + private String description; +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/create/CreateRuntimeByDeployScriptDO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/create/CreateRuntimeByDeployScriptDO.java new file mode 100644 index 00000000..94ac5266 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/create/CreateRuntimeByDeployScriptDO.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.deploy.create; + +import org.apache.eventmesh.dashboard.common.enums.ReplicationType; +import org.apache.eventmesh.dashboard.console.modle.ClusterIdDTO; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class CreateRuntimeByDeployScriptDO extends ClusterIdDTO { + + + private Long deployScriptId; + + private Long resourcesConfigId; + + private Integer createNum; + + private ReplicationType replicationType; +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/create/CreateRuntimeByDeployScriptDTO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/create/CreateRuntimeByDeployScriptDTO.java new file mode 100644 index 00000000..73a556eb --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/create/CreateRuntimeByDeployScriptDTO.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.eventmesh.dashboard.console.modle.deploy.create; + +import org.apache.eventmesh.dashboard.common.enums.ReplicationType; +import org.apache.eventmesh.dashboard.console.modle.ClusterIdDTO; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class CreateRuntimeByDeployScriptDTO extends ClusterIdDTO { + + + private Long deployScriptId; + + private Long resourcesConfigId; + + private ReplicationType replicationType; +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/create/CreateRuntimeByOnlyDataDO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/create/CreateRuntimeByOnlyDataDO.java new file mode 100644 index 00000000..4bc8927f --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/create/CreateRuntimeByOnlyDataDO.java @@ -0,0 +1,57 @@ +/* + * 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.deploy.create; + +import org.apache.eventmesh.dashboard.common.enums.ClusterTrusteeshipType; +import org.apache.eventmesh.dashboard.common.enums.ClusterTrusteeshipType.FirstToWhom; +import org.apache.eventmesh.dashboard.console.modle.ClusterIdDTO; + +import javax.validation.constraints.NotNull; + +import lombok.Data; +import lombok.EqualsAndHashCode; + + +@Data +@EqualsAndHashCode(callSuper = true) +public class CreateRuntimeByOnlyDataDO extends ClusterIdDTO { + + @NotNull + private String name; + + @NotNull + private String host; + + /** + * 添加的时候只需要 host 与 post eventmesh runtime 是 admin port。通过 runtime admin 获得所有的配置。 meta 需要 host 与 post store host 与 post jmxPort + */ + @NotNull + private Integer port; + + private Integer jmxPort; + + private Integer adminPort; + + @NotNull + private ClusterTrusteeshipType trusteeshipType; + + @NotNull + private FirstToWhom firstToWhom; + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/resouce/QueryResourceByObjectTypeDTO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/resouce/QueryResourceByObjectTypeDTO.java new file mode 100644 index 00000000..292a4a2f --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/resouce/QueryResourceByObjectTypeDTO.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.console.modle.deploy.resouce; + +import org.apache.eventmesh.dashboard.console.modle.deploy.cases.QueryCaseByObjectTypeDTO; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class QueryResourceByObjectTypeDTO extends QueryCaseByObjectTypeDTO { + + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/domain/ClusterEntityDO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/domain/ClusterEntityDO.java new file mode 100644 index 00000000..2fa04ebf --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/domain/ClusterEntityDO.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.domain; + +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; +import org.apache.eventmesh.dashboard.console.entity.function.ConfigEntity; +import org.apache.eventmesh.dashboard.core.cluster.ClusterBaseDO; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class ClusterEntityDO extends ClusterBaseDO { + + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/config/ConfigControllerMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/domain/RuntimeEntityDO.java similarity index 66% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/config/ConfigControllerMapper.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/domain/RuntimeEntityDO.java index 2afd16c0..1046a9d9 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/config/ConfigControllerMapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/domain/RuntimeEntityDO.java @@ -15,23 +15,20 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.mapstruct.config; +package org.apache.eventmesh.dashboard.console.modle.domain; +import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; import org.apache.eventmesh.dashboard.console.entity.function.ConfigEntity; -import org.apache.eventmesh.dashboard.console.modle.dto.config.GetConfigsListDTO; +import org.apache.eventmesh.dashboard.core.cluster.RuntimeBaseDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; +import lombok.Data; +import lombok.EqualsAndHashCode; -/** - * - */ -@Mapper -public interface ConfigControllerMapper { +@Data +@EqualsAndHashCode(callSuper = true) +public class RuntimeEntityDO extends RuntimeBaseDO { - ConfigControllerMapper INSTANCE = Mappers.getMapper(ConfigControllerMapper.class); - public ConfigEntity queryEntityByConfig(GetConfigsListDTO getConfigsListDTO); } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/config/RocketmqConfig.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/config/ChangeConfigDTO.java similarity index 82% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/config/RocketmqConfig.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/config/ChangeConfigDTO.java index e49d5152..1aa30462 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/config/RocketmqConfig.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/config/ChangeConfigDTO.java @@ -15,18 +15,21 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.function.health.check.config; + +package org.apache.eventmesh.dashboard.console.modle.dto.config; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; -@Data @NoArgsConstructor @AllArgsConstructor -public class RocketmqConfig { +@Data +public class ChangeConfigDTO { + + private String configName; + + private String configValue; - private String brokerUrl; - private String nameServerUrl; - private String endPoint; + 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 index 1796fa53..10e05e91 100644 --- 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 @@ -15,10 +15,15 @@ * 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 { 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 index e1420a24..93b0c792 100644 --- 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 @@ -15,10 +15,15 @@ * 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 { 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 index 69232c0f..ff073180 100644 --- 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 @@ -15,24 +15,19 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.modle.dto.config; -import org.apache.eventmesh.dashboard.console.modle.config.ChangeConfigEntity; +package org.apache.eventmesh.dashboard.console.modle.dto.config; -import java.util.List; +import org.apache.eventmesh.dashboard.console.modle.dto.operation.OperationBaseDTO; import lombok.Data; +import lombok.EqualsAndHashCode; -@Data -public class UpdateConfigDTO { - - private Long clusterId; - - private List changeConfigEntities; - private String username; +@Data +@EqualsAndHashCode(callSuper = true) +public class UpdateConfigDTO extends OperationBaseDTO { - private Integer instanceType; - private Long instanceId; + private String configValue; } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/config/UpdateConfigsLog.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/config/UpdateConfigsLog.java similarity index 85% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/config/UpdateConfigsLog.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/config/UpdateConfigsLog.java index 6dafeef6..1a5e3a4f 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/config/UpdateConfigsLog.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/config/UpdateConfigsLog.java @@ -15,11 +15,16 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.modle.config; +package org.apache.eventmesh.dashboard.console.modle.dto.config; + +import lombok.AllArgsConstructor; import lombok.Data; +import lombok.NoArgsConstructor; +@NoArgsConstructor +@AllArgsConstructor @Data public class UpdateConfigsLog { diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/connection/AddConnectionEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/connection/AddConnectionDTO.java similarity index 85% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/connection/AddConnectionEntity.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/connection/AddConnectionDTO.java index 917462a7..9c33dc92 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/connection/AddConnectionEntity.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/connection/AddConnectionDTO.java @@ -15,12 +15,17 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.entity.connection; +package org.apache.eventmesh.dashboard.console.modle.dto.connection; + +import lombok.AllArgsConstructor; import lombok.Data; +import lombok.NoArgsConstructor; +@NoArgsConstructor +@AllArgsConstructor @Data -public class AddConnectionEntity { +public class AddConnectionDTO { private String sinkName; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/connection/AddConnectorConfigEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/connection/AddConnectorConfigDTO.java similarity index 83% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/connection/AddConnectorConfigEntity.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/connection/AddConnectorConfigDTO.java index 291fe8cc..a6d00b4e 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/connection/AddConnectorConfigEntity.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/connection/AddConnectorConfigDTO.java @@ -15,16 +15,21 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.entity.connection; + +package org.apache.eventmesh.dashboard.console.modle.dto.connection; import org.apache.eventmesh.dashboard.console.entity.function.ConfigEntity; import java.util.List; +import lombok.AllArgsConstructor; import lombok.Data; +import lombok.NoArgsConstructor; +@NoArgsConstructor +@AllArgsConstructor @Data -public class AddConnectorConfigEntity { +public class AddConnectorConfigDTO { private List sinkConnectorConfigs; 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 index f204296f..e7ee5e4d 100644 --- 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 @@ -15,19 +15,21 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.modle.dto.connection; -import org.apache.eventmesh.dashboard.console.entity.connection.AddConnectionEntity; -import org.apache.eventmesh.dashboard.console.entity.connection.AddConnectorConfigEntity; +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 AddConnectionEntity addConnectionEntity; + private AddConnectionDTO addConnectionDTO; - private AddConnectorConfigEntity addConnectorConfigEntity; + 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 index ea5936d0..d6e0e317 100644 --- 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 @@ -15,10 +15,15 @@ * 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 { 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 index cd086ba9..bde8f813 100644 --- 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 @@ -15,10 +15,15 @@ * 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 { diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/meta/NewMetaDTO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/meta/NewMetaDTO.java index ff0888c2..44307054 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/meta/NewMetaDTO.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/meta/NewMetaDTO.java @@ -15,10 +15,15 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.modle.dto.meta; +import lombok.AllArgsConstructor; import lombok.Data; +import lombok.NoArgsConstructor; +@NoArgsConstructor +@AllArgsConstructor @Data public class NewMetaDTO { diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/operation/OperationBaseDTO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/operation/OperationBaseDTO.java new file mode 100644 index 00000000..0c084a59 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/operation/OperationBaseDTO.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.operation; + +import org.apache.eventmesh.dashboard.common.enums.MetadataType; +import org.apache.eventmesh.dashboard.common.enums.OperationRange.OperationRangeType; +import org.apache.eventmesh.dashboard.console.modle.ClusterIdDTO; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 问题:数据关系。批量修改行为如何处理 比如:修改 runtime 的配置。用户行为如何。 具体数据由子类决定。 视图称提供多维度数据视图与操作 1. 添加 2. 删除 3. 修改 4. queue + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class OperationBaseDTO extends ClusterIdDTO { + + private MetadataType rangeType; + + + /** + * 页面传递 + */ + private OperationRangeType operationRangeType; + + /** + * 页面传递 + */ + private Long operationRangeId; + + /** + * 操作目标 id , 修噶配置,重置offset,拷贝 metadata + */ + private Long operationDataTypeId; + + private Long operationDataId; +} 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 index 15d9c8b1..a6e3cb61 100644 --- 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 @@ -15,19 +15,22 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.modle.dto.topic; +import org.apache.eventmesh.dashboard.console.modle.dto.operation.OperationBaseDTO; + import lombok.Data; +import lombok.EqualsAndHashCode; /** * TODO this class is copied from storage plugin, needs update */ @Data -public class CreateTopicDTO { - - private Long clusterId; +@EqualsAndHashCode(callSuper = true) +public class CreateTopicDTO extends OperationBaseDTO { private String name; 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 index b3652781..88f25db2 100644 --- 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 @@ -15,15 +15,16 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.modle.dto.topic; +import org.apache.eventmesh.dashboard.console.modle.ClusterIdDTO; + import lombok.Data; @Data -public class GetTopicListDTO { - - private Long clusterId; +public class GetTopicListDTO extends ClusterIdDTO { private String topicName; } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/function/OverviewDTO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/function/OverviewDTO.java index 1edd8df9..d6b49808 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/function/OverviewDTO.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/function/OverviewDTO.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.modle.function; import org.apache.eventmesh.dashboard.console.modle.IdDTO; @@ -22,8 +23,10 @@ import javax.validation.constraints.NotNull; import lombok.Data; +import lombok.EqualsAndHashCode; @Data +@EqualsAndHashCode(callSuper = true) public class OverviewDTO extends IdDTO { @NotNull diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/function/OverviewType.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/function/OverviewType.java index 33172446..7e10c85e 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/function/OverviewType.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/function/OverviewType.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.modle.function; public enum OverviewType { diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/message/offset/QueryOffsetByMessageMetadataDTO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/message/offset/QueryOffsetByMessageMetadataDTO.java index 3e59a03a..c9ac5bdc 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/message/offset/QueryOffsetByMessageMetadataDTO.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/message/offset/QueryOffsetByMessageMetadataDTO.java @@ -15,14 +15,17 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.modle.message.offset; import org.apache.eventmesh.dashboard.console.modle.ClusterIdDTO; import lombok.Data; +import lombok.EqualsAndHashCode; @Data +@EqualsAndHashCode(callSuper = true) public class QueryOffsetByMessageMetadataDTO extends ClusterIdDTO { diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/message/offset/ResetOffsetDTO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/message/offset/ResetOffsetDTO.java index ca3b9d87..eb559a7d 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/message/offset/ResetOffsetDTO.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/message/offset/ResetOffsetDTO.java @@ -16,24 +16,35 @@ */ + package org.apache.eventmesh.dashboard.console.modle.message.offset; +import org.apache.eventmesh.dashboard.common.enums.OperationRange.OperationRangeType; import org.apache.eventmesh.dashboard.common.enums.ResetOffsetMode; import org.apache.eventmesh.dashboard.console.modle.ClusterIdDTO; +import java.time.LocalDateTime; + import lombok.Data; +import lombok.EqualsAndHashCode; @Data +@EqualsAndHashCode(callSuper = true) public class ResetOffsetDTO extends ClusterIdDTO { - private Long groupId; + private OperationRangeType operationRangeType; + + private Long rangeId; - private String groupName; + private Long subscribeId; - private Integer partitionId; + private Integer queueIndex; private ResetOffsetMode resetOffsetMode; - private String modeValue; + /** + * + */ + private LocalDateTime resetTime; } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/vo/RuntimeIdDTO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/vo/RuntimeIdDTO.java new file mode 100644 index 00000000..62fccd87 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/vo/RuntimeIdDTO.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; + +import org.apache.eventmesh.dashboard.console.modle.ClusterIdDTO; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class RuntimeIdDTO extends ClusterIdDTO { + + private Long runtimeId; + +} 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 index fde7d2ef..8652652b 100644 --- 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 @@ -15,10 +15,15 @@ * 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 { 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 index 95deb96e..a7dab34f 100644 --- 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 @@ -15,10 +15,15 @@ * 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 { 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 index 61846b9d..495b3384 100644 --- 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 @@ -15,11 +15,16 @@ * 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; 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 index 9abd0d26..d11bd9ef 100644 --- 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 @@ -15,10 +15,15 @@ * 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 { 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 index 10581e5e..d6f2a6d0 100644 --- 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 @@ -15,12 +15,17 @@ * 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 { diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/DataServiceWrapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/DataServiceWrapper.java deleted file mode 100644 index a687b3bc..00000000 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/DataServiceWrapper.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.console.service; - - -import org.apache.eventmesh.dashboard.console.service.cluster.ClientDataService; -import org.apache.eventmesh.dashboard.console.service.cluster.ClusterService; -import org.apache.eventmesh.dashboard.console.service.cluster.ConnectionDataService; -import org.apache.eventmesh.dashboard.console.service.cluster.RuntimeService; -import org.apache.eventmesh.dashboard.console.service.connector.ConnectorDataService; -import org.apache.eventmesh.dashboard.console.service.function.ConfigService; -import org.apache.eventmesh.dashboard.console.service.function.HealthDataService; -import org.apache.eventmesh.dashboard.console.service.message.GroupMemberService; -import org.apache.eventmesh.dashboard.console.service.message.GroupService; -import org.apache.eventmesh.dashboard.console.service.message.TopicService; -import org.apache.eventmesh.dashboard.console.service.store.StoreService; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import lombok.Getter; - -/** - * DataServiceWrapper is a wrapper class for all data services. It is used to inject all data services in spring environment. - */ -@Component -@Getter -public class DataServiceWrapper { - - @Autowired - private ClientDataService clientDataService; - - @Autowired - private ClusterService clusterDataService; - - @Autowired - private ConfigService configDataService; - - @Autowired - private ConnectionDataService connectionDataService; - - @Autowired - private ConnectorDataService connectorDataService; - - @Autowired - private GroupService groupDataService; - - @Autowired - private GroupMemberService groupMemberDataService; - - @Autowired - private HealthDataService healthDataService; - - @Autowired - private RuntimeService runtimeDataService; - - @Autowired - private StoreService storeDataService; - - @Autowired - private TopicService topicDataService; -} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/OverviewService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/OverviewService.java index cf919fd7..6516540e 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/OverviewService.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/OverviewService.java @@ -15,9 +15,10 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.service; -import org.apache.eventmesh.dashboard.console.modle.function.OverviewType; +import org.apache.eventmesh.dashboard.console.modle.function.OverviewDTO; /** * @@ -25,5 +26,5 @@ public interface OverviewService { - Object overview(OverviewType overviewType); + Object overview(OverviewDTO overviewDTO); } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/AclService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/AclService.java index 8702d758..3504e74b 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/AclService.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/AclService.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.service.cluster; import org.apache.eventmesh.dashboard.console.entity.cluster.AclEntity; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/ClientDataService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/ClientDataService.java index eb555456..bb8b7535 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/ClientDataService.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/ClientDataService.java @@ -15,9 +15,11 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.service.cluster; import org.apache.eventmesh.dashboard.console.entity.cluster.ClientEntity; +import org.apache.eventmesh.dashboard.console.modle.cluster.client.QueryClientByUserFormDTO; import java.util.List; @@ -26,15 +28,9 @@ */ public interface ClientDataService { - Integer deActive(ClientEntity clientEntity); - - Integer deActiveByHostPort(ClientEntity clientEntity); - - void insertClient(ClientEntity clientEntity); - - Integer batchInsert(List clientEntityList); + List queryClientByUserForm(QueryClientByUserFormDTO queryClientByUserFormDTO); - List selectByHostPort(ClientEntity clientEntity); + void batchInsert(List clientEntityList); List selectByClusterId(ClientEntity clientEntity); } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/ClusterRelationshipService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/ClusterRelationshipService.java index 18c2cb2d..1523bb3d 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/ClusterRelationshipService.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/ClusterRelationshipService.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.service.cluster; import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterAndRelationshipEntity; @@ -28,7 +29,9 @@ public interface ClusterRelationshipService { - void insertClusterRelationshipEntry(ClusterRelationshipEntity clusterRelationshipEntity); + Integer addClusterRelationshipEntry(ClusterRelationshipEntity clusterRelationshipEntity); + + Integer addClusterRelationshipEntry(List clusterRelationshipList); Integer relieveRelationship(ClusterRelationshipEntity clusterRelationshipEntity); @@ -39,4 +42,7 @@ public interface ClusterRelationshipService { List selectNewlyIncreased(ClusterRelationshipEntity clusterRelationshipEntity); + List queryByUpdateTime(ClusterRelationshipEntity clusterRelationshipEntity); + + } 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 66ecfb6e..a38ce54f 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 @@ -15,11 +15,15 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.service.cluster; import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterRelationshipEntity; +import org.apache.eventmesh.dashboard.console.modle.ClusterIdDTO; import org.apache.eventmesh.dashboard.console.modle.vo.cluster.GetClusterBaseMessageVO; +import java.util.Deque; import java.util.List; import java.util.Map; @@ -29,14 +33,29 @@ public interface ClusterService { + boolean nameExist(ClusterEntity clusterEntity); + + ClusterEntity queryClusterById(ClusterEntity clusterEntity); + + List queryClusterByOrganizationIdAndType(ClusterEntity clusterEntity); + + + List queryRelationClusterByClusterIdAndType(ClusterEntity clusterEntity); + + ClusterEntity queryRelationshipClusterByClusterIdAndType(ClusterEntity clusterEntity); + + List queryStorageByClusterId(ClusterEntity clusterEntity); + + List queryAllSubClusterByClusterId(ClusterEntity clusterEntity); + void createCluster(ClusterEntity clusterEntity); - GetClusterBaseMessageVO selectClusterBaseMessage(Long clusterId); + GetClusterBaseMessageVO getClusterBaseMessage(ClusterIdDTO clusterIdDTO); - Map queryHomeClusterData(Long clusterId); + Map queryHomeClusterData(ClusterIdDTO clusterIdDTO); - Integer batchInsert(List clusterEntities); + Integer batchInsert(List clusterEntities, ClusterEntity clusterEntity); List selectAll(); @@ -44,11 +63,16 @@ public interface ClusterService { void insertCluster(ClusterEntity cluster); + void insertClusterAndRelationship(ClusterEntity cluster, ClusterRelationshipEntity clusterRelationshipEntity); + List selectAllCluster(); - ClusterEntity selectClusterById(ClusterEntity cluster); Integer updateClusterById(ClusterEntity cluster); Integer deactivate(ClusterEntity cluster); + + List queryByUpdateTime(ClusterEntity clusterEntity); + + Deque getIndex(ClusterEntity clusterEntity); } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/ConnectionDataService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/ConnectionDataService.java index c1a6345f..4533a2dd 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/ConnectionDataService.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/ConnectionDataService.java @@ -15,23 +15,21 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.service.cluster; -import org.apache.eventmesh.dashboard.console.entity.CreateConnectionEntity; import org.apache.eventmesh.dashboard.console.entity.cluster.ConnectionEntity; import org.apache.eventmesh.dashboard.console.entity.connector.ConnectorEntity; import org.apache.eventmesh.dashboard.console.entity.function.ConfigEntity; +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; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - /** * Service providing ConnectionEntity data. */ -@Service public interface ConnectionDataService { ConnectorEntity getConnectorById(Long connectorId); @@ -40,16 +38,13 @@ public interface ConnectionDataService { List getAllConnectionsByClusterId(Long clusterId); - boolean createConnection(CreateConnectionEntity connectionEntity); + boolean createConnection(CreateConnectionDTO createConnectionDTO); List getAllConnections(); - List getConnectionToFrontByCluster(ConnectionEntity connectionEntity); - - @Transactional - void replaceAllConnections(List connectionEntityList); + List getConnectionToFrontByCluster(Long clusterId, GetConnectionListDTO getConnectionListDTO); List getConnectorConfigsByClassAndVersion(String classType, String version); - void insert(ConnectionEntity connectionEntity); + Long insert(ConnectionEntity connectionEntity); } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/RuntimeService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/RuntimeService.java index d8011542..f0c68baf 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/RuntimeService.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/RuntimeService.java @@ -15,10 +15,13 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.service.cluster; import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; +import org.apache.eventmesh.dashboard.console.modle.DO.runtime.QueryRuntimeByBigExpandClusterDO; +import org.apache.eventmesh.dashboard.console.modle.deploy.ClusterAllMetadataDO; import java.util.List; @@ -29,19 +32,27 @@ public interface RuntimeService { RuntimeEntity queryRuntimeEntityById(RuntimeEntity runtimeEntity); - List selectRuntimeToFrontByClusterId(RuntimeEntity runtimeEntity); + List queryRuntimeToFrontByClusterId(RuntimeEntity runtimeEntity); + + List queryRuntimeByBigExpandCluster(QueryRuntimeByBigExpandClusterDO data); + + List queryMetaRuntimeByStorageClusterId(QueryRuntimeByBigExpandClusterDO queryRuntimeByBigExpandClusterDO); + + ClusterAllMetadataDO queryAllByClusterId(RuntimeEntity runtimeEntity, boolean isRuntime, boolean isRelationship); + + void batchInsert(List runtimeEntities); - Integer batchInsert(List runtimeEntities); + Integer batchUpdate(List runtimeEntities); List selectAll(); - List selectByHostPort(RuntimeEntity runtimeEntity); + List queryByUpdateTime(RuntimeEntity runtimeEntity); void insertRuntime(RuntimeEntity runtimeEntity); - Integer updateRuntimeByCluster(RuntimeEntity runtimeEntity); + void updateRuntimeByCluster(RuntimeEntity runtimeEntity); - Integer deleteRuntimeByCluster(RuntimeEntity runtimeEntity); + void deleteRuntimeByCluster(RuntimeEntity runtimeEntity); - Integer deactivate(RuntimeEntity runtimeEntity); + void deactivate(RuntimeEntity runtimeEntity); } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/impl/AclServiceImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/impl/AclServiceImpl.java index 80fb0740..6e555a82 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/impl/AclServiceImpl.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/impl/AclServiceImpl.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.service.cluster.impl; import org.apache.eventmesh.dashboard.console.entity.cluster.AclEntity; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/impl/ClientDataServiceImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/impl/ClientDataServiceImpl.java index c5f64fcc..ad78f7f9 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/impl/ClientDataServiceImpl.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/impl/ClientDataServiceImpl.java @@ -15,10 +15,12 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.service.cluster.impl; import org.apache.eventmesh.dashboard.console.entity.cluster.ClientEntity; import org.apache.eventmesh.dashboard.console.mapper.cluster.ClientMapper; +import org.apache.eventmesh.dashboard.console.modle.cluster.client.QueryClientByUserFormDTO; import org.apache.eventmesh.dashboard.console.service.cluster.ClientDataService; import java.util.List; @@ -32,31 +34,18 @@ public class ClientDataServiceImpl implements ClientDataService { @Autowired private ClientMapper clientMapper; - @Override - public Integer deActive(ClientEntity clientEntity) { - return clientMapper.deactivate(clientEntity); - } @Override - public Integer deActiveByHostPort(ClientEntity clientEntity) { - return clientMapper.deActiveByHostPort(clientEntity); + public List queryClientByUserForm(QueryClientByUserFormDTO queryClientByUserFormDTO) { + return this.clientMapper.queryClientByUserForm(queryClientByUserFormDTO); } - @SuppressWarnings("checkstyle:Indentation") - @Override - public void insertClient(ClientEntity clientEntity) { - clientMapper.insert(clientEntity); - } @Override - public Integer batchInsert(List clientEntityList) { - return clientMapper.batchInsert(clientEntityList); + public void batchInsert(List clientEntityList) { + clientMapper.batchInsert(clientEntityList); } - @Override - public List selectByHostPort(ClientEntity clientEntity) { - return clientMapper.selectByHostPort(clientEntity); - } @Override public List selectByClusterId(ClientEntity clientEntity) { diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/impl/ClusterRelationshipServiceImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/impl/ClusterRelationshipServiceImpl.java index 171cafea..4ec04426 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/impl/ClusterRelationshipServiceImpl.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/impl/ClusterRelationshipServiceImpl.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.service.cluster.impl; import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterAndRelationshipEntity; @@ -34,8 +35,13 @@ public class ClusterRelationshipServiceImpl implements ClusterRelationshipServic private ClusterRelationshipMapper clusterRelationshipMapper; @Override - public void insertClusterRelationshipEntry(ClusterRelationshipEntity clusterRelationshipEntity) { - this.clusterRelationshipMapper.insertClusterRelationshipEntry(clusterRelationshipEntity); + public Integer addClusterRelationshipEntry(ClusterRelationshipEntity clusterRelationshipEntity) { + return this.clusterRelationshipMapper.insertClusterRelationshipEntry(clusterRelationshipEntity); + } + + @Override + public Integer addClusterRelationshipEntry(List clusterRelationshipList) { + return this.clusterRelationshipMapper.batchClusterRelationshipEntry(clusterRelationshipList); } @Override @@ -50,11 +56,16 @@ public List queryClusterAndRelationshipEntityListB @Override public List selectAll() { - return this.clusterRelationshipMapper.selectAll(); + return this.clusterRelationshipMapper.queryAll(null); } @Override public List selectNewlyIncreased(ClusterRelationshipEntity clusterRelationshipEntity) { - return this.clusterRelationshipMapper.selectNewlyIncreased(); + return this.clusterRelationshipMapper.queryNewlyIncreased(clusterRelationshipEntity); + } + + @Override + public List queryByUpdateTime(ClusterRelationshipEntity clusterRelationshipEntity) { + return null; } } 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 3756faa4..fb6a9eb6 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 @@ -15,23 +15,29 @@ * limitations under the License. */ + 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.cluster.ClusterRelationshipEntity; import org.apache.eventmesh.dashboard.console.entity.cluster.ConnectionEntity; import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; import org.apache.eventmesh.dashboard.console.entity.message.GroupEntity; import org.apache.eventmesh.dashboard.console.entity.message.TopicEntity; import org.apache.eventmesh.dashboard.console.mapper.cluster.ClusterMapper; +import org.apache.eventmesh.dashboard.console.mapper.cluster.ClusterRelationshipMapper; import org.apache.eventmesh.dashboard.console.mapper.cluster.ConnectionMapper; import org.apache.eventmesh.dashboard.console.mapper.cluster.RuntimeMapper; -import org.apache.eventmesh.dashboard.console.mapper.message.OprGroupMapper; +import org.apache.eventmesh.dashboard.console.mapper.message.GroupMapper; import org.apache.eventmesh.dashboard.console.mapper.message.TopicMapper; -import org.apache.eventmesh.dashboard.console.modle.function.OverviewType; +import org.apache.eventmesh.dashboard.console.modle.ClusterIdDTO; +import org.apache.eventmesh.dashboard.console.modle.function.OverviewDTO; import org.apache.eventmesh.dashboard.console.modle.vo.cluster.GetClusterBaseMessageVO; import org.apache.eventmesh.dashboard.console.service.OverviewService; import org.apache.eventmesh.dashboard.console.service.cluster.ClusterService; +import java.util.ArrayList; +import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -48,11 +54,14 @@ public class ClusterServiceImpl implements ClusterService, OverviewService { @Autowired private ClusterMapper clusterMapper; + @Autowired + private ClusterRelationshipMapper clusterRelationshipMapper; + @Autowired private RuntimeMapper runtimeMapper; @Autowired - private OprGroupMapper oprGroupMapper; + private GroupMapper groupMapper; @Autowired private TopicMapper topicMapper; @@ -64,42 +73,99 @@ public void createCluster(ClusterEntity clusterEntity) { } @Override - public GetClusterBaseMessageVO selectClusterBaseMessage(Long clusterId) { + public ClusterEntity queryClusterById(ClusterEntity clusterEntity) { + return this.clusterMapper.queryByClusterId(clusterEntity); + } + + @Override + public List queryClusterByOrganizationIdAndType(ClusterEntity clusterEntity) { + return this.clusterMapper.queryClusterByOrganizationIdAndType(clusterEntity); + } + + @Override + public List queryRelationClusterByClusterIdAndType(ClusterEntity clusterEntity) { + return this.clusterMapper.queryRelationClusterByClusterIdAndType(clusterEntity); + } + + @Override + public ClusterEntity queryRelationshipClusterByClusterIdAndType(ClusterEntity clusterEntity) { + List queryData = new ArrayList<>(); + queryData.add(clusterEntity); + List clusterEntityList = this.clusterMapper.queryRelationshipClusterByClusterIdAndType(queryData); + return clusterEntityList.isEmpty() ? null : clusterEntityList.get(0); + } + + @Override + public List queryStorageByClusterId(ClusterEntity clusterEntity) { + List clusterEntityList = new ArrayList<>(); + this.clusterMapper.queryRelationshipClusterByClusterIdAndType(clusterEntityList).forEach(entity -> { + if (entity.getClusterType().isStorage()) { + clusterEntityList.add(entity); + } + }); + return clusterEntityList; + } + + + @Override + public List queryAllSubClusterByClusterId(ClusterEntity clusterEntity) { + return null; + } + + @Override + public boolean nameExist(ClusterEntity clusterEntity) { + return true; + } + + @Override + public GetClusterBaseMessageVO getClusterBaseMessage(ClusterIdDTO clusterIdDTO) { + Long clusterId = clusterIdDTO.getClusterId(); 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.selectConsumerNumByCluster(groupEntity)); + getClusterBaseMessageVO.setConsumerGroupNum(groupMapper.getConsumerNumByCluster(groupEntity)); ConnectionEntity connectionEntity = new ConnectionEntity(); connectionEntity.setClusterId(clusterId); getClusterBaseMessageVO.setConnectionNum(connectionMapper.selectConnectionNumByCluster(connectionEntity)); RuntimeEntity runtimeEntity = new RuntimeEntity(); runtimeEntity.setClusterId(clusterId); - getClusterBaseMessageVO.setRuntimeNum(runtimeMapper.selectRuntimeNumByCluster(runtimeEntity)); + getClusterBaseMessageVO.setRuntimeNum(runtimeMapper.getRuntimeNumByCluster(runtimeEntity)); return getClusterBaseMessageVO; } @Override - public Map queryHomeClusterData(Long clusterId) { + public Map queryHomeClusterData(ClusterIdDTO clusterIdDTO) { return null; } @Override - public Integer batchInsert(List clusterEntities) { - return clusterMapper.batchInsert(clusterEntities); + public Integer batchInsert(List clusterEntities, ClusterEntity clusterEntity) { + clusterMapper.batchInsert(clusterEntities); + List clusterRelationshipEntityList = new ArrayList<>(); + clusterEntities.forEach(entity -> { + ClusterRelationshipEntity clusterRelationshipEntity = new ClusterRelationshipEntity(); + clusterRelationshipEntityList.add(clusterRelationshipEntity); + + clusterRelationshipEntityList.add(clusterRelationshipEntity); + clusterRelationshipEntity.setClusterId(clusterEntity.getId()); + clusterRelationshipEntity.setClusterType(clusterEntity.getClusterType()); + }); + this.clusterRelationshipMapper.batchClusterRelationshipEntry(clusterRelationshipEntityList); + return 1; } @Override public List selectAll() { - return clusterMapper.selectAllCluster(); + return clusterMapper.queryAllCluster(); } @Override public List selectNewlyIncreased(ClusterEntity clusterEntity) { - return clusterMapper.selectAllCluster(); + return clusterMapper.queryAllCluster(); } @Override @@ -108,13 +174,14 @@ public void insertCluster(ClusterEntity cluster) { } @Override - public List selectAllCluster() { - return clusterMapper.selectAllCluster(); + public void insertClusterAndRelationship(ClusterEntity cluster, ClusterRelationshipEntity clusterRelationshipEntity) { + clusterMapper.insertCluster(cluster); + clusterRelationshipMapper.insertClusterRelationshipEntry(clusterRelationshipEntity); } @Override - public ClusterEntity selectClusterById(ClusterEntity cluster) { - return clusterMapper.selectClusterById(cluster); + public List selectAllCluster() { + return clusterMapper.queryAllCluster(); } @@ -129,7 +196,23 @@ public Integer deactivate(ClusterEntity cluster) { } @Override - public Object overview(OverviewType overviewtype) { + public Object overview(OverviewDTO overviewDTO) { return null; } + + @Override + public List queryByUpdateTime(ClusterEntity clusterEntity) { + return null; + } + + @Override + public LinkedList getIndex(ClusterEntity clusterEntity) { + ClusterEntity before = this.clusterMapper.lockByClusterId(clusterEntity); + this.clusterMapper.updateNumByClusterId(clusterEntity); + LinkedList indexList = new LinkedList<>(); + for (int i = before.getRuntimeIndex(); i <= before.getRuntimeIndex() + clusterEntity.getRuntimeIndex(); i++) { + indexList.add(i); + } + return indexList; + } } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/impl/ConnectionDataServiceDatabaseImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/impl/ConnectionDataServiceDatabaseImpl.java deleted file mode 100644 index 2ba287a8..00000000 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/impl/ConnectionDataServiceDatabaseImpl.java +++ /dev/null @@ -1,231 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.console.service.cluster.impl; - - - -import org.apache.eventmesh.dashboard.console.annotation.EmLog; -import org.apache.eventmesh.dashboard.console.entity.CreateConnectionEntity; -import org.apache.eventmesh.dashboard.console.entity.cluster.ConnectionEntity; -import org.apache.eventmesh.dashboard.console.entity.connection.AddConnectionEntity; -import org.apache.eventmesh.dashboard.console.entity.connector.ConnectorEntity; -import org.apache.eventmesh.dashboard.console.entity.function.ConfigEntity; -import org.apache.eventmesh.dashboard.console.mapper.cluster.ConnectionMapper; -import org.apache.eventmesh.dashboard.console.mapper.connector.ConnectorMapper; -import org.apache.eventmesh.dashboard.console.mapper.function.ConfigMapper; -import org.apache.eventmesh.dashboard.console.modle.vo.connection.ConnectionListVO; -import org.apache.eventmesh.dashboard.console.service.cluster.ConnectionDataService; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - - -@Service -public class ConnectionDataServiceDatabaseImpl implements ConnectionDataService { - - @Autowired - private ConnectionMapper connectionMapper; - - @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) { - ConnectionEntity connectionEntity = new ConnectionEntity(); - connectionEntity.setClusterId(clusterId); - return connectionMapper.selectByClusterId(connectionEntity); - } - - @Override - public void insert(ConnectionEntity connectionEntity) { - connectionMapper.insert(connectionEntity); - } - - - @EmLog(OprType = "add", OprTarget = "Connection") - @Override - public boolean createConnection(CreateConnectionEntity createConnectionEntity) { - ConnectorEntity sinkConnector = this.createSinkConnector(createConnectionEntity.getClusterId(), - createConnectionEntity.getAddConnectionEntity()); - ConnectorEntity sourceConnector = this.createSourceConnector(createConnectionEntity.getClusterId(), - createConnectionEntity.getAddConnectionEntity()); - ConnectionEntity connectionEntity = this.setConnection(createConnectionEntity); - connectionEntity.setSinkId(sinkConnector.getId()); - connectionEntity.setSourceId(sourceConnector.getId()); - connectionMapper.insert(connectionEntity); - this.addConnectorConfigs(createConnectionEntity.getAddConnectorConfigEntity().getSinkConnectorConfigs(), sinkConnector); - this.addConnectorConfigs(createConnectionEntity.getAddConnectorConfigEntity().getSourceConnectorConfigs(), sourceConnector); - return false; - } - - private ConnectionEntity setConnection(CreateConnectionEntity createConnectionEntity) { - ConnectionEntity connectionEntity = new ConnectionEntity(); - connectionEntity.setClusterId(createConnectionEntity.getClusterId()); - connectionEntity.setSourceType("connector"); - connectionEntity.setSinkType("connector"); - connectionEntity.setRuntimeId(-1L); - connectionEntity.setGroupId(createConnectionEntity.getAddConnectionEntity().getGroupId()); - connectionEntity.setStatus(1); - connectionEntity.setDescription(createConnectionEntity.getAddConnectionEntity().getConnectionDescription()); - connectionEntity.setTopic(createConnectionEntity.getAddConnectionEntity().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, AddConnectionEntity addConnectionEntity) { - ConnectorEntity connectorEntity = new ConnectorEntity(); - connectorEntity.setName(addConnectionEntity.getSinkName()); - connectorEntity.setHost(addConnectionEntity.getSinkHost()); - connectorEntity.setClusterId(clusterId); - connectorEntity.setClassName(addConnectionEntity.getSinkClass()); - connectorEntity.setType("Connector"); - connectorEntity.setStatus(1); - connectorEntity.setPodState(0); - connectorEntity.setPort(addConnectionEntity.getSinkPort()); - connectorMapper.insert(connectorEntity); - return connectorEntity; - } - - public ConnectorEntity createSourceConnector(Long clusterId, AddConnectionEntity addConnectionEntity) { - ConnectorEntity connectorEntity = new ConnectorEntity(); - connectorEntity.setName(addConnectionEntity.getSourceName()); - connectorEntity.setHost(addConnectionEntity.getSourceHost()); - connectorEntity.setClusterId(clusterId); - connectorEntity.setClassName(addConnectionEntity.getSourceClass()); - connectorEntity.setType("Connector"); - connectorEntity.setStatus(1); - connectorEntity.setPodState(0); - connectorEntity.setPort(addConnectionEntity.getSourcePort()); - connectorMapper.insert(connectorEntity); - return connectorEntity; - } - - - @Override - public List getAllConnections() { - return connectionMapper.selectAll(); - } - - @Override - public List getConnectionToFrontByCluster(ConnectionEntity 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 - public void replaceAllConnections(List connectionEntityList) { - Map> connectionsGroupedByClusterId = connectionEntityList.stream() - .collect(Collectors.groupingBy(ConnectionEntity::getClusterId)); - - connectionsGroupedByClusterId.forEach((clusterId, newConnections) -> { - ConnectionEntity connectionEntity = new ConnectionEntity(); - connectionEntity.setClusterId(clusterId); - List existingConnections = connectionMapper.selectByClusterId(connectionEntity); - - // Collect connections that are not in the new list - List connectionsToInactive = existingConnections.stream() - .filter(existingConnection -> !newConnections.contains(existingConnection)) - .collect(Collectors.toList()); - - // Collect new connections that are not in the existing list - List connectionsToInsert = newConnections.stream() - .filter(connection -> !existingConnections.contains(connection)) - .collect(Collectors.toList()); - - // Delete connections in batch - if (!connectionsToInactive.isEmpty()) { - connectionMapper.batchEndConnectionById(connectionsToInactive); - } - - // Insert new connections in batch - if (!connectionsToInsert.isEmpty()) { - connectionMapper.batchInsert(connectionsToInsert); - } - }); - } - - - @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/cluster/impl/InstanceUserServiceImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/impl/InstanceUserServiceImpl.java deleted file mode 100644 index 716e1d4f..00000000 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/impl/InstanceUserServiceImpl.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.console.service.cluster.impl; - -import org.apache.eventmesh.dashboard.console.entity.cluster.InstanceUserEntity; -import org.apache.eventmesh.dashboard.console.mapper.cluster.InstanceUserMapper; -import org.apache.eventmesh.dashboard.console.service.cluster.InstanceUserService; - -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -@Transactional - -@Service -public class InstanceUserServiceImpl implements InstanceUserService { - - @Autowired - private InstanceUserMapper instanceUserMapper; - - @Override - public void insert(InstanceUserEntity instanceuserEntity) { - instanceUserMapper.insert(instanceuserEntity); - } - - @Override - public void deleteInstanceUserByCluster(InstanceUserEntity instanceuserEntity) { - instanceUserMapper.deleteInstanceUserById(instanceuserEntity); - } - - @Override - public void updatePasswordById(InstanceUserEntity instanceuserEntity) { - instanceUserMapper.updatePasswordById(instanceuserEntity); - } - - @Override - public List selectAll() { - return instanceUserMapper.selectAll(); - } - - @Override - public InstanceUserEntity selectById(InstanceUserEntity instanceuserEntity) { - return instanceUserMapper.selectById(instanceuserEntity); - } - - @Override - public List selectByName(InstanceUserEntity instanceuserEntity) { - return instanceUserMapper.selectByName(instanceuserEntity); - } - -} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/impl/RuntimeServiceImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/impl/RuntimeServiceImpl.java index d414d137..54d4849a 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/impl/RuntimeServiceImpl.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/impl/RuntimeServiceImpl.java @@ -15,19 +15,29 @@ * limitations under the License. */ + 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.cluster.ClusterRelationshipEntity; import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; import org.apache.eventmesh.dashboard.console.function.health.CheckResultCache; +import org.apache.eventmesh.dashboard.console.mapper.cluster.ClusterMapper; +import org.apache.eventmesh.dashboard.console.mapper.cluster.ClusterRelationshipMapper; import org.apache.eventmesh.dashboard.console.mapper.cluster.RuntimeMapper; import org.apache.eventmesh.dashboard.console.mapper.function.HealthCheckResultMapper; +import org.apache.eventmesh.dashboard.console.modle.DO.clusterRelationship.QueryListByClusterIdAndTypeDO; +import org.apache.eventmesh.dashboard.console.modle.DO.runtime.QueryRuntimeByBigExpandClusterDO; +import org.apache.eventmesh.dashboard.console.modle.deploy.ClusterAllMetadataDO; import org.apache.eventmesh.dashboard.console.service.cluster.RuntimeService; +import java.util.ArrayList; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; @Service public class RuntimeServiceImpl implements RuntimeService { @@ -39,14 +49,74 @@ public class RuntimeServiceImpl implements RuntimeService { private HealthCheckResultMapper healthCheckResultMapper; + @Autowired + private ClusterMapper clusterMapper; + + + @Autowired + private ClusterRelationshipMapper clusterRelationshipMapper; + @Override public RuntimeEntity queryRuntimeEntityById(RuntimeEntity runtimeEntity) { return this.runtimeMapper.queryRuntimeEntityById(runtimeEntity); } + + @Override + public List queryRuntimeByBigExpandCluster(QueryRuntimeByBigExpandClusterDO queryRuntimeByBigExpandClusterDO) { + return this.runtimeMapper.queryRuntimeByBigExpandCluster(queryRuntimeByBigExpandClusterDO); + } + @Override - public List selectRuntimeToFrontByClusterId(RuntimeEntity runtimeEntity) { - List runtimeByClusterId = runtimeMapper.selectRuntimesToFrontByCluster(runtimeEntity); + public List queryMetaRuntimeByStorageClusterId(QueryRuntimeByBigExpandClusterDO queryRuntimeByBigExpandClusterDO) { + // 通过 storage cluster id , 获得 main cluster id + // 通过 子集群 id 获得 主(多) 集群 下面的其他集群 + return this.runtimeMapper.queryClusterRuntimeOnClusterSpecifyByClusterId(queryRuntimeByBigExpandClusterDO); + } + + @Override + @Transactional(readOnly = true) + public ClusterAllMetadataDO queryAllByClusterId(RuntimeEntity runtimeEntity, boolean isRuntime, boolean isRelationship) { + + ClusterEntity clusterEntity = new ClusterEntity(); + clusterEntity.setId(runtimeEntity.getClusterId()); + clusterEntity = this.clusterMapper.queryByClusterId(clusterEntity); + + List clusterEntityList = new ArrayList<>(); + List definitionList = new ArrayList<>(); + definitionList.add(clusterEntity); + for (int i = 0; i < 5; i++) { + List relationshipList = this.clusterMapper.queryRelationshipClusterByClusterIdAndType(definitionList); + definitionList.clear(); + relationshipList.forEach(entity -> { + if (entity.getClusterType().isRuntime()) { + definitionList.add(entity); + } + clusterEntityList.add(entity); + }); + if (definitionList.isEmpty()) { + break; + } + } + + ClusterAllMetadataDO clusterAllMetadata = new ClusterAllMetadataDO(); + clusterAllMetadata.setClusterEntityList(clusterEntityList); + if (isRuntime) { + List runtimeEntityList = this.runtimeMapper.queryRuntimeByClusterId(clusterEntityList); + clusterAllMetadata.setRuntimeEntityList(runtimeEntityList); + } + if (isRelationship) { + QueryListByClusterIdAndTypeDO data = QueryListByClusterIdAndTypeDO.builder().build(); + List relationshipEntityList = + this.clusterRelationshipMapper.queryClusterRelationshipEntityListByClusterId(data); + clusterAllMetadata.setClusterRelationshipEntityList(relationshipEntityList); + } + return clusterAllMetadata; + } + + @Override + public List queryRuntimeToFrontByClusterId(RuntimeEntity runtimeEntity) { + List runtimeByClusterId = runtimeMapper.getRuntimesToFrontByCluster(runtimeEntity); runtimeByClusterId.forEach(n -> { n.setStatus(CheckResultCache.getINSTANCE().getLastHealthyCheckResult("runtime", n.getId())); }); @@ -55,37 +125,43 @@ public List selectRuntimeToFrontByClusterId(RuntimeEntity runtime @Override - public Integer batchInsert(List runtimeEntities) { - return runtimeMapper.batchInsert(runtimeEntities); + public void batchInsert(List runtimeEntities) { + runtimeMapper.batchInsert(runtimeEntities); + } + + @Override + public Integer batchUpdate(List runtimeEntities) { + return 0; } @Override public List selectAll() { - return runtimeMapper.selectAll(); + return runtimeMapper.queryAll(); } @Override - public List selectByHostPort(RuntimeEntity runtimeEntity) { - return runtimeMapper.selectByHostPort(runtimeEntity); + public List queryByUpdateTime(RuntimeEntity runtimeEntity) { + return runtimeMapper.queryByUpdateTime(runtimeEntity); } + @Override public void insertRuntime(RuntimeEntity runtimeEntity) { runtimeMapper.insertRuntime(runtimeEntity); } @Override - public Integer updateRuntimeByCluster(RuntimeEntity runtimeEntity) { - return runtimeMapper.updateRuntimeByCluster(runtimeEntity); + public void updateRuntimeByCluster(RuntimeEntity runtimeEntity) { + runtimeMapper.updateRuntimeByCluster(runtimeEntity); } @Override - public Integer deleteRuntimeByCluster(RuntimeEntity runtimeEntity) { - return runtimeMapper.deleteRuntimeByCluster(runtimeEntity); + public void deleteRuntimeByCluster(RuntimeEntity runtimeEntity) { + runtimeMapper.deleteRuntimeByCluster(runtimeEntity); } @Override - public Integer deactivate(RuntimeEntity runtimeEntity) { - return runtimeMapper.deactivate(runtimeEntity); + public void deactivate(RuntimeEntity runtimeEntity) { + runtimeMapper.deactivate(runtimeEntity); } } 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 227f1e91..c8d45c54 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 @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.service.connector; import org.apache.eventmesh.dashboard.console.entity.connector.ConnectorEntity; @@ -26,7 +27,7 @@ */ public interface ConnectorDataService { - void createConnector(ConnectorEntity connectorEntity); + Long createConnector(ConnectorEntity connectorEntity); List selectAll(); 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 12ac190e..51ebb6f6 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 @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.service.connector.Impl; import org.apache.eventmesh.dashboard.console.entity.connector.ConnectorEntity; @@ -33,8 +34,8 @@ public class ConnectorDataServiceImpl implements ConnectorDataService { private ConnectorMapper connectorMapper; @Override - public void createConnector(ConnectorEntity connectorEntity) { - connectorMapper.insert(connectorEntity); + public Long createConnector(ConnectorEntity connectorEntity) { + return connectorMapper.insert(connectorEntity); } @Override diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/cluster/TopicSyncFromClusterService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/connector/Impl/ResourcesConfigServiceImpl.java similarity index 52% rename from eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/cluster/TopicSyncFromClusterService.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/connector/Impl/ResourcesConfigServiceImpl.java index a12dee50..139eb3a0 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/cluster/TopicSyncFromClusterService.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/connector/Impl/ResourcesConfigServiceImpl.java @@ -15,43 +15,41 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.core.metadata.cluster; -import org.apache.eventmesh.dashboard.common.model.metadata.TopicMetadata; -import org.apache.eventmesh.dashboard.common.model.remoting.GlobalRequest; -import org.apache.eventmesh.dashboard.common.model.remoting.GlobalResult; -import org.apache.eventmesh.dashboard.common.model.remoting.topic.GetTopicsRequest; -import org.apache.eventmesh.dashboard.service.remoting.TopicRemotingService; +package org.apache.eventmesh.dashboard.console.service.connector.Impl; + + +import org.apache.eventmesh.dashboard.console.entity.cases.ResourcesConfigEntity; +import org.apache.eventmesh.dashboard.console.service.connector.ResourcesConfigService; import java.util.List; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; -import lombok.extern.slf4j.Slf4j; - -@Slf4j @Service -public class TopicSyncFromClusterService extends AbstractMetadataHandler { +@Transactional +public class ResourcesConfigServiceImpl implements ResourcesConfigService { - @Override - public void addMetadata(TopicMetadata meta) { - } @Override - public void deleteMetadata(TopicMetadata meta) { + public void insertResources(ResourcesConfigEntity resourcesConfigEntity) { } - @Override - public List getData(GlobalRequest globalRequest) { + public ResourcesConfigEntity queryResourcesById(ResourcesConfigEntity resourcesConfigEntity) { return null; } + @Override + public List queryResourcesByOrganizationId(ResourcesConfigEntity resourcesConfigEntity) { + return List.of(); + } @Override - public GlobalResult request(TopicRemotingService topicRemotingService, GetTopicsRequest key) { - return null; + public void copyResources(ResourcesConfigEntity resourcesConfigEntity) { + } } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/connector/ResourcesConfigService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/connector/ResourcesConfigService.java new file mode 100644 index 00000000..41c38e23 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/connector/ResourcesConfigService.java @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.console.service.connector; + +import org.apache.eventmesh.dashboard.console.entity.cases.ResourcesConfigEntity; + +import java.util.List; + +/** + * + */ +public interface ResourcesConfigService { + + + + void insertResources(ResourcesConfigEntity resourcesConfigEntity); + + + ResourcesConfigEntity queryResourcesById(ResourcesConfigEntity resourcesConfigEntity); + + + List queryResourcesByOrganizationId(ResourcesConfigEntity resourcesConfigEntity); + + void copyResources(ResourcesConfigEntity resourcesConfigEntity); +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/deploy/DeployScriptService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/deploy/DeployScriptService.java new file mode 100644 index 00000000..81616ce2 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/deploy/DeployScriptService.java @@ -0,0 +1,41 @@ +/* + * 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.deploy; + +import org.apache.eventmesh.dashboard.console.entity.cases.DeployScriptEntity; + +/** + * + */ +public interface DeployScriptService { + + + void insert(DeployScriptEntity deployScriptEntity); + + + void update(DeployScriptEntity deployScriptEntity); + + + void deleteById(DeployScriptEntity deployScriptEntity); + + + DeployScriptEntity queryById(DeployScriptEntity deployScriptEntity); + + void queryByName(DeployScriptEntity deployScriptEntity); +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/deploy/PortService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/deploy/PortService.java new file mode 100644 index 00000000..d5937eb6 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/deploy/PortService.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.service.deploy; + +import org.apache.eventmesh.dashboard.console.modle.deploy.GetPortsDO; + +import java.util.List; + +/** + * + */ +public interface PortService { + + + List getPorts(GetPortsDO getPortsDO); + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/deploy/impl/DeployScriptServiceImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/deploy/impl/DeployScriptServiceImpl.java new file mode 100644 index 00000000..ab9c129f --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/deploy/impl/DeployScriptServiceImpl.java @@ -0,0 +1,61 @@ +/* + * 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.deploy.impl; + +import org.apache.eventmesh.dashboard.console.entity.cases.DeployScriptEntity; +import org.apache.eventmesh.dashboard.console.mapper.deploy.DeployScriptMapper; +import org.apache.eventmesh.dashboard.console.service.deploy.DeployScriptService; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + + +@Service +@Transactional +public class DeployScriptServiceImpl implements DeployScriptService { + + @Autowired + private DeployScriptMapper deployScriptMapper; + + @Override + public void insert(DeployScriptEntity deployScriptEntity) { + this.deployScriptMapper.insert(deployScriptEntity); + } + + @Override + public void update(DeployScriptEntity deployScriptEntity) { + this.deployScriptMapper.update(deployScriptEntity); + } + + @Override + public void deleteById(DeployScriptEntity deployScriptEntity) { + this.deployScriptMapper.deleteById(deployScriptEntity); + } + + @Override + public DeployScriptEntity queryById(DeployScriptEntity deployScriptEntity) { + return null; + } + + @Override + public void queryByName(DeployScriptEntity deployScriptEntity) { + this.deployScriptMapper.queryByName(deployScriptEntity); + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/deploy/impl/PortServiceImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/deploy/impl/PortServiceImpl.java new file mode 100644 index 00000000..7099316c --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/deploy/impl/PortServiceImpl.java @@ -0,0 +1,56 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.console.service.deploy.impl; + +import org.apache.eventmesh.dashboard.console.entity.cases.PortEntity; +import org.apache.eventmesh.dashboard.console.mapper.deploy.PortMapper; +import org.apache.eventmesh.dashboard.console.modle.deploy.GetPortsDO; +import org.apache.eventmesh.dashboard.console.service.deploy.PortService; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class PortServiceImpl implements PortService { + + @Autowired + private PortMapper portMapper; + + @Override + public List getPorts(GetPortsDO getPortsDO) { + PortEntity portEntity = new PortEntity(); + portEntity.setClusterId(getPortsDO.getClusterId()); + PortEntity newPort = this.portMapper.lockPort(portEntity); + if (Objects.isNull(newPort)) { + portEntity.setCurrentPort(2000); + this.portMapper.insertPort(portEntity); + newPort = this.portMapper.lockPort(portEntity); + } + List ports = new ArrayList<>(); + this.portMapper.updatePort(portEntity); + for (int i = 1; i <= getPortsDO.getPortNum(); i++) { + ports.add((newPort.getCurrentPort() + i) + ""); + } + return ports; + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/ConfigService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/ConfigService.java index c619bd17..5b3ab842 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/ConfigService.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/ConfigService.java @@ -15,11 +15,13 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.service.function; import org.apache.eventmesh.dashboard.console.entity.function.ConfigEntity; -import org.apache.eventmesh.dashboard.console.modle.config.ChangeConfigEntity; +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; @@ -30,18 +32,19 @@ */ public interface ConfigService { - List selectToFront(ConfigEntity configEntity); + List queryByClusterAndInstanceId(ConfigEntity configEntity); + + List selectToFront(Long instanceId, Integer type, GetConfigsListDTO getConfigsListDTO); - void updateConfigsByInstanceId(String name, Long clusterId, Integer instanceType, Long instanceId, - List changeConfigEntityList); + void updateConfigsByInstanceId(String name, Long clusterId, Integer instanceType, Long instanceId, List changeConfigDTOList); List selectAll(); - Integer batchInsert(List configEntityList); + void batchInsert(List configEntityList); - String mapToYaml(Map stringMap); + void copyConfig(Long sourceId, Long targetId); - void insertConfig(ConfigEntity configEntity); + void restoreConfig(Long sourceId, Long targetId); Integer deleteConfig(ConfigEntity configEntity); @@ -51,7 +54,7 @@ void updateConfigsByInstanceId(String name, Long clusterId, Integer instanceType List selectByInstanceIdAndType(Long instanceId, Integer type); - Map selectDefaultConfig(String businessType); + Map selectDefaultConfig(String version, Long instanceId, Integer instanceType); } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/HealthDataService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/HealthDataService.java index 2b7f370a..d37d5874 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/HealthDataService.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/HealthDataService.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.service.function; import org.apache.eventmesh.dashboard.console.entity.function.HealthCheckResultEntity; @@ -29,24 +30,24 @@ */ public interface HealthDataService { - InstanceLiveProportionVo selectInstanceLiveProportion(Long clusterId, Integer instanceType); + InstanceLiveProportionVo getInstanceLiveProportion(Long clusterId, Integer instanceType); - List selectInstanceLiveStatusHistory(Integer type, Long clusterId, LocalDateTime startTime); + List getInstanceLiveStatusHistory(Integer type, Long clusterId, LocalDateTime startTime); HealthCheckResultEntity insertHealthCheckResult(HealthCheckResultEntity healthCheckResultEntity); - Integer batchInsertHealthCheckResult(List healthCheckResultEntityList); + void batchInsertHealthCheckResult(List healthCheckResultEntityList); /** * New check results have state 4: SDK client not created or connected */ - Integer batchInsertNewCheckResult(List healthCheckResultEntityList); + void batchInsertNewCheckResult(List healthCheckResultEntityList); List selectAll(); List queryHealthCheckResultByClusterIdAndTypeAndTypeId(HealthCheckResultEntity entity); - Integer batchUpdateCheckResult(List healthCheckResultEntityList); + void batchUpdateCheckResult(List healthCheckResultEntityList); void batchUpdateCheckResultByClusterIdAndTypeAndTypeId(List healthCheckResultEntityList); diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/HealthDataServiceMemoryStorage.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/HealthDataServiceMemoryStorage.java index 43b99760..319b2aa5 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/HealthDataServiceMemoryStorage.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/HealthDataServiceMemoryStorage.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.service.function; import org.apache.eventmesh.dashboard.console.entity.function.HealthCheckResultEntity; @@ -28,6 +29,7 @@ import org.springframework.stereotype.Component; @Component +@Deprecated public class HealthDataServiceMemoryStorage { private static final List cache = new ArrayList<>(); diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/Impl/ConfigServiceImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/Impl/ConfigServiceImpl.java index b6b42c1d..38b19c5b 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/Impl/ConfigServiceImpl.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/Impl/ConfigServiceImpl.java @@ -15,14 +15,16 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.service.function.Impl; import org.apache.eventmesh.dashboard.console.annotation.EmLog; import org.apache.eventmesh.dashboard.console.entity.DefaultConfigKey; import org.apache.eventmesh.dashboard.console.entity.function.ConfigEntity; import org.apache.eventmesh.dashboard.console.mapper.function.ConfigMapper; -import org.apache.eventmesh.dashboard.console.modle.config.ChangeConfigEntity; -import org.apache.eventmesh.dashboard.console.modle.config.UpdateConfigsLog; +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.function.ConfigService; import java.util.Arrays; @@ -48,10 +50,10 @@ public class ConfigServiceImpl implements ConfigService { @EmLog(OprTarget = "Runtime", OprType = "UpdateConfigs") - public void logUpdateRuntimeConfigs(UpdateConfigsLog updateConfigsLog, List changeConfigEntityList) { - changeConfigEntityList.forEach(n -> { + public void logUpdateRuntimeConfigs(UpdateConfigsLog updateConfigsLog, List changeConfigDTOList) { + changeConfigDTOList.forEach(n -> { ConfigEntity config = new ConfigEntity(); - config.setInstanceType(0); + config.setInstanceType(null); config.setInstanceId(updateConfigsLog.getInstanceId()); config.setConfigName(n.getConfigName()); config.setConfigValue(n.getConfigValue()); @@ -62,10 +64,10 @@ public void logUpdateRuntimeConfigs(UpdateConfigsLog updateConfigsLog, List changeConfigEntityList) { - changeConfigEntityList.forEach(n -> { + public void logUpdateStoreConfigs(UpdateConfigsLog updateConfigsLog, List changeConfigDTOList) { + changeConfigDTOList.forEach(n -> { ConfigEntity config = new ConfigEntity(); - config.setInstanceType(1); + config.setInstanceType(null); config.setInstanceId(updateConfigsLog.getInstanceId()); config.setConfigName(n.getConfigName()); config.setConfigValue(n.getConfigValue()); @@ -76,10 +78,10 @@ public void logUpdateStoreConfigs(UpdateConfigsLog updateConfigsLog, List changeConfigEntityList) { - changeConfigEntityList.forEach(n -> { + public void logUpdateConnectorConfigs(UpdateConfigsLog updateConfigsLog, List changeConfigDTOList) { + changeConfigDTOList.forEach(n -> { ConfigEntity config = new ConfigEntity(); - config.setInstanceType(2); + config.setInstanceType(null); config.setInstanceId(updateConfigsLog.getInstanceId()); config.setConfigName(n.getConfigName()); config.setConfigValue(n.getConfigValue()); @@ -90,10 +92,10 @@ public void logUpdateConnectorConfigs(UpdateConfigsLog updateConfigsLog, List changeConfigEntityList) { - changeConfigEntityList.forEach(n -> { + public void logUpdateTopicConfigs(UpdateConfigsLog updateConfigsLog, List changeConfigDTOList) { + changeConfigDTOList.forEach(n -> { ConfigEntity config = new ConfigEntity(); - config.setInstanceType(3); + config.setInstanceType(null); config.setInstanceId(updateConfigsLog.getInstanceId()); config.setConfigName(n.getConfigName()); config.setConfigValue(n.getConfigValue()); @@ -104,40 +106,51 @@ public void logUpdateTopicConfigs(UpdateConfigsLog updateConfigsLog, List changeConfigEntityList) { + List changeConfigDTOList) { ConcurrentHashMap stringStringConcurrentHashMap = new ConcurrentHashMap<>(); - changeConfigEntityList.forEach(n -> { + changeConfigDTOList.forEach(n -> { stringStringConcurrentHashMap.put(n.getConfigName(), n.getConfigValue()); }); - UpdateConfigsLog updateConfigsLog = new UpdateConfigsLog(); - updateConfigsLog.setInstanceId(instanceId); - updateConfigsLog.setClusterId(clusterId); - updateConfigsLog.setName(name); - updateConfigsLog.setConfigProperties(this.mapToProperties(stringStringConcurrentHashMap)); + UpdateConfigsLog updateConfigsLog = + new UpdateConfigsLog(instanceId, clusterId, name, this.mapToProperties(stringStringConcurrentHashMap)); ConfigServiceImpl service = (ConfigServiceImpl) AopContext.currentProxy(); if (instanceType == 0) { - service.logUpdateRuntimeConfigs(updateConfigsLog, changeConfigEntityList); + service.logUpdateRuntimeConfigs(updateConfigsLog, changeConfigDTOList); } else if (instanceType == 1) { - service.logUpdateStoreConfigs(updateConfigsLog, changeConfigEntityList); + service.logUpdateStoreConfigs(updateConfigsLog, changeConfigDTOList); } else if (instanceType == 2) { - service.logUpdateConnectorConfigs(updateConfigsLog, changeConfigEntityList); + service.logUpdateConnectorConfigs(updateConfigsLog, changeConfigDTOList); } else if (instanceType == 3) { - service.logUpdateTopicConfigs(updateConfigsLog, changeConfigEntityList); + service.logUpdateTopicConfigs(updateConfigsLog, changeConfigDTOList); } } + @Override + public List queryByClusterAndInstanceId(ConfigEntity configEntity) { + return null; + } + @Override public List selectAll() { return configMapper.selectAll(); } @Override - public Integer batchInsert(List configEntityList) { - return configMapper.batchInsert(configEntityList); + public void batchInsert(List configEntityList) { + configMapper.batchInsert(configEntityList); + } + + @Override + public void copyConfig(Long sourceId, Long targetId) { + configMapper.copyConfig(sourceId, targetId); } @Override + public void restoreConfig(Long sourceId, Long targetId) { + + } + public String mapToYaml(Map stringMap) { Yaml yaml = new Yaml(); return yaml.dumpAsMap(stringMap); @@ -165,9 +178,9 @@ public Map propertiesToMap(String configProperties) { return stringStringConcurrentHashMap; } - @Override - public void insertConfig(ConfigEntity configEntity) { - configMapper.insertConfig(configEntity); + + public Integer addConfig(ConfigEntity configEntity) { + return configMapper.addConfig(configEntity); } @Override @@ -179,31 +192,47 @@ public Integer deleteConfig(ConfigEntity configEntity) { public List selectByInstanceIdAndType(Long instanceId, Integer type) { ConfigEntity config = new ConfigEntity(); config.setInstanceId(instanceId); - config.setInstanceType(type); + config.setInstanceType(null); return configMapper.selectByInstanceId(config); } + 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 List selectToFront(ConfigEntity config) { - return configMapper.selectConfigsToFrontWithDynamic(config); + public List selectToFront(Long instanceId, Integer type, GetConfigsListDTO getConfigsListDTO) { + ConfigEntity config = new ConfigEntity(); + config.setInstanceId(instanceId); + config.setInstanceType(null); + config = this.setSearchCriteria(getConfigsListDTO, config); + return configMapper.getConfigsToFrontWithDynamic(config); } - public void insertDefaultConfigToCache() { + public void addDefaultConfigToCache() { List configEntityList = configMapper.selectAllDefaultConfig(); configEntityList.forEach(n -> { - DefaultConfigKey defaultConfigKey = new DefaultConfigKey(); - defaultConfigKey.setConfigName(n.getConfigName()); - defaultConfigKey.setBusinessType(n.getBusinessType()); + DefaultConfigKey defaultConfigKey = new DefaultConfigKey(n.getBusinessType(), n.getConfigName()); defaultConfigCache.putIfAbsent(defaultConfigKey, n.getConfigValue()); }); } @Override - public Map selectDefaultConfig(String businessType) { + public Map selectDefaultConfig(String businessType, Long instanceId, Integer instanceType) { if (defaultConfigCache.size() == 0) { - this.insertDefaultConfigToCache(); + this.addDefaultConfigToCache(); } ConcurrentHashMap stringStringConcurrentHashMap = new ConcurrentHashMap<>(); defaultConfigCache.forEach((k, v) -> { diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/Impl/HealthDataServiceDatabaseImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/Impl/HealthDataServiceDatabaseImpl.java index 2b315ae6..973e5823 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/Impl/HealthDataServiceDatabaseImpl.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/Impl/HealthDataServiceDatabaseImpl.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.service.function.Impl; import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; @@ -48,14 +49,14 @@ public class HealthDataServiceDatabaseImpl implements HealthDataService { @Override - public InstanceLiveProportionVo selectInstanceLiveProportion(Long clusterId, Integer instanceType) { + public InstanceLiveProportionVo getInstanceLiveProportion(Long clusterId, Integer instanceType) { InstanceLiveProportionVo instanceLiveProportionVo = new InstanceLiveProportionVo(); switch (instanceType) { case 2: - instanceLiveProportionVo = this.selectRuntimeLiveProportion(clusterId); + instanceLiveProportionVo = this.getRuntimeLiveProportion(clusterId); break; case 3: - instanceLiveProportionVo = this.selectTopicLiveProportion(clusterId); + instanceLiveProportionVo = this.getTopicLiveProportion(clusterId); break; default: break; @@ -63,7 +64,7 @@ public InstanceLiveProportionVo selectInstanceLiveProportion(Long clusterId, Int return instanceLiveProportionVo; } - public InstanceLiveProportionVo selectTopicLiveProportion(Long clusterId) { + public InstanceLiveProportionVo getTopicLiveProportion(Long clusterId) { TopicEntity topicEntity = new TopicEntity(); topicEntity.setClusterId(clusterId); Integer topicNum = topicMapper.selectTopicNumByCluster(topicEntity); @@ -74,17 +75,14 @@ public InstanceLiveProportionVo selectTopicLiveProportion(Long clusterId) { abnormalNum++; } } - InstanceLiveProportionVo instanceLiveProportionVo = new InstanceLiveProportionVo(); - instanceLiveProportionVo.setAbnormalNum(abnormalNum); - instanceLiveProportionVo.setAllNum(topicNum); - return instanceLiveProportionVo; + return new InstanceLiveProportionVo(abnormalNum, topicNum); } - public InstanceLiveProportionVo selectRuntimeLiveProportion(Long clusterId) { + public InstanceLiveProportionVo getRuntimeLiveProportion(Long clusterId) { RuntimeEntity runtimeEntity = new RuntimeEntity(); runtimeEntity.setClusterId(clusterId); - Integer topicNum = runtimeMapper.selectRuntimeNumByCluster(runtimeEntity); + Integer topicNum = runtimeMapper.getRuntimeNumByCluster(runtimeEntity); List runtimeEntities = runtimeMapper.selectRuntimeByCluster(runtimeEntity); int abnormalNum = 0; for (RuntimeEntity n : runtimeEntities) { @@ -92,15 +90,12 @@ public InstanceLiveProportionVo selectRuntimeLiveProportion(Long clusterId) { abnormalNum++; } } - InstanceLiveProportionVo instanceLiveProportionVo = new InstanceLiveProportionVo(); - instanceLiveProportionVo.setAbnormalNum(abnormalNum); - instanceLiveProportionVo.setAllNum(topicNum); - return instanceLiveProportionVo; + return new InstanceLiveProportionVo(abnormalNum, topicNum); } @Override - public List selectInstanceLiveStatusHistory(Integer type, Long instanceId, LocalDateTime startTime) { + public List getInstanceLiveStatusHistory(Integer type, Long instanceId, LocalDateTime startTime) { HealthCheckResultEntity healthCheckResultEntity = new HealthCheckResultEntity(); healthCheckResultEntity.setType(type); healthCheckResultEntity.setTypeId(instanceId); @@ -115,19 +110,19 @@ public HealthCheckResultEntity insertHealthCheckResult(HealthCheckResultEntity h } @Override - public Integer batchInsertHealthCheckResult(List healthCheckResultEntityList) { + public void batchInsertHealthCheckResult(List healthCheckResultEntityList) { if (healthCheckResultEntityList.isEmpty()) { - return 0; + return; } - return healthCheckResultMapper.batchInsert(healthCheckResultEntityList); + healthCheckResultMapper.batchInsert(healthCheckResultEntityList); } @Override - public Integer batchInsertNewCheckResult(List healthCheckResultEntityList) { + public void batchInsertNewCheckResult(List healthCheckResultEntityList) { if (healthCheckResultEntityList.isEmpty()) { - return 0; + return; } - return healthCheckResultMapper.insertNewChecks(healthCheckResultEntityList); + healthCheckResultMapper.insertNewChecks(healthCheckResultEntityList); } @Override @@ -141,8 +136,8 @@ public List queryHealthCheckResultByClusterIdAndTypeAnd } @Override - public Integer batchUpdateCheckResult(List healthCheckResultEntityList) { - return healthCheckResultMapper.batchUpdate(healthCheckResultEntityList); + public void batchUpdateCheckResult(List healthCheckResultEntityList) { + healthCheckResultMapper.batchUpdate(healthCheckResultEntityList); } @Override @@ -150,7 +145,7 @@ public void batchUpdateCheckResultByClusterIdAndTypeAndTypeId(List entitiesNeedToBeUpdate = healthCheckResultMapper.selectIdsNeedToBeUpdateByClusterIdAndTypeAndTypeId( + List entitiesNeedToBeUpdate = healthCheckResultMapper.getIdsNeedToBeUpdateByClusterIdAndTypeAndTypeId( healthCheckResultEntityList); if (entitiesNeedToBeUpdate.isEmpty()) { return; @@ -159,7 +154,7 @@ public void batchUpdateCheckResultByClusterIdAndTypeAndTypeId(List { if (entity.getClusterId().equals(updateEntity.getClusterId()) && entity.getType().equals(updateEntity.getType()) && entity.getTypeId().equals(updateEntity.getTypeId())) { - entity.setState(updateEntity.getState()); + entity.setStatus(updateEntity.getStatus()); entity.setResultDesc(updateEntity.getResultDesc()); } }); diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/Impl/LogServiceImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/Impl/LogServiceImpl.java index cc4ea338..b2a320de 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/Impl/LogServiceImpl.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/Impl/LogServiceImpl.java @@ -15,10 +15,12 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.service.function.Impl; import org.apache.eventmesh.dashboard.console.entity.function.LogEntity; import org.apache.eventmesh.dashboard.console.mapper.function.OprLogMapper; +import org.apache.eventmesh.dashboard.console.modle.dto.log.GetLogListDTO; import org.apache.eventmesh.dashboard.console.service.function.LogService; import java.util.List; @@ -33,14 +35,20 @@ public class LogServiceImpl implements LogService { OprLogMapper oprLogMapper; @Override - public List selectLogListByCluster(LogEntity logEntity) { - return oprLogMapper.selectLogListToFront(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 - public void insertLog(LogEntity logEntity) { + public Long addLog(LogEntity logEntity) { - oprLogMapper.insertLog(logEntity); + return oprLogMapper.addLog(logEntity); } @Override diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/Impl/MetadataSyncResultServiceImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/Impl/MetadataSyncResultServiceImpl.java new file mode 100644 index 00000000..60b7809d --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/Impl/MetadataSyncResultServiceImpl.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.service.function.Impl; + +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; +import org.apache.eventmesh.dashboard.console.entity.function.MetadataSyncResultEntity; +import org.apache.eventmesh.dashboard.console.service.function.MetadataSyncResultService; + +import java.util.Collections; +import java.util.List; + +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@Transactional +public class MetadataSyncResultServiceImpl implements MetadataSyncResultService { + + @Override + public void bachMetadataSyncResult(List healthCheckResultEntityList, List runtimeList, + List clusterEntityList) { + + } + + @Override + public List queueHealthCheckResultEntityList(MetadataSyncResultEntity healthCheckResultEntity) { + return Collections.emptyList(); + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/LogService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/LogService.java index dd9b993f..454ad532 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/LogService.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/LogService.java @@ -15,10 +15,11 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.service.function; import org.apache.eventmesh.dashboard.console.entity.function.LogEntity; - +import org.apache.eventmesh.dashboard.console.modle.dto.log.GetLogListDTO; import java.util.List; @@ -31,9 +32,9 @@ @Service public interface LogService { - List selectLogListByCluster(LogEntity logEntity); + List getLogListByCluster(GetLogListDTO getLogListDTO); - void insertLog(LogEntity logEntity); + Long addLog(LogEntity logEntity); Integer updateLog(LogEntity logEntity); 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/function/MetadataSyncResultService.java similarity index 56% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/store/StoreService.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/MetadataSyncResultService.java index 65282419..756e2471 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/function/MetadataSyncResultService.java @@ -15,32 +15,25 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.service.store; -import org.apache.eventmesh.dashboard.console.entity.StoreEntity; +package org.apache.eventmesh.dashboard.console.service.function; + +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; +import org.apache.eventmesh.dashboard.console.entity.function.MetadataSyncResultEntity; import java.util.List; + /** - * store data service + * */ -public interface StoreService { - - StoreEntity selectStoreToFrontListByCluster(Long clusterId); - - List selectAll(); - - StoreEntity selectById(Long storeId); - - StoreEntity selectByHostPort(String host, Integer port); - - Integer batchInsert(List storeEntities); +public interface MetadataSyncResultService { - void insertStore(StoreEntity storeEntity); - Integer deleteStoreByUnique(StoreEntity storeEntity); + void bachMetadataSyncResult(List healthCheckResultEntityList, List runtimeList, + List clusterEntityList); - StoreEntity selectStoreByCluster(Long clusterId); - Integer updateStoreByUnique(StoreEntity storeEntity); + List queueHealthCheckResultEntityList(MetadataSyncResultEntity healthCheckResultEntity); } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/GroupMemberService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/GroupMemberService.java index a92cc34b..1071001d 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/GroupMemberService.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/GroupMemberService.java @@ -15,10 +15,11 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.service.message; import org.apache.eventmesh.dashboard.console.entity.message.GroupEntity; -import org.apache.eventmesh.dashboard.console.entity.message.GroupMemberEntity; +import org.apache.eventmesh.dashboard.console.entity.message.SubscriptionEntity; import java.util.List; @@ -27,22 +28,22 @@ */ public interface GroupMemberService { - List selectAll(); + List selectAll(); - Integer batchInsert(List groupMemberEntities); + void batchInsert(List groupMemberEntities); - List selectGroupMemberByClusterId(GroupMemberEntity groupMemberEntity); + List getGroupMemberByClusterId(SubscriptionEntity subscriptionEntity); - void insertGroupMember(GroupMemberEntity groupMemberEntity); + void addGroupMember(SubscriptionEntity subscriptionEntity); - Integer updateGroupMember(GroupMemberEntity groupMemberEntity); + void updateGroupMember(SubscriptionEntity subscriptionEntity); - Integer deleteGroupMember(GroupMemberEntity groupMemberEntity); + SubscriptionEntity deleteGroupMember(SubscriptionEntity subscriptionEntity); - GroupMemberEntity selectGroupMemberById(GroupMemberEntity groupMemberEntity); + SubscriptionEntity selectGroupMemberById(SubscriptionEntity subscriptionEntity); - List selectGroupMemberByGroup(GroupEntity groupEntity); + List selectGroupMemberByGroup(GroupEntity groupEntity); - List selectAllMemberByTopic(GroupMemberEntity groupMemberEntity); + List selectAllMemberByTopic(SubscriptionEntity subscriptionEntity); } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/GroupService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/GroupService.java index a2bd08f6..3d5b7a12 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/GroupService.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/GroupService.java @@ -15,10 +15,11 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.service.message; import org.apache.eventmesh.dashboard.console.entity.message.GroupEntity; -import org.apache.eventmesh.dashboard.console.entity.message.GroupMemberEntity; +import org.apache.eventmesh.dashboard.console.entity.message.SubscriptionEntity; import java.util.List; @@ -28,21 +29,26 @@ public interface GroupService { + @Deprecated List selectAll(); - Integer batchInsert(List groupEntities); + void batchInsert(List groupEntities); - List selectGroupByClusterId(GroupEntity groupEntity); + List getGroupByClusterId(GroupEntity groupEntity); - void insertGroup(GroupEntity groupEntity); + void addGroup(GroupEntity groupEntity); + @Deprecated void updateGroup(GroupEntity groupEntity); Integer deleteGroup(GroupEntity groupEntity); + @Deprecated GroupEntity selectGroup(GroupEntity groupEntity); - Integer insertMemberToGroup(GroupMemberEntity groupMemberEntity); + @Deprecated + Integer insertMemberToGroup(SubscriptionEntity subscriptionEntity); - Integer deleteMemberFromGroup(GroupMemberEntity groupMemberEntity); + @Deprecated + Integer deleteMemberFromGroup(SubscriptionEntity subscriptionEntity); } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/TopicService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/TopicService.java index 714be9d4..94446aac 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/TopicService.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/TopicService.java @@ -15,8 +15,10 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.service.message; +import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; import org.apache.eventmesh.dashboard.console.entity.message.TopicEntity; import org.apache.eventmesh.dashboard.console.modle.vo.topic.TopicDetailGroupVO; @@ -27,25 +29,28 @@ */ public interface TopicService { - List selectTopicDetailGroups(Long topicId); + List getTopicDetailGroups(Long topicId); void createTopic(TopicEntity topicEntity); + void batchInsert(List topicEntities); + List queryRuntimeByBaseSyncEntity(List topicName); + List selectAll(); - void insertTopic(TopicEntity topicEntity); + void addTopic(TopicEntity topicEntity); - Integer updateTopic(TopicEntity topicEntity); + void updateTopic(TopicEntity topicEntity); - void deleteTopicById(TopicEntity topicEntity); + Integer deleteTopicById(TopicEntity topicEntity); TopicEntity selectTopicById(TopicEntity topicEntity); - Integer deleteTopic(TopicEntity topicEntity); + Integer deleteTopicByRuntimeIdAndTopicName(List topicEntity); List selectTopiByCluster(TopicEntity topicEntity); - List selectTopicListToFront(TopicEntity topicEntity); + List getTopicListToFront(TopicEntity topicEntity); } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/impl/GroupMemberServiceImp.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/impl/GroupMemberServiceImp.java index bbb46b3f..b3c6a80c 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/impl/GroupMemberServiceImp.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/impl/GroupMemberServiceImp.java @@ -15,11 +15,12 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.service.message.impl; import org.apache.eventmesh.dashboard.console.annotation.EmLog; import org.apache.eventmesh.dashboard.console.entity.message.GroupEntity; -import org.apache.eventmesh.dashboard.console.entity.message.GroupMemberEntity; +import org.apache.eventmesh.dashboard.console.entity.message.SubscriptionEntity; import org.apache.eventmesh.dashboard.console.mapper.message.OprGroupMemberMapper; import org.apache.eventmesh.dashboard.console.service.message.GroupMemberService; @@ -35,54 +36,54 @@ public class GroupMemberServiceImp implements GroupMemberService { OprGroupMemberMapper oprGroupMemberMapper; @Override - public List selectAll() { + public List selectAll() { return oprGroupMemberMapper.selectAll(); } @Override - public Integer batchInsert(List groupMemberEntities) { - return oprGroupMemberMapper.batchInsert(groupMemberEntities); + public void batchInsert(List groupMemberEntities) { + oprGroupMemberMapper.batchInsert(groupMemberEntities); } @Override @EmLog(OprType = "View", OprTarget = "GroupMember") - public List selectGroupMemberByClusterId(GroupMemberEntity groupMemberEntity) { - return oprGroupMemberMapper.selectGroupByClusterId(groupMemberEntity); + public List getGroupMemberByClusterId(SubscriptionEntity subscriptionEntity) { + return oprGroupMemberMapper.getGroupByClusterId(subscriptionEntity); } @Override @EmLog(OprType = "add", OprTarget = "GroupMember") - public void insertGroupMember(GroupMemberEntity groupMemberEntity) { - oprGroupMemberMapper.insertGroupMember(groupMemberEntity); + public void addGroupMember(SubscriptionEntity subscriptionEntity) { + oprGroupMemberMapper.addGroupMember(subscriptionEntity); } @Override - public Integer updateGroupMember(GroupMemberEntity groupMemberEntity) { - return oprGroupMemberMapper.updateGroupMember(groupMemberEntity); + public void updateGroupMember(SubscriptionEntity subscriptionEntity) { + oprGroupMemberMapper.updateGroupMember(subscriptionEntity); } @Override - public Integer deleteGroupMember(GroupMemberEntity groupMemberEntity) { - return oprGroupMemberMapper.deleteGroupMember(groupMemberEntity); + public SubscriptionEntity deleteGroupMember(SubscriptionEntity subscriptionEntity) { + return oprGroupMemberMapper.deleteGroupMember(subscriptionEntity); } @Override - public GroupMemberEntity selectGroupMemberById(GroupMemberEntity groupMemberEntity) { - return oprGroupMemberMapper.selectGroupMemberById(groupMemberEntity); + public SubscriptionEntity selectGroupMemberById(SubscriptionEntity subscriptionEntity) { + return oprGroupMemberMapper.selectGroupMemberById(subscriptionEntity); } @Override - public List selectGroupMemberByGroup(GroupEntity groupEntity) { - GroupMemberEntity groupMemberEntity = new GroupMemberEntity(); - groupMemberEntity.setGroupName(groupEntity.getName()); - groupMemberEntity.setClusterId(groupEntity.getClusterId()); + public List selectGroupMemberByGroup(GroupEntity groupEntity) { + SubscriptionEntity subscriptionEntity = new SubscriptionEntity(); + subscriptionEntity.setGroupName(groupEntity.getName()); + subscriptionEntity.setClusterId(groupEntity.getClusterId()); //Obtain a member who meets the conditions of a group - return oprGroupMemberMapper.selectMember(groupMemberEntity); + return oprGroupMemberMapper.selectMember(subscriptionEntity); } @Override - public List selectAllMemberByTopic(GroupMemberEntity groupMemberEntity) { - List groupMemberEntities = oprGroupMemberMapper.selectMember(groupMemberEntity); + public List selectAllMemberByTopic(SubscriptionEntity subscriptionEntity) { + List groupMemberEntities = oprGroupMemberMapper.selectMember(subscriptionEntity); return groupMemberEntities; } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/impl/GroupServiceImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/impl/GroupServiceImpl.java index 41997150..6c744905 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/impl/GroupServiceImpl.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/impl/GroupServiceImpl.java @@ -15,12 +15,13 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.service.message.impl; import org.apache.eventmesh.dashboard.console.annotation.EmLog; import org.apache.eventmesh.dashboard.console.entity.message.GroupEntity; -import org.apache.eventmesh.dashboard.console.entity.message.GroupMemberEntity; -import org.apache.eventmesh.dashboard.console.mapper.message.OprGroupMapper; +import org.apache.eventmesh.dashboard.console.entity.message.SubscriptionEntity; +import org.apache.eventmesh.dashboard.console.mapper.message.GroupMapper; import org.apache.eventmesh.dashboard.console.service.message.GroupMemberService; import org.apache.eventmesh.dashboard.console.service.message.GroupService; @@ -34,78 +35,78 @@ public class GroupServiceImpl implements GroupService { @Autowired - private OprGroupMapper oprGroupMapper; + private GroupMapper groupMapper; @Autowired private GroupMemberService groupMemberService; @Override public List selectAll() { - return oprGroupMapper.selectAll(); + return groupMapper.selectAll(); } @Override - public Integer batchInsert(List groupEntities) { - return oprGroupMapper.batchInsert(groupEntities); + public void batchInsert(List groupEntities) { + groupMapper.batchInsert(groupEntities); } @EmLog(OprType = "search", OprTarget = "Group") @Override - public List selectGroupByClusterId(GroupEntity groupEntity) { - return oprGroupMapper.selectGroup(groupEntity); + public List getGroupByClusterId(GroupEntity groupEntity) { + return groupMapper.selectGroup(groupEntity); } @EmLog(OprType = "add", OprTarget = "Group") @Override - public void insertGroup(GroupEntity groupEntity) { - oprGroupMapper.insertGroup(groupEntity); + public void addGroup(GroupEntity groupEntity) { + groupMapper.addGroup(groupEntity); } @Override public void updateGroup(GroupEntity groupEntity) { - oprGroupMapper.updateGroup(groupEntity); + groupMapper.updateGroup(groupEntity); } @Override public Integer deleteGroup(GroupEntity groupEntity) { - return oprGroupMapper.deleteGroup(groupEntity); + return groupMapper.deleteGroup(groupEntity); } @Override public GroupEntity selectGroup(GroupEntity groupEntity) { - return oprGroupMapper.selectGroupById(groupEntity); + return groupMapper.selectGroupById(groupEntity); } @Override - public Integer insertMemberToGroup(GroupMemberEntity groupMemberEntity) { - groupMemberService.insertGroupMember(groupMemberEntity); + public Integer insertMemberToGroup(SubscriptionEntity subscriptionEntity) { + groupMemberService.addGroupMember(subscriptionEntity); GroupEntity groupEntity = new GroupEntity(); - groupEntity.setName(groupMemberEntity.getGroupName()); - groupEntity.setClusterId(groupMemberEntity.getClusterId()); - GroupEntity groupEntity1 = oprGroupMapper.selectGroupByUnique(groupEntity); + groupEntity.setName(subscriptionEntity.getGroupName()); + groupEntity.setClusterId(subscriptionEntity.getClusterId()); + GroupEntity groupEntity1 = groupMapper.selectGroupByUnique(groupEntity); //^Obtain the group to which the member belongs - groupEntity1.setMembers(groupMemberEntity.getId() + "" + "," + groupEntity1.getMembers()); + groupEntity1.setMembers(subscriptionEntity.getId() + "" + "," + groupEntity1.getMembers()); //Concatenate the members of the group groupEntity1.setMemberCount(groupEntity1.getMemberCount() + 1); groupEntity1.setUpdateTime(LocalDateTime.now()); - oprGroupMapper.updateGroup(groupEntity1); + groupMapper.updateGroup(groupEntity1); return 1; //Modify the group member information } @Override - public Integer deleteMemberFromGroup(GroupMemberEntity groupMemberEntity) { - groupMemberService.deleteGroupMember(groupMemberEntity); + public Integer deleteMemberFromGroup(SubscriptionEntity subscriptionEntity) { + groupMemberService.deleteGroupMember(subscriptionEntity); GroupEntity groupEntity = new GroupEntity(); - groupEntity.setName(groupMemberEntity.getGroupName()); - groupEntity.setClusterId(groupMemberEntity.getClusterId()); - GroupEntity groupEntity1 = oprGroupMapper.selectGroupByUnique(groupEntity); + groupEntity.setName(subscriptionEntity.getGroupName()); + groupEntity.setClusterId(subscriptionEntity.getClusterId()); + GroupEntity groupEntity1 = groupMapper.selectGroupByUnique(groupEntity); //^Obtain the group to which the member belongs - groupEntity1.setMembers(groupEntity1.getMembers().replaceAll(groupMemberEntity.getId() + "" + ",", "")); + groupEntity1.setMembers(groupEntity1.getMembers().replaceAll(subscriptionEntity.getId() + "" + ",", "")); groupEntity1.setMemberCount(groupEntity1.getMemberCount() - 1); groupEntity1.setUpdateTime(LocalDateTime.now()); - oprGroupMapper.updateGroup(groupEntity1); + groupMapper.updateGroup(groupEntity1); return 1; } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/impl/TopicServiceImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/impl/TopicServiceImpl.java index 45f5c4cc..ec471645 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/impl/TopicServiceImpl.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/impl/TopicServiceImpl.java @@ -15,21 +15,22 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.service.message.impl; import org.apache.eventmesh.dashboard.console.annotation.EmLog; +import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; import org.apache.eventmesh.dashboard.console.entity.message.GroupEntity; -import org.apache.eventmesh.dashboard.console.entity.message.GroupMemberEntity; +import org.apache.eventmesh.dashboard.console.entity.message.SubscriptionEntity; import org.apache.eventmesh.dashboard.console.entity.message.TopicEntity; -import org.apache.eventmesh.dashboard.console.function.health.CheckResultCache; import org.apache.eventmesh.dashboard.console.mapper.cluster.RuntimeMapper; import org.apache.eventmesh.dashboard.console.mapper.function.ConfigMapper; import org.apache.eventmesh.dashboard.console.mapper.function.HealthCheckResultMapper; -import org.apache.eventmesh.dashboard.console.mapper.message.OprGroupMapper; +import org.apache.eventmesh.dashboard.console.mapper.message.GroupMapper; import org.apache.eventmesh.dashboard.console.mapper.message.OprGroupMemberMapper; import org.apache.eventmesh.dashboard.console.mapper.message.TopicMapper; -import org.apache.eventmesh.dashboard.console.mapper.storage.StoreMapper; +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.message.TopicService; @@ -58,35 +59,32 @@ public class TopicServiceImpl implements TopicService { RuntimeMapper runtimeMapper; @Autowired - StoreMapper storeMapper; - - @Autowired - OprGroupMapper groupMapper; + GroupMapper groupMapper; @Override - public List selectTopicDetailGroups(Long topicId) { + public List getTopicDetailGroups(Long topicId) { TopicEntity topicEntity = new TopicEntity(); topicEntity.setId(topicId); topicEntity = this.selectTopicById(topicEntity); - GroupMemberEntity groupMemberEntity = new GroupMemberEntity(); - groupMemberEntity.setClusterId(topicEntity.getClusterId()); - groupMemberEntity.setTopicName(topicEntity.getTopicName()); - List groupNamelist = oprGroupMemberMapper.selectGroupNameByTopicName(groupMemberEntity); + SubscriptionEntity subscriptionEntity = new SubscriptionEntity(); + subscriptionEntity.setClusterId(topicEntity.getClusterId()); + subscriptionEntity.setTopicName(topicEntity.getTopicName()); + List groupNamelist = oprGroupMemberMapper.selectGroupNameByTopicName(subscriptionEntity); ArrayList topicDetailGroupVOList = new ArrayList<>(); TopicEntity finalTopicEntity = topicEntity; groupNamelist.forEach(n -> { TopicDetailGroupVO topicDetailGroupVO = new TopicDetailGroupVO(); topicDetailGroupVO.setGroupName(n); - groupMemberEntity.setGroupName(n); - List list = oprGroupMemberMapper.selectTopicsByGroupNameAndClusterId(groupMemberEntity); + subscriptionEntity.setGroupName(n); + List list = oprGroupMemberMapper.selectTopicsByGroupNameAndClusterId(subscriptionEntity); topicDetailGroupVO.setTopics(list); GroupEntity groupEntity = new GroupEntity(); groupEntity.setClusterId(finalTopicEntity.getClusterId()); groupEntity.setName(n); GroupEntity group = groupMapper.selectGroupByNameAndClusterId(groupEntity); topicDetailGroupVO.setMemberNum(group.getMemberCount()); - topicDetailGroupVO.setState(group.getState()); + topicDetailGroupVOList.add(topicDetailGroupVO); }); return topicDetailGroupVOList; @@ -99,11 +97,18 @@ public void createTopic(TopicEntity topicEntity) { topicMapper.insertTopic(topicEntity); } + @Override public void batchInsert(List topicEntities) { topicMapper.batchInsert(topicEntities); } + public List queryRuntimeByBaseSyncEntity(List topicName) { + + return null; + } + + @Override public List selectAll() { return topicMapper.selectAll(); @@ -111,33 +116,32 @@ public List selectAll() { @Override - public void insertTopic(TopicEntity topicEntity) { - GroupMemberEntity groupMemberEntity = new GroupMemberEntity(); - groupMemberEntity.setTopicName(topicEntity.getTopicName()); - groupMemberEntity.setState("active"); - oprGroupMemberMapper.updateMemberByTopic(groupMemberEntity); + public void addTopic(TopicEntity topicEntity) { + SubscriptionEntity subscriptionEntity = new SubscriptionEntity(); + subscriptionEntity.setTopicName(topicEntity.getTopicName()); + oprGroupMemberMapper.updateMemberByTopic(subscriptionEntity); topicMapper.insertTopic(topicEntity); } @Override - public Integer updateTopic(TopicEntity topicEntity) { - return topicMapper.updateTopic(topicEntity); + public void updateTopic(TopicEntity topicEntity) { + topicMapper.updateTopic(topicEntity); } @Override - public void deleteTopicById(TopicEntity topicEntity) { - topicMapper.deleteTopic(topicEntity); + public Integer deleteTopicById(TopicEntity topicEntity) { + return topicMapper.deleteTopicById(topicEntity); } @Override public TopicEntity selectTopicById(TopicEntity topicEntity) { - return topicMapper.selectTopicById(topicEntity); + return topicMapper.queryTopicById(topicEntity); } @Override - public Integer deleteTopic(TopicEntity topicEntity) { - return topicMapper.deleteTopic(topicEntity); + public Integer deleteTopicByRuntimeIdAndTopicName(List topicEntity) { + return topicMapper.deleteTopicByIds(topicEntity); } @Override @@ -145,12 +149,15 @@ public List selectTopiByCluster(TopicEntity topicEntity) { return topicMapper.selectTopicByCluster(topicEntity); } + + public TopicEntity setSearchCriteria(GetTopicListDTO getTopicListDTO, TopicEntity topicEntity) { + topicEntity.setTopicName(getTopicListDTO.getTopicName()); + return topicEntity; + } + @Override - public List selectTopicListToFront(TopicEntity topicEntity) { + public List getTopicListToFront(TopicEntity topicEntity) { List topicEntityList = topicMapper.queryTopicsToFrontByClusterId(topicEntity); - topicEntityList.forEach(n -> { - n.setStatus(CheckResultCache.getINSTANCE().getLastHealthyCheckResult("topic", n.getId())); - }); return topicEntityList; } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/metadata/AbstractDBDataMetadataHandler.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/metadata/AbstractDBDataMetadataHandler.java new file mode 100644 index 00000000..3ba31525 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/metadata/AbstractDBDataMetadataHandler.java @@ -0,0 +1,124 @@ +/* + * 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.metadata; + +import org.apache.eventmesh.dashboard.console.entity.base.BaseRuntimeIdEntity; +import org.apache.eventmesh.dashboard.console.mapper.SyncDataHandlerMapper; +import org.apache.eventmesh.dashboard.core.metadata.DataMetadataHandler; + +import org.apache.commons.lang3.reflect.FieldUtils; + +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Proxy; +import java.lang.reflect.Type; +import java.time.LocalDateTime; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +import javax.annotation.PostConstruct; + +import org.springframework.beans.BeansException; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; +import org.springframework.context.support.AbstractApplicationContext; + +import lombok.extern.slf4j.Slf4j; + +@Slf4j +public abstract class AbstractDBDataMetadataHandler implements DataMetadataHandler, ApplicationContextAware { + + private static final Map CLASS_SYNC_DATA_HANDLER_MAPPER_MAP = new HashMap<>(); + + private AbstractApplicationContext applicationContext; + + private T baseRuntimeIdBase; + + private SyncDataHandlerMapper syncDataHandlerMapper; + + /** + * TODO + * 初始化时间有问题, + * 1. 是否需要 check 两端数据, + * 1. 如果 check 第一次全量加载 + * 2. 如果 不 check , 不需要全量加载 + */ + @PostConstruct + public void init() { + Type superClass = getClass().getGenericSuperclass(); + Type type = ((ParameterizedType) superClass).getActualTypeArguments()[0]; + try { + this.baseRuntimeIdBase = (T) ((Class) type).newInstance(); + LocalDateTime date = LocalDateTime.of(2000, 1, 1, 0, 0, 0, 0); + baseRuntimeIdBase.setUpdateTime(date); + if (CLASS_SYNC_DATA_HANDLER_MAPPER_MAP.isEmpty()) { + this.applicationContext.getBeansOfType(SyncDataHandlerMapper.class).values().forEach(syncDataHandlerMapper -> { + try { + Object proxyObject = Proxy.getInvocationHandler(syncDataHandlerMapper); + Class mapperInterface = (Class) FieldUtils.readField(proxyObject, "mapperInterface", true); + for (Type mapperType : mapperInterface.getGenericInterfaces()) { + Class mapperClass = (Class) ((ParameterizedType) mapperType).getRawType(); + if (Objects.equals(mapperClass, SyncDataHandlerMapper.class)) { + Type syncType = ((ParameterizedType) mapperType).getActualTypeArguments()[0]; + CLASS_SYNC_DATA_HANDLER_MAPPER_MAP.put(syncType, syncDataHandlerMapper); + } + } + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } + }); + } + this.syncDataHandlerMapper = (SyncDataHandlerMapper) CLASS_SYNC_DATA_HANDLER_MAPPER_MAP.get(type); + if (Objects.isNull(syncDataHandlerMapper)) { + log.error("syncDataHandlerMapper is null, type is {}", type); + } + } catch (Exception e) { + throw new RuntimeException(e); + } + + } + + public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { + this.applicationContext = (AbstractApplicationContext) applicationContext; + } + + public T getEntity() { + return this.baseRuntimeIdBase; + } + + public void handleAll(List addData, List updateData, List deleteData) { + + } + + public List getData() { + LocalDateTime date = LocalDateTime.now(); + try { + + //this.syncDataHandlerMapper.syncGet(this.baseRuntimeIdBase); + return this.doGetData(); + } finally { + this.baseRuntimeIdBase.setUpdateTime(date); + } + } + + abstract List doGetData(); + + +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/meta/subscription/EtcdSubscriptionCore.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/metadata/ClientDataMetadataHandler.java similarity index 59% rename from eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/meta/subscription/EtcdSubscriptionCore.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/metadata/ClientDataMetadataHandler.java index 4fd39c81..3b53207f 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/meta/subscription/EtcdSubscriptionCore.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/metadata/ClientDataMetadataHandler.java @@ -15,26 +15,29 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.core.meta.subscription; -import org.apache.eventmesh.dashboard.common.dto.Result; -import org.apache.eventmesh.dashboard.common.model.SubscriptionInfo; -import org.apache.eventmesh.dashboard.service.meta.SubscriptionCore; +package org.apache.eventmesh.dashboard.console.service.metadata; + +import org.apache.eventmesh.dashboard.console.entity.cluster.ClientEntity; import java.util.List; -import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@Transactional +public class ClientDataMetadataHandler extends AbstractDBDataMetadataHandler { -@Slf4j -public class EtcdSubscriptionCore implements SubscriptionCore { @Override - public String retrieveConfig(String dataId, String group) { - return null; + public void handleAll(List addData, List updateData, List deleteData) { + } + @Override - public Result> retrieveConfigs(Integer page, Integer size, String dataId, String group) { - return null; + List doGetData() { + return List.of(); } } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/metadata/ConfigDataMetadataHandler.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/metadata/ConfigDataMetadataHandler.java new file mode 100644 index 00000000..5366614c --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/metadata/ConfigDataMetadataHandler.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.service.metadata; + +import org.apache.eventmesh.dashboard.console.entity.function.ConfigEntity; +import org.apache.eventmesh.dashboard.core.metadata.DataMetadataHandler; + +import java.util.Collections; +import java.util.List; + +public class ConfigDataMetadataHandler implements DataMetadataHandler { + + @Override + public void handleAll(List addData, List updateData, List deleteData) { + + } + + @Override + public List getData() { + return Collections.emptyList(); + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/metadata/ConsumeOffsetDataMetadataHandler.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/metadata/ConsumeOffsetDataMetadataHandler.java new file mode 100644 index 00000000..bd2123ed --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/metadata/ConsumeOffsetDataMetadataHandler.java @@ -0,0 +1,44 @@ +/* + * 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.metadata; + +import org.apache.eventmesh.dashboard.console.entity.message.ConsumeOffsetEntity; + +import java.util.List; + +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@Transactional +public class ConsumeOffsetDataMetadataHandler extends AbstractDBDataMetadataHandler { + + + @Override + public void handleAll(List addData, List updateData, List deleteData) { + + + } + + + @Override + List doGetData() { + return List.of(); + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/metadata/GroupDataMetadataHandler.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/metadata/GroupDataMetadataHandler.java new file mode 100644 index 00000000..171d299a --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/metadata/GroupDataMetadataHandler.java @@ -0,0 +1,44 @@ +/* + * 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.metadata; + +import org.apache.eventmesh.dashboard.console.entity.message.GroupEntity; + +import java.util.List; + +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@Transactional +public class GroupDataMetadataHandler extends AbstractDBDataMetadataHandler { + + + @Override + public void handleAll(List addData, List updateData, List deleteData) { + + + } + + + @Override + List doGetData() { + return List.of(); + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/metadata/NetConnectionDataMetadataHandler.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/metadata/NetConnectionDataMetadataHandler.java new file mode 100644 index 00000000..e7a70a44 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/metadata/NetConnectionDataMetadataHandler.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.service.metadata; + +import org.apache.eventmesh.dashboard.console.entity.cluster.NetConnectionEntity; +import org.apache.eventmesh.dashboard.core.metadata.DataMetadataHandler; + +import java.util.Collections; +import java.util.List; + +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@Transactional +public class NetConnectionDataMetadataHandler implements DataMetadataHandler { + + @Override + public void handleAll(List addData, List updateData, List deleteData) { + + } + + @Override + public List getData() { + return Collections.emptyList(); + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/metadata/RuntimeDataMetadataHandler.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/metadata/RuntimeDataMetadataHandler.java new file mode 100644 index 00000000..bc1efe17 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/metadata/RuntimeDataMetadataHandler.java @@ -0,0 +1,51 @@ +/* + * 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.metadata; + +import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; +import org.apache.eventmesh.dashboard.console.mapper.cluster.RuntimeMapper; +import org.apache.eventmesh.dashboard.core.metadata.DataMetadataHandler; + +import java.util.Collections; +import java.util.List; + +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@Transactional +public class RuntimeDataMetadataHandler implements DataMetadataHandler { + + private RuntimeMapper runtimeMapper; + + @Override + public void handleAll(List addData, List updateData, List deleteData) { + + } + + /** + * 不存在查询 + * + * @return + */ + @Override + public List getData() { + return Collections.emptyList(); + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/metadata/TopicDataMetadataHandler.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/metadata/TopicDataMetadataHandler.java new file mode 100644 index 00000000..463ef5c7 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/metadata/TopicDataMetadataHandler.java @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.console.service.metadata; + +import org.apache.eventmesh.dashboard.console.entity.message.TopicEntity; +import org.apache.eventmesh.dashboard.console.mapper.message.TopicMapper; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@Transactional +public class TopicDataMetadataHandler extends AbstractDBDataMetadataHandler { + + @Autowired + private TopicMapper topicMapper; + + @Override + public void handleAll(List addData, List updateData, List deleteData) { + topicMapper.batchInsert(addData); + + } + + + @Override + List doGetData() { + TopicEntity topicEntity = this.getEntity(); + return List.of(); + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/metadata/TopicOffsetDataMetadataHandler.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/metadata/TopicOffsetDataMetadataHandler.java new file mode 100644 index 00000000..3ca44c31 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/metadata/TopicOffsetDataMetadataHandler.java @@ -0,0 +1,44 @@ +/* + * 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.metadata; + +import org.apache.eventmesh.dashboard.console.entity.message.TopicOffsetEntity; + +import java.util.List; + +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@Transactional +public class TopicOffsetDataMetadataHandler extends AbstractDBDataMetadataHandler { + + + @Override + public void handleAll(List addData, List updateData, List deleteData) { + + + } + + + @Override + List doGetData() { + return List.of(); + } +} 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 deleted file mode 100644 index f95aed8a..00000000 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/store/Impl/StoreServiceImpl.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.console.service.store.Impl; - -import org.apache.eventmesh.dashboard.console.entity.StoreEntity; -import org.apache.eventmesh.dashboard.console.mapper.storage.StoreMapper; -import org.apache.eventmesh.dashboard.console.service.store.StoreService; - -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -@Service -public class StoreServiceImpl implements StoreService { - - @Autowired - private StoreMapper storeMapper; - - @Override - public StoreEntity selectStoreToFrontListByCluster(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 StoreEntity selectByHostPort(String host, Integer port) { - StoreEntity query = new StoreEntity(); - query.setHost(host); - query.setPort(port); - return storeMapper.selectByHostPort(query); - } - - @Override - public Integer batchInsert(List storeEntities) { - return storeMapper.batchInsert(storeEntities); - } - - @Override - public void insertStore(StoreEntity storeEntity) { - storeMapper.insertStore(storeEntity); - } - - @Override - public Integer deleteStoreByUnique(StoreEntity storeEntity) { - return storeMapper.deleteStoreByUnique(storeEntity); - } - - @Override - public StoreEntity selectStoreByCluster(Long clusterId) { - StoreEntity storeEntity = new StoreEntity(); - storeEntity.setClusterId(clusterId); - return storeMapper.selectStoreByCluster(storeEntity); - } - - @Override - public Integer updateStoreByUnique(StoreEntity storeEntity) { - return storeMapper.updateStoreByUnique(storeEntity); - } -} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/DefaultDataHandler.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/DefaultDataHandler.java new file mode 100644 index 00000000..3cc2dc12 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/DefaultDataHandler.java @@ -0,0 +1,81 @@ +/* + * 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.spring.support; + +import org.apache.eventmesh.dashboard.common.enums.ClusterSyncMetadataEnum; +import org.apache.eventmesh.dashboard.common.model.ClusterSyncMetadata; +import org.apache.eventmesh.dashboard.common.model.metadata.RuntimeMetadata; +import org.apache.eventmesh.dashboard.console.domain.metadata.ClusterMetadataDomain.DataHandler; +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; +import org.apache.eventmesh.dashboard.console.function.health.Health2Service; +import org.apache.eventmesh.dashboard.console.spring.support.metadata.convert.RuntimeConvertMetaData; +import org.apache.eventmesh.dashboard.core.cluster.ClusterDO; +import org.apache.eventmesh.dashboard.core.cluster.ColonyDO; +import org.apache.eventmesh.dashboard.core.cluster.RuntimeDO; +import org.apache.eventmesh.dashboard.core.function.SDK.SDKManage; +import org.apache.eventmesh.dashboard.core.function.SDK.SDKTypeEnum; +import org.apache.eventmesh.dashboard.core.metadata.MetadataSyncManage; + +import lombok.Setter; + +@Setter +public class DefaultDataHandler implements DataHandler { + + + private MetadataSyncManage metadataSyncManage; + + + private Health2Service healthService; + + + @Override + public void registerRuntime(RuntimeEntity runtimeEntity, RuntimeDO runtimeDO, ColonyDO colonyDO) { + RuntimeMetadata runtimeMetadata = RuntimeConvertMetaData.INSTANCE.toMetaData(runtimeEntity); + SDKManage.getInstance().createClient(SDKTypeEnum.ADMIN, runtimeMetadata, runtimeDO.getCreateSDKConfig(), runtimeMetadata.getClusterType()); + healthService.register(runtimeDO.getRuntimeMetadata()); + metadataSyncManage.register(runtimeDO.getRuntimeMetadata()); + } + + @Override + public void unRegisterRuntime(RuntimeEntity runtimeEntity, RuntimeDO runtimeDO, ColonyDO colonyDO) { + RuntimeMetadata runtimeMetadata = RuntimeConvertMetaData.INSTANCE.toMetaData(runtimeEntity); + healthService.unRegister(runtimeMetadata); + metadataSyncManage.unRegister(runtimeMetadata); + } + + @Override + public void registerCluster(ClusterEntity clusterEntity, ClusterDO clusterDO, ColonyDO colonyDO) { + ClusterSyncMetadata clusterSyncMetadata = ClusterSyncMetadataEnum.getClusterSyncMetadata(clusterEntity.getClusterType()); + if (!clusterSyncMetadata.getClusterFramework().isCAP()) { + return; + } + SDKManage.getInstance().createClient(SDKTypeEnum.ADMIN, clusterDO.getClusterInfo(), clusterDO.getMultiCreateSDKConfig(), + clusterDO.getClusterInfo().getClusterType()); + healthService.register(clusterDO.getClusterInfo()); + metadataSyncManage.register(clusterDO.getClusterInfo()); + } + + @Override + public void unRegisterCluster(ClusterEntity clusterEntity, ClusterDO clusterDO, ColonyDO colonyDO) { + healthService.unRegisterCluster(clusterEntity.getClusterId()); + + } + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/FunctionManage.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/FunctionManage.java new file mode 100644 index 00000000..356d0672 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/FunctionManage.java @@ -0,0 +1,178 @@ +/* + * 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.spring.support; + +import org.apache.eventmesh.dashboard.common.model.DatabaseAndMetadataMapper; +import org.apache.eventmesh.dashboard.console.domain.metadata.ClusterMetadataDomain; +import org.apache.eventmesh.dashboard.console.domain.metadata.MetadataAllDO; +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterRelationshipEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; +import org.apache.eventmesh.dashboard.console.function.health.Health2Service; +import org.apache.eventmesh.dashboard.console.service.cluster.ClusterRelationshipService; +import org.apache.eventmesh.dashboard.console.service.cluster.ClusterService; +import org.apache.eventmesh.dashboard.console.service.cluster.RuntimeService; +import org.apache.eventmesh.dashboard.console.service.function.HealthDataService; +import org.apache.eventmesh.dashboard.console.spring.support.metadata.DatabaseAndMetadataType; +import org.apache.eventmesh.dashboard.console.spring.support.metadata.DefaultMetadataSyncResultHandler; +import org.apache.eventmesh.dashboard.core.metadata.DataMetadataHandler; +import org.apache.eventmesh.dashboard.core.metadata.MetadataSyncManage; + +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; + +import javax.annotation.PostConstruct; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +import lombok.extern.slf4j.Slf4j; + +/** + * FunctionManager is in charge of tasks such as scheduled health checks + */ +@Slf4j +@Component +public class FunctionManage { + + + @Autowired + private RuntimeService runtimeService; + + + @Autowired + private ClusterService clusterService; + + @Autowired + private ClusterRelationshipService clusterRelationshipService; + + + @Autowired + private DefaultMetadataSyncResultHandler defaultMetadataSyncResultHandler; + + @Autowired + private HealthDataService dataService; + + @Autowired + private List dataMetadataHandlerList; + + + private final MetadataSyncManage metadataSyncManage = new MetadataSyncManage(); + + private final Health2Service healthService = new Health2Service(); + + private final ClusterMetadataDomain clusterMetadataDomain = new ClusterMetadataDomain(); + + private final RuntimeEntity runtimeEntity = new RuntimeEntity(); + + private final ClusterEntity clusterEntity = new ClusterEntity(); + + private final ClusterRelationshipEntity clusterRelationshipEntity = new ClusterRelationshipEntity(); + + @Value("${function.enabled:false}") + private boolean enabled; + + @PostConstruct + private void init() { + if (!this.enabled) { + return; + } + clusterMetadataDomain.rootClusterDHO(); + this.initQueueData(); + this.createHandler(); + this.buildMetadataSyncManage(); + } + + private void initQueueData() { + LocalDateTime date = LocalDateTime.of(2000, 1, 1, 0, 0, 0, 0); + runtimeEntity.setUpdateTime(date); + clusterEntity.setCreateTime(date); + clusterRelationshipEntity.setUpdateTime(date); + } + + private void buildMetadataSyncManage() { + List databaseAndMetadataMapperList = new ArrayList<>(); + for (DatabaseAndMetadataType databaseAndMetadataType : DatabaseAndMetadataType.values()) { + databaseAndMetadataMapperList.add(databaseAndMetadataType.getDatabaseAndMetadataMapper()); + } + this.metadataSyncManage.setMetadataSyncResultHandler(this.defaultMetadataSyncResultHandler); + this.metadataSyncManage.setDataMetadataHandlerList((List>) ((Object) this.dataMetadataHandlerList)); + + this.metadataSyncManage.init(5000, 100, databaseAndMetadataMapperList); + } + + /** + * TODO 核心逻辑在这里 + */ + private void createHandler() { + DefaultDataHandler defaultDataHandler = new DefaultDataHandler(); + defaultDataHandler.setHealthService(healthService); + defaultDataHandler.setMetadataSyncManage(metadataSyncManage); + this.clusterMetadataDomain.setHandler(defaultDataHandler); + } + + @Bean + public ClusterMetadataDomain registerBean() { + return this.clusterMetadataDomain; + } + + /** + * meta 同步 只获得 实例 实例 同步 kubernetes 数据 全量读取数据 ,创建对应的 meta 对象 + *

+ * 然后 然后日常 + */ + @Scheduled(fixedRate = 5000) + public void initFunctionManager() { + if (!this.enabled) { + return; + } + healthService.executeAll(); + + } + + @Scheduled(initialDelay = 500L, fixedDelay = 100) + public void sync() { + if (!this.enabled) { + return; + } + LocalDateTime date = LocalDateTime.now(); + List runtimeEntityList = this.runtimeService.queryByUpdateTime(runtimeEntity); + List clusterEntityList = this.clusterService.queryByUpdateTime(clusterEntity); + List clusterRelationshipEntityList = + this.clusterRelationshipService.queryByUpdateTime(clusterRelationshipEntity); + if (runtimeEntityList.isEmpty() && clusterEntityList.isEmpty() && clusterRelationshipEntityList.isEmpty()) { + log.info("No runtime entities found"); + } + runtimeEntity.setUpdateTime(date); + clusterEntity.setUpdateTime(date); + clusterRelationshipEntity.setUpdateTime(date); + + MetadataAllDO metadataAll = + MetadataAllDO.builder().clusterEntityList(clusterEntityList).clusterRelationshipEntityList(clusterRelationshipEntityList) + .runtimeEntityList(runtimeEntityList).build(); + this.clusterMetadataDomain.handlerMetadata(metadataAll); + + } + + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/FunctionManager.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/FunctionManager.java deleted file mode 100644 index 9a785fb7..00000000 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/FunctionManager.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.console.spring.support; - -import org.apache.eventmesh.dashboard.console.config.FunctionManagerConfigs; -import org.apache.eventmesh.dashboard.console.function.health.CheckResultCache; -import org.apache.eventmesh.dashboard.console.function.health.HealthService; - -import lombok.Getter; -import lombok.Setter; -import lombok.extern.slf4j.Slf4j; - -/** - * FunctionManager is in charge of tasks such as scheduled health checks - */ -@Slf4j -public class FunctionManager { - - @Setter - private FunctionManagerProperties properties; - - @Setter - private FunctionManagerConfigs configs; - - @Setter - @Getter - private HealthService healthService; - - public void initFunctionManager() { - //Health Check - healthService = new HealthService(); - healthService.createExecutor(properties.getDataServiceContainer().getHealthDataService(), CheckResultCache.getINSTANCE()); - healthService.startScheduledUpdateConfig(configs.getHealthCheck().getUpdateConfig().getInitialDelay(), - configs.getHealthCheck().getUpdateConfig().getPeriod(), properties.getDataServiceContainer()); - healthService.startScheduledExecution(configs.getHealthCheck().getDoCheck().getInitialDelay(), - configs.getHealthCheck().getDoCheck().getPeriod()); - } - -} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/FunctionManagerLoader.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/FunctionManagerLoader.java deleted file mode 100644 index 2ffa3c7b..00000000 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/FunctionManagerLoader.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.console.spring.support; - -import org.apache.eventmesh.dashboard.console.config.FunctionManagerConfigs; -import org.apache.eventmesh.dashboard.console.function.health.HealthService; -import org.apache.eventmesh.dashboard.console.function.metadata.handler.MetadataHandlerWrapper; -import org.apache.eventmesh.dashboard.console.function.metadata.syncservice.SyncDataServiceWrapper; -import org.apache.eventmesh.dashboard.console.service.DataServiceWrapper; - -import javax.annotation.PostConstruct; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Profile; -import org.springframework.stereotype.Component; - -@Profile("!test") -@Component -public class FunctionManagerLoader { - - private FunctionManager functionManager; - - private FunctionManagerProperties properties; - - @Autowired - private DataServiceWrapper dataServiceContainer; - @Autowired - private SyncDataServiceWrapper syncDataServiceWrapper; - @Autowired - private MetadataHandlerWrapper metadataHandlerWrapper; - - @Autowired - private FunctionManagerConfigs functionManagerConfigs; - - @Bean - public HealthService getHealthService() { - return functionManager.getHealthService(); - } - - - @PostConstruct - void initManager() { - functionManager = new FunctionManager(); - properties = new FunctionManagerProperties(); - properties.setDataServiceContainer( - dataServiceContainer); - properties.setSyncDataServiceWrapper( - syncDataServiceWrapper); - properties.setMetadataHandlerWrapper(metadataHandlerWrapper); - - functionManager.setProperties(properties); - functionManager.setConfigs(functionManagerConfigs); - functionManager.initFunctionManager(); - } - -} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/FunctionManagerProperties.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/FunctionManagerProperties.java deleted file mode 100644 index 62693a0f..00000000 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/FunctionManagerProperties.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.console.spring.support; - -import org.apache.eventmesh.dashboard.console.function.metadata.handler.MetadataHandlerWrapper; -import org.apache.eventmesh.dashboard.console.function.metadata.syncservice.SyncDataServiceWrapper; -import org.apache.eventmesh.dashboard.console.service.DataServiceWrapper; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; - -@Data -@NoArgsConstructor -@AllArgsConstructor -@SuperBuilder -public class FunctionManagerProperties { - - private DataServiceWrapper dataServiceContainer; - private SyncDataServiceWrapper syncDataServiceWrapper; - private MetadataHandlerWrapper metadataHandlerWrapper; -} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/RuntimeDeployService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/RuntimeDeployService.java new file mode 100644 index 00000000..92b028a9 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/RuntimeDeployService.java @@ -0,0 +1,422 @@ +/* + * 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.spring.support; + +import org.apache.eventmesh.dashboard.common.enums.ClusterFramework; +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.common.enums.DeployStatusType; +import org.apache.eventmesh.dashboard.common.enums.MetadataType; +import org.apache.eventmesh.dashboard.common.model.base.BaseSyncBase; +import org.apache.eventmesh.dashboard.common.model.metadata.ClusterMetadata; +import org.apache.eventmesh.dashboard.common.port.PortValidate; +import org.apache.eventmesh.dashboard.console.entity.cases.DeployScriptEntity; +import org.apache.eventmesh.dashboard.console.entity.cases.ResourcesConfigEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; +import org.apache.eventmesh.dashboard.console.entity.function.ConfigEntity; +import org.apache.eventmesh.dashboard.console.modle.DO.runtime.QueryRuntimeByBigExpandClusterDO; +import org.apache.eventmesh.dashboard.console.modle.deploy.GetPortsDO; +import org.apache.eventmesh.dashboard.console.service.cluster.ClusterRelationshipService; +import org.apache.eventmesh.dashboard.console.service.cluster.ClusterService; +import org.apache.eventmesh.dashboard.console.service.cluster.RuntimeService; +import org.apache.eventmesh.dashboard.console.service.connector.ResourcesConfigService; +import org.apache.eventmesh.dashboard.console.service.deploy.DeployScriptService; +import org.apache.eventmesh.dashboard.console.service.deploy.PortService; +import org.apache.eventmesh.dashboard.console.service.function.ConfigService; +import org.apache.eventmesh.dashboard.console.spring.support.register.BuildMetadata; +import org.apache.eventmesh.dashboard.console.spring.support.register.BuildMetadataManage; +import org.apache.eventmesh.dashboard.console.spring.support.register.ScriptBuildData; +import org.apache.eventmesh.dashboard.core.function.SDK.SDKManage; +import org.apache.eventmesh.dashboard.core.function.SDK.SDKTypeEnum; + +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Objects; +import java.util.concurrent.LinkedBlockingDeque; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +import io.fabric8.kubernetes.client.KubernetesClient; + +import lombok.extern.slf4j.Slf4j; + +/** + * 不会处理 关联 + */ +@Slf4j +@Component +public class RuntimeDeployService { + + private static final Map DEPLOY_FAIL_STATUS = new HashMap<>(); + + private static final Map DEPLOY_ING_STATUS = new HashMap<>(); + + private static final Map DEPLOY_SUCCESS_STATUS = new HashMap<>(); + + static { + DEPLOY_FAIL_STATUS.put(DeployStatusType.CREATE_WAIT, DeployStatusType.CREATE_FAIL); + DEPLOY_FAIL_STATUS.put(DeployStatusType.CREATE_FULL_WAIT, DeployStatusType.CREATE_FULL_FAIL); + DEPLOY_FAIL_STATUS.put(DeployStatusType.CREATE_CAP_UPDATE_WAIT, DeployStatusType.CREATE_CAP_UPDATE_FAIL); + DEPLOY_FAIL_STATUS.put(DeployStatusType.UPDATE_WAIT, DeployStatusType.UPDATE_FAIL); + DEPLOY_FAIL_STATUS.put(DeployStatusType.UPDATE_FULL_WAIT, DeployStatusType.UPDATE_FULL_FAIL); + DEPLOY_FAIL_STATUS.put(DeployStatusType.PAUSE_WAIT, DeployStatusType.UPDATE_FAIL); + DEPLOY_FAIL_STATUS.put(DeployStatusType.PAUSE_FULL_WAIT, DeployStatusType.PAUSE_FULL_FAIL); + DEPLOY_FAIL_STATUS.put(DeployStatusType.RESET_WAIT, DeployStatusType.RESET_FAIL); + DEPLOY_FAIL_STATUS.put(DeployStatusType.UNINSTALL, DeployStatusType.UNINSTALL_FAIL); + + DEPLOY_SUCCESS_STATUS.put(DeployStatusType.CREATE_WAIT, DeployStatusType.CREATE_SUCCESS); + DEPLOY_SUCCESS_STATUS.put(DeployStatusType.CREATE_FULL_WAIT, DeployStatusType.CREATE_FULL_SUCCESS); + DEPLOY_SUCCESS_STATUS.put(DeployStatusType.CREATE_CAP_UPDATE_WAIT, DeployStatusType.CREATE_CAP_UPDATE_SUCCESS); + DEPLOY_SUCCESS_STATUS.put(DeployStatusType.UPDATE_WAIT, DeployStatusType.UPDATE_SUCCESS); + DEPLOY_SUCCESS_STATUS.put(DeployStatusType.UPDATE_FULL_WAIT, DeployStatusType.UPDATE_FULL_SUCCESS); + DEPLOY_SUCCESS_STATUS.put(DeployStatusType.PAUSE_WAIT, DeployStatusType.UPDATE_SUCCESS); + DEPLOY_SUCCESS_STATUS.put(DeployStatusType.PAUSE_FULL_WAIT, DeployStatusType.PAUSE_FULL_SUCCESS); + DEPLOY_SUCCESS_STATUS.put(DeployStatusType.RESET_WAIT, DeployStatusType.RESET_SUCCESS); + DEPLOY_SUCCESS_STATUS.put(DeployStatusType.UNINSTALL, DeployStatusType.UNINSTALL_SUCCESS); + + DEPLOY_ING_STATUS.put(DeployStatusType.CREATE_WAIT, DeployStatusType.CREATE_ING); + DEPLOY_ING_STATUS.put(DeployStatusType.CREATE_FULL_WAIT, DeployStatusType.CREATE_FULL_ING); + DEPLOY_ING_STATUS.put(DeployStatusType.CREATE_CAP_UPDATE_WAIT, DeployStatusType.CREATE_CAP_UPDATE_ING); + DEPLOY_ING_STATUS.put(DeployStatusType.UPDATE_WAIT, DeployStatusType.UPDATE_ING); + DEPLOY_ING_STATUS.put(DeployStatusType.UPDATE_FULL_WAIT, DeployStatusType.UPDATE_FULL_ING); + DEPLOY_ING_STATUS.put(DeployStatusType.PAUSE_WAIT, DeployStatusType.UPDATE_ING); + DEPLOY_ING_STATUS.put(DeployStatusType.PAUSE_FULL_WAIT, DeployStatusType.PAUSE_FULL_ING); + DEPLOY_ING_STATUS.put(DeployStatusType.RESET_WAIT, DeployStatusType.RESET_ING); + DEPLOY_ING_STATUS.put(DeployStatusType.UNINSTALL, DeployStatusType.UNINSTALL_ING); + + } + + static DeployStatusType getFailedType(DeployStatusType deployStatusType) { + return DEPLOY_FAIL_STATUS.get(deployStatusType); + } + + static DeployStatusType getIngType(DeployStatusType deployStatusType) { + return DEPLOY_ING_STATUS.get(deployStatusType); + } + + static DeployStatusType getSuccess(DeployStatusType deployStatusType) { + return DEPLOY_ING_STATUS.get(deployStatusType); + } + + @Autowired + private ClusterService clusterService; + + @Autowired + private RuntimeService runtimeService; + + @Autowired + private ClusterRelationshipService clusterRelationshipService; + + @Autowired + private DeployScriptService deployScriptService; + + @Autowired + private ResourcesConfigService resourcesConfigService; + + @Autowired + private ConfigService configService; + + @Autowired + private PortService portService; + + + private final BuildMetadataManage buildMetadataManage = new BuildMetadataManage(); + + private final ThreadPoolExecutor deployThreadPoolExecutor = new ThreadPoolExecutor(10, 10, 20, TimeUnit.SECONDS, new LinkedBlockingDeque<>(), + new ThreadFactory() { + final AtomicInteger counter = new AtomicInteger(0); + + @Override + public Thread newThread(Runnable r) { + return new Thread(r, "deploy-" + counter.incrementAndGet()); + } + }); + + + @Scheduled(initialDelay = 100, fixedDelay = 100) + public void deploy() { + RuntimeEntity runtimeEntity = new RuntimeEntity(); + runtimeEntity.setUpdateTime(LocalDateTime.now().minusMinutes(500)); + List runtimeEntityList = this.runtimeService.queryByUpdateTime(runtimeEntity); + + runtimeEntityList.forEach(entity -> { + AbstractRuntimeServiceTask abstractRuntimeServiceTask = this.createTask(entity); + if (Objects.isNull(abstractRuntimeServiceTask)) { + return; + } + abstractRuntimeServiceTask.runtimeEntity = entity; + deployThreadPoolExecutor.execute(abstractRuntimeServiceTask); + }); + } + + + public AbstractRuntimeServiceTask createTask(RuntimeEntity entity) { + switch (entity.getDeployStatusType()) { + case CREATE_WAIT, CREATE_FULL_WAIT, CREATE_CAP_UPDATE_WAIT, UPDATE_WAIT -> { + return new RuntimeCreateDeploy(); + } + case PAUSE_ING, PAUSE_FULL_WAIT -> { + return new RuntimePauseDeploy(); + } + case UNINSTALL -> { + return new RuntimeUninstallDeploy(); + } + default -> { + return null; + } + } + } + + public abstract class AbstractRuntimeServiceTask implements Runnable { + + protected RuntimeEntity runtimeEntity; + + protected ClusterEntity clusterEntity; + + protected ClusterType clusterType; + + protected ClusterFramework clusterFramework; + + protected ClusterEntity kubeClusterEntity; + + protected KubernetesClient kubernetesClient; + + protected List metaAndRuntimeList; + + protected List updateRuntimeList = new ArrayList<>(); + + protected ScriptBuildData scriptBuildData = new ScriptBuildData(); + + protected BuildMetadata buildMetadata; + + + public void queryHandlerData() { + this.clusterType = this.runtimeEntity.getClusterType(); + ClusterEntity clusterEntity = new ClusterEntity(); + clusterEntity.setId(this.runtimeEntity.getClusterId()); + this.clusterEntity = clusterService.queryClusterById(clusterEntity); + /* + * 查询 kubernetes cluster + * TODO 目前无法处理 多 kubernetes 的问题 + */ + this.kubeClusterEntity = clusterService.queryRelationshipClusterByClusterIdAndType(clusterEntity); + BaseSyncBase base = new ClusterMetadata(); + base.setId(this.kubeClusterEntity.getId()); + this.kubernetesClient = SDKManage.getInstance().getClient(SDKTypeEnum.ADMIN, base.getUnique()); + this.buildMetadata = buildMetadataManage.getBuildMetaAddress(this.runtimeEntity.getClusterType()); + } + + public void buildOperationMetaData() { + scriptBuildData.put("namespace", runtimeEntity.getClusterId()); + scriptBuildData.put("name", runtimeEntity.getId()); + + scriptBuildData.put("clusterType", runtimeEntity.getClusterType()); + scriptBuildData.put("clusterId", runtimeEntity.getClusterId()); + scriptBuildData.put("runtimeId", runtimeEntity.getId()); + } + + public void buildMetaAddress() { + if (!Objects.equals(RuntimeCreateDeploy.class, this.getClass())) { + return; + } + // TODO 非 mate 都需要 meta, + if (!this.clusterType.isMeta() && !this.clusterType.isMetaAndRuntime()) { + // 存储节点必须要 meta信息 + + QueryRuntimeByBigExpandClusterDO queryRuntimeByBigExpandClusterDO = QueryRuntimeByBigExpandClusterDO.builder() + .followClusterId(clusterEntity.getId()).queryClusterTypeList(this.clusterType.getMetaClusterType()).build(); + + List newRuntimeEntityList = runtimeService.queryMetaRuntimeByStorageClusterId(queryRuntimeByBigExpandClusterDO); + this.buildMetadata.buildMetaAddress(this.scriptBuildData, runtimeEntity, newRuntimeEntityList); + } + // 如果是创建 runtime , 需要得到 所有存储的 runtime + if (Objects.equals(this.clusterType, ClusterType.EVENTMESH_RUNTIME)) { + QueryRuntimeByBigExpandClusterDO data = QueryRuntimeByBigExpandClusterDO.builder().followClusterId(this.clusterEntity.getId()) + .mainClusterType(ClusterType.EVENTMESH_CLUSTER).storageClusterTypeList(ClusterType.getStorageCluster()) + .storageMetaClusterTypeList(ClusterType.getStorageMetaCluster()).build(); + + List storageMetaRuntimeList = runtimeService.queryRuntimeByBigExpandCluster(data); + this.buildMetadata.buildMetaAddress(this.scriptBuildData, runtimeEntity, storageMetaRuntimeList); + } + if (this.clusterType.isMetaAndRuntime() || (this.clusterType.isMeta() && this.clusterFramework.isCAP())) { + // CAP 模式 需要得到本集群里面所有 runtime + List metaAndRuntimeList = runtimeService.queryRuntimeToFrontByClusterId(runtimeEntity); + this.buildMetadata.buildMetaAddress(this.scriptBuildData, runtimeEntity, metaAndRuntimeList); + } + } + + + + /** + * runtime 进行操作的时候,会影响 当前集群 或则 依赖菊琴 + * + *

    + *
  1. CAP 集群修改,集群内所有节点都必须修改,同时 依赖集群同时也要修改
  2. + *
  3. TODO CAP 集群是 批量创建创建 @see PAUSE_FULL_WAIT CREATE_FULL_WAIT , 不会影响
  4. + *
+ */ + public void influence() { + if (Objects.equals(this.runtimeEntity.getDeployStatusType(), DeployStatusType.PAUSE_FULL_WAIT) || Objects.equals( + this.runtimeEntity.getDeployStatusType(), DeployStatusType.CREATE_FULL_WAIT)) { + return; + } + + if (this.clusterType.isMetaAndRuntime() && Objects.equals(this.runtimeEntity.getDeployStatusType(), + DeployStatusType.CREATE_WAIT)) { + // 修改数据 + this.metaAndRuntimeList.forEach((value) -> { + value.setDeployStatusType(DeployStatusType.CREATE_CAP_UPDATE_WAIT); + this.updateRuntimeList.add(value); + }); + } + if (this.clusterType.isMeta()) { + // 查询 当前集群下 所有 节点, 然后更新这些节点的内容 + runtimeService.queryRuntimeToFrontByClusterId(this.runtimeEntity).forEach((value) -> { + if (Objects.equals(this.runtimeEntity.getId(), value.getId())) { + return; + } + value.setDeployStatusType(DeployStatusType.UPDATE_WAIT); + this.updateRuntimeList.add(runtimeEntity); + }); + } + + } + + @Override + public void run() { + try { + this.queryHandlerData(); + this.buildOperationMetaData(); + if (Objects.equals(this.runtimeEntity.getDeployStatusType(), DeployStatusType.UNINSTALL)) { + this.handler(); + return; + } + this.buildMetaAddress(); + this.handler(); + this.influence(); + this.runtimeEntity.setDeployStatusType(getSuccess(runtimeEntity.getDeployStatusType())); + } catch (Exception e) { + log.error(e.getMessage(), e); + this.runtimeEntity.setDeployStatusType(getFailedType(runtimeEntity.getDeployStatusType())); + } + this.updateRuntimeList.add(this.runtimeEntity); + + try { + runtimeService.batchUpdate(this.updateRuntimeList); + } catch (Exception e) { + log.error(e.getMessage(), e); + } + } + + abstract void handler(); + } + + class RuntimeUninstallDeploy extends AbstractRuntimeServiceTask { + + + @Override + void handler() { + // 直接从 云 or 容器 删除资源 + } + + } + + class RuntimePauseDeploy extends AbstractRuntimeServiceTask { + + @Override + void handler() { + + } + } + + + class RuntimeCreateCheckDeploy extends AbstractRuntimeServiceTask { + + @Override + void handler() { + + } + } + + class RuntimeCreateDeploy extends AbstractRuntimeServiceTask { + + private DeployScriptEntity deployScriptEntity; + + + @Override + void handler() { + runtimeEntity.setKubernetesClusterId(this.kubeClusterEntity.getId()); + deployScriptEntity = new DeployScriptEntity(); + deployScriptEntity.setId(this.clusterEntity.getDeployScriptId()); + this.deployScriptEntity = deployScriptService.queryById(deployScriptEntity); + + ResourcesConfigEntity resourcesConfigEntity = new ResourcesConfigEntity(); + resourcesConfigEntity.setId(this.clusterEntity.getResourcesConfigId()); + + resourcesConfigEntity = resourcesConfigService.queryResourcesById(resourcesConfigEntity); + this.scriptBuildData.setResourcesConfigEntity(resourcesConfigEntity); + + ConfigEntity configEntity = new ConfigEntity(); + configEntity.setClusterId(this.clusterEntity.getId()); + configEntity.setInstanceId(this.clusterEntity.getId()); + configEntity.setInstanceType(MetadataType.CLUSTER); + List configEntityList = configService.queryByClusterAndInstanceId(configEntity); + + this.scriptBuildData.setConfigEntityList(configEntityList); + this.buildMetadata.buildConfig(this.scriptBuildData, this.runtimeEntity); + this.applyPort(); + this.kubernetesClient.resource(this.buildScriptContent()).serverSideApply(); + + //kubernetesClient.load(new ByteArrayInputStream(this.buildScriptContent().getBytes())).serverSideApply(). + + } + + private void applyPort() { + PortValidate portValidate = this.buildMetadata.portValidate(); + portValidate.portRules(); + GetPortsDO getPortsDO = new GetPortsDO(); + getPortsDO.setClusterId(this.clusterEntity.getId()); + getPortsDO.setPortNum(portValidate.portRules().size()); + List port = portService.getPorts(getPortsDO); + for (int i = 0; i < port.size(); i++) { + this.scriptBuildData.put(portValidate.portRules().get(i).getName(), port.get(i)); + } + } + + private String buildScriptContent() { + String scriptContent = this.deployScriptEntity.getContent(); + + for (Entry entity : this.scriptBuildData.getData().entrySet()) { + scriptContent = scriptContent.replace("${" + entity.getKey() + "}", entity.getValue().toString()); + } + + return scriptContent; + } + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/metadata/DatabaseAndMetadataType.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/metadata/DatabaseAndMetadataType.java new file mode 100644 index 00000000..92aa46d7 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/metadata/DatabaseAndMetadataType.java @@ -0,0 +1,80 @@ +/* + * 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.spring.support.metadata; + +import org.apache.eventmesh.dashboard.common.enums.MetadataType; +import org.apache.eventmesh.dashboard.common.model.DatabaseAndMetadataMapper; +import org.apache.eventmesh.dashboard.console.service.metadata.ClientDataMetadataHandler; +import org.apache.eventmesh.dashboard.console.service.metadata.ConfigDataMetadataHandler; +import org.apache.eventmesh.dashboard.console.service.metadata.ConsumeOffsetDataMetadataHandler; +import org.apache.eventmesh.dashboard.console.service.metadata.GroupDataMetadataHandler; +import org.apache.eventmesh.dashboard.console.service.metadata.RuntimeDataMetadataHandler; +import org.apache.eventmesh.dashboard.console.service.metadata.TopicDataMetadataHandler; +import org.apache.eventmesh.dashboard.console.service.metadata.TopicOffsetDataMetadataHandler; +import org.apache.eventmesh.dashboard.console.spring.support.metadata.convert.ConfigConvertMetaData; +import org.apache.eventmesh.dashboard.console.spring.support.metadata.convert.ConsumeOffsetConvertMetaData; +import org.apache.eventmesh.dashboard.console.spring.support.metadata.convert.GroupConvertMetaData; +import org.apache.eventmesh.dashboard.console.spring.support.metadata.convert.RuntimeConvertMetaData; +import org.apache.eventmesh.dashboard.console.spring.support.metadata.convert.TopicOffsetConvertMetaData; +import org.apache.eventmesh.dashboard.service.remoting.ClientRemotingService; +import org.apache.eventmesh.dashboard.service.remoting.ConfigRemotingService; +import org.apache.eventmesh.dashboard.service.remoting.ConsumeOffsetRemotingService; +import org.apache.eventmesh.dashboard.service.remoting.GroupRemotingService; +import org.apache.eventmesh.dashboard.service.remoting.MetaRemotingService; +import org.apache.eventmesh.dashboard.service.remoting.TopicOffsetRemotingService; +import org.apache.eventmesh.dashboard.service.remoting.TopicRemotingService; + +import lombok.Getter; + +@Getter +public enum DatabaseAndMetadataType { + + RUNTIME(DatabaseAndMetadataMapper.builder().metaType(MetadataType.RUNTIME).databaseHandlerClass(RuntimeDataMetadataHandler.class) + .metadataHandlerClass(MetaRemotingService.class).convertMetaData(RuntimeConvertMetaData.INSTANCE).build()), + + TOPIC(DatabaseAndMetadataMapper.builder().metaType(MetadataType.TOPIC).databaseHandlerClass(TopicDataMetadataHandler.class) + .metadataHandlerClass(TopicRemotingService.class).convertMetaData(RuntimeConvertMetaData.INSTANCE).build()), + + + TOPIC_OFFSET(DatabaseAndMetadataMapper.builder().metaType(MetadataType.TOPIC_OFFSET).databaseHandlerClass(TopicOffsetDataMetadataHandler.class) + .metadataHandlerClass(TopicOffsetRemotingService.class).convertMetaData(TopicOffsetConvertMetaData.INSTANCE).build()), + + CONSUME_OFFSET( + DatabaseAndMetadataMapper.builder().metaType(MetadataType.CONSUME_OFFSET).databaseHandlerClass(ConsumeOffsetDataMetadataHandler.class) + .metadataHandlerClass(ConsumeOffsetRemotingService.class).convertMetaData(ConsumeOffsetConvertMetaData.INSTANCE).build()), + + GROUP(DatabaseAndMetadataMapper.builder().metaType(MetadataType.GROUP).databaseHandlerClass(GroupDataMetadataHandler.class) + .metadataHandlerClass(GroupRemotingService.class).convertMetaData(GroupConvertMetaData.INSTANCE).build()), + + CONFIG(DatabaseAndMetadataMapper.builder().metaType(MetadataType.CONFIG).databaseHandlerClass(ConfigDataMetadataHandler.class) + .metadataHandlerClass(ConfigRemotingService.class).convertMetaData(ConfigConvertMetaData.INSTANCE).build()), + + CLIENT(DatabaseAndMetadataMapper.builder().metaType(MetadataType.CLIENT).databaseHandlerClass(ClientDataMetadataHandler.class) + .metadataHandlerClass(ClientRemotingService.class).convertMetaData(ConfigConvertMetaData.INSTANCE).build()), + ; + + + private DatabaseAndMetadataMapper databaseAndMetadataMapper; + + + DatabaseAndMetadataType(DatabaseAndMetadataMapper databaseAndMetadataMapper) { + this.databaseAndMetadataMapper = databaseAndMetadataMapper; + } + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/metadata/DefaultMetadataSyncResultHandler.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/metadata/DefaultMetadataSyncResultHandler.java new file mode 100644 index 00000000..b0c4c59a --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/metadata/DefaultMetadataSyncResultHandler.java @@ -0,0 +1,205 @@ +/* + * 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.spring.support.metadata; + +import org.apache.eventmesh.dashboard.common.enums.ClusterTrusteeshipType.FirstToWhom; +import org.apache.eventmesh.dashboard.common.enums.MetadataType; +import org.apache.eventmesh.dashboard.common.model.base.BaseSyncBase; +import org.apache.eventmesh.dashboard.common.model.metadata.ClusterMetadata; +import org.apache.eventmesh.dashboard.common.model.metadata.RuntimeMetadata; +import org.apache.eventmesh.dashboard.console.entity.base.BaseSyncEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; +import org.apache.eventmesh.dashboard.console.entity.function.MetadataSyncResultEntity; +import org.apache.eventmesh.dashboard.console.service.function.MetadataSyncResultService; +import org.apache.eventmesh.dashboard.console.spring.support.metadata.convert.ClusterConvertMetaData; +import org.apache.eventmesh.dashboard.console.spring.support.metadata.convert.RuntimeConvertMetaData; +import org.apache.eventmesh.dashboard.core.metadata.result.MetadataSyncResult; +import org.apache.eventmesh.dashboard.core.metadata.result.MetadataSyncResultHandler; + +import org.apache.commons.collections4.MapUtils; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.concurrent.ConcurrentHashMap; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class DefaultMetadataSyncResultHandler implements MetadataSyncResultHandler { + + + private final Map dimensionMap = new ConcurrentHashMap<>(); + + private final Object recordLock = new Object(); + + private List record = new ArrayList<>(); + + private final Object runtimeLock = new Object(); + + private List runtimeList = new ArrayList<>(); + + private final Object clusterLock = new Object(); + + private List clusterList = new ArrayList<>(); + + + @Autowired + private MetadataSyncResultService metadataSyncResultService; + + + /** + * TODO + * 1. 如何优化这里的持久。只保存错误记录还是全量报错 + * 2. 保存 FirstToWhom 处理结果 + * 3. 保存 节点异常状态 + */ + @Override + public void persistence() { + List record = null; + if (!this.record.isEmpty()) { + synchronized (recordLock) { + record = this.record; + this.record = new ArrayList<>(); + } + } + + List runtimeList = null; + if (!this.runtimeList.isEmpty()) { + synchronized (runtimeLock) { + runtimeList = this.runtimeList; + this.runtimeList = new ArrayList<>(); + } + } + + List clusterList = null; + if (!this.clusterList.isEmpty()) { + synchronized (clusterLock) { + clusterList = this.clusterList; + this.clusterList = new ArrayList<>(); + } + } + metadataSyncResultService.bachMetadataSyncResult(record, runtimeList, clusterList); + } + + + @Override + public void register(List metadataSyncResults) { + MetadataSyncResult metadataSyncResult = metadataSyncResults.get(0); + Dimension dimension = new Dimension(); + dimensionMap.put(metadataSyncResult.getBaseSyncBase().getUnique(), dimension); + + metadataSyncResults.forEach((value) -> { + dimension.metadataTypeMap.put(value.getMetadataType(), 1); + }); + dimension.baseSyncBase = metadataSyncResult.getBaseSyncBase(); + } + + @Override + public void unregister(BaseSyncBase baseSyncBase) { + dimensionMap.remove(baseSyncBase.getUnique()); + } + + /** + * 分为正常同步,校验校验 ruguo + * + * @param metadataSyncResult + */ + @Override + public void handleMetadataSyncResult(MetadataSyncResult metadataSyncResult) { + Dimension dimension = this.dimensionMap.get(metadataSyncResult.getBaseSyncBase().getUnique()); + if (!metadataSyncResult.isSuccess()) { + MetadataSyncResultEntity metadataSyncResultEntity = getMetadataSyncResultEntity(metadataSyncResult, dimension); + synchronized (record) { + record.add(metadataSyncResultEntity); + } + BaseSyncEntity baseSyncEntity = dimension.getBaseSyncEntity(); + baseSyncEntity.setSyncErrorType(metadataSyncResult.getSyncErrorType()); + + } + if (Objects.equals(dimension.baseSyncBase.getFirstToWhom(), FirstToWhom.COMPLETE)) { + return; + } + dimension.metadataTypeMap.remove(metadataSyncResult.getMetadataType()); + if (MapUtils.isEmpty(dimension.metadataTypeMap)) { + dimension.baseSyncBase.setFirstSyncState(FirstToWhom.COMPLETE); + BaseSyncEntity baseSyncEntity = dimension.getBaseSyncEntity(); + baseSyncEntity.setFirstSyncState(FirstToWhom.COMPLETE); + } + } + + private static MetadataSyncResultEntity getMetadataSyncResultEntity(MetadataSyncResult metadataSyncResult, Dimension dimension) { + BaseSyncEntity baseSyncEntity = dimension.getBaseSyncEntity(); + + MetadataSyncResultEntity metadataSyncResultEntity = new MetadataSyncResultEntity(); + metadataSyncResultEntity.setClusterId(baseSyncEntity.getClusterId()); + metadataSyncResultEntity.setSyncId(baseSyncEntity.getId()); + metadataSyncResultEntity.setMetadataType(metadataSyncResult.getMetadataType()); + metadataSyncResultEntity.setSyncErrorType(metadataSyncResult.getSyncErrorType()); + metadataSyncResultEntity.setResultData(metadataSyncResultEntity.getResultData()); + return metadataSyncResultEntity; + } + + + /** + * + */ + public class Dimension { + + /** + * 如果第一次同步,需要修改对应的, dimension 对象。runtime cluster + * + * @see org.apache.eventmesh.dashboard.common.enums.ClusterTrusteeshipType.FirstToWhom + *

+ * 每次完成同步,进行整理,如果有失败的,进行记录并且对 dimension 队形进行标记 + */ + private BaseSyncBase baseSyncBase; + + + private Map metadataTypeMap = new ConcurrentHashMap<>(); + + + public BaseSyncEntity getBaseSyncEntity() { + return Objects.equals(ClusterMetadata.class, baseSyncBase.getClass()) ? this.getClusterEntity() : this.getRuntimeEntity(); + } + + public RuntimeEntity getRuntimeEntity() { + RuntimeEntity runtimeEntity = RuntimeConvertMetaData.INSTANCE.toEntity((RuntimeMetadata) baseSyncBase); + synchronized (DefaultMetadataSyncResultHandler.this.runtimeLock) { + DefaultMetadataSyncResultHandler.this.runtimeList.add(runtimeEntity); + } + return runtimeEntity; + } + + private ClusterEntity getClusterEntity() { + ClusterEntity clusterEntity = ClusterConvertMetaData.INSTANCE.toEntity((ClusterMetadata) this.baseSyncBase); + synchronized (DefaultMetadataSyncResultHandler.this.clusterLock) { + DefaultMetadataSyncResultHandler.this.clusterList.add(clusterEntity); + } + return clusterEntity; + } + + public boolean isCluster() { + return Objects.equals(ClusterMetadata.class, baseSyncBase.getClass()); + } + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/metadata/convert/ClientConvertMetaData.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/metadata/convert/ClientConvertMetaData.java new file mode 100644 index 00000000..db44aff7 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/metadata/convert/ClientConvertMetaData.java @@ -0,0 +1,41 @@ +/* + * 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.spring.support.metadata.convert; + +import org.apache.eventmesh.dashboard.common.model.ConvertMetaData; +import org.apache.eventmesh.dashboard.common.model.metadata.ClientMetadata; +import org.apache.eventmesh.dashboard.console.entity.cluster.ClientEntity; + +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +/** + * + */ +@Mapper +public interface ClientConvertMetaData extends ConvertMetaData { + + ClientConvertMetaData INSTANCE = Mappers.getMapper(ClientConvertMetaData.class); + + @Override + ClientEntity toEntity(ClientMetadata meta); + + @Override + ClientMetadata toMetaData(ClientEntity entity); +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/metadata/convert/ClusterConvertMetaData.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/metadata/convert/ClusterConvertMetaData.java new file mode 100644 index 00000000..9b3be65c --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/metadata/convert/ClusterConvertMetaData.java @@ -0,0 +1,41 @@ +/* + * 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.spring.support.metadata.convert; + +import org.apache.eventmesh.dashboard.common.model.ConvertMetaData; +import org.apache.eventmesh.dashboard.common.model.metadata.ClusterMetadata; +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; + +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +/** + * + */ +@Mapper +public interface ClusterConvertMetaData extends ConvertMetaData { + + ClusterConvertMetaData INSTANCE = Mappers.getMapper(ClusterConvertMetaData.class); + + @Override + ClusterEntity toEntity(ClusterMetadata meta); + + @Override + ClusterMetadata toMetaData(ClusterEntity entity); +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/metadata/convert/ConfigConvertMetaData.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/metadata/convert/ConfigConvertMetaData.java new file mode 100644 index 00000000..51e783e1 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/metadata/convert/ConfigConvertMetaData.java @@ -0,0 +1,41 @@ +/* + * 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.spring.support.metadata.convert; + +import org.apache.eventmesh.dashboard.common.model.ConvertMetaData; +import org.apache.eventmesh.dashboard.common.model.metadata.ConfigMetadata; +import org.apache.eventmesh.dashboard.console.entity.function.ConfigEntity; + +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +/** + * + */ +@Mapper +public interface ConfigConvertMetaData extends ConvertMetaData { + + ConfigConvertMetaData INSTANCE = Mappers.getMapper(ConfigConvertMetaData.class); + + @Override + ConfigEntity toEntity(ConfigMetadata meta); + + @Override + ConfigMetadata toMetaData(ConfigEntity entity); +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/connection/ConnectionControllerMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/metadata/convert/ConsumeOffsetConvertMetaData.java similarity index 54% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/connection/ConnectionControllerMapper.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/metadata/convert/ConsumeOffsetConvertMetaData.java index a1c22646..e47a7224 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/connection/ConnectionControllerMapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/metadata/convert/ConsumeOffsetConvertMetaData.java @@ -15,23 +15,26 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.mapstruct.connection; +package org.apache.eventmesh.dashboard.console.spring.support.metadata.convert; -import org.apache.eventmesh.dashboard.console.entity.CreateConnectionEntity; -import org.apache.eventmesh.dashboard.console.entity.cluster.ConnectionEntity; -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.common.model.ConvertMetaData; +import org.apache.eventmesh.dashboard.common.model.metadata.ConsumeOffsetMetadata; +import org.apache.eventmesh.dashboard.console.entity.message.ConsumeOffsetEntity; +import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; /** * */ -public interface ConnectionControllerMapper { +@Mapper +public interface ConsumeOffsetConvertMetaData extends ConvertMetaData { - ConnectionControllerMapper INSTANCE = Mappers.getMapper(ConnectionControllerMapper.class); + ConsumeOffsetConvertMetaData INSTANCE = Mappers.getMapper(ConsumeOffsetConvertMetaData.class); - ConnectionEntity queryEntityByConnection(GetConnectionListDTO getConnectionListDTO); + @Override + ConsumeOffsetEntity toEntity(ConsumeOffsetMetadata meta); - CreateConnectionEntity queryCreateEntityByConnection(CreateConnectionDTO createConnectionDTO); + @Override + ConsumeOffsetMetadata toMetaData(ConsumeOffsetEntity entity); } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/metadata/convert/GroupConvertMetaData.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/metadata/convert/GroupConvertMetaData.java new file mode 100644 index 00000000..3192db3b --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/metadata/convert/GroupConvertMetaData.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.console.spring.support.metadata.convert; + +import org.apache.eventmesh.dashboard.common.model.ConvertMetaData; +import org.apache.eventmesh.dashboard.common.model.metadata.GroupMetadata; +import org.apache.eventmesh.dashboard.console.entity.message.GroupEntity; + +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + + +/** + * + */ +@Mapper +public interface GroupConvertMetaData extends ConvertMetaData { + + GroupConvertMetaData INSTANCE = Mappers.getMapper(GroupConvertMetaData.class); + + @Override + GroupEntity toEntity(GroupMetadata meta); + + @Override + GroupMetadata toMetaData(GroupEntity entity); +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/metadata/convert/RuntimeConvertMetaData.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/metadata/convert/RuntimeConvertMetaData.java new file mode 100644 index 00000000..d7bfdecf --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/metadata/convert/RuntimeConvertMetaData.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.spring.support.metadata.convert; + +import org.apache.eventmesh.dashboard.common.model.ConvertMetaData; +import org.apache.eventmesh.dashboard.common.model.metadata.RuntimeMetadata; +import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; + + +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + + +/** + * + */ +@Mapper +public interface RuntimeConvertMetaData extends ConvertMetaData { + + RuntimeConvertMetaData INSTANCE = Mappers.getMapper(RuntimeConvertMetaData.class); + + @Override + RuntimeEntity toEntity(RuntimeMetadata meta); + + @Override + RuntimeMetadata toMetaData(RuntimeEntity entity); +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/metadata/convert/TopicConvertMetaData.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/metadata/convert/TopicConvertMetaData.java new file mode 100644 index 00000000..d9f751ce --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/metadata/convert/TopicConvertMetaData.java @@ -0,0 +1,41 @@ +/* + * 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.spring.support.metadata.convert; + +import org.apache.eventmesh.dashboard.common.model.ConvertMetaData; +import org.apache.eventmesh.dashboard.common.model.metadata.TopicMetadata; +import org.apache.eventmesh.dashboard.console.entity.message.TopicEntity; + +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +/** + * + */ +@Mapper +public interface TopicConvertMetaData extends ConvertMetaData { + + TopicConvertMetaData INSTANCE = Mappers.getMapper(TopicConvertMetaData.class); + + @Override + TopicEntity toEntity(TopicMetadata meta); + + @Override + TopicMetadata toMetaData(TopicEntity entity); +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/metadata/convert/TopicOffsetConvertMetaData.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/metadata/convert/TopicOffsetConvertMetaData.java new file mode 100644 index 00000000..66c64b75 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/metadata/convert/TopicOffsetConvertMetaData.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.spring.support.metadata.convert; + +import org.apache.eventmesh.dashboard.common.model.ConvertMetaData; +import org.apache.eventmesh.dashboard.common.model.metadata.TopicOffsetMetadata; +import org.apache.eventmesh.dashboard.console.entity.message.TopicOffsetEntity; + +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +/** + * + */ +@Mapper +public interface TopicOffsetConvertMetaData extends ConvertMetaData { + + TopicOffsetConvertMetaData INSTANCE = Mappers.getMapper(TopicOffsetConvertMetaData.class); + + @Override + TopicOffsetEntity toEntity(TopicOffsetMetadata meta); + + @Override + TopicOffsetMetadata toMetaData(TopicOffsetEntity entity); +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/register/AbstractBuildMetadata.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/register/AbstractBuildMetadata.java new file mode 100644 index 00000000..08e0aae5 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/register/AbstractBuildMetadata.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.spring.support.register; + +import org.apache.eventmesh.dashboard.common.port.PortValidate; +import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; + +import java.util.List; +import java.util.Objects; + +/** + * + */ +public abstract class AbstractBuildMetadata implements BuildMetadata { + + private PortValidate portValidate; + + + protected void setPortValidate(PortValidate portValidate) { + this.portValidate = portValidate; + } + + @Override + public PortValidate portValidate() { + return this.portValidate; + } + + public char separator() { + return ';'; + } + + + public String buildRuntime(RuntimeEntity target, RuntimeEntity runtimeEntity) { + if (Objects.equals(target.getKubernetesClusterId(), runtimeEntity.getKubernetesClusterId())) { + return runtimeEntity.getHost() + ":" + runtimeEntity.getPort() + this.separator(); + } else { + return runtimeEntity.getHost() + ":" + runtimeEntity.getPort() + this.separator(); + } + } + + public String standardRuntime(ScriptBuildData data, RuntimeEntity target, List runtimeEntityList) { + StringBuffer nameService = new StringBuffer(); + runtimeEntityList.forEach(runtimeEntity -> { + nameService.append(this.buildRuntime(target, runtimeEntity)); + }); + data.put("metaService", nameService.toString()); + return nameService.toString(); + } + + public String generatePropertiesConfig(ScriptBuildData data) { + StringBuffer config = new StringBuffer(); + data.getConfigEntityList().forEach(configEntity -> { + config.append(configEntity.getConfigName()).append("=").append(configEntity.getConfigValue()).append(System.lineSeparator()); + }); + String runtimeConfig = config.toString(); + data.put("runtimeConfig", runtimeConfig); + return runtimeConfig; + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/InstanceUserService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/register/BuildMetadata.java similarity index 58% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/InstanceUserService.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/register/BuildMetadata.java index 6958480d..6050e057 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/cluster/InstanceUserService.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/register/BuildMetadata.java @@ -15,27 +15,31 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.service.cluster; +package org.apache.eventmesh.dashboard.console.spring.support.register; -import org.apache.eventmesh.dashboard.console.entity.cluster.InstanceUserEntity; +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.common.port.PortValidate; +import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; import java.util.List; /** - * InstanceUser data service + * */ -public interface InstanceUserService { +public interface BuildMetadata { + + + boolean isMeta(); + - void insert(InstanceUserEntity instanceuserEntity); + PortValidate portValidate(); - void deleteInstanceUserByCluster(InstanceUserEntity instanceuserEntity); - void updatePasswordById(InstanceUserEntity instanceuserentity); + List runtimeTypes(); - List selectAll(); + void buildMetaAddress(ScriptBuildData data, RuntimeEntity target, List runtimeMetadataList); - InstanceUserEntity selectById(InstanceUserEntity instanceuserEntity); - List selectByName(InstanceUserEntity instanceuserEntity); + void buildConfig(ScriptBuildData data, RuntimeEntity target); } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/register/BuildMetadataManage.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/register/BuildMetadataManage.java new file mode 100644 index 00000000..366edbd5 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/register/BuildMetadataManage.java @@ -0,0 +1,81 @@ +/* + * 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.spring.support.register; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.common.port.PortValidate; +import org.apache.eventmesh.dashboard.common.util.ClasspathScanner; +import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +public class BuildMetadataManage { + + private final Map buildMetadataMap = new HashMap<>(); + + { + Set> interfaceSet = new HashSet<>(); + interfaceSet.add(BuildMetadata.class); + ClasspathScanner classpathScanner = + ClasspathScanner.builder().base(BuildMetadata.class).subPath("/**").interfaceSet(interfaceSet).build(); + try { + List> classList = classpathScanner.getClazz(); + classList.forEach(this::register); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + private void register(Class clazz) { + try { + BuildMetadata buildMetadata = (BuildMetadata) clazz.getConstructor().newInstance(); + buildMetadata.runtimeTypes().forEach(clusterType -> { + buildMetadataMap.put(clusterType, buildMetadata); + }); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + public BuildMetadata getBuildMetaAddress(ClusterType clusterType) { + BuildMetadata buildMetadata = this.buildMetadataMap.get(clusterType); + if (Objects.isNull(buildMetadata)) { + buildMetadata = this.buildMetadataMap.get(clusterType.getAssemblyBusiness()); + } + return buildMetadata; + } + + + public void buildMetaAddress(ScriptBuildData data, RuntimeEntity target, List runtimeMetadataList) { + this.getBuildMetaAddress(target.getClusterType()).buildMetaAddress(data, target, runtimeMetadataList); + } + + public void buildConfig(ScriptBuildData data, RuntimeEntity target) { + this.getBuildMetaAddress(target.getClusterType()).buildConfig(data, target); + } + + public PortValidate getPortValidate(RuntimeEntity target) { + return this.getBuildMetaAddress(target.getClusterType()).portValidate(); + } + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/register/ScriptBuildData.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/register/ScriptBuildData.java new file mode 100644 index 00000000..207c481a --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/register/ScriptBuildData.java @@ -0,0 +1,58 @@ +/* + * 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.spring.support.register; + +import org.apache.eventmesh.dashboard.console.entity.cases.ResourcesConfigEntity; +import org.apache.eventmesh.dashboard.console.entity.function.ConfigEntity; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; + +import lombok.Data; + +@Data +public class ScriptBuildData { + + private Map data = new HashMap(); + + + private List configEntityList = new ArrayList(); + + public void put(String key, Object value) { + data.put(key, value); + } + + public void setResourcesConfigEntity(ResourcesConfigEntity resourcesConfigEntity) { + JSONObject jsonObject = (JSONObject) JSON.toJSON(resourcesConfigEntity); + this.data.putAll(jsonObject); + } + + public void setConfigEntityList(List configEntityList) { + this.configEntityList.addAll(configEntityList); + } + + public void setConfigEntity(ConfigEntity configEntity) { + this.configEntityList.add(configEntity); + } + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/register/meta/AbstractMetaBuildMetadata.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/register/meta/AbstractMetaBuildMetadata.java new file mode 100644 index 00000000..c200a360 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/register/meta/AbstractMetaBuildMetadata.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.spring.support.register.meta; + +import org.apache.eventmesh.dashboard.console.spring.support.register.AbstractBuildMetadata; + +/** + * + */ +public abstract class AbstractMetaBuildMetadata extends AbstractBuildMetadata { + + + @Override + public boolean isMeta() { + return true; + } + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/register/meta/RocketNameServiceBuildMetadata.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/register/meta/RocketNameServiceBuildMetadata.java new file mode 100644 index 00000000..0bb964c7 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/register/meta/RocketNameServiceBuildMetadata.java @@ -0,0 +1,64 @@ +/* + * 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.spring.support.register.meta; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.common.port.AbstractPortValidate; +import org.apache.eventmesh.dashboard.common.port.PortRule; +import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; +import org.apache.eventmesh.dashboard.console.spring.support.register.ScriptBuildData; + +import java.util.List; + +public class RocketNameServiceBuildMetadata extends AbstractMetaBuildMetadata { + + + { + this.setPortValidate(new RocketMQNamePortValidate()); + } + + @Override + public List runtimeTypes() { + return List.of(ClusterType.STORAGE_ROCKETMQ_NAMESERVER); + } + + + @Override + public void buildMetaAddress(ScriptBuildData data, RuntimeEntity target, List runtimeMetadataList) { + + } + + @Override + public void buildConfig(ScriptBuildData data, RuntimeEntity target) { + + } + + + static class RocketMQNamePortValidate extends AbstractPortValidate { + + { + PortRule portRule = PortRule.builder().valid(false).build(); + this.setPortRules(portRule); + } + + @Override + public boolean validate(PortRule lastPortRule, Integer lastPort, PortRule current, Integer port, List portRules) { + return true; + } + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/register/meta/ZookeeperBuildMetadata.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/register/meta/ZookeeperBuildMetadata.java new file mode 100644 index 00000000..093e5706 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/register/meta/ZookeeperBuildMetadata.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.eventmesh.dashboard.console.spring.support.register.meta; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.common.port.PortValidate; +import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; +import org.apache.eventmesh.dashboard.console.spring.support.register.ScriptBuildData; + +import java.util.List; + +public class ZookeeperBuildMetadata extends AbstractMetaBuildMetadata { + + + @Override + public PortValidate portValidate() { + return null; + } + + @Override + public List runtimeTypes() { + return List.of(ClusterType.META_TYPE_ZK); + } + + + @Override + public void buildMetaAddress(ScriptBuildData data, RuntimeEntity target, List runtimeMetadataList) { + + } + + @Override + public void buildConfig(ScriptBuildData data, RuntimeEntity target) { + + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/register/runtime/AbstractRuntimeBuildMetadata.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/register/runtime/AbstractRuntimeBuildMetadata.java new file mode 100644 index 00000000..68abe5d8 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/register/runtime/AbstractRuntimeBuildMetadata.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.spring.support.register.runtime; + +import org.apache.eventmesh.dashboard.console.spring.support.register.AbstractBuildMetadata; + +/** + * + */ +public abstract class AbstractRuntimeBuildMetadata extends AbstractBuildMetadata { + + @Override + public boolean isMeta() { + return false; + } + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/register/runtime/EventMethRuntimeBuildMetadata.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/register/runtime/EventMethRuntimeBuildMetadata.java new file mode 100644 index 00000000..1b3aaefc --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/register/runtime/EventMethRuntimeBuildMetadata.java @@ -0,0 +1,78 @@ +/* + * 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.spring.support.register.runtime; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.common.port.AbstractPortValidate; +import org.apache.eventmesh.dashboard.common.port.PortRule; +import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; +import org.apache.eventmesh.dashboard.console.spring.support.register.ScriptBuildData; + +import java.util.List; +import java.util.Objects; + +public class EventMethRuntimeBuildMetadata extends AbstractRuntimeBuildMetadata { + + { + EventmeshPortValidate runTimeValidate = new EventmeshPortValidate(); + setPortValidate(runTimeValidate); + } + + @Override + public List runtimeTypes() { + return List.of(ClusterType.EVENTMESH_RUNTIME); + } + + + @Override + public void buildMetaAddress(ScriptBuildData data, RuntimeEntity target, List runtimeMetadataList) { + ClusterType clusterType = runtimeMetadataList.get(0).getClusterType(); + if (clusterType.isEventMethMeta()) { + StringBuffer nameService = new StringBuffer(); + runtimeMetadataList.forEach(runtimeMetadata -> { + if (Objects.equals(target.getKubernetesClusterId(), runtimeMetadata.getKubernetesClusterId())) { + nameService.append(runtimeMetadata.getHost()).append(":").append(runtimeMetadata.getPort()).append(";"); + } else { + nameService.append(runtimeMetadata.getHost()).append(":").append(runtimeMetadata.getPort()).append(";"); + } + }); + data.put("metaService", nameService.toString()); + } + if (clusterType.isStorageMeta()) { + // + } + } + + @Override + public void buildConfig(ScriptBuildData data, RuntimeEntity target) { + this.generatePropertiesConfig(data); + } + + static class EventmeshPortValidate extends AbstractPortValidate { + + + { + this.createNotValid(List.of("tcpPort", "httpPort", "grpcPort", "adminPort")); + } + + @Override + public boolean validate(PortRule lastPortRule, Integer lastPort, PortRule current, Integer port, List portRules) { + return true; + } + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/register/runtime/RocketMQBuildMetadata.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/register/runtime/RocketMQBuildMetadata.java new file mode 100644 index 00000000..e9bd7292 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/register/runtime/RocketMQBuildMetadata.java @@ -0,0 +1,73 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.eventmesh.dashboard.console.spring.support.register.runtime; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.common.port.AbstractPortValidate; +import org.apache.eventmesh.dashboard.common.port.PortRule; +import org.apache.eventmesh.dashboard.common.port.PortValidate; +import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; +import org.apache.eventmesh.dashboard.console.spring.support.register.ScriptBuildData; + +import java.util.List; +import java.util.Objects; + +public class RocketMQBuildMetadata extends AbstractRuntimeBuildMetadata { + + { + PortValidate portValidate = new RocketMQBrokerPortValidate(); + this.setPortValidate(portValidate); + } + + @Override + public List runtimeTypes() { + return List.of(ClusterType.STORAGE_ROCKETMQ_BROKER_MAIN_SLAVE, ClusterType.STORAGE_ROCKETMQ_BROKER_RAFT); + } + + + @Override + public void buildMetaAddress(ScriptBuildData data, RuntimeEntity target, List runtimeMetadataList) { + this.standardRuntime(data, target, runtimeMetadataList); + } + + @Override + public void buildConfig(ScriptBuildData data, RuntimeEntity target) { + + } + + static class RocketMQBrokerPortValidate extends AbstractPortValidate { + + + { + PortRule portRule = PortRule.builder().valid(true).index(1).name("fastPort").build(); + this.setPortRules(portRule); + portRule = PortRule.builder().valid(true).index(2).name("nullPort").spanValue(1).build(); + this.setPortRules(portRule); + portRule = PortRule.builder().valid(true).index(3).name("port").spanValue(1).build(); + this.setPortRules(portRule); + } + + @Override + public boolean validate(PortRule lastPortRule, Integer lastPort, PortRule current, Integer port, List portRules) { + if (Objects.equals(lastPortRule.getIndex(), 1)) { + return true; + } + return true; + } + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/utils/RuntimeUtils.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/utils/RuntimeUtils.java new file mode 100644 index 00000000..87ea33eb --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/utils/RuntimeUtils.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.utils; + +import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class RuntimeUtils { + + + public Map> groupByClusterId(List runtimeEntityList) { + Map> runtimeEntityMap = new HashMap>(); + runtimeEntityList.forEach(entity -> { + runtimeEntityMap.computeIfAbsent(entity.getClusterId(), k -> new ArrayList<>()).add(entity); + }); + return runtimeEntityMap; + } + +} diff --git a/eventmesh-dashboard-console/src/main/resources/RENAME.md b/eventmesh-dashboard-console/src/main/resources/RENAME.md new file mode 100644 index 00000000..fe5c9b44 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/resources/RENAME.md @@ -0,0 +1,38 @@ + +无法进行确认,支持同类型修改 + +1. 用户进来,是进入默认组织 首页 +2. 通过左上角切换 +3. 组织视图与 cluster 共存,这样是否会出现三级路由 +4. 人员添加,可以从组织添加,也可以从 cluster 里面添加。如果从 cluster 里面添加,是否就属于合格组织一员? +5. 资源维度,是否是cluster 的 + +6. 删除 topic 之后,同时需要作废对应的 订阅吗? +7. 删除 group 之后,同时需要作废对应的 订阅吗? +8. 删除 cluster 或则 runtime 之后对应的信息是否全部作废。 +9. 暂停状态数据如何标记,激活 对应的 metadata 之前相关的数据是否启动 +10. 删除 cluster 之前之后校验 关联。如何关联存在是否允许删除 +11. kafka 的查询维度全是 cluster +12. RocketMQ 大集群查询,是否支持 metadata 数据查询,如何对数据进行展示? 是否现实差异化,是否提示差异字段 + 1. 那些 topic 有差异? + 2. 是否配置 不允许有差异? + 3. 如果不允许有差异, console 进行处理的 metadata 是否要进行具体标识 +14. RocketMQ 支持大集群,小集群,runtime 维度的展示 + + +项目发起人,项目架构师,项目设计师,项目经理, +交互设计师,半个ui设计 +前端,后台,运维,产品,测试, + + +## 用户域 +### 用户首页 +1. 查看 组织 + +### 组织首页 +1. 左边是一级菜单: + 1. 工作台 + 2. eventmesh集群 + 3. +1. 集群信息 + 2. 集群列表 \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/main/resources/application-dev.yml b/eventmesh-dashboard-console/src/main/resources/application-dev.yml index 6ebdf9c9..b5f7118c 100644 --- a/eventmesh-dashboard-console/src/main/resources/application-dev.yml +++ b/eventmesh-dashboard-console/src/main/resources/application-dev.yml @@ -17,6 +17,8 @@ server: port: 9898 + servlet: + context-path: "/eventmesh/dashboard" spring: servlet: @@ -32,7 +34,7 @@ spring: driver-class-name: com.mysql.cj.jdbc.Driver url: jdbc:mysql://${DB_ADDRESS:localhost:3306}/eventmesh_dashboard?useSSL=false&useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&zeroDateTimeBehavior=convertToNull&allowPublicKeyRetrieval=true username: ${DB_USERNAME:root} - password: ${DB_PASSWORD:password} + password: ${DB_PASSWORD:Ab123123@} initial-size: 1 max-active: 50 @@ -62,17 +64,4 @@ decoration: function: - healthCheck: - doCheck: - initialDelay: 60 - period: 60 - updateConfig: - initialDelay: 30 - period: 60 - sync: - enable: true - initialDelay: 120 - period: 60 - toDb: - runtime: true - + enabled: false diff --git a/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.jmx b/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.jmx new file mode 100644 index 00000000..57f546b4 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.jmx @@ -0,0 +1,253 @@ + + + + + + false + true + false + + + + + + + + continue + + false + 1 + + 1 + 1 + false + + + + + + + + host + 127.0.0.1 + = + + + port + 9898 + = + + + path + /eventmesh/dashboard/ + = + + + + + + + + content-type + application/json + + + queryClause + {"limitPageNum":1,limitSize:10} + + + + + + + + true + + + + false + { + "clusterId":1 +} + = + + + + ${host} + ${port} + + + ${path}/runtime/queryRuntimeListByClusterId + POST + true + false + true + false + + + + + + + true + + + + false + { + "id":1 +} + = + + + + ${host} + ${port} + + + ${path}/runtime/queryRuntimeListByClusterId + POST + true + false + true + false + + + + + + + + + + true + + + + false + { + "clusterId":1, + "clusterType": "EVENTMESH_CLUSTER" +} + = + + + + ${host} + ${port} + + + ${path}/user/cluster/createEventMeshClusterByOnlyData + POST + true + false + true + false + + + + + + + true + + + + false + { + "clusterId":1, + "clusterType": "EVENTMESH_CLUSTER" +} + = + + + + ${host} + ${port} + + + ${path}/user/cluster/queryClusterByOrganizationIdAndType + POST + true + false + true + false + + + + + + + + + + true + + + + false + { + "name": "test", + "description": "111" +} + = + + + + ${host} + ${port} + + + ${path}/organization/clusterCycleDeploy/createEventMeshClusterByOnlyData + POST + true + false + true + false + + + + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + true + true + true + + + + + + + + + diff --git a/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql b/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql index 50056d01..9cb612fa 100644 --- a/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql +++ b/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql @@ -1,35 +1,90 @@ /* - * licensed to the apache software foundation (asf) under one or more - * contributor license agreements. see the notice file distributed with + * 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 + * 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 + * 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. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ + + +drop table if exists `case`; + +create table `case` +( + id bigint unsigned primary key auto_increment comment 'id', + organization_id bigint unsigned not null comment '组织id', + name varchar(128) not null comment '案例名', + case_type varchar(16) not null comment '案例类型', + object_type varchar(16) not null comment '对象类型', + object_id varchar(32) not null comment '', + status int not null default 1 comment '', + create_time timestamp not null default current_timestamp comment '接入时间', + update_time timestamp not null default current_timestamp on update current_timestamp comment '修改时间', + is_delete int not null default 0 comment '数据逻辑标记', + key object_type_id (object_type, object_id) +) comment =''; + +drop table if exists `resources_config`; + +create table `resources_config` +( + id bigint unsigned primary key auto_increment comment 'id', + organization_id bigint unsigned not null comment '组织id', + name varchar(128) not null comment '案例名', + object_type varchar(16) not null comment '对象类型', + object_id varchar(32) not null comment '', + cpu_num int not null comment '', + men_num int not null comment '', + disk_num int not null comment '', + gpu_num int not null comment '', + status int not null default 1 comment '', + create_time timestamp not null default current_timestamp comment '接入时间', + update_time timestamp not null default current_timestamp on update current_timestamp comment '修改时间', + is_delete int not null default 0 comment '数据逻辑标记', + key object_type_id (object_type, object_id) +) comment ='资源配置表'; + drop table if exists `cluster`; create table cluster ( - id bigint unsigned primary key auto_increment comment '集群id', - name varchar(128) not null comment '集群名称', - cluster_type varchar(16) not null comment '集群类型', - trusteeship_type varchar(16) not null comment '托管类型', - version varchar(32) not null comment 'eventmesh版本', - jmx_properties text comment 'jmx配置', - description text comment '备注', - auth_type int not null default 0 comment '认证类型,-1未知,0:无认证,', - run_state tinyint not null default 1 comment '运行状态, 0表示未监控, 1监控中,有注册中心,2:监控中,无注册中心', - status int not null default 1 comment '0', - create_time timestamp not null default current_timestamp comment '接入时间', - update_time timestamp not null default current_timestamp on update current_timestamp comment '修改时间', - is_delete int not null default 0 comment '数据逻辑标记', + id bigint unsigned primary key auto_increment comment '集群id', + organization_id bigint unsigned not null comment '组织id', + cluster_type varchar(64) not null comment '集群类型', + name varchar(128) not null comment '集群名称', + version varchar(32) not null comment 'eventmesh版本', + cluster_index int not null default 0 comment '在 集群里面的索引', + jmx_properties varchar(256) not null default '' comment 'jmx配置', + trusteeship_type varchar(32) not null comment '托管类型', + cluster_own_type varchar(32) not null comment '共享类型', + runtime_index int not null default 0 comment 'runtime索引值', + first_to_whom varchar(16) not null comment '第一次同步模式', + first_sync_state varchar(16) not null default 'NOT' comment '第一次同步结果', + replication_type varchar(16) not null comment '复制模式', + sync_error_type varchar(16) not null default 'NOT' comment '同步数据异常标识字段', + deploy_status_type varchar(16) not null comment '部署进行中状态', + resources_config_id varchar(16) not null comment '默认部署配置', + deploy_script_id bigint unsigned not null comment '默认部署脚本id', + deploy_script_name varchar(16) not null default '' comment '脚本名字', + deploy_script_version varchar(16) not null default '' comment '脚本版本', + config varchar(8192) not null comment '集群配置', + description text comment '备注', + auth_type varchar(32) not null default 0 comment '认证类型,-1未知,0:无认证,', + run_state tinyint not null default 1 comment '运行状态, 0表示未监控, 1监控中,有注册中心,2:监控中,无注册中心', + online_timestamp datetime not null default current_timestamp comment '上线时间', + offline_timestamp datetime not null default current_timestamp comment '下线时间', + status int not null default 1 comment '0', + create_time timestamp not null default current_timestamp comment '接入时间', + update_time timestamp not null default current_timestamp on update current_timestamp comment '修改时间', + is_delete int not null default 0 comment '数据逻辑标记', unique key uniq_name (name) ) comment '物理集群信息表'; @@ -38,14 +93,15 @@ drop table if exists `cluster_relationship`; create table `cluster_relationship` ( id bigint unsigned primary key auto_increment, - cluster_type varchar(16) not null comment '集群类型', - cluster_id bigint not null comment '集群id', - relationship_type varchar(16) not null comment '集群类型', - relationship_id bigint not null comment '集群id', - create_time timestamp not null default current_timestamp comment '创建时间', - update_time timestamp not null default current_timestamp on update current_timestamp comment '修改时间', - status int not null default 1 comment '0', - is_delete int not null default 0 comment '0', + organization_id bigint unsigned not null comment '组织id', + cluster_type varchar(63) not null comment '主集群类型', + cluster_id bigint not null comment '主集群id', + relationship_type varchar(63) not null comment '关联集群类型', + relationship_id bigint not null comment '关联集群id', + create_time timestamp not null default current_timestamp comment '创建时间', + update_time timestamp not null default current_timestamp on update current_timestamp comment '修改时间', + status int not null default 1 comment '0', + is_delete int not null default 0 comment '0', unique key cluster_id_relationship_id_unique (`cluster_id`, `relationship_id`), key cluster_id_key (`cluster_id`), key relationship_id_key (`relationship_id`) @@ -54,43 +110,65 @@ create table `cluster_relationship` drop table if exists `config`; create table config ( - id bigint unsigned auto_increment primary key, - cluster_id bigint not null comment '集群id', - instance_type tinyint not null comment '实例类型 0:runtime,1:storage,2:connector,3:topic', - instance_id bigint not null default -1 comment '实例id,上面配置对应的(比如runtime)的id,如果是-1,是cluster的配置', - config_type varchar(31) not null default '' comment '配置类型', - config_name varchar(192) not null comment '配置名称', - config_value text not null comment '配置值', - start_version varchar(64) not null default '' comment '配置开始使用的版本', - end_version varchar(64) not null default '' comment '配置结束使用的版本', - status int not null default 1 comment '0 关闭 1 开启 ', - is_default int not null default 1, - diff_type int not null default -1 comment '差异类型', - description varchar(1000) not null default '' comment '备注', - edit int not null default 1 comment '是否可以编辑 1 不可编辑(程序获取) 2 可编辑', - create_time timestamp not null default current_timestamp comment '创建时间', - update_time timestamp not null default current_timestamp on update current_timestamp comment '修改时间', - is_modify int not null default 0, - already_update int not null default 0 comment '0:no,1:yes', - is_delete int not null default 0 comment '0', + id bigint unsigned auto_increment primary key, + organization_id bigint unsigned not null comment '组织id', + cluster_id bigint not null comment '集群id', + instance_type tinyint not null comment '实例类型 0:runtime,1:storage,2:connector,3:topic', + instance_id bigint not null default -1 comment '实例id,上面配置对应的(比如runtime)的id,如果是-1,是cluster的配置', + config_type varchar(31) not null default '' comment '配置类型', + config_name varchar(192) not null comment '配置名称', + config_value text not null comment '配置值', + start_version varchar(64) not null default '' comment '配置开始使用的版本', + end_version varchar(64) not null default '' comment '配置结束使用的版本', + status int not null default 1 comment '0 关闭 1 开启 ', + is_default int not null default 1, + diff_type int not null default -1 comment '差异类型', + description varchar(1000) not null default '' comment '备注', + edit int not null default 1 comment '是否可以编辑 1 不可编辑(程序获取) 2 可编辑', + create_time timestamp not null default current_timestamp comment '创建时间', + update_time timestamp not null default current_timestamp on update current_timestamp comment '修改时间', + is_modify int not null default 0 comment '是否修改元版本数据', + already_update int not null default 0 comment '0:no,1:yes', + is_delete int not null default 0 comment '0', unique key uniq_cluster_id_instance_type_instance_id_config_name (instance_id, config_name, instance_type, cluster_id) ) comment '配置信息表'; +drop table if exists `topic`; +create table `topic` +( + `id` bigint unsigned primary key auto_increment comment 'id', + `cluster_id` bigint not null default '-1' comment '集群id', + runtime_id bigint unsigned not null default 0 comment 'kafka 没有runtime', + `topic_name` varchar(192) not null default '' comment 'topic名称', + topic_type varchar(16) not null default '' comment 'topic 类型。用户,broker,console,console', + read_queue_num int not null default 8 comment '读队列数量', + write_queue_num int not null default 8 comment '写队列数量', + replication_factor int not null default 0 comment '副本数量', + `order` int not null default 0 comment '是否是定时队列', + `status` int not null default 1, + `create_progress` int not null default 1 comment '0:创建成功,1:创建中,2:创建失败', + `retention_ms` bigint not null default '-2' comment '保存时间,-2:未知,-1:无限制,>=0对应时间,单位ms', + `description` varchar(1024) default '' comment '备注信息', + `create_time` timestamp not null default current_timestamp comment '创建时间(尽量与topic实际创建时间一致)', + `update_time` timestamp not null default current_timestamp on update current_timestamp comment '修改时间(尽量与topic实际创建时间一致)', + `is_delete` int not null default '0', + unique key `uniq_cluster_phy_id_topic_name` (`cluster_id`, `topic_name`) +) comment ='topic信息表'; drop table if exists `group`; create table `group` ( - id bigint unsigned primary key auto_increment comment 'id', - cluster_id bigint not null comment '集群id', - name varchar(192) not null comment 'group名称', - member_count int unsigned not null default '0' comment '成员数', - members text null comment 'group的member列表', - type tinyint not null comment 'group类型 0:consumer 1:producer', - state varchar(64) not null default '' comment '状态', - create_time timestamp not null default current_timestamp comment '创建时间', - update_time timestamp not null default current_timestamp on update current_timestamp comment '修改时间', - status int not null default 1, - is_delete int not null default 0 comment '0', + id bigint unsigned primary key auto_increment comment 'id', + organization_id bigint unsigned not null comment '组织id', + cluster_id bigint not null comment '集群id', + name varchar(192) not null comment 'group名称', + type tinyint not null comment 'group类型 0:consumer 1:producer', + own_type varchar(16) not null default '' comment 'topic 类型。用户,broker,console,console', + state varchar(64) not null default '' comment '状态', + create_time timestamp not null default current_timestamp comment '创建时间', + update_time timestamp not null default current_timestamp on update current_timestamp comment '修改时间', + status int not null default 1, + is_delete int not null default 0 comment '0', unique key uniq_cluster_phy_id_name (cluster_id, name) ) comment 'group信息表'; @@ -98,16 +176,17 @@ create table `group` drop table if exists group_member; create table group_member ( - id bigint unsigned primary key auto_increment comment 'id', - cluster_id bigint default -1 not null comment '集群id', - topic_name varchar(192) default '' not null comment 'topic名称', - group_name varchar(192) default '' not null comment 'group名称', - eventmesh_user varchar(192) default '' not null comment 'eventmesh用户', - state varchar(64) default '' not null comment '状态', - create_time timestamp default current_timestamp not null comment '创建时间', - update_time timestamp default current_timestamp on update current_timestamp not null comment '修改时间', - status int default 1 not null, - is_delete int not null default 0 comment '0', + id bigint unsigned primary key auto_increment comment 'id', + organization_id bigint unsigned not null comment '组织id', + cluster_id bigint not null default -1 comment '集群id', + topic_name varchar(192) not null default '' comment 'topic名称', + group_name varchar(192) not null default '' comment 'group名称', + eventmesh_user varchar(192) not null default '' comment 'eventmesh用户', + state varchar(64) not null default '' comment '状态', + create_time timestamp not null default current_timestamp comment '创建时间', + update_time timestamp not null default current_timestamp on update current_timestamp comment '修改时间', + status int not null default 1, + is_delete int not null default 0 comment '0', unique key uniq_cluster_topic_group (cluster_id, topic_name, group_name) ) comment 'groupmember信息表'; @@ -115,20 +194,39 @@ create table group_member drop table if exists runtime; create table runtime ( - id bigint primary key auto_increment comment 'id', - cluster_id bigint not null comment '物理集群id', - `name` varchar(128) not null comment 'runtime名称', - host varchar(128) not null comment 'runtime主机名', - port varchar(128) not null comment 'runtime端口', - jmx_port int not null default -1 comment 'jmx端口', - start_timestamp timestamp not null default current_timestamp comment '启动时间', - rack varchar(128) not null default '' comment 'rack信息', - status int not null default 1 comment '状态: 1启用,0未启用', - create_time timestamp not null default current_timestamp comment '创建时间', - update_time timestamp not null default current_timestamp on update current_timestamp comment '修改时间', - endpoint_map varchar(1024) not null default '' comment '监听信息', - is_delete int not null default 0 comment '0', - unique key uniq_cluster_phy_id__host_port (cluster_id, host) + id bigint primary key auto_increment comment 'id', + organization_id bigint unsigned not null comment '组织id', + cluster_id bigint not null default -1 comment '集群id', + cluster_type varchar(63) not null comment '集群类型', + `name` varchar(128) not null comment '节点名字', + host int not null comment 'runtime 对外的 IP,kubernetes这个ip 有问题', + port int not null comment 'runtime port', + runtime_index int not null default -1 comment 'runtime 在 cluster 里面的索引', + version varchar(32) not null comment 'runtime版本', + jmx_port varchar(256) not null default '' comment 'jmx配置', + trusteeship_type varchar(16) not null comment '托管类型', + first_to_whom varchar(16) not null comment '第一次同步模式', + first_sync_state varchar(16) not null default 'NOT' comment '第一次同步结果', + replication_type varchar(16) not null comment '节点在集群的复制类型', + sync_error_type varchar(16) not null default 'NOT' comment '同步数据异常标识字段', + deploy_status_type varchar(16) not null comment '部署进行中状态', + kubernetes_cluster_id bigint unique not null default 0 comment 'kubernetes cluster id', + create_script_content text not null comment ' kubernetes 创建时的内容', + resources_config_id varchar(16) not null comment '默认部署配置', + deploy_script_id bigint unsigned not null comment '默认部署脚本id', + deploy_script_name varchar(16) not null default '' comment '脚本名字', + deploy_script_version varchar(16) not null default '' comment '脚本版本', + auth_type varchar(16) not null default '' comment '认真类型', + description text comment '备注', + rack varchar(128) not null default '' comment '哪个机架信息', + status int not null default 1 comment '状态: 1启用,0未启用', + online_timestamp datetime not null default current_timestamp comment '上线时间', + offline_timestamp datetime not null default current_timestamp comment '下线时间', + create_time timestamp not null default current_timestamp comment '创建时间', + update_time timestamp not null default current_timestamp on update current_timestamp comment '修改时间', + endpoint_map varchar(1024) not null default '' comment '监听信息', + is_delete int not null default 0 comment '0', + unique key uniq_cluster_phy_id_host_port (cluster_id, host) ) comment 'runtime信息表'; drop table if exists `client`; @@ -213,42 +311,6 @@ create table `acl` -drop table if exists `group`; -create table `group` -( - `id` bigint unsigned primary key auto_increment comment 'id', - `cluster_id` bigint not null default '-1' comment '集群id', - `name` varchar(192) not null default '' comment 'group名称', - `member_count` int unsigned not null default '0' comment '成员数', - `members` varchar(1024) not null default '' comment 'group的member列表', - `type` tinyint not null comment 'group类型 0:consumer 1:producer', - `state` varchar(64) not null default '' comment '状态', - `create_time` timestamp not null default current_timestamp comment '创建时间', - `update_time` timestamp not null default current_timestamp on update current_timestamp comment '修改时间', - `status` int not null default 1, - unique key `uniq_cluster_phy_id_name` (`cluster_id`, `name`), - key `cluster_id` (`cluster_id`, `name`) -) comment ='group信息表'; - - -drop table if exists `group_member`; -create table `group_member` -( - `id` bigint unsigned primary key auto_increment comment 'id', - `cluster_id` bigint not null default '-1' comment '集群id', - `client_id` bigint unsigned not null comment '客服端id', - `topic_name` varchar(192) not null default '' comment 'topic名称', - `group_name` varchar(192) not null default '' comment 'group名称', - `eventmesh_user` varchar(192) not null default '' comment 'eventmesh用户', - `state` varchar(64) not null default '' comment '状态', - `create_time` timestamp not null default current_timestamp comment '创建时间', - `update_time` timestamp not null default current_timestamp on update current_timestamp comment '修改时间', - `status` int not null default 1, - unique key `uniq_cluster_topic_group` (`cluster_id`, `topic_name`, `group_name`), - key `cluster_id` (`cluster_id`, `topic_name`, `group_name`) -) comment ='groupmember信息表'; - - drop table if exists `operation_log`; create table `operation_log` ( @@ -267,24 +329,6 @@ create table `operation_log` ) comment ='操作记录信息表'; -drop table if exists `topic`; -create table `topic` -( - `id` bigint unsigned primary key auto_increment comment 'id', - `cluster_id` bigint not null default '-1' comment '集群id', - `topic_name` varchar(192) not null default '' comment 'topic名称', - `status` int not null default 1, - `create_progress` int not null default 1 comment '0:创建成功,1:创建中,2:创建失败', - `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 on update current_timestamp comment '修改时间(尽量与topic实际创建时间一致)', - `is_delete` int not null default '0', - unique key `uniq_cluster_phy_id_topic_name` (`cluster_id`, `topic_name`) -) comment ='topic信息表'; - - drop table if exists `connector`; create table `connector` @@ -323,7 +367,19 @@ create table `health_check_result` +drop table if exists `port`; +create table `port` +( + `id` bigint unsigned primary key auto_increment comment '自增id', + `cluster_id` bigint not null default '0' comment '集群id', + `current_port` int not null default 0 comment '当前 port value', + `status` int default 1 not null comment '状态: 1启用,0未启用', + `create_time` timestamp not null default current_timestamp comment '创建时间', + `update_time` timestamp not null default current_timestamp on update current_timestamp comment '修改时间', + is_delete int not null default 0 comment '0', + unique key unique_cluster_id (cluster_id) +); diff --git a/eventmesh-dashboard-console/src/main/resources/logback.xml b/eventmesh-dashboard-console/src/main/resources/logback.xml index ae23589f..4c874927 100644 --- a/eventmesh-dashboard-console/src/main/resources/logback.xml +++ b/eventmesh-dashboard-console/src/main/resources/logback.xml @@ -1,19 +1,10 @@ @@ -36,7 +27,7 @@ UTF-8 - + diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/EventMeshDashboardApplicationTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/EventMeshDashboardApplicationTest.java index a2f3ac4d..59ead5bf 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/EventMeshDashboardApplicationTest.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/EventMeshDashboardApplicationTest.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console; import java.util.Objects; diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/databuild/BuildFullMetadata.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/databuild/BuildFullMetadata.java new file mode 100644 index 00000000..f6594967 --- /dev/null +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/databuild/BuildFullMetadata.java @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.eventmesh.dashboard.console.databuild; + +import org.apache.eventmesh.dashboard.common.enums.ClusterOwnType; +import org.apache.eventmesh.dashboard.common.enums.ClusterTrusteeshipType; +import org.apache.eventmesh.dashboard.common.enums.ClusterTrusteeshipType.FirstToWhom; +import org.apache.eventmesh.dashboard.common.enums.ClusterType; + +import java.util.Set; + +import lombok.Builder; +import lombok.Data; + +@Data +@Builder +public class BuildFullMetadata { + + private boolean eventMeshEnabled; + + private Set clusterTypeSet; + + private Set metaTypeSet; + + private Set runtimeTypeSet; + + + private Set firstToWhomSet; + + private Set clusterTrusteeshipTypesSet; + + private Set clusterOwnTypesSet; + +} diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/databuild/BuildFullSceneData.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/databuild/BuildFullSceneData.java new file mode 100644 index 00000000..b6265c4d --- /dev/null +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/databuild/BuildFullSceneData.java @@ -0,0 +1,395 @@ +/* + * 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.databuild; + +import org.apache.eventmesh.dashboard.common.enums.ClusterOwnType; +import org.apache.eventmesh.dashboard.common.enums.ClusterTrusteeshipType; +import org.apache.eventmesh.dashboard.common.enums.ClusterTrusteeshipType.FirstToWhom; +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.common.enums.DeployStatusType; +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterRelationshipEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; +import org.apache.eventmesh.dashboard.console.mapper.cluster.ClusterEntityMapperTest; +import org.apache.eventmesh.dashboard.console.mapper.cluster.ClusterRelationshipMapperTest; +import org.apache.eventmesh.dashboard.console.mapper.cluster.RuntimeEntityMapperTest; + +import org.apache.commons.lang3.tuple.Pair; +import org.apache.commons.lang3.tuple.Triple; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.Set; +import java.util.concurrent.atomic.AtomicInteger; + +import lombok.Data; +import lombok.Getter; + +public class BuildFullSceneData { + + + private final List> tripleList = new ArrayList<>(); + + private final List/* meta */, List>> clusterTypeTripleList = new ArrayList<>(); + + + @Getter + private final List>> eventMeshRuntimeTripleList = new ArrayList<>(); + + @Getter + private final List/* meta */, List>> clusterTripleList = new ArrayList<>(); + + @Getter + private final List clusterEntityList = new ArrayList<>(); + + @Getter + private final List clusterRelationshipEntityList = new ArrayList<>(); + + + private final Map runtimeEntityMap = new HashMap<>(); + + + private ShareMetadata runtimeShareMetadata = new ShareMetadata(); + + private ShareMetadata mateShareMetadata = new ShareMetadata(); + + + @Getter + private BuildFullMetadata buildFullMetadata; + + + private ClusterEntity createClusterEntity(ClusterType clusterType) { + ClusterEntity clusterEntity = ClusterEntityMapperTest.createClusterEntity(); + clusterEntity.setClusterType(clusterType); + this.clusterEntityList.add(clusterEntity); + return clusterEntity; + } + + /** + * 构建思路 + *

+ * 维度 + *

    + *
  1. 所有集群
  2. + *
  3. eventmesh 下 所有不同类型 storage
  4. + *
  5. cluster 集群下 所有不同类型 meta
  6. + *
  7. cluster 集群下 所有不同类型 runtime
  8. + *
  9. ClusterTrusteeshipType 所有状态
  10. + *
  11. FirstToWhom 所有状态
  12. + *
  13. ClusterOwnType 状态
  14. + *
+ *

+ *

+ * TODO 如何构建 , RocketMQ 三个结构 + */ + public void build() { + this.buildBase(); + this.buildReplica(); + this.association(); + } + + public void association() { + tripleList.forEach(this::buildCluster); + // 写入数据库 + + //this.createClusterRelationshipEntity(); + // 写入数据库 + + //this.clusterEntityList.forEach(this::createRuntimeEntity); + // 写入数据库 + + } + + public List, List>> getClusterTripleList(ClusterType clusterType) { + List, List>> tripleList = new ArrayList<>(); + this.clusterTripleList.forEach(tripleList1 -> { + if (tripleList1.getLeft().getClusterType() == clusterType) { + tripleList.add(tripleList1); + } + }); + return tripleList; + } + + public void buildBase() { + buildFullMetadata.getClusterTrusteeshipTypesSet().forEach(clusterTrusteeshipType -> { + buildFullMetadata.getFirstToWhomSet().forEach(firstToWhom -> { + buildFullMetadata.getClusterOwnTypesSet().forEach(clusterOwnType -> { + Triple triple = + Triple.of(clusterTrusteeshipType, firstToWhom, clusterOwnType); + if (ClusterOwnType.SHARE == clusterOwnType) { + this.mateShareMetadata.shareNum++; + this.runtimeShareMetadata.shareNum++; + } + this.tripleList.add(triple); + }); + }); + }); + } + + + public void buildReplica() { + + this.buildFullMetadata.getClusterTypeSet().forEach(this::buildReplica); + + this.buildShare(this.buildFullMetadata.getRuntimeTypeSet(), this.runtimeShareMetadata); + this.buildShare(this.buildFullMetadata.getMetaTypeSet(), this.mateShareMetadata); + + } + + private void buildCluster(Triple triple) { + clusterTypeTripleList.forEach(cluster -> { + ClusterType clusterType = cluster.getLeft(); + ClusterEntity clusterEntity = this.createClusterEntity(clusterType); + this.build(clusterEntity, triple); + clusterTripleList.add(Triple.of(clusterEntity, this.buildCluster(clusterType, cluster.getMiddle(), triple), + this.buildCluster(clusterType, cluster.getRight(), triple))); + }); + if (this.buildFullMetadata.isEventMeshEnabled()) { + List eventMeshEntities = new ArrayList<>(); + List clusterEntityList1 = new ArrayList<>(); + this.clusterTripleList.forEach(tripleList1 -> { + ClusterEntity clusterEntity = tripleList1.getLeft(); + if (clusterEntity.getClusterType() == ClusterType.EVENTMESH_CLUSTER) { + eventMeshEntities.add(clusterEntity); + } else { + clusterEntityList1.add(clusterEntity); + } + }); + int num = clusterEntityList1.size() % eventMeshEntities.size(); + for (int i = 0; i < eventMeshEntities.size(); i++) { + eventMeshRuntimeTripleList.add(Pair.of(eventMeshEntities.get(i), clusterEntityList1.subList(i * num, num))); + } + + } + } + + private List buildCluster(ClusterType clusterType, List clusterTypeList, + Triple triple) { + Set oneSet = Set.of(ClusterType.STORAGE_KAFKA_BROKER, ClusterType.STORAGE_KAFKA_ZK, ClusterType.STORAGE_KAFKA_RAFT); + List runtimeClusterEntity = new ArrayList<>(); + Random random = new Random(); + clusterTypeList.forEach(middle -> { + Map> shareMap = middle.isMeta() ? mateShareMetadata.getShareMap() : runtimeShareMetadata.getShareMap(); + int num = 1; + if (!oneSet.contains(middle)) { + if (middle.isMeta()) { + num = random.nextInt(3) + 1; + } else { + num = random.nextInt(5) + 2; + } + } + int shareNum = random.nextInt(num) + 1; + Set shareNumSet = new HashSet<>(); + for (int i = 0; i < num; i++) { + ClusterEntity runtime = null; + if (triple.getRight() == ClusterOwnType.SHARE && shareNum != 0) { + List clusterEntitieList = shareMap.get(middle); + for (; ; ) { + int randomNum = random.nextInt(clusterEntitieList.size()); + if (shareNumSet.contains(randomNum)) { + continue; + } + shareNumSet.add(randomNum); + runtime = clusterEntitieList.get(random.nextInt(clusterEntitieList.size())); + break; + } + } else { + runtime = this.createClusterEntity(middle); + } + runtimeClusterEntity.add(runtime); + + if (runtime != null) { + this.build(runtime, triple); + } + } + }); + return runtimeClusterEntity; + } + + private void build(ClusterEntity clusterEntity, Triple triple) { + clusterEntity.setTrusteeshipType(triple.getLeft()); + clusterEntity.setFirstToWhom(triple.getMiddle()); + clusterEntity.setClusterOwnType(triple.getRight()); + } + + + private void buildShare(Set clusterTypeList, ShareMetadata mateShareMetadata) { + Random random = new Random(); + clusterTypeList.forEach(clusterType -> { + AtomicInteger atomicInteger1 = new AtomicInteger(mateShareMetadata.getShareNum()); + for (; ; ) { + int num = random.nextInt(3) + 2; + if (num > atomicInteger1.get()) { + num = atomicInteger1.get(); + } + atomicInteger1.set(atomicInteger1.get() - num); + ClusterEntity clusterEntity = this.createClusterEntity(clusterType); + //clusterEntityList.add(clusterEntity); + clusterEntity.setClusterOwnType(ClusterOwnType.SHARE); + mateShareMetadata.getShareMap().computeIfAbsent(clusterType, (key) -> new ArrayList<>()).add(clusterEntity); + if (atomicInteger1.get() <= 0) { + return; + } + } + + }); + } + + + public void buildReplica(ClusterType type) { + List metaList = new ArrayList<>(); + for (ClusterType meta : type.getMetaClusterType()) { + metaList.add(meta); + List runtimeList = new ArrayList<>(); + for (ClusterType runtime : type.getRuntimeClusterType()) { + if (runtime.isDefinition()) { + for (ClusterType clusterType : runtime.getRuntimeClusterType()) { + runtimeList.add(clusterType); + clusterTypeTripleList.add(Triple.of(type, List.copyOf(metaList), List.of(clusterType))); + if (runtimeList.size() > 1) { + clusterTypeTripleList.add(Triple.of(type, List.copyOf(metaList), List.copyOf(runtimeList))); + } + } + } else { + runtimeList.add(runtime); + clusterTypeTripleList.add(Triple.of(type, List.copyOf(metaList), List.of(runtime))); + if (runtimeList.size() > 1) { + clusterTypeTripleList.add(Triple.of(type, List.copyOf(metaList), List.copyOf(runtimeList))); + } + } + } + } + } + + + public List createRuntimeEntity() { + this.clusterEntityList.forEach(this::createRuntimeEntity); + return new ArrayList<>(this.runtimeEntityMap.values()); + } + + public List getRuntimeEntityList(List clusterEntityList) { + List runtimeEntityList = new ArrayList<>(); + for (ClusterEntity clusterEntity : clusterEntityList) { + runtimeEntityList.add(this.runtimeEntityMap.get(clusterEntity.getId())); + } + return runtimeEntityList; + } + + public List createClusterRelationshipEntity() { + this.clusterTripleList.forEach(triple -> { + + triple.getMiddle().forEach(middle -> { + this.createClusterRelationshipEntity(triple.getLeft(), middle); + }); + triple.getRight().forEach(r -> { + this.createClusterRelationshipEntity(triple.getLeft(), r); + }); + }); + this.eventMeshRuntimeTripleList.forEach(tripleList1 -> { + tripleList1.getRight().forEach(r -> { + this.createClusterRelationshipEntity(tripleList1.getLeft(), r); + }); + }); + return this.clusterRelationshipEntityList; + } + + private void createClusterRelationshipEntity(ClusterEntity clusterEntity, ClusterEntity relationshipClusterEntity) { + ClusterRelationshipEntity clusterRelationshipEntity = + ClusterRelationshipMapperTest.buildClusterRelationshipEntity(clusterEntity, relationshipClusterEntity); + + this.clusterRelationshipEntityList.add(clusterRelationshipEntity); + } + + private void createRuntimeEntity(ClusterEntity clusterEntity) { + if (!this.buildFullMetadata.getClusterOwnTypesSet().contains(clusterEntity.getClusterOwnType())) { + return; + } + if (clusterEntity.getClusterType().isDefinition()) { + return; + } + Random random = new Random(); + int num = random.nextInt(3) + 3; + for (int i = 0; i < num; i++) { + RuntimeEntity runtimeEntity = RuntimeEntityMapperTest.createRuntimeEntity(clusterEntity); + runtimeEntity.setDeployStatusType(DeployStatusType.CREATE_FULL_WAIT); + if (num == i + 1) { + runtimeEntity.setDeployStatusType(DeployStatusType.CREATE_WAIT); + } + this.runtimeEntityMap.put(runtimeEntity.getId(), runtimeEntity); + } + } + + + public void buildFullMetadata() { + this.buildFullMetadata = + BuildFullMetadata.builder() + .eventMeshEnabled(true) + .clusterTypeSet(new HashSet<>(ClusterType.getStorageCluster())) + .metaTypeSet(new HashSet<>(ClusterType.getStorageRuntimeCluster())) + .runtimeTypeSet(new HashSet<>(ClusterType.getStorageMetaCluster())) + .firstToWhomSet(Set.of(FirstToWhom.NOT)) + .clusterTrusteeshipTypesSet(Set.of(ClusterTrusteeshipType.SELF)) + .clusterOwnTypesSet(Set.of(ClusterOwnType.INDEPENDENCE)).build(); + + this.buildFullMetadata.getClusterTypeSet().add(ClusterType.EVENTMESH_CLUSTER); + this.buildFullMetadata.getMetaTypeSet().addAll(ClusterType.EVENTMESH_CLUSTER.getMetaClusterType()); + this.buildFullMetadata.getRuntimeTypeSet().addAll(ClusterType.EVENTMESH_CLUSTER.getMetaClusterInStorage()); + this.build(); + } + + public void buildStorageAll() { + this.buildFullMetadata = + BuildFullMetadata.builder() + .clusterTypeSet(new HashSet<>(ClusterType.getStorageCluster())) + .metaTypeSet(new HashSet<>(ClusterType.getStorageRuntimeCluster())) + .runtimeTypeSet(new HashSet<>(ClusterType.getStorageMetaCluster())) + .firstToWhomSet(Set.of(FirstToWhom.NOT)) + .clusterTrusteeshipTypesSet(Set.of(ClusterTrusteeshipType.SELF)) + .clusterOwnTypesSet(Set.of(ClusterOwnType.INDEPENDENCE)).build(); + this.build(); + } + + public void build(ClusterType clusterType) { + this.buildFullMetadata = BuildFullMetadata.builder().clusterTypeSet(Set.of(clusterType)) + .metaTypeSet(Set.copyOf(clusterType.getMetaClusterType())) + .runtimeTypeSet(Set.copyOf(clusterType.getRuntimeClusterType())) + .firstToWhomSet(Set.of(FirstToWhom.NOT)) + .clusterTrusteeshipTypesSet(Set.of(ClusterTrusteeshipType.SELF)) + .clusterOwnTypesSet(Set.of(ClusterOwnType.INDEPENDENCE)).build(); + this.build(); + } + + public void build(BuildFullMetadata buildFullMetadata) { + this.buildFullMetadata = buildFullMetadata; + } + + @Data + private static class ShareMetadata { + + private final List shareClusterEntityList = new ArrayList<>(); + + private Integer shareNum = 0; + + private final Map> shareMap = new HashMap<>(); + } + +} diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/Health2ServiceTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/Health2ServiceTest.java new file mode 100644 index 00000000..28c374a8 --- /dev/null +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/Health2ServiceTest.java @@ -0,0 +1,80 @@ +/* + * 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.function.health; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.common.model.base.BaseSyncBase; +import org.apache.eventmesh.dashboard.common.model.metadata.RuntimeMetadata; +import org.apache.eventmesh.dashboard.console.service.function.HealthDataService; +import org.apache.eventmesh.dashboard.core.function.SDK.SDKManage; +import org.apache.eventmesh.dashboard.core.function.SDK.SDKTypeEnum; +import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateJvmCapConfig; +import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateJvmConfig; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; + +@RunWith(MockitoJUnitRunner.class) +public class Health2ServiceTest { + + @Mock + private HealthDataService dataService; + + public static BaseSyncBase createJvm() { + SDKTypeEnum sdkTypeEnum = SDKTypeEnum.ADMIN; + BaseSyncBase baseSyncBase = new RuntimeMetadata(); + baseSyncBase.setId(1L); + baseSyncBase.setClusterType(ClusterType.STORAGE_JVM_BROKER); + CreateJvmConfig config = new CreateJvmConfig(); + config.setKey(baseSyncBase.getId().toString()); + SDKManage.getInstance().createClient(sdkTypeEnum, baseSyncBase, config, baseSyncBase.getClusterType()); + return baseSyncBase; + } + + public static BaseSyncBase createJvmCap() { + SDKTypeEnum sdkTypeEnum = SDKTypeEnum.ADMIN; + BaseSyncBase baseSyncBase = new RuntimeMetadata(); + baseSyncBase.setId(1L); + baseSyncBase.setClusterType(ClusterType.STORAGE_JVM_CAP_BROKER); + CreateJvmCapConfig config = new CreateJvmCapConfig(); + config.setKey(baseSyncBase.getId().toString()); + SDKManage.getInstance().createClient(sdkTypeEnum, baseSyncBase, config, baseSyncBase.getClusterType()); + return baseSyncBase; + } + + private Health2Service health2Service = new Health2Service(); + + + + @Before + public void init(){ + health2Service.setDataService(dataService); + } + + @Test + public void test(){ + BaseSyncBase baseSyncBase = createJvm(); + health2Service.register(baseSyncBase); + health2Service.executeAll(); + } + +} diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/HealthExecutorTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/HealthExecutorTest.java deleted file mode 100644 index 964126ef..00000000 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/HealthExecutorTest.java +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.console.function.health; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.mockito.ArgumentMatchers.any; - -import org.apache.eventmesh.dashboard.common.enums.health.HealthCheckStatus; -import org.apache.eventmesh.dashboard.common.enums.health.HealthCheckType; -import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication; -import org.apache.eventmesh.dashboard.console.entity.function.HealthCheckResultEntity; -import org.apache.eventmesh.dashboard.console.function.health.callback.HealthCheckCallback; -import org.apache.eventmesh.dashboard.console.function.health.check.AbstractHealthCheckService; -import org.apache.eventmesh.dashboard.console.function.health.check.config.HealthCheckObjectConfig; -import org.apache.eventmesh.dashboard.console.service.function.HealthDataService; - -import java.util.concurrent.CompletableFuture; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.Timeout; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.junit.jupiter.MockitoExtension; -import org.mockito.stubbing.Answer; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.jdbc.Sql; -import org.springframework.test.context.junit.jupiter.SpringExtension; - -@ExtendWith(MockitoExtension.class) -@ExtendWith(SpringExtension.class) -@SpringBootTest(classes = EventMeshDashboardApplication.class) -@ActiveProfiles("test") -@Sql(executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, scripts = {"classpath:use-test-schema.sql", "classpath:eventmesh-dashboard.sql"}) -@Timeout(value = 5) -class HealthExecutorTest { - - @Autowired - HealthDataService healthDataService; - @Mock - AbstractHealthCheckService successHealthCheckService; - @Mock - AbstractHealthCheckService failHealthCheckService; - @Mock - AbstractHealthCheckService timeoutHealthCheckService; - private HealthExecutor healthExecutor = new HealthExecutor(); - private CheckResultCache memoryCache = CheckResultCache.getINSTANCE(); - - @BeforeEach - public void initMock() { - Mockito.lenient().doAnswer((Answer) invocation -> { - HealthCheckCallback callback = invocation.getArgument(0); - callback.onSuccess(); - return null; - }).when(successHealthCheckService).doCheck(any(HealthCheckCallback.class)); - Mockito.lenient().doAnswer((Answer) invocation -> { - HealthCheckCallback callback = invocation.getArgument(0); - callback.onFail(new RuntimeException("TestRuntimeException: This check is designed to be failed. Ignore This!")); - return null; - }).when(failHealthCheckService).doCheck(any(HealthCheckCallback.class)); - Mockito.lenient().doAnswer((Answer) invocation -> { - HealthCheckCallback callback = invocation.getArgument(0); - CompletableFuture.runAsync(() -> { - try { - Thread.sleep(10000); - } catch (InterruptedException e) { - return; - } - callback.onFail(new RuntimeException("TestRuntimeException")); - }); - return null; - }).when(timeoutHealthCheckService).doCheck(any(HealthCheckCallback.class)); - - healthExecutor.setDataService(healthDataService); - healthExecutor.setMemoryCache(memoryCache); - HealthCheckObjectConfig config1 = HealthCheckObjectConfig.builder() - .instanceId(1L) - .healthCheckResourceType("storage") - .healthCheckResourceSubType("redis") - .connectUrl("redis://localhost:6379") - .simpleClassName("RedisCheck") - .clusterId(1L) - .build(); - Mockito.lenient().when(successHealthCheckService.getConfig()).thenReturn(config1); - Mockito.lenient().when(timeoutHealthCheckService.getConfig()).thenReturn(config1); - HealthCheckObjectConfig config2 = HealthCheckObjectConfig.builder() - .instanceId(2L) - .healthCheckResourceType("storage") - .healthCheckResourceSubType("redis") - .connectUrl("redis://localhost:6379") - .simpleClassName("RedisCheck") - .clusterId(1L) - .build(); - Mockito.lenient().when(failHealthCheckService.getConfig()).thenReturn(config2); - } - - @Test - public void testExecute() throws InterruptedException { - healthExecutor.execute(successHealthCheckService); - healthExecutor.execute(failHealthCheckService); - Thread.sleep(1000); - assertEquals(2, memoryCache.getCacheMap().get("storage").size()); - assertNotEquals(memoryCache.getCacheMap().get("storage").get(1L).getStatus(), memoryCache.getCacheMap().get("storage").get(2L).getStatus()); - } - - - @Test - public void testEndExecute() { - healthExecutor.execute(successHealthCheckService); - healthExecutor.execute(failHealthCheckService); - healthExecutor.endExecute(); - HealthCheckResultEntity query = new HealthCheckResultEntity(); - query.setClusterId(1L); - query.setType(HealthCheckType.STORAGE.getNumber()); - query.setTypeId(2L); - assertNotNull(healthDataService.queryHealthCheckResultByClusterIdAndTypeAndTypeId(query).get(0).getState()); - } - - @Test - public void testStartExecute() throws InterruptedException { - healthExecutor.execute(successHealthCheckService); - healthExecutor.execute(failHealthCheckService); - //to test startExecute(), we need to call endExecute() first - healthExecutor.endExecute(); - Thread.sleep(500); - healthExecutor.startExecute(); - HealthCheckResultEntity query = new HealthCheckResultEntity(); - query.setClusterId(1L); - query.setType(HealthCheckType.STORAGE.getNumber()); - query.setTypeId(1L); - assertEquals(1, healthDataService.queryHealthCheckResultByClusterIdAndTypeAndTypeId(query).get(0).getState()); - } - - @Test - public void testTimeout() { - healthExecutor.execute(timeoutHealthCheckService); - healthExecutor.endExecute(); - healthExecutor.startExecute(); - - HealthCheckResultEntity query = new HealthCheckResultEntity(); - query.setClusterId(1L); - query.setType(HealthCheckType.STORAGE.getNumber()); - query.setTypeId(1L); - assertEquals(HealthCheckStatus.TIMEOUT.getNumber(), - healthDataService.queryHealthCheckResultByClusterIdAndTypeAndTypeId(query).get(0).getState()); - } - - @Test - public void testFull() throws InterruptedException { - healthExecutor.startExecute(); - healthExecutor.execute(successHealthCheckService); - healthExecutor.execute(failHealthCheckService); - healthExecutor.endExecute(); - Thread.sleep(1000); - healthExecutor.startExecute(); - healthExecutor.execute(successHealthCheckService); - healthExecutor.execute(failHealthCheckService); - healthExecutor.endExecute(); - HealthCheckResultEntity query = new HealthCheckResultEntity(); - query.setClusterId(1L); - query.setType(HealthCheckType.STORAGE.getNumber()); - query.setTypeId(1L); - assertEquals(2, healthDataService.queryHealthCheckResultByClusterIdAndTypeAndTypeId(query).size()); - } - -} \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/HealthServiceTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/HealthServiceTest.java deleted file mode 100644 index 0d5f5bd2..00000000 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/HealthServiceTest.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.console.function.health; - -import org.apache.eventmesh.dashboard.console.function.health.callback.HealthCheckCallback; -import org.apache.eventmesh.dashboard.console.function.health.check.AbstractHealthCheckService; -import org.apache.eventmesh.dashboard.console.function.health.check.config.HealthCheckObjectConfig; -import org.apache.eventmesh.dashboard.console.service.function.HealthDataService; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.Timeout; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.Mock; -import org.mockito.junit.jupiter.MockitoExtension; - -@ExtendWith(MockitoExtension.class) -@Timeout(value = 5) -class HealthServiceTest { - - HealthService healthService = new HealthService(); - - @Mock - private HealthDataService healthDataService; - - @Mock - private CheckResultCache checkResultCache; - - @BeforeEach - void init() { - healthService.createExecutor(healthDataService, checkResultCache); - } - - @Test - void testInsertCheckServiceWithAnnotation() { - HealthCheckObjectConfig config = HealthCheckObjectConfig.builder() - .instanceId(1L) - .healthCheckResourceType("storage") - .healthCheckResourceSubType("redis") - .connectUrl("redis://localhost:6379") - .build(); - healthService.insertCheckService(config); - } - - @Test - void testInsertCheckServiceWithSimpleClassName() { - HealthCheckObjectConfig config = HealthCheckObjectConfig.builder() - .instanceId(1L) - .simpleClassName("RedisCheck") - .healthCheckResourceType("storage") - .healthCheckResourceSubType("redis") - .clusterId(1L) - .connectUrl("redis://localhost:6379") - .build(); - healthService.insertCheckService(config); - } - - @Test - void testInsertCheckServiceWithClass() { - HealthCheckObjectConfig config = HealthCheckObjectConfig.builder() - .instanceId(1L) - .healthCheckResourceType("storage") - .healthCheckResourceSubType("redis") - .clusterId(1L) - .checkClass(TestHealthCheckService.class) - .build(); - healthService.insertCheckService(config); - } - - @Test - void testDeleteCheckService() { - HealthCheckObjectConfig config = HealthCheckObjectConfig.builder() - .instanceId(1L) - .healthCheckResourceType("storage") - .healthCheckResourceSubType("redis") - .clusterId(1L) - .checkClass(TestHealthCheckService.class) - .build(); - healthService.insertCheckService(config); - healthService.deleteCheckService("storage", 1L); - } - - @Test - void testExecuteAll() { - HealthCheckObjectConfig config = HealthCheckObjectConfig.builder() - .instanceId(1L) - .healthCheckResourceType("storage") - .healthCheckResourceSubType("redis") - .clusterId(1L) - .checkClass(TestHealthCheckService.class) - .build(); - healthService.insertCheckService(config); - healthService.executeAll(); - } - - public static class TestHealthCheckService extends AbstractHealthCheckService { - - - public TestHealthCheckService(HealthCheckObjectConfig healthCheckObjectConfig) { - super(healthCheckObjectConfig); - } - - @Override - public void doCheck(HealthCheckCallback callback) { - callback.onSuccess(); - } - - @Override - public void init() { - - } - - @Override - public void destroy() { - - } - } -} \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/meta/NacosConfigCheckTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/meta/NacosConfigCheckTest.java index 7915bd0d..18cb33ba 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/meta/NacosConfigCheckTest.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/meta/NacosConfigCheckTest.java @@ -15,10 +15,10 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.function.health.check.impl.meta; import org.apache.eventmesh.dashboard.console.function.health.callback.HealthCheckCallback; -import org.apache.eventmesh.dashboard.console.function.health.check.config.HealthCheckObjectConfig; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; @@ -39,15 +39,7 @@ class NacosConfigCheckTest { @BeforeEach public void init() { try { - HealthCheckObjectConfig config = HealthCheckObjectConfig.builder() - .instanceId(1L) - .healthCheckResourceType("meta") - .healthCheckResourceSubType("nacos") - .clusterId(1L) - .connectUrl("127.0.0.1:8848") - .requestTimeoutMillis(1000L) - .build(); - nacosCheck = new NacosConfigCheck(config); + nacosCheck = new NacosConfigCheck(); } catch (Exception e) { log.error("NacosConfigCheck failed.", e); } @@ -79,6 +71,6 @@ public void onFail(Exception e) { @AfterEach public void destroy() { - nacosCheck.destroy(); + } } \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/meta/NacosNamingServiceCheckTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/meta/NacosNamingServiceCheckTest.java index 080273be..f9501096 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/meta/NacosNamingServiceCheckTest.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/meta/NacosNamingServiceCheckTest.java @@ -15,15 +15,14 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.function.health.check.impl.meta; import org.apache.eventmesh.dashboard.console.function.health.callback.HealthCheckCallback; -import org.apache.eventmesh.dashboard.console.function.health.check.config.HealthCheckObjectConfig; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Timeout; @@ -39,15 +38,8 @@ class NacosNamingServiceCheckTest { @BeforeEach public void init() { try { - HealthCheckObjectConfig config = HealthCheckObjectConfig.builder() - .instanceId(1L) - .healthCheckResourceType("meta") - .healthCheckResourceSubType("nacos") - .clusterId(1L) - .connectUrl("127.0.0.1:8848") - .requestTimeoutMillis(1000L) - .build(); - nacosRegisterCheck = new NacosNamingServiceCheck(config); + + nacosRegisterCheck = new NacosNamingServiceCheck(); } catch (Exception e) { log.error("NacosNamingServiceCheck failed.", e); } @@ -77,8 +69,4 @@ public void onFail(Exception e) { } } - @AfterEach - public void destroy() { - nacosRegisterCheck.destroy(); - } } \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/RedisCheckTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/RedisCheckTest.java deleted file mode 100644 index 9f0cd474..00000000 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/RedisCheckTest.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.console.function.health.check.impl.storage; - -import org.apache.eventmesh.dashboard.console.function.health.callback.HealthCheckCallback; -import org.apache.eventmesh.dashboard.console.function.health.check.config.HealthCheckObjectConfig; - -import java.util.concurrent.CountDownLatch; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.Timeout; - -import io.lettuce.core.RedisException; - -import lombok.extern.slf4j.Slf4j; - -@Slf4j -@Timeout(value = 5) -class RedisCheckTest { - - private RedisCheck redisCheck; - - @BeforeEach - public void init() { - try { - HealthCheckObjectConfig config = HealthCheckObjectConfig.builder() - .instanceId(1L) - .healthCheckResourceType("storage") - .healthCheckResourceSubType("redis") - .simpleClassName("RedisCheck") - .clusterId(1L) - .connectUrl("127.0.0.1:6379") - .password("") - .build(); - redisCheck = new RedisCheck(config); - } catch (RedisException e) { - log.error("RedisCheck failed.", e); - } - } - - @Test - public void testDoCheck() throws InterruptedException { - try { - CountDownLatch latch = new CountDownLatch(1); - if (redisCheck == null) { - log.error("RedisCheck is null."); - return; - } - redisCheck.doCheck(new HealthCheckCallback() { - @Override - public void onSuccess() { - latch.countDown(); - log.info("{} success", this.getClass().getSimpleName()); - } - - @Override - public void onFail(Exception e) { - latch.countDown(); - log.error("{}, failed for reason {}", this.getClass().getSimpleName(), e); - } - }); - latch.await(); - } catch (RedisException e) { - log.error("RedisCheck failed.", e); - } - } -} \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/Rocketmq4BrokerCheckTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/Rocketmq4BrokerCheckTest.java index eaa7d5b4..016ca807 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/Rocketmq4BrokerCheckTest.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/Rocketmq4BrokerCheckTest.java @@ -15,10 +15,10 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.function.health.check.impl.storage.rocketmq4; import org.apache.eventmesh.dashboard.console.function.health.callback.HealthCheckCallback; -import org.apache.eventmesh.dashboard.console.function.health.check.config.HealthCheckObjectConfig; import java.util.concurrent.CountDownLatch; @@ -37,12 +37,7 @@ class Rocketmq4BrokerCheckTest { @BeforeEach public void init() { try { - HealthCheckObjectConfig config = HealthCheckObjectConfig.builder() - .host("127.0.0.1") - .port(10911) - .requestTimeoutMillis(1000L) - .build(); - rocketmqCheck = new Rocketmq4BrokerCheck(config); + rocketmqCheck = new Rocketmq4BrokerCheck(); } catch (Exception e) { log.error("Rocketmq4BrokerCheck failed.", e); } diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/Rocketmq4NameserverCheckTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/Rocketmq4NameserverCheckTest.java index 8c2cab21..8b661025 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/Rocketmq4NameserverCheckTest.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/Rocketmq4NameserverCheckTest.java @@ -15,10 +15,10 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.function.health.check.impl.storage.rocketmq4; import org.apache.eventmesh.dashboard.console.function.health.callback.HealthCheckCallback; -import org.apache.eventmesh.dashboard.console.function.health.check.config.HealthCheckObjectConfig; import java.util.concurrent.CountDownLatch; @@ -37,12 +37,7 @@ class Rocketmq4NameserverCheckTest { @BeforeEach public void init() { try { - HealthCheckObjectConfig config = HealthCheckObjectConfig.builder() - - .connectUrl("127.0.0.1:9876") - .requestTimeoutMillis(1000L) - .build(); - rocketmqCheck = new Rocketmq4NameServerCheck(config); + rocketmqCheck = new Rocketmq4NameServerCheck(); } catch (Exception e) { log.error("Rocketmq4NameserverCheck failed.", e); } diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/Rocketmq4TopicCheckTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/Rocketmq4TopicCheckTest.java index 1d4eb093..3d2c66aa 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/Rocketmq4TopicCheckTest.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/storage/rocketmq4/Rocketmq4TopicCheckTest.java @@ -15,10 +15,10 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.function.health.check.impl.storage.rocketmq4; import org.apache.eventmesh.dashboard.console.function.health.callback.HealthCheckCallback; -import org.apache.eventmesh.dashboard.console.function.health.check.config.HealthCheckObjectConfig; import java.util.concurrent.CountDownLatch; @@ -37,11 +37,7 @@ class Rocketmq4TopicCheckTest { @BeforeEach public void init() throws InterruptedException { try { - HealthCheckObjectConfig config = new HealthCheckObjectConfig(); - config.getRocketmqConfig().setBrokerUrl("127.0.0.1:10911"); - config.getRocketmqConfig().setNameServerUrl("127.0.0.1:9876"); - config.setRequestTimeoutMillis(1000L); - rocketmqCheck = new Rocketmq4TopicCheck(config); + rocketmqCheck = new Rocketmq4TopicCheck(); } catch (Exception e) { log.error("Rocketmq4TopicCheck failed.", e); } diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/ConfigMetadataHandlerToDbImplTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/ConfigMetadataHandlerToDbImplTest.java deleted file mode 100644 index ca25df2d..00000000 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/ConfigMetadataHandlerToDbImplTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.console.function.metadata.handler.db; - -import org.apache.eventmesh.dashboard.common.model.metadata.ConfigMetadata; -import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication; -import org.apache.eventmesh.dashboard.console.service.function.ConfigService; - -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.jdbc.Sql; -import org.springframework.test.context.junit.jupiter.SpringExtension; - -@ExtendWith(SpringExtension.class) -@ActiveProfiles("test") -@SpringBootTest(classes = EventMeshDashboardApplication.class) -@Sql(executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, scripts = {"classpath:use-test-schema.sql", "classpath:eventmesh-dashboard.sql"}) -class ConfigMetadataHandlerToDbImplTest { - - @Autowired - private ConfigMetadataHandlerToDbImpl configMetadataHandlerToDb; - - @Autowired - private ConfigService configDataService; - - @Test - public void testAddMetadata() { - ConfigMetadata configMetadata = new ConfigMetadata(); - configMetadata.setConfigKey("configKey"); - configMetadata.setConfigValue("configValue"); - configMetadata.setInstanceType(0); - configMetadata.setInstanceId(0L); - configMetadata.setClusterId(0L); - configMetadataHandlerToDb.addMetadata(configMetadata); - } -} \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/ConnectionMetadataHandlerToDbImplTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/ConnectionMetadataHandlerToDbImplTest.java deleted file mode 100644 index 1057cab5..00000000 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/ConnectionMetadataHandlerToDbImplTest.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.console.function.metadata.handler.db; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import org.apache.eventmesh.dashboard.common.model.metadata.ConnectionMetadata; -import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication; -import org.apache.eventmesh.dashboard.console.entity.cluster.ClientEntity; -import org.apache.eventmesh.dashboard.console.entity.cluster.ConnectionEntity; -import org.apache.eventmesh.dashboard.console.entity.connector.ConnectorEntity; -import org.apache.eventmesh.dashboard.console.service.cluster.ClientDataService; -import org.apache.eventmesh.dashboard.console.service.cluster.ConnectionDataService; -import org.apache.eventmesh.dashboard.console.service.connector.ConnectorDataService; -import org.apache.eventmesh.dashboard.core.metadata.MetadataHandler; - -import java.util.List; - -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.jdbc.Sql; -import org.springframework.test.context.junit.jupiter.SpringExtension; - -@ExtendWith(SpringExtension.class) -@ActiveProfiles("test") -@SpringBootTest(classes = EventMeshDashboardApplication.class) -@Sql(executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, scripts = {"classpath:use-test-schema.sql", "classpath:eventmesh-dashboard.sql"}) -@Sql(executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, scripts = {"classpath:client-test.sql", "classpath:connector-test.sql", - "classpath:connection-test.sql"}) -class ConnectionMetadataHandlerToDbImplTest { - - @Autowired - MetadataHandler connectionMetadataMetadataHandler; - - @Autowired - ConnectionDataService connectionDataService; - - @Autowired - ConnectorDataService connectorDataService; - - @Autowired - ClientDataService clientDataService; - - @Test - public void testNewConnectorNewClientNewConnection() { - ConnectionMetadata connectionMetadata = new ConnectionMetadata(); - connectionMetadata.setSourceType("connector"); - connectionMetadata.setSourceId(0L); - connectionMetadata.setSourceHost("192.168.1.1"); - connectionMetadata.setSourcePort(8888); - connectionMetadata.setSourceName(""); - connectionMetadata.setSinkType("client"); - connectionMetadata.setSinkHost(""); - connectionMetadata.setSinkPort(0); - connectionMetadata.setSinkName(""); - connectionMetadata.setSinkId(0L); - connectionMetadata.setRuntimeId(0L); - connectionMetadata.setTopic(""); - connectionMetadata.setGroupId(0L); - connectionMetadata.setDescription(""); - connectionMetadata.setRegistryAddress(""); - connectionMetadata.setClusterId(0L); - - connectionMetadataMetadataHandler.addMetadata(connectionMetadata); - - assertEquals(7, connectionDataService.getAllConnections().size()); - assertEquals(6, connectorDataService.selectAll().size()); - assertEquals(5, clientDataService.selectAll().size()); - } - - @Test - public void testOldConnectorNewClientNewConnection() { - ConnectionMetadata connectionMetadata = new ConnectionMetadata(); - - connectionMetadata.setSourceType("connector"); - connectionMetadata.setSourceHost("192.168.3.1"); - connectionMetadata.setSourcePort(8888); - connectionMetadata.setSourceName(""); - connectionMetadata.setSinkType("client"); - connectionMetadata.setSinkHost(""); - connectionMetadata.setSinkPort(0); - connectionMetadata.setSinkName(""); - connectionMetadata.setRuntimeId(0L); - connectionMetadata.setTopic(""); - connectionMetadata.setGroupId(0L); - connectionMetadata.setDescription(""); - connectionMetadata.setRegistryAddress(""); - connectionMetadata.setClusterId(0L); - - connectionMetadataMetadataHandler.addMetadata(connectionMetadata); - - List connections = connectionDataService.getAllConnections(); - List connectors = connectorDataService.selectAll(); - List clients = clientDataService.selectAll(); - - assertEquals(7, connections.size()); - assertEquals(5, connectors.size()); - assertEquals(5, clients.size()); - - assertEquals(2, connections.get(connections.size() - 1).getSourceId().intValue()); - assertEquals(5, connections.get(connections.size() - 1).getSinkId().intValue()); - } -} \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/GroupMetadataHandlerToDbImplTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/GroupMetadataHandlerToDbImplTest.java deleted file mode 100644 index acfacb2f..00000000 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/GroupMetadataHandlerToDbImplTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.console.function.metadata.handler.db; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import org.apache.eventmesh.dashboard.common.model.metadata.GroupMetadata; -import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication; -import org.apache.eventmesh.dashboard.console.entity.message.GroupEntity; -import org.apache.eventmesh.dashboard.console.service.message.GroupService; -import org.apache.eventmesh.dashboard.core.metadata.MetadataHandler; - -import java.util.List; - -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.jdbc.Sql; -import org.springframework.test.context.junit.jupiter.SpringExtension; - -@ExtendWith(SpringExtension.class) -@ActiveProfiles("test") -@SpringBootTest(classes = EventMeshDashboardApplication.class) -@Sql(executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, scripts = {"classpath:use-test-schema.sql", "classpath:eventmesh-dashboard.sql"}) -class GroupMetadataHandlerToDbImplTest { - - @Autowired - MetadataHandler groupMetadataHandlerToDb; - - @Autowired - GroupService groupDataService; - - @Test - public void testAddMetadata() { - GroupMetadata groupMetadata = new GroupMetadata(); - groupMetadata.setName("group"); - groupMetadata.setState(""); - groupMetadata.setType(0); - groupMetadata.setClusterId(1L); - groupMetadata.setMembers(""); - groupMetadataHandlerToDb.addMetadata(groupMetadata); - List results = groupDataService.selectAll(); - assertEquals("group", results.get(results.size() - 1).getName()); - } -} \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/RuntimeMetadataHandlerToDbImplTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/RuntimeMetadataHandlerToDbImplTest.java deleted file mode 100644 index f87cc141..00000000 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/RuntimeMetadataHandlerToDbImplTest.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.console.function.metadata.handler.db; - -import org.apache.eventmesh.dashboard.common.model.metadata.RuntimeMetadata; -import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication; -import org.apache.eventmesh.dashboard.console.cache.ClusterCacheBase; -import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; -import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; -import org.apache.eventmesh.dashboard.console.service.cluster.ClusterService; -import org.apache.eventmesh.dashboard.console.service.cluster.RuntimeService; -import org.apache.eventmesh.dashboard.core.metadata.MetadataHandler; - -import java.util.List; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.jdbc.Sql; -import org.springframework.test.context.junit.jupiter.SpringExtension; - -@ExtendWith(SpringExtension.class) -@ActiveProfiles("test") -@SpringBootTest(classes = EventMeshDashboardApplication.class) -@Sql(executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, scripts = {"classpath:use-test-schema.sql", "classpath:eventmesh-dashboard.sql"}) -@Sql(executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, scripts = "classpath:runtime-test.sql") -class RuntimeMetadataHandlerToDbImplTest extends ClusterCacheBase { - - @Autowired - private MetadataHandler runtimeMetadataHandlerToDb; - - private RuntimeMetadata runtimeMetadata; - - @Autowired - private RuntimeService runtimeService; - - @Autowired - private ClusterService clusterService; - - @BeforeEach - public void initData() { - runtimeMetadata = new RuntimeMetadata(); - runtimeMetadata.setHost("192.168.3.14"); - runtimeMetadata.setPort(1234); - runtimeMetadata.setRack("rack"); - runtimeMetadata.setRegistryAddress("12333"); - runtimeMetadata.setJmxPort(12345); - runtimeMetadata.setClusterName("cluster1"); - runtimeMetadata.setEndpointMap("endpointMap"); - runtimeMetadata.setStorageClusterId(1L); - runtimeMetadata.setStartTimestamp(123456L); - runtimeMetadata.setRegistryAddress("registryAddress"); - } - - @Test - void testAddMetadataWhenClusterExistRuntimeNotExist() { - runtimeMetadataHandlerToDb.addMetadata(runtimeMetadata); - List runtimeEntities = runtimeService.selectAll(); - Assertions.assertEquals("endpointMap", runtimeEntities.get(runtimeEntities.size() - 1).getEndpointMap()); - List clusterEntities = clusterService.selectAll(); - Assertions.assertEquals("cluster1", clusterEntities.get(clusterEntities.size() - 1).getName()); - } - - @Test - void testAddMetadataWhenClusterNotExistRuntimeNotExist() { - runtimeMetadata.setClusterName("cluster2"); - runtimeMetadataHandlerToDb.addMetadata(runtimeMetadata); - List runtimeEntities = runtimeService.selectAll(); - Assertions.assertEquals("endpointMap", runtimeEntities.get(runtimeEntities.size() - 1).getEndpointMap()); - List clusterEntities = clusterService.selectAll(); - Assertions.assertEquals("cluster2", clusterEntities.get(clusterEntities.size() - 1).getName()); - } - - @Test - void testAddMetadataWhenClusterExistRuntimeExist() { - runtimeMetadata.setClusterId(1L); - runtimeMetadata.setHost("127.0.0.1"); - runtimeMetadata.setPort(12345); - runtimeMetadataHandlerToDb.addMetadata(runtimeMetadata); - List runtimeEntities = runtimeService.selectAll(); - Assertions.assertEquals(3, runtimeEntities.size()); - Assertions.assertNotEquals("2024-03-18 09:53:10", runtimeEntities.get(0).getUpdateTime().toString()); - Assertions.assertNotEquals(-1, runtimeEntities.get(0).getStartTimestamp()); - Assertions.assertEquals(-1, runtimeEntities.get(1).getStartTimestamp()); - List clusterEntities = clusterService.selectAll(); - Assertions.assertEquals(1, clusterEntities.size()); - } - - @Test - void testAddMetadataWhenClusterNotExistRuntimeExist() { - runtimeMetadata.setClusterName("cluster2"); - runtimeMetadata.setHost("127.0.0.1"); - runtimeMetadata.setPort(12345); - runtimeMetadataHandlerToDb.addMetadata(runtimeMetadata); - List runtimeEntities = runtimeService.selectAll(); - Assertions.assertEquals(3, runtimeEntities.size()); - Assertions.assertNotEquals("2024-03-18 09:53:10", runtimeEntities.get(0).getUpdateTime()); - Assertions.assertNotEquals(-1, runtimeEntities.get(0).getStartTimestamp()); - Assertions.assertEquals(-1, runtimeEntities.get(1).getStartTimestamp()); - List clusterEntities = clusterService.selectAll(); - Assertions.assertEquals(1, clusterEntities.size()); - } -} \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/TopicMetadataHandlerToDbImplTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/TopicMetadataHandlerToDbImplTest.java deleted file mode 100644 index 0e996c93..00000000 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/metadata/handler/db/TopicMetadataHandlerToDbImplTest.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.console.function.metadata.handler.db; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import org.apache.eventmesh.dashboard.common.enums.StoreType; -import org.apache.eventmesh.dashboard.common.model.metadata.TopicMetadata; -import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication; -import org.apache.eventmesh.dashboard.console.cache.ClusterCacheBase; -import org.apache.eventmesh.dashboard.console.entity.message.TopicEntity; -import org.apache.eventmesh.dashboard.console.service.message.TopicService; -import org.apache.eventmesh.dashboard.core.metadata.MetadataHandler; - -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.jdbc.Sql; -import org.springframework.test.context.junit.jupiter.SpringExtension; - -@ExtendWith(SpringExtension.class) -@ActiveProfiles("test") -@SpringBootTest(classes = EventMeshDashboardApplication.class) -@Sql(executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, scripts = {"classpath:use-test-schema.sql", "classpath:eventmesh-dashboard.sql"}) -@Sql(executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, scripts = "classpath:topic-test.sql") -class TopicMetadataHandlerToDbImplTest extends ClusterCacheBase { - - @Autowired - MetadataHandler topicMetadataHandlerToDb; - - @Autowired - private TopicService topicService; - - @Test - public void testAddMetadata() { - TopicMetadata topicMetadata = new TopicMetadata(); - topicMetadata.setTopicName("testTopic"); - //set id to 0, this should be checked and recovered in another module - topicMetadata.setRuntimeId(0L); - topicMetadata.setStorageId(0L); - topicMetadata.setClusterId(135L); - - topicMetadata.setType(0); - topicMetadata.setStoreType(StoreType.REDIS); - topicMetadata.setDescription("function/metadata/handler/db/TopicMetadataHandlerToDbImplTest.java"); - topicMetadata.setRetentionMs(-1L); - topicMetadataHandlerToDb.addMetadata(topicMetadata); - TopicEntity topicEntity = new TopicEntity(); - topicEntity.setId(135L); - assertEquals("function/metadata/handler/db/TopicMetadataHandlerToDbImplTest.java", - topicService.selectTopiByCluster(topicEntity).get(0).getDescription()); - } - -} \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/integration/health/HealthServiceIntegrateTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/integration/health/HealthServiceIntegrateTest.java deleted file mode 100644 index 1a16de2c..00000000 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/integration/health/HealthServiceIntegrateTest.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.console.integration.health; - -import org.apache.eventmesh.dashboard.common.enums.health.HealthCheckType; -import org.apache.eventmesh.dashboard.console.entity.function.HealthCheckResultEntity; -import org.apache.eventmesh.dashboard.console.function.health.CheckResultCache; -import org.apache.eventmesh.dashboard.console.function.health.HealthService; -import org.apache.eventmesh.dashboard.console.function.health.check.config.HealthCheckObjectConfig; -import org.apache.eventmesh.dashboard.console.service.function.HealthDataService; - -import java.util.List; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.Timeout; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.jdbc.Sql; - -@SpringBootTest -@ActiveProfiles("test") -@Sql(executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, scripts = {"classpath:use-test-schema.sql", "classpath:eventmesh-dashboard.sql"}) -@Timeout(value = 10) -public class HealthServiceIntegrateTest { - - private final CheckResultCache checkResultCache = CheckResultCache.getINSTANCE(); - HealthService healthService = new HealthService(); - @Autowired - private HealthDataService healthDataService; - - @BeforeEach - void init() { - healthService.createExecutor(healthDataService, checkResultCache); - } - - @Test - void testStorageRedis() throws InterruptedException { - HealthCheckObjectConfig config = HealthCheckObjectConfig.builder() - .clusterId(1L) - .instanceId(1L) - .healthCheckResourceType("storage") - .healthCheckResourceSubType("redis") - .connectUrl("redis://localhost:6379") - .build(); - healthService.insertCheckService(config); - healthService.executeAll(); - Thread.sleep(1000); - healthService.executeAll(); - - HealthCheckResultEntity queryEntity = new HealthCheckResultEntity(); - queryEntity.setClusterId(1L); - queryEntity.setType(HealthCheckType.STORAGE.getNumber()); - queryEntity.setTypeId(1L); - List results = healthDataService.queryHealthCheckResultByClusterIdAndTypeAndTypeId(queryEntity); - Assertions.assertEquals(2, results.size()); - } -} 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 c52b31a5..47088f01 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 @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.console.linkage.log; import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication; @@ -48,10 +49,10 @@ public void testGroupServiceOprLog() { GroupEntity groupEntity = new GroupEntity(); groupEntity.setClusterId(1L); groupEntity.setName("logTest"); - groupEntity.setStatus(1); + groupEntity.setStatus(1L); groupEntity.setType(0); - groupEntity.setState("OS"); - groupService.insertGroup(groupEntity); + + groupService.addGroup(groupEntity); LogEntity logEntity = new LogEntity(); logEntity.setClusterId(1L); logEntity.setOperationType("add"); @@ -59,7 +60,7 @@ public void testGroupServiceOprLog() { logEntity.setContent(groupEntity.toString()); logEntity.setResult(groupEntity.toString()); logEntity.setId(groupEntity.getId()); - List logListByCluster = logService.selectLogListByCluster(new GetLogListDTO()); + 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/cluster/ClusterDataMapperTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/cluster/ClusterDataMapperTest.java new file mode 100644 index 00000000..fd3a64fa --- /dev/null +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/cluster/ClusterDataMapperTest.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.eventmesh.dashboard.console.mapper.cluster; + +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; + +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; +import org.mapstruct.factory.Mappers; + +@Mapper +public interface ClusterDataMapperTest { + + ClusterDataMapperTest INSTANCE = Mappers.getMapper(ClusterDataMapperTest.class); + + @Mapping(source = "id", target = "clusterId") + RuntimeEntity toRuntimeEntity(ClusterEntity clusterEntity); + +} diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/cluster/ClusterEntityMapperTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/cluster/ClusterEntityMapperTest.java new file mode 100644 index 00000000..03819d3d --- /dev/null +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/cluster/ClusterEntityMapperTest.java @@ -0,0 +1,133 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.eventmesh.dashboard.console.mapper.cluster; + + +import org.apache.eventmesh.dashboard.common.enums.ClusterOwnType; +import org.apache.eventmesh.dashboard.common.enums.ClusterTrusteeshipType; +import org.apache.eventmesh.dashboard.common.enums.ClusterTrusteeshipType.FirstToWhom; +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.common.enums.DeployStatusType; +import org.apache.eventmesh.dashboard.common.enums.ReplicationType; +import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication; +import org.apache.eventmesh.dashboard.console.databuild.BuildFullSceneData; +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.atomic.AtomicLong; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; +import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase.Replace; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.jdbc.Sql; +import org.springframework.test.context.junit4.SpringRunner; + + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = {EventMeshDashboardApplication.class}) +@Sql(scripts = {"classpath:eventmesh-dashboard.sql"}) +@AutoConfigureTestDatabase(replace = Replace.NONE) +public class ClusterEntityMapperTest { + + + @Autowired + private ClusterMapper clusterMapper; + + + @Autowired + private ClusterRelationshipMapper clusterRelationshipMapper; + + private BuildFullSceneData buildFullSceneData = new BuildFullSceneData(); + + private static final AtomicLong nameIndex = new AtomicLong(); + + private ClusterEntity clusterEntity = new ClusterEntity(); + + @Before + public void init() { + this.clusterEntity = createClusterEntity(); + this.clusterMapper.insertCluster(clusterEntity); + } + + public static ClusterEntity createClusterEntity(){ + return createClusterEntity(ClusterType.EVENTMESH_CLUSTER); + } + + public static ClusterEntity createClusterEntity(ClusterType clusterType) { + ClusterEntity clusterEntity = new ClusterEntity(); + clusterEntity.setOrganizationId(1L); + clusterEntity.setName("test-" + nameIndex.incrementAndGet()); + clusterEntity.setClusterType(clusterType); + clusterEntity.setVersion(""); + clusterEntity.setTrusteeshipType(ClusterTrusteeshipType.SELF); + clusterEntity.setFirstToWhom(FirstToWhom.NOT); + clusterEntity.setReplicationType(ReplicationType.NOT); + clusterEntity.setDeployStatusType(DeployStatusType.CREATE_WAIT); + clusterEntity.setClusterOwnType(ClusterOwnType.INDEPENDENCE); + clusterEntity.setResourcesConfigId(1L); + clusterEntity.setDeployScriptId(1L); + + clusterEntity.setDescription(""); + clusterEntity.setConfig(""); + clusterEntity.setAuthType(""); + clusterEntity.setJmxProperties(""); + + return clusterEntity; + } + + + @Test + public void test_queryRelationClusterByClusterIdAndType() { + this.buildFullSceneData.buildReplica(ClusterType.STORAGE_REDIS_CLUSTER); + + } + + @Test + public void test_batch_cluster() { + List clusterEntityList = new ArrayList<>(); + for (int i = 0; i < 10; i++) { + clusterEntityList.add(createClusterEntity()); + } + this.clusterMapper.batchInsert(clusterEntityList); + clusterEntityList.forEach(clusterEntity -> { + ClusterEntity newClusterEntity = this.clusterMapper.queryByClusterId(clusterEntity); + Assert.assertNotNull(newClusterEntity); + }); + List newClusterEntity = this.clusterMapper.queryAllCluster(); + Assert.assertEquals(11, newClusterEntity.size()); + } + + @Test + public void test_insert_cluster() { + ClusterEntity newClusterEntity = this.clusterMapper.queryByClusterId(clusterEntity); + Assert.assertNotNull(newClusterEntity); + } + + public void test_updateNumByClusterId() { + + this.clusterMapper.insertCluster(clusterEntity); + + clusterMapper.updateNumByClusterId(clusterEntity); + } +} diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/cluster/ClusterRelationshipMapperTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/cluster/ClusterRelationshipMapperTest.java new file mode 100644 index 00000000..59b1f73d --- /dev/null +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/cluster/ClusterRelationshipMapperTest.java @@ -0,0 +1,152 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.eventmesh.dashboard.console.mapper.cluster; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication; +import org.apache.eventmesh.dashboard.console.databuild.BuildFullSceneData; +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterRelationshipEntity; +import org.apache.eventmesh.dashboard.console.modle.DO.clusterRelationship.QueryListByClusterIdAndTypeDO; + +import java.time.LocalDateTime; +import java.time.temporal.ChronoUnit; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.atomic.AtomicLong; + +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; +import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase.Replace; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.jdbc.Sql; +import org.springframework.test.context.junit4.SpringRunner; + +import lombok.extern.slf4j.Slf4j; + +@Slf4j +@RunWith(SpringRunner.class) +@SpringBootTest(classes = {EventMeshDashboardApplication.class}) +@Sql(scripts = {"classpath:eventmesh-dashboard.sql"}) +@AutoConfigureTestDatabase(replace = Replace.NONE) +public class ClusterRelationshipMapperTest { + + @Autowired + private ClusterRelationshipMapper clusterRelationshipMapper; + + + @Autowired + private ClusterMapper clusterMapper; + + private BuildFullSceneData buildFullSceneData = new BuildFullSceneData(); + + private static final AtomicLong nameIndex = new AtomicLong(2); + + private ClusterRelationshipEntity clusterRelationshipEntity; + + + @Test + public void test_queryListByClusterIdAndType() { + this.buildFullSceneData.build(ClusterType.EVENTMESH_CLUSTER); + this.clusterMapper.batchInsert(this.buildFullSceneData.getClusterEntityList()); + this.buildFullSceneData.createClusterRelationshipEntity(); + List clusterRelationshipEntityList = this.buildFullSceneData.getClusterRelationshipEntityList(); + + this.clusterRelationshipMapper.batchClusterRelationshipEntry(clusterRelationshipEntityList); + + QueryListByClusterIdAndTypeDO data = new QueryListByClusterIdAndTypeDO(); + data.setClusterId(this.buildFullSceneData.getClusterTripleList().get(0).getLeft().getId()); + List newClusterRelationshipEntityList = this.clusterRelationshipMapper.queryListByClusterIdAndType(data); + + data.setRelationshipTypeList(List.of(ClusterType.EVENTMESH_RUNTIME)); + newClusterRelationshipEntityList = this.clusterRelationshipMapper.queryListByClusterIdAndType(data); + + newClusterRelationshipEntityList.size(); + } + + @Test + public void test_selectNewlyIncreased() { + this.test_batchClusterRelationshipEntry(); + + ClusterRelationshipEntity clusterRelationshipEntity = new ClusterRelationshipEntity(); + clusterRelationshipEntity.setUpdateTime(LocalDateTime.now().plusHours(1L).truncatedTo(ChronoUnit.MILLIS)); + List clusterRelationshipEntityList = + this.clusterRelationshipMapper.queryNewlyIncreased(clusterRelationshipEntity); + Assert.assertEquals(0, clusterRelationshipEntityList.size()); + + clusterRelationshipEntity.setUpdateTime(LocalDateTime.now().minusHours(1L).truncatedTo(ChronoUnit.MILLIS)); + clusterRelationshipEntityList = this.clusterRelationshipMapper.queryNewlyIncreased(clusterRelationshipEntity); + Assert.assertEquals(10, clusterRelationshipEntityList.size()); + } + + @Test + public void test_relieveRelationship() { + this.test_insert_ClusterRelationshipEntry(); + this.clusterRelationshipMapper.relieveRelationship(this.clusterRelationshipEntity); + ClusterRelationshipEntity clusterRelationshipEntity = this.clusterRelationshipMapper.queryById(this.clusterRelationshipEntity); + Assert.assertEquals(3, clusterRelationshipEntity.getStatus(), 1L); + + } + + @Test + public void test_batchClusterRelationshipEntry() { + List clusterRelationshipEntityList = new ArrayList<>(); + for (int i = 0; i < 10; i++) { + clusterRelationshipEntityList.add(this.buildClusterRelationshipEntity()); + } + this.clusterRelationshipMapper.batchClusterRelationshipEntry(clusterRelationshipEntityList); + clusterRelationshipEntityList = this.clusterRelationshipMapper.queryAll(null); + Assert.assertEquals(10, clusterRelationshipEntityList.size()); + + } + + @Test + public void test_insert_ClusterRelationshipEntry() { + clusterRelationshipEntity = this.buildClusterRelationshipEntity(); + this.clusterRelationshipMapper.insertClusterRelationshipEntry(clusterRelationshipEntity); + clusterRelationshipEntity = this.clusterRelationshipMapper.queryById(clusterRelationshipEntity); + Assert.assertNotNull(clusterRelationshipEntity); + } + + public static ClusterRelationshipEntity buildClusterRelationshipEntity(ClusterEntity clusterEntity, ClusterEntity relationshipEntity) { + ClusterRelationshipEntity clusterRelationshipEntity = new ClusterRelationshipEntity(); + clusterRelationshipEntity.setOrganizationId(clusterEntity.getOrganizationId()); + clusterRelationshipEntity.setClusterId(clusterEntity.getId()); + clusterRelationshipEntity.setClusterType(clusterEntity.getClusterType()); + clusterRelationshipEntity.setRelationshipId(relationshipEntity.getId()); + clusterRelationshipEntity.setRelationshipType(relationshipEntity.getClusterType()); + return clusterRelationshipEntity; + + } + + public ClusterRelationshipEntity buildClusterRelationshipEntity() { + ClusterEntity clusterEntity = new ClusterEntity(); + clusterEntity.setOrganizationId(1L); + clusterEntity.setClusterType(ClusterType.EVENTMESH_CLUSTER); + clusterEntity.setId(1L); + ClusterEntity relationshipEntity = new ClusterEntity(); + relationshipEntity.setClusterType(ClusterType.EVENTMESH_RUNTIME); + relationshipEntity.setId(nameIndex.incrementAndGet()); + return buildClusterRelationshipEntity(clusterEntity, relationshipEntity); + } + + +} diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/cluster/RuntimeEntityMapperTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/cluster/RuntimeEntityMapperTest.java new file mode 100644 index 00000000..e14cafde --- /dev/null +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/cluster/RuntimeEntityMapperTest.java @@ -0,0 +1,194 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.eventmesh.dashboard.console.mapper.cluster; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication; +import org.apache.eventmesh.dashboard.console.databuild.BuildFullSceneData; +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; +import org.apache.eventmesh.dashboard.console.modle.DO.runtime.QueryRuntimeByBigExpandClusterDO; + +import org.apache.commons.lang3.tuple.Triple; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.Set; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicLong; +import java.util.concurrent.atomic.AtomicReference; +import java.util.stream.Collectors; + +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; +import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase.Replace; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.jdbc.Sql; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = {EventMeshDashboardApplication.class}) +@Sql(scripts = {"classpath:eventmesh-dashboard.sql"}) +@AutoConfigureTestDatabase(replace = Replace.NONE) +public class RuntimeEntityMapperTest { + + @Autowired + private ClusterMapper clusterMapper; + + @Autowired + private RuntimeMapper runtimeMapper; + + @Autowired + private ClusterRelationshipMapper clusterRelationshipMapper; + + private BuildFullSceneData buildFullSceneData = new BuildFullSceneData(); + + private static final AtomicLong nameIndex = new AtomicLong(2); + + @Test + public void test_queryClusterRuntimeOnClusterSpecifyByClusterId() { + buildFullSceneData.build(ClusterType.EVENTMESH_CLUSTER); + clusterMapper.batchInsert(buildFullSceneData.getClusterEntityList()); + clusterRelationshipMapper.batchClusterRelationshipEntry(buildFullSceneData.createClusterRelationshipEntity()); + runtimeMapper.batchInsert(buildFullSceneData.createRuntimeEntity()); + + buildFullSceneData.getClusterTripleList().forEach(triple -> { + final Set idSet = + buildFullSceneData.getRuntimeEntityList(triple.getRight()).stream().map(RuntimeEntity::getClusterId).collect(Collectors.toSet()); + triple.getMiddle().forEach(entity -> { + test_queryClusterRuntimeOnClusterSpecifyByClusterId(entity, triple.getLeft().getClusterType().getRuntimeClusterType(), idSet); + }); + final Set idSet1 = + buildFullSceneData.getRuntimeEntityList(triple.getMiddle()).stream().map(RuntimeEntity::getClusterId).collect(Collectors.toSet()); + triple.getRight().forEach(entity -> { + test_queryClusterRuntimeOnClusterSpecifyByClusterId(entity, triple.getLeft().getClusterType().getMetaClusterType(), idSet1); + }); + + }); + } + + private void test_queryClusterRuntimeOnClusterSpecifyByClusterId(ClusterEntity clusterEntity, List clusterTypeList, + Set idSet) { + QueryRuntimeByBigExpandClusterDO queryRuntimeByBigExpandClusterDO = + QueryRuntimeByBigExpandClusterDO.builder() + .followClusterId(clusterEntity.getId()) + .queryClusterTypeList(clusterTypeList).build(); + List runtimeEntityList = runtimeMapper.queryClusterRuntimeOnClusterSpecifyByClusterId(queryRuntimeByBigExpandClusterDO); + Set neIdSet = runtimeEntityList.stream().map(RuntimeEntity::getClusterId).collect(Collectors.toSet()); + Assert.assertEquals(idSet, neIdSet); + } + + @Test + public void test_queryRuntimeByBigExpandCluster() { + buildFullSceneData.build(ClusterType.EVENTMESH_CLUSTER); + clusterMapper.batchInsert(buildFullSceneData.getClusterEntityList()); + clusterRelationshipMapper.batchClusterRelationshipEntry(buildFullSceneData.createClusterRelationshipEntity()); + runtimeMapper.batchInsert(buildFullSceneData.createRuntimeEntity()); + + List, List>> triples = + buildFullSceneData.getClusterTripleList(ClusterType.EVENTMESH_CLUSTER); + List allEntityList = new ArrayList<>(); + triples.forEach(triple -> { + AtomicReference> oldRef = new AtomicReference<>(); + triple.getRight().forEach(triple1 -> { + QueryRuntimeByBigExpandClusterDO queryRuntimeByBigExpandClusterDO = + QueryRuntimeByBigExpandClusterDO.builder() + .followClusterId(triple1.getId()) + .mainClusterType(ClusterType.EVENTMESH_CLUSTER) + .storageClusterTypeList(ClusterType.getStorageCluster()) + .storageMetaClusterTypeList(ClusterType.getStorageMetaCluster()) + .build(); + List runtimeEntityList = runtimeMapper.queryRuntimeByBigExpandCluster(queryRuntimeByBigExpandClusterDO); + allEntityList.addAll(runtimeEntityList); + if (Objects.nonNull(oldRef.get())) { + Assert.assertEquals(oldRef.get(), runtimeEntityList); + } + oldRef.set(runtimeEntityList); + }); + + }); + + + } + + + @Test + public void test_queryRuntimeByClusterId() { + buildFullSceneData.build(ClusterType.EVENTMESH_CLUSTER); + clusterMapper.batchInsert(buildFullSceneData.getClusterEntityList()); + + List runtimeEntityList = buildFullSceneData.createRuntimeEntity(); + runtimeMapper.batchInsert(runtimeEntityList); + AtomicInteger atomicInteger = new AtomicInteger(); + List list = new ArrayList<>(); + buildFullSceneData.getClusterTripleList().forEach(triple -> { + List clusterEntityList = new ArrayList<>(); + clusterEntityList.addAll(triple.getMiddle()); + clusterEntityList.addAll(triple.getRight()); + List runtimeEntityList1 = this.runtimeMapper.queryRuntimeByClusterId(clusterEntityList); + list.addAll(runtimeEntityList1); + }); + Assert.assertEquals(list.size(), runtimeEntityList.size()); + } + + + @Test + public void test_batch() { + ClusterEntity clusterEntity = ClusterEntityMapperTest.createClusterEntity(); + clusterEntity.setId(1L); + List runtimeEntityList = new ArrayList<>(); + for (int i = 0; i < 10; i++) { + RuntimeEntity runtimeEntity = createRuntimeEntity(clusterEntity); + runtimeEntityList.add(runtimeEntity); + } + this.runtimeMapper.batchInsert(runtimeEntityList); + runtimeEntityList = this.runtimeMapper.queryAll(); + Assert.assertEquals(10, runtimeEntityList.size()); + } + + @Test + public void test_insert() { + ClusterEntity clusterEntity = ClusterEntityMapperTest.createClusterEntity(); + clusterEntity.setId(1L); + RuntimeEntity runtimeEntity = createRuntimeEntity(clusterEntity); + runtimeEntity.setClusterId(clusterEntity.getId()); + this.runtimeMapper.insertRuntime(runtimeEntity); + runtimeEntity = this.runtimeMapper.queryRuntimeEntityById(runtimeEntity); + + Assert.assertNotNull(runtimeEntity); + this.runtimeMapper.insertRuntime(runtimeEntity); + RuntimeEntity newRuntimeEntity = this.runtimeMapper.queryRuntimeEntityById(runtimeEntity); + // TODO h2 不支持 MySQL ON DUPLICATE KEY UPDATE + //Assert.assertNotEquals(runtimeEntity.getOnlineTimestamp(), newRuntimeEntity.getOnlineTimestamp()); + } + + public static RuntimeEntity createRuntimeEntity(ClusterEntity clusterEntity) { + RuntimeEntity runtimeEntity = ClusterDataMapperTest.INSTANCE.toRuntimeEntity(clusterEntity); + runtimeEntity.setName(nameIndex.incrementAndGet() + "-----runtime"); + runtimeEntity.setHost(nameIndex.incrementAndGet() + ""); + runtimeEntity.setPort((int) nameIndex.get()); + runtimeEntity.setJmxPort((int) nameIndex.get()); + runtimeEntity.setKubernetesClusterId(nameIndex.get()); + return runtimeEntity; + } + +} diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/message/TopicEntityMapperTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/message/TopicEntityMapperTest.java new file mode 100644 index 00000000..a6bfff80 --- /dev/null +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/message/TopicEntityMapperTest.java @@ -0,0 +1,106 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.eventmesh.dashboard.console.mapper.message; + + +import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication; +import org.apache.eventmesh.dashboard.console.entity.message.TopicEntity; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.atomic.AtomicLong; + +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; +import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase.Replace; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.jdbc.Sql; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = {EventMeshDashboardApplication.class}) +@Sql(scripts = {"classpath:eventmesh-dashboard.sql"}) +@AutoConfigureTestDatabase(replace = Replace.NONE) +public class TopicEntityMapperTest { + + @Autowired + private TopicMapper topicMapper; + + private static AtomicLong nameIndex = new AtomicLong(); + + @Test + public void test_batch_delete() { + this.test_batch_insert(); + List topicEntityList = this.topicMapper.selectAll(); + int num = this.topicMapper.deleteTopicByIds(topicEntityList); + Assert.assertEquals(num, topicEntityList.size()); + + List newTopicEntityList = this.topicMapper.selectAll(); + Assert.assertEquals(0, newTopicEntityList.size()); + + } + + @Test + public void test_batch_insert() { + List topicEntityList = new ArrayList<>(); + for (int i = 0; i < 10; i++) { + topicEntityList.add(createTopicEntity()); + } + topicMapper.batchInsert(topicEntityList); + + List newTopicEntityList = this.topicMapper.selectAll(); + Assert.assertEquals(topicEntityList.size(), newTopicEntityList.size()); + } + + @Test + public void test_insertTopic() { + TopicEntity topicEntity = createTopicEntity(); + topicMapper.insertTopic(topicEntity); + + topicEntity = topicMapper.queryTopicById(topicEntity); + Assert.assertNotNull(topicEntity); + + } + + + public static TopicEntity createTopicEntity() { + return createTopicEntity(1L, 2L); + } + + public static TopicEntity createTopicEntity(Long clusterId, Long topicId) { + TopicEntity topicEntity = new TopicEntity(); + topicEntity.setClusterId(1L); + topicEntity.setRuntimeId(2L); + topicEntity.setTopicName("test-" + nameIndex.getAndIncrement()); + topicEntity.setTopicType("topicType"); + topicEntity.setNumQueue(8L); + topicEntity.setReplicationFactor(2); + topicEntity.setTopicFilterType("topicFilterType"); + topicEntity.setAttributes("1"); + topicEntity.setOrder("desc"); + topicEntity.setRetentionMs(1L); + topicEntity.setDescription("desc"); + topicEntity.setCreateProgress(1); + return topicEntity; + } + + +} diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/model/domain/ClusterMetadataDomainTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/model/domain/ClusterMetadataDomainTest.java new file mode 100644 index 00000000..a4a186e4 --- /dev/null +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/model/domain/ClusterMetadataDomainTest.java @@ -0,0 +1,218 @@ +/* + * 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.model.domain; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.console.domain.metadata.ClusterMetadataDomain; +import org.apache.eventmesh.dashboard.console.domain.metadata.ClusterMetadataDomain.DataHandler; +import org.apache.eventmesh.dashboard.console.domain.metadata.MetadataAllDO; +import org.apache.eventmesh.dashboard.console.entity.base.BaseIdEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterRelationshipEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; +import org.apache.eventmesh.dashboard.core.cluster.ClusterBaseDO; +import org.apache.eventmesh.dashboard.core.cluster.ColonyDO; +import org.apache.eventmesh.dashboard.core.cluster.RuntimeBaseDO; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.Random; +import java.util.concurrent.atomic.AtomicLong; + +import org.junit.Before; +import org.junit.Test; + +public class ClusterMetadataDomainTest { + + public ClusterMetadataDomain clusterMetadataDomain = new ClusterMetadataDomain(); + + private MetadataAllDO metadataAllDO; + + private MetadataAllDO deleteMetadataAllDO; + + private ClusterEntity clusterEntity = new ClusterEntity(); + + private List clusterEntityList = new ArrayList<>(); + + private List clusterRelationshipEntityList = new ArrayList<>(); + + private List runtimeEntityList = new ArrayList<>(); + + private AtomicLong atomicLong = new AtomicLong(1L); + + + @Before + public void init() { + clusterMetadataDomain.rootClusterDHO(); + clusterMetadataDomain.useBuildConfig(); + clusterMetadataDomain.isConsoleModel(); + clusterMetadataDomain.setHandler(new DataHandler() { + @Override + public void registerRuntime(RuntimeEntity runtimeEntity, RuntimeBaseDO runtimeBaseDO, ColonyDO colonyDO) { + ClusterType clusterType = runtimeEntity.getClusterType(); + System.out.println("registerRuntime clusterType : " + clusterType); + } + + @Override + public void unRegisterRuntime(RuntimeEntity runtimeEntity, RuntimeBaseDO runtimeBaseDO, ColonyDO colonyDO) { + ClusterType clusterType = runtimeEntity.getClusterType(); + System.out.println("unRegisterRuntime clusterType : " + clusterType); + } + + @Override + public void registerCluster(ClusterEntity clusterEntity, ClusterBaseDO clusterBaseDO, ColonyDO colonyDO) { + ClusterType clusterType = clusterEntity.getClusterType(); + System.out.println("registerCluster clusterType : " + clusterType); + } + + @Override + public void unRegisterCluster(ClusterEntity clusterEntity, ClusterBaseDO clusterBaseDO, ColonyDO colonyDO) { + ClusterType clusterType = clusterEntity.getClusterType(); + System.out.println("clusterType clusterType : " + clusterType); + } + }); + metadataAllDO = + MetadataAllDO.builder().clusterEntityList(clusterEntityList).clusterRelationshipEntityList(clusterRelationshipEntityList) + .runtimeEntityList(runtimeEntityList).build(); + this.test_EventMesh_Cluster(); + } + + public Long getId() { + return atomicLong.getAndIncrement(); + } + + private void handler() { + this.clusterMetadataDomain.handlerMetadata(this.metadataAllDO); + this.randomDelete(); + } + + private void randomDelete() { + + deleteMetadataAllDO = + MetadataAllDO.builder() + .runtimeEntityList(this.deleteEntity(this.runtimeEntityList)).build(); + this.clusterMetadataDomain.handlerMetadata(this.deleteMetadataAllDO); + + deleteMetadataAllDO = + MetadataAllDO.builder() + .clusterEntityList(this.deleteEntity(this.clusterEntityList)).build(); + this.clusterMetadataDomain.handlerMetadata(this.deleteMetadataAllDO); + + } + + private T deleteEntity(Object object) { + List baseIdEntities = (List) object; + Random random = new Random(); + List deleteBaseIdEntity = new ArrayList<>(); + baseIdEntities.forEach((value) -> { + if (random.nextInt(100) < 10) { + value.setStatus(0L); + deleteBaseIdEntity.add(value); + } + }); + return (T) deleteBaseIdEntity; + } + + private void createClusterRelationshipEntity(ClusterEntity mainCluster, ClusterEntity clusterEntity) { + ClusterRelationshipEntity clusterRelationshipEntity = new ClusterRelationshipEntity(); + clusterRelationshipEntity.setClusterId(mainCluster.getId()); + clusterRelationshipEntity.setClusterType(mainCluster.getClusterType()); + + clusterRelationshipEntity.setRelationshipId(clusterEntity.getId()); + clusterRelationshipEntity.setRelationshipType(clusterEntity.getClusterType()); + this.clusterRelationshipEntityList.add(clusterRelationshipEntity); + } + + @Test + public void test_EventMesh_Cluster() { + + clusterEntity.setId(this.getId()); + clusterEntity.setClusterType(ClusterType.EVENTMESH_CLUSTER); + clusterEntityList.add(clusterEntity); + + this.createCluster(clusterEntity, ClusterType.EVENTMESH_META_NACOS); + this.createCluster(clusterEntity, ClusterType.EVENTMESH_META_NACOS); + + this.createCluster(clusterEntity, ClusterType.EVENTMESH_RUNTIME); + this.createCluster(clusterEntity, ClusterType.EVENTMESH_RUNTIME); + + } + + public void createRuntime(ClusterEntity cluster) { + for (int i = 0; i < 5; i++) { + RuntimeEntity runtimeEntity = new RuntimeEntity(); + runtimeEntity.setId(this.getId()); + runtimeEntity.setClusterId(cluster.getId()); + runtimeEntity.setClusterType(cluster.getClusterType()); + runtimeEntity.setStatus(1L); + this.runtimeEntityList.add(runtimeEntity); + } + } + + @Test + public void test_RockerMQ_Cluster() { + ClusterEntity clusterEntity = this.createCluster(this.clusterEntity, ClusterType.STORAGE_ROCKETMQ_CLUSTER); + + this.createCluster(clusterEntity, ClusterType.STORAGE_ROCKETMQ_NAMESERVER); + this.createCluster(clusterEntity, ClusterType.STORAGE_ROCKETMQ_NAMESERVER); + + // 创建 broker cluster + + ClusterEntity runtimeCluster = this.createCluster(clusterEntity, ClusterType.STORAGE_ROCKETMQ_BROKER); + this.createCluster(runtimeCluster, ClusterType.STORAGE_ROCKETMQ_BROKER_MAIN_SLAVE); + this.createCluster(runtimeCluster, ClusterType.STORAGE_ROCKETMQ_BROKER_MAIN_SLAVE); + + // 创建 broker cluster + runtimeCluster = this.createCluster(clusterEntity, ClusterType.STORAGE_ROCKETMQ_BROKER); + this.createCluster(runtimeCluster, ClusterType.STORAGE_ROCKETMQ_BROKER_MAIN_SLAVE); + this.createCluster(runtimeCluster, ClusterType.STORAGE_ROCKETMQ_BROKER_MAIN_SLAVE); + + this.handler(); + + } + + @Test + public void test_Kafka_Cluster() { + ClusterEntity clusterEntity = this.createCluster(this.clusterEntity, ClusterType.STORAGE_KAFKA_CLUSTER); + + this.createCluster(clusterEntity, ClusterType.STORAGE_KAFKA_ZK); + + // 创建 broker cluster + this.createCluster(clusterEntity, ClusterType.STORAGE_KAFKA_BROKER); + this.handler(); + } + + public ClusterEntity createCluster(ClusterEntity mainCluster, ClusterType clusterType) { + ClusterEntity clusterEntity = new ClusterEntity(); + clusterEntity.setId(this.getId()); + clusterEntity.setClusterType(clusterType); + clusterEntity.setStatus(1L); + clusterEntityList.add(clusterEntity); + this.createClusterRelationshipEntity(mainCluster, clusterEntity); + if (!Objects.equals(clusterType.getAssemblyBusiness(), ClusterType.DEFINITION)) { + this.createRuntime(clusterEntity); + } + return clusterEntity; + } + + private static class TestDataWrapper { + + } +} diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/service/cluster/impl/ClusterEntityServiceImplTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/service/cluster/impl/ClusterEntityServiceImplTest.java new file mode 100644 index 00000000..83dd4e0c --- /dev/null +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/service/cluster/impl/ClusterEntityServiceImplTest.java @@ -0,0 +1,102 @@ +/* + * 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.cluster.impl; + +import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication; +import org.apache.eventmesh.dashboard.console.service.cluster.ClusterService; + +import org.junit.Before; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = EventMeshDashboardApplication.class) +public class ClusterEntityServiceImplTest { + + @Autowired + private ClusterService clusterService; + + + @Before + public void nameExist() { + } + + public void queryClusterById() { + } + + public void queryClusterByOrganizationIdAndType() { + } + + + public void queryRelationClusterByClusterIdAndType() { + } + + public void queryRelationshipClusterByClusterIdAndType() { + } + + public void queryStorageByClusterId() { + } + + public void queryAllSubClusterByClusterId() { + } + + public void createCluster() { + } + + public void getClusterBaseMessage() { + } + + + public void queryHomeClusterData() { + } + + public void batchInsert() { + } + + public void selectAll() { + } + + public void selectNewlyIncreased() { + } + + void insertCluster() { + } + + void insertClusterAndRelationship() { + } + + public void selectAllCluster() { + } + + + public void updateClusterById() { + } + + public void deactivate() { + } + + public void queryByUpdateTime() { + } + + public void getIndex() { + } + + +} diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/service/connection/impl/ConnectionDataServiceDatabaseImplTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/service/connection/impl/ConnectionDataServiceDatabaseImplTest.java index 0884b5cf..1b98ef9c 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/service/connection/impl/ConnectionDataServiceDatabaseImplTest.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/service/connection/impl/ConnectionDataServiceDatabaseImplTest.java @@ -15,18 +15,11 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.service.connection.impl; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import org.apache.eventmesh.dashboard.console.entity.cluster.ConnectionEntity; -import org.apache.eventmesh.dashboard.console.service.cluster.impl.ConnectionDataServiceDatabaseImpl; -import java.util.List; +package org.apache.eventmesh.dashboard.console.service.connection.impl; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.jdbc.Sql; @@ -39,18 +32,14 @@ @SpringBootTest public class ConnectionDataServiceDatabaseImplTest { - @Autowired - private ConnectionDataServiceDatabaseImpl connectionServiceDatabaseImpl; @Test public void testGetAllConnectionsByClusterId() { - List connectionEntityList = connectionServiceDatabaseImpl.getAllConnectionsByClusterId(1L); - assertEquals(3, connectionEntityList.size()); + } @Test public void testGetAllConnections() { - List connectionEntityList = connectionServiceDatabaseImpl.getAllConnections(); - assertEquals(6, connectionEntityList.size()); + } -} +} \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/spring/support/DefaultDataHandlerTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/spring/support/DefaultDataHandlerTest.java new file mode 100644 index 00000000..cad7767b --- /dev/null +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/spring/support/DefaultDataHandlerTest.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.spring.support; + + +import org.apache.eventmesh.dashboard.console.model.domain.ClusterMetadataDomainTest; + +import org.junit.Test; + +public class DefaultDataHandlerTest { + + private ClusterMetadataDomainTest clusterMetadataDomainTest = new ClusterMetadataDomainTest(); + + @Test + public void test() { + clusterMetadataDomainTest.clusterMetadataDomain.rootClusterDHO(); + } +} diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/spring/support/FunctionManagerTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/spring/support/FunctionManagerTest.java deleted file mode 100644 index 5a1b63c2..00000000 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/spring/support/FunctionManagerTest.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.console.spring.support; - -import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication; -import org.apache.eventmesh.dashboard.console.function.health.CheckResultCache; -import org.apache.eventmesh.dashboard.console.function.health.HealthService; -import org.apache.eventmesh.dashboard.console.function.metadata.syncservice.SyncDataServiceWrapper; -import org.apache.eventmesh.dashboard.console.service.DataServiceWrapper; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.junit.jupiter.MockitoExtension; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.jdbc.Sql; -import org.springframework.test.context.junit.jupiter.SpringExtension; - -import lombok.extern.slf4j.Slf4j; - -@Slf4j -@ExtendWith(MockitoExtension.class) -@ExtendWith(SpringExtension.class) -@ActiveProfiles("test") -@SpringBootTest(classes = EventMeshDashboardApplication.class) -@Sql(executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, scripts = {"classpath:use-test-schema.sql", "classpath:eventmesh-dashboard.sql"}) -//We don't have runtime and topic check for now, so runtime-test.sql and topic-test.sql is not used -@Sql(executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD, scripts = {"classpath:client-test.sql", "classpath:connection-test.sql", - "classpath:connector-test.sql", "classpath:meta-test.sql", "classpath:store-test.sql"}) -class FunctionManagerTest { - - @Autowired - private DataServiceWrapper dataServiceWrapper; - - @Autowired - private SyncDataServiceWrapper syncDataServiceWrapper; - - private FunctionManager functionManager; - - private HealthService healthService; - - @BeforeEach - void setUpData() { - functionManager = new FunctionManager(); - FunctionManagerProperties properties = new FunctionManagerProperties(); - properties.setDataServiceContainer(dataServiceWrapper); - properties.setSyncDataServiceWrapper(syncDataServiceWrapper); - - functionManager.setProperties(properties); - healthService = new HealthService(); - healthService.createExecutor(properties.getDataServiceContainer().getHealthDataService(), CheckResultCache.getINSTANCE()); - functionManager.setHealthService(healthService); - } - - @Test - void testHealthCheck() { - functionManager.getHealthService().updateHealthCheckConfigs(dataServiceWrapper); - healthService.executeAll(); - healthService.executeAll(); - Assertions.assertNotEquals(4, dataServiceWrapper.getHealthDataService().selectAll().size()); - } -} \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/spring/support/RuntimeDeployServiceTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/spring/support/RuntimeDeployServiceTest.java new file mode 100644 index 00000000..011a798f --- /dev/null +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/spring/support/RuntimeDeployServiceTest.java @@ -0,0 +1,171 @@ +/* + * 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.spring.support; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.common.enums.DeployStatusType; +import org.apache.eventmesh.dashboard.console.entity.cases.DeployScriptEntity; +import org.apache.eventmesh.dashboard.console.entity.cases.ResourcesConfigEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; +import org.apache.eventmesh.dashboard.console.entity.function.ConfigEntity; +import org.apache.eventmesh.dashboard.console.service.cluster.ClusterRelationshipService; +import org.apache.eventmesh.dashboard.console.service.cluster.ClusterService; +import org.apache.eventmesh.dashboard.console.service.cluster.RuntimeService; +import org.apache.eventmesh.dashboard.console.service.connector.ResourcesConfigService; +import org.apache.eventmesh.dashboard.console.service.deploy.DeployScriptService; +import org.apache.eventmesh.dashboard.console.service.deploy.PortService; +import org.apache.eventmesh.dashboard.console.service.function.ConfigService; +import org.apache.eventmesh.dashboard.console.spring.support.RuntimeDeployService.AbstractRuntimeServiceTask; +import org.apache.eventmesh.dashboard.core.function.SDK.SDKManage; + +import org.apache.commons.lang3.reflect.FieldUtils; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.MockedStatic; +import org.mockito.Mockito; +import org.mockito.junit.MockitoJUnitRunner; + +import io.fabric8.kubernetes.client.KubernetesClient; +import io.micrometer.core.instrument.util.IOUtils; + +@RunWith(MockitoJUnitRunner.class) +public class RuntimeDeployServiceTest { + + + private RuntimeDeployService runtimeDeployService = new RuntimeDeployService(); + + + @Mock + private ClusterService clusterService; + + @Mock + private RuntimeService runtimeService; + + @Mock + private ClusterRelationshipService clusterRelationshipService; + + @Mock + private DeployScriptService deployScriptService; + + @Mock + private ResourcesConfigService resourcesConfigService; + + @Mock + private ConfigService configService; + + + private RuntimeEntity runtimeEntity = new RuntimeEntity(); + + private MockedStatic sdkManageMockedStatic; + + @Mock + private SDKManage sdkManageMock; + + @Mock + private KubernetesClient kubernetesClient; + + @Mock + private PortService portService; + + + @Before + public void init() throws IllegalAccessException { + runtimeEntity.setClusterId(10L); + runtimeEntity.setId(10000L); + + FieldUtils.writeField(runtimeDeployService, "clusterService", clusterService, true); + FieldUtils.writeField(runtimeDeployService, "runtimeService", runtimeService, true); + FieldUtils.writeField(runtimeDeployService, "clusterRelationshipService", clusterRelationshipService, true); + FieldUtils.writeField(runtimeDeployService, "deployScriptService", deployScriptService, true); + FieldUtils.writeField(runtimeDeployService, "resourcesConfigService", resourcesConfigService, true); + FieldUtils.writeField(runtimeDeployService, "configService", configService, true); + FieldUtils.writeField(runtimeDeployService, "portService", portService, true); + + sdkManageMockedStatic = Mockito.mockStatic(SDKManage.class); + sdkManageMockedStatic.when(SDKManage::getInstance).thenReturn(sdkManageMock); + + Mockito.when(sdkManageMock.getClient(Mockito.any(), Mockito.any())).thenReturn(kubernetesClient); + + + } + + + @Test + public void test_CREATE_WAIT() throws IllegalAccessException { + ClusterEntity clusterEntity = new ClusterEntity(); + clusterEntity.setId(1L); + Mockito.when(clusterService.queryClusterById(Mockito.any())).thenReturn(clusterEntity); + + ClusterEntity kubeClusterEntity = new ClusterEntity(); + kubeClusterEntity.setId(2L); + Mockito.when(clusterService.queryRelationshipClusterByClusterIdAndType(Mockito.any())).thenReturn(kubeClusterEntity); + + ResourcesConfigEntity resourcesConfigEntity = new ResourcesConfigEntity(); + resourcesConfigEntity.setCpuNum(1F); + resourcesConfigEntity.setMemNum(2F); + resourcesConfigEntity.setDiskNum(3F); + Mockito.when(resourcesConfigService.queryResourcesById(Mockito.any())).thenReturn(resourcesConfigEntity); + + DeployScriptEntity deployScriptEntity = new DeployScriptEntity(); + deployScriptEntity.setId(1L); + String content = IOUtils.toString(RuntimeDeployServiceTest.class.getResourceAsStream("/kubernetes/EventMesh-runtime.yaml")); + deployScriptEntity.setContent(content); + Mockito.when(deployScriptService.queryById(Mockito.any())).thenReturn(deployScriptEntity); + + Mockito.when(portService.getPorts(Mockito.any())).thenReturn(List.of(100 + "", 101 + "", 102 + "", 103 + "")); + + List configEntityList = new ArrayList<>(); + for (int i = 1; i <= 30; i++) { + ConfigEntity configEntity = new ConfigEntity(); + configEntity.setConfigName("config" + i); + configEntity.setConfigValue("config" + i); + configEntityList.add(configEntity); + } + Mockito.when(configService.queryByClusterAndInstanceId(Mockito.any())).thenReturn(configEntityList); + + runtimeEntity.setClusterType(ClusterType.EVENTMESH_RUNTIME); + runtimeEntity.setDeployStatusType(DeployStatusType.CREATE_WAIT); + AbstractRuntimeServiceTask abstractRuntimeServiceTask = runtimeDeployService.createTask(runtimeEntity); + FieldUtils.writeField(abstractRuntimeServiceTask, "runtimeEntity", runtimeEntity, true); + abstractRuntimeServiceTask.run(); + } + + @Test + public void test_CREATE_UNINSTALL() throws IllegalAccessException { + ClusterEntity clusterEntity = new ClusterEntity(); + clusterEntity.setId(1L); + Mockito.when(clusterService.queryClusterById(Mockito.any())).thenReturn(clusterEntity); + + ClusterEntity kubeClusterEntity = new ClusterEntity(); + kubeClusterEntity.setId(2L); + Mockito.when(clusterService.queryRelationshipClusterByClusterIdAndType(Mockito.any())).thenReturn(kubeClusterEntity); + + runtimeEntity.setClusterType(ClusterType.EVENTMESH_RUNTIME); + runtimeEntity.setDeployStatusType(DeployStatusType.UNINSTALL); + AbstractRuntimeServiceTask abstractRuntimeServiceTask = runtimeDeployService.createTask(runtimeEntity); + FieldUtils.writeField(abstractRuntimeServiceTask, "runtimeEntity", runtimeEntity, true); + abstractRuntimeServiceTask.run(); + } +} diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/spring/support/metadata/convert/RuntimeConvertMetaDataTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/spring/support/metadata/convert/RuntimeConvertMetaDataTest.java new file mode 100644 index 00000000..345861e8 --- /dev/null +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/spring/support/metadata/convert/RuntimeConvertMetaDataTest.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.spring.support.metadata.convert; + +import org.apache.eventmesh.dashboard.common.model.ConvertMetaData; +import org.apache.eventmesh.dashboard.common.model.metadata.RuntimeMetadata; +import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; + +import org.junit.Test; + +public class RuntimeConvertMetaDataTest { + + + @Test + public void test() { + ConvertMetaData convertMetaData = RuntimeConvertMetaData.INSTANCE; + RuntimeEntity runtimeEntity = new RuntimeEntity(); + runtimeEntity.setId(1L); + runtimeEntity.setName("test"); + runtimeEntity.setClusterId(2L); + RuntimeMetadata runtimeMetadata = convertMetaData.toMetaData(runtimeEntity); + System.out.println(runtimeMetadata); + } +} diff --git a/eventmesh-dashboard-console/src/test/resources/acl-test.sql b/eventmesh-dashboard-console/src/test/resources/acl-test.sql index 5352e477..90c5838f 100644 --- a/eventmesh-dashboard-console/src/test/resources/acl-test.sql +++ b/eventmesh-dashboard-console/src/test/resources/acl-test.sql @@ -15,6 +15,7 @@ * limitations under the License. */ + INSERT INTO eventmesh_dashboard_test.acl (id, cluster_id, pattern, operation, permission_type, host, resource_type, resource_name, pattern_type, create_time, update_time) VALUES (3, 0, '', 0, '0', '', '0', 'source_name', 1, '2024-03-27 13:22:36', '2024-03-27 14:12:07'); diff --git a/eventmesh-dashboard-console/src/test/resources/application-test.yml b/eventmesh-dashboard-console/src/test/resources/application-test.yml index 0b8c0387..3c70abbe 100644 --- a/eventmesh-dashboard-console/src/test/resources/application-test.yml +++ b/eventmesh-dashboard-console/src/test/resources/application-test.yml @@ -15,26 +15,13 @@ # limitations under the License. # + spring: datasource: - name: eventmesh-console - type: com.alibaba.druid.pool.DruidDataSource - druid: - driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://${DB_ADDRESS:localhost:3306}/eventmesh_dashboard_test?useSSL=false&useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&zeroDateTimeBehavior=convertToNull&allowPublicKeyRetrieval=true - username: ${DB_USERNAME:root} - password: ${DB_PASSWORD:password} - - initial-size: 1 - max-active: 50 - min-idle: 5 - max-wait: 6000 - validation-query: select 'x' - validation-query-timeout: 15 - test-on-borrow: false - test-while-idle: true - min-evictable-idle-time-millis: 300000 - + url: jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1;TIMEZONE=UTC # 内存模式,禁止自动关闭 + driver-class-name: org.h2.Driver + username: sa + password: "" logging: level: - root: INFO \ No newline at end of file + root: INFO diff --git a/eventmesh-dashboard-console/src/test/resources/client-test.sql b/eventmesh-dashboard-console/src/test/resources/client-test.sql index 4a652f81..30c1afa5 100644 --- a/eventmesh-dashboard-console/src/test/resources/client-test.sql +++ b/eventmesh-dashboard-console/src/test/resources/client-test.sql @@ -15,6 +15,7 @@ * limitations under the License. */ + DELETE FROM `eventmesh_dashboard_test`.client WHERE TRUE; diff --git a/eventmesh-dashboard-console/src/test/resources/connection-test.sql b/eventmesh-dashboard-console/src/test/resources/connection-test.sql index b52a19b6..8c4d135b 100644 --- a/eventmesh-dashboard-console/src/test/resources/connection-test.sql +++ b/eventmesh-dashboard-console/src/test/resources/connection-test.sql @@ -15,6 +15,7 @@ * limitations under the License. */ + DELETE FROM `eventmesh_dashboard_test`.connection WHERE TRUE; diff --git a/eventmesh-dashboard-console/src/test/resources/connector-test.sql b/eventmesh-dashboard-console/src/test/resources/connector-test.sql index 52cc0abd..2f294ecb 100644 --- a/eventmesh-dashboard-console/src/test/resources/connector-test.sql +++ b/eventmesh-dashboard-console/src/test/resources/connector-test.sql @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + DELETE FROM `eventmesh_dashboard_test`.connection WHERE TRUE; diff --git a/eventmesh-dashboard-console/src/test/resources/health-test.sql b/eventmesh-dashboard-console/src/test/resources/health-test.sql index 26400206..7a6875e3 100644 --- a/eventmesh-dashboard-console/src/test/resources/health-test.sql +++ b/eventmesh-dashboard-console/src/test/resources/health-test.sql @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + DELETE FROM `eventmesh_dashboard_test`.health_check_result WHERE TRUE; ALTER TABLE `eventmesh_dashboard_test`.health_check_result AUTO_INCREMENT = 1; diff --git a/eventmesh-dashboard-console/src/test/resources/instance-user-test.sql b/eventmesh-dashboard-console/src/test/resources/instance-user-test.sql index 2a4b47ba..4c26a19d 100644 --- a/eventmesh-dashboard-console/src/test/resources/instance-user-test.sql +++ b/eventmesh-dashboard-console/src/test/resources/instance-user-test.sql @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + DELETE FROM `eventmesh_dashboard_test`.instance_user WHERE TRUE; ALTER TABLE `eventmesh_dashboard_test`.instance_user AUTO_INCREMENT = 1; diff --git a/eventmesh-dashboard-console/src/test/resources/kubernetes/EventMesh-runtime-refer.yaml b/eventmesh-dashboard-console/src/test/resources/kubernetes/EventMesh-runtime-refer.yaml new file mode 100644 index 00000000..3628a86f --- /dev/null +++ b/eventmesh-dashboard-console/src/test/resources/kubernetes/EventMesh-runtime-refer.yaml @@ -0,0 +1,63 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: eventmesh-runtime + labels: + app: eventmesh +spec: + replicas: 2 + selector: + matchLabels: + app: eventmesh-runtime + template: + metadata: + labels: + app: eventmesh-runtime + spec: + containers: + - name: eventmesh-container + image: apache/eventmesh-runtime:latest + ports: + - containerPort: 10000 # HTTP API 端口 + - containerPort: 10105 # gRPC 端口 + - containerPort: 10111 # tcp 端口 + - containerPort: 11111 # admin 端口 + env: + - name: EVENTMESH_STORAGE_TYPE + value: "rocketmq" # 指定事件存储类型(如 RocketMQ/Kafka) + - name: ROCKETMQ_NAMESRV_ADDR + value: "rocketmq-namesrv:9876" # 中间件地址 + volumeMounts: + - name: eventmesh-config + mountPath: /eventmesh/conf + volumes: + - name: eventmesh-config + configMap: + name: eventmesh-config + +--- +apiVersion: v1 +kind: Service +metadata: + name: eventmesh-service +spec: + type: LoadBalancer + ports: + - name: admin + port: 11111 + targetPort: 11111 + protocol: TCP + - name: TCP + port: 10111 + targetPort: 10111 + protocol: TCP + - name: http + port: 10000 + targetPort: 10000 + protocol: TCP + - name: grpc + port: 10105 + targetPort: 10105 + protocol: TCP + selector: + app: eventmesh-runtime diff --git a/eventmesh-dashboard-console/src/test/resources/kubernetes/EventMesh-runtime.yaml b/eventmesh-dashboard-console/src/test/resources/kubernetes/EventMesh-runtime.yaml new file mode 100644 index 00000000..9429cd39 --- /dev/null +++ b/eventmesh-dashboard-console/src/test/resources/kubernetes/EventMesh-runtime.yaml @@ -0,0 +1,60 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: ${name} + namespace: ${namespace} + labels: + app: eventmesh +spec: + replicas: 1 + selector: + matchLabels: + app: ${name} + template: + metadata: + labels: + app: ${name} + spec: + containers: + - name: eventmesh-container + image: apache/eventmesh-runtime:latest + ports: + - containerPort: 10000 # HTTP API 端口 + - containerPort: 10105 # gRPC 端口 + - containerPort: 10111 # tcp 端口 + - containerPort: 11111 # admin 端口 + env: + - name: EVENTMESH_STORAGE_TYPE + value: "rocketmq" # 指定事件存储类型(如 RocketMQ/Kafka) + - name: ROCKETMQ_NAMESRV_ADDR + value: "rocketmq-namesrv:9876" # 中间件地址 + - name: CONFIG + value: "${runtimeConfig}" + +--- +apiVersion: v1 +kind: Service +metadata: + name: ${name}-service + namespace: ${namespace} +spec: + type: LoadBalancer + ports: + - name: admin + port: ${adminPort} + targetPort: 11111 + protocol: TCP + - name: TCP + port: ${tcpPort} + targetPort: 10111 + protocol: TCP + - name: http + port: ${httpPort} + targetPort: 10000 + protocol: TCP + - name: grpc + port: ${grpcPort} + targetPort: 10105 + protocol: TCP + selector: + app: ${name} diff --git a/eventmesh-dashboard-console/src/test/resources/kubernetes/RocketMQ-broker-refer.yaml b/eventmesh-dashboard-console/src/test/resources/kubernetes/RocketMQ-broker-refer.yaml new file mode 100644 index 00000000..0461ab4d --- /dev/null +++ b/eventmesh-dashboard-console/src/test/resources/kubernetes/RocketMQ-broker-refer.yaml @@ -0,0 +1,39 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app: rocketmq-broker + name: rocketmq-broker + namespace: default +spec: + replicas: 1 + selector: + matchLabels: + app: rocketmq-broker + template: + metadata: + labels: + app: rocketmq-broker + spec: + containers: + - env: + - name: NAMESRV_ADDR #通过环境变量指定namesrv 地址,注意该值为namesrv svc地址 + value: rocketmq-dialevoneid:9876 + image: rocketmqinc/rocketmq:4.4.0 + command: ["/bin/sh","mqbroker"] + name: rocketmq-broker + ports: + - containerPort: 10909 + name: tcp-10909 + protocol: TCP + - containerPort: 10911 + name: tcp-10911 + protocol: TCP + - containerPort: 10912 + name: tcp-10912 + protocol: TCP + resources: + limits: + memory: 1200Mi + requests: + memory: 1200Mi \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/test/resources/kubernetes/RocketMQ-broker.yaml b/eventmesh-dashboard-console/src/test/resources/kubernetes/RocketMQ-broker.yaml new file mode 100644 index 00000000..3846b1a6 --- /dev/null +++ b/eventmesh-dashboard-console/src/test/resources/kubernetes/RocketMQ-broker.yaml @@ -0,0 +1,39 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app: rocketmq-broker + name: rocketmq-broker + namespace: default +spec: + replicas: 1 + selector: + matchLabels: + app: rocketmq-broker + template: + metadata: + labels: + app: rocketmq-broker + spec: + containers: + - env: + - name: ${metaAddress} #通过环境变量指定namesrv 地址,注意该值为namesrv svc地址 + value: rocketmq-dialevoneid:9876 + image: rocketmqinc/rocketmq:4.4.0 + command: ["/bin/sh","mqbroker"] + name: rocketmq-broker + ports: + - containerPort: ${prot1} + name: tcp-10909 + protocol: TCP + - containerPort: ${prot2} + name: tcp-10911 + protocol: TCP + - containerPort: ${prot3} + name: tcp-10912 + protocol: TCP + resources: + limits: + memory: 1200Mi + requests: + memory: 1200Mi \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/test/resources/kubernetes/RocketMQ-nameservice-refer.yaml b/eventmesh-dashboard-console/src/test/resources/kubernetes/RocketMQ-nameservice-refer.yaml new file mode 100644 index 00000000..e31876b9 --- /dev/null +++ b/eventmesh-dashboard-console/src/test/resources/kubernetes/RocketMQ-nameservice-refer.yaml @@ -0,0 +1,30 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app: rocketmq-namesrv + name: rocketmq-namesrv + namespace: default +spec: + replicas: 1 + selector: + matchLabels: + app: rocketmq-namesrv + template: + metadata: + labels: + app: rocketmq-namesrv + spec: + containers: + - image: rocketmqinc/rocketmq:4.4.0 + name: rockermq-namesrv + command: ["/bin/sh","mqnamesrv"] + ports: + - containerPort: 9876 + name: tcp-9876 + protocol: TCP + resources: + limits: + memory: 600Mi + requests: + memory: 600Mi \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/test/resources/kubernetes/RocketMQ-nameservice.yaml b/eventmesh-dashboard-console/src/test/resources/kubernetes/RocketMQ-nameservice.yaml new file mode 100644 index 00000000..e31876b9 --- /dev/null +++ b/eventmesh-dashboard-console/src/test/resources/kubernetes/RocketMQ-nameservice.yaml @@ -0,0 +1,30 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app: rocketmq-namesrv + name: rocketmq-namesrv + namespace: default +spec: + replicas: 1 + selector: + matchLabels: + app: rocketmq-namesrv + template: + metadata: + labels: + app: rocketmq-namesrv + spec: + containers: + - image: rocketmqinc/rocketmq:4.4.0 + name: rockermq-namesrv + command: ["/bin/sh","mqnamesrv"] + ports: + - containerPort: 9876 + name: tcp-9876 + protocol: TCP + resources: + limits: + memory: 600Mi + requests: + memory: 600Mi \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/test/resources/meta-test.sql b/eventmesh-dashboard-console/src/test/resources/meta-test.sql index 580e67b4..8b9180af 100644 --- a/eventmesh-dashboard-console/src/test/resources/meta-test.sql +++ b/eventmesh-dashboard-console/src/test/resources/meta-test.sql @@ -15,6 +15,7 @@ * limitations under the License. */ + DELETE FROM `eventmesh_dashboard_test`.meta WHERE TRUE; ALTER TABLE `eventmesh_dashboard_test`.meta AUTO_INCREMENT = 1; diff --git a/eventmesh-dashboard-console/src/test/resources/runtime-test.sql b/eventmesh-dashboard-console/src/test/resources/runtime-test.sql index 16951243..39095b4b 100644 --- a/eventmesh-dashboard-console/src/test/resources/runtime-test.sql +++ b/eventmesh-dashboard-console/src/test/resources/runtime-test.sql @@ -15,6 +15,7 @@ * limitations under the License. */ + DELETE FROM `eventmesh_dashboard_test`.runtime WHERE TRUE; ALTER TABLE `eventmesh_dashboard_test`.runtime AUTO_INCREMENT = 1; diff --git a/eventmesh-dashboard-console/src/test/resources/store-test.sql b/eventmesh-dashboard-console/src/test/resources/store-test.sql index 1807027e..d6098590 100644 --- a/eventmesh-dashboard-console/src/test/resources/store-test.sql +++ b/eventmesh-dashboard-console/src/test/resources/store-test.sql @@ -15,6 +15,7 @@ * limitations under the License. */ + DELETE FROM `eventmesh_dashboard_test`.store WHERE TRUE; diff --git a/eventmesh-dashboard-console/src/test/resources/topic-test.sql b/eventmesh-dashboard-console/src/test/resources/topic-test.sql index 6db880a3..6d6ba97a 100644 --- a/eventmesh-dashboard-console/src/test/resources/topic-test.sql +++ b/eventmesh-dashboard-console/src/test/resources/topic-test.sql @@ -15,6 +15,7 @@ * limitations under the License. */ + DELETE FROM `eventmesh_dashboard_test`.topic WHERE TRUE; diff --git a/eventmesh-dashboard-console/src/test/resources/use-test-schema.sql b/eventmesh-dashboard-console/src/test/resources/use-test-schema.sql index db0c0a26..8eff34f2 100644 --- a/eventmesh-dashboard-console/src/test/resources/use-test-schema.sql +++ b/eventmesh-dashboard-console/src/test/resources/use-test-schema.sql @@ -15,4 +15,5 @@ * limitations under the License. */ + USE `eventmesh_dashboard_test`; diff --git a/eventmesh-dashboard-core/pom.xml b/eventmesh-dashboard-core/pom.xml index 787e8fbb..10dc26cc 100644 --- a/eventmesh-dashboard-core/pom.xml +++ b/eventmesh-dashboard-core/pom.xml @@ -30,9 +30,10 @@ 0.0.1-SNAPSHOT eventmesh-dashboard-core - 1.8 + 17 UTF-8 UTF-8 + 7.1.0 @@ -107,8 +108,17 @@ org.apache.kafka kafka-clients + + org.apache.zookeeper + zookeeper + 3.9.3 + - + + io.fabric8 + kubernetes-client + ${kubernetes.client.version} + org.springframework.boot diff --git a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/store/TopicCore.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/cluster/BaseDataDO.java similarity index 70% rename from eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/store/TopicCore.java rename to eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/cluster/BaseDataDO.java index 2e637725..fd7ed4ad 100644 --- a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/store/TopicCore.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/cluster/BaseDataDO.java @@ -15,21 +15,25 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.service.store; -import org.apache.eventmesh.dashboard.service.dto.TopicProperties; +package org.apache.eventmesh.dashboard.core.cluster; + +import org.apache.eventmesh.dashboard.common.model.metadata.ConfigMetadata; import java.util.List; -/** - * Manage topics of eventmesh-storage-plugin (EventMesh Store). - */ +public class BaseDataDO { + + /** + * RE 资源信息 + */ + private Object resource; -public interface TopicCore { + /** + * CM 配置参数 + */ + private List configMetadata; - List getTopics(); - Boolean createTopic(String topicName); - Boolean deleteTopic(String topicName); } diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/cluster/ClusterBaseDO.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/cluster/ClusterBaseDO.java new file mode 100644 index 00000000..ca3627d1 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/cluster/ClusterBaseDO.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.core.cluster; + +import org.apache.eventmesh.dashboard.core.function.SDK.config.AbstractMultiCreateSDKConfig; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class ClusterBaseDO extends BaseDataDO { + + + private C clusterInfo; + + private Map runtimeMap = new ConcurrentHashMap<>(); + + private AbstractMultiCreateSDKConfig multiCreateSDKConfig; + + + +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/cluster/ClusterDO.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/cluster/ClusterDO.java index 20621ae7..b62042ac 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/cluster/ClusterDO.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/cluster/ClusterDO.java @@ -15,21 +15,18 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.core.cluster; import org.apache.eventmesh.dashboard.common.model.metadata.ClusterMetadata; -import org.apache.eventmesh.dashboard.common.model.metadata.RuntimeMetadata; - -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; +import org.apache.eventmesh.dashboard.common.model.metadata.ConfigMetadata; import lombok.Data; +import lombok.EqualsAndHashCode; @Data -public class ClusterDO { - - private ClusterMetadata clusterInfo; +@EqualsAndHashCode(callSuper = true) +public class ClusterDO extends ClusterBaseDO { - private Map runtimeMap = new ConcurrentHashMap<>(); } diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/cluster/ClusterDoCache.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/cluster/ClusterDoCache.java index 61ac242f..20bb32e6 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/cluster/ClusterDoCache.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/cluster/ClusterDoCache.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.core.cluster; diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/cluster/ColonyDO.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/cluster/ColonyDO.java index b2218695..f56a49e4 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/cluster/ColonyDO.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/cluster/ColonyDO.java @@ -15,42 +15,185 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.core.cluster; +import org.apache.eventmesh.dashboard.common.enums.ClusterSyncMetadataEnum; +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.common.model.ClusterSyncMetadata; +import org.apache.eventmesh.dashboard.core.function.SDK.config.AbstractMultiCreateSDKConfig; +import org.apache.eventmesh.dashboard.core.function.SDK.config.NetAddress; + import java.util.Map; import java.util.Objects; import java.util.concurrent.ConcurrentHashMap; import lombok.Data; +import lombok.Getter; /** - * eventmesh ClusterDO meta ClusterDO runtime ClusterDO storage ClusterDO meta(注册中心,zk,) ClusterDO runtime(broker) ClusterDO + * eventmesh ClusterDO meta ClusterDO runtime ClusterDO storage ClusterDO meta(注册中心,zk,) ClusterDO runtime(broker) ClusterDO 一个集群 eventmesh 集群有 + * 1.有多个 runtime 集群 2.有多个 存储 集群 3.有多个 meta 集群 + *

+ * 一个 RocketMQ 集群 1. 有多个 存储群集(这里是 runtime 集群,是内部实例,不是外部实例) 2. 有一个注册中心集群(这里是 meta ) */ +@SuppressWarnings({"rawtypes", "unchecked"}) @Data -public class ColonyDO { +public class ColonyDO { private Long superiorId; - private ClusterDO clusterDO; + //private ColonyDO superiorDO; + + @Getter + private Long clusterId; + + private C clusterDO; // 双活集群 所以是可以是一个list的 // 可以默认一个集群 - private Map runtimeColonyDOList = new ConcurrentHashMap<>(); + private Map> runtimeColonyDOMap = new ConcurrentHashMap<>(); // 只有 eventmesh 集群有这个点,其他没有。 - private Map storageColonyDOList = new ConcurrentHashMap<>(); + private Map> storageColonyDOMap = new ConcurrentHashMap<>(); /** * A(nameserver cluster) a1 a2 a3 B(nameserver cluster) b1 b2 b3 *

* rocketmq a1,a2,a3,b1,b2,b3 */ - private Map metaColonyDOList = new ConcurrentHashMap<>(); + private Map> metaColonyDOList = new ConcurrentHashMap<>(); + + + private Map> allColonyDO; + + private Class clusterBaseDOClass; + + private ClusterType clusterType; + + private ClusterSyncMetadata clusterSyncMetadata; + + + public static T create(Class clusterDO, Object metadata) { + + try { + ColonyDO colonyDO = new ColonyDO<>(); + //ClusterBaseDO clusterEntityDO = (ClusterBaseDO) clusterDO.newInstance(); + //clusterEntityDO.setClusterInfo(metadata); + colonyDO.setClusterDO((ClusterBaseDO) metadata); + colonyDO.allColonyDO = new ConcurrentHashMap<>(); + return (T) colonyDO; + } catch (Exception e) { + throw new RuntimeException(e); + } + + } + + private static T createBaseDO(Class clusterDO, Object metadata) { + try { + ClusterBaseDO clusterEntityDO = (ClusterBaseDO) clusterDO.newInstance(); + clusterEntityDO.setClusterInfo(metadata); + return (T) clusterEntityDO; + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + + public void setClusterType(ClusterType clusterType) { + this.clusterType = clusterType; + this.clusterSyncMetadata = ClusterSyncMetadataEnum.getClusterSyncMetadata(clusterType); + } + + + public ColonyDO register(Long mainId, Long runtimeId, Object object, NetAddress netAddress) { + ColonyDO mainColony = this.allColonyDO.get(mainId); + if (Objects.isNull(mainColony)) { + return null; + } + mainColony.getClusterDO().getRuntimeMap().put(runtimeId, object); + if (mainColony.getClusterSyncMetadata().getClusterFramework().isCAP()) { + AbstractMultiCreateSDKConfig abstractMultiCreateSDKConfig = mainColony.getClusterDO().getMultiCreateSDKConfig(); + if (mainColony.getClusterType().isMeta()) { + abstractMultiCreateSDKConfig.addMetaAddress(netAddress); + } else { + abstractMultiCreateSDKConfig.addNetAddress(netAddress); + } + } + return mainColony; + } + + public ColonyDO register(Long clusterId, ClusterType clusterType, Object object) { + ColonyDO current = this.allColonyDO.get(clusterId); + if (Objects.isNull(current)) { + ColonyDO colonyDO = create(this.clusterBaseDOClass, object); + colonyDO.setClusterId(clusterId); + colonyDO.setClusterType(clusterType); + colonyDO.setClusterSyncMetadata(ClusterSyncMetadataEnum.getClusterSyncMetadata(clusterType)); + this.allColonyDO.put(clusterId, colonyDO); + current = colonyDO; + } else { + current.setClusterDO((C) object); + } + return current; + } + + public void relationship(Long mainId, Long clusterId) { + ColonyDO mainColony = this.allColonyDO.get(mainId); + + ColonyDO colonyDO = this.allColonyDO.get(clusterId); + colonyDO.setSuperiorId(mainId); + //colonyDO.setSuperiorDO(mainColony); + + mainColony.relationship(colonyDO.getClusterType(), clusterId, colonyDO); + } + + private void relationship(ClusterType clusterType, Long clusterId, ColonyDO colonyDO) { + Map> colonyDOMap = this.getColonyDOMap(clusterType); + colonyDOMap.put(clusterId, colonyDO); + } + + public void unRelationship(Long mainId, Long clusterId) { + ColonyDO mainColony = this.allColonyDO.get(mainId); + ColonyDO colonyDO = this.allColonyDO.get(clusterId); + mainColony.remove(colonyDO.getClusterType(), clusterId); + } + + + public ColonyDO removeRuntime(Long clusterId, Long runtimeId, NetAddress netAddress) { + ColonyDO mainColony = this.allColonyDO.get(clusterId); + if (Objects.isNull(mainColony)) { + return null; + } + mainColony.getClusterDO().getRuntimeMap().remove(runtimeId); + if (mainColony.getClusterSyncMetadata().getClusterFramework().isCAP()) { + AbstractMultiCreateSDKConfig abstractMultiCreateSDKConfig = mainColony.getClusterDO().getMultiCreateSDKConfig(); + if (mainColony.getClusterType().isMeta()) { + abstractMultiCreateSDKConfig.removeMetaAddress(netAddress); + } else { + abstractMultiCreateSDKConfig.removeNetAddress(netAddress); + } + } + return mainColony; + } + + public ColonyDO remove(Long clusterId) { + return this.allColonyDO.remove(clusterId); + } + + public void remove(ClusterType clusterType, Long clusterId) { + Map> colonyDOMap = this.getColonyDOMap(clusterType); + colonyDOMap.remove(clusterId); + } + + public Map> getColonyDOMap(ClusterType clusterType) { + if (Objects.equals(this.clusterType, ClusterType.EVENTMESH_CLUSTER)) { + return clusterType.isStorage() ? this.storageColonyDOMap + : clusterType.isMeta() ? this.metaColonyDOList : this.runtimeColonyDOMap; + } + return clusterType.isMeta() ? this.metaColonyDOList : this.runtimeColonyDOMap; - public Long getClusterId() { - return Objects.nonNull(this.clusterDO.getClusterInfo().getClusterId()) ? this.clusterDO.getClusterInfo().getClusterId() - : this.clusterDO.getClusterInfo().getId(); } } diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/cluster/MetadataBaseDO.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/cluster/MetadataBaseDO.java new file mode 100644 index 00000000..a4650f35 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/cluster/MetadataBaseDO.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.core.cluster; + +import org.apache.eventmesh.dashboard.common.model.metadata.ConfigMetadata; + +import lombok.Data; +import lombok.EqualsAndHashCode; + + +@Data +@EqualsAndHashCode(callSuper = true) +public class MetadataBaseDO extends ClusterBaseDO { + + +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/cluster/RuntimeBaseDO.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/cluster/RuntimeBaseDO.java new file mode 100644 index 00000000..ece58779 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/cluster/RuntimeBaseDO.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.core.cluster; + + +import org.apache.eventmesh.dashboard.common.model.ClusterSyncMetadata; +import org.apache.eventmesh.dashboard.core.function.SDK.config.AbstractCreateSDKConfig; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class RuntimeBaseDO extends BaseDataDO { + + private R runtimeMetadata; + + private AbstractCreateSDKConfig createSDKConfig; + + + private ClusterSyncMetadata clusterSyncMetadata; + + +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/cluster/RuntimeDO.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/cluster/RuntimeDO.java new file mode 100644 index 00000000..dc4c28c5 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/cluster/RuntimeDO.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.core.cluster; + +import org.apache.eventmesh.dashboard.common.model.metadata.ConfigMetadata; +import org.apache.eventmesh.dashboard.common.model.metadata.RuntimeMetadata; + +import lombok.Data; +import lombok.EqualsAndHashCode; + + +@Data +@EqualsAndHashCode(callSuper = true) +public class RuntimeDO extends RuntimeBaseDO { + + + +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/config/AdminProperties.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/config/AdminProperties.java deleted file mode 100644 index 66f1420c..00000000 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/config/AdminProperties.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.core.config; - -import org.apache.eventmesh.dashboard.common.constant.ConfigConst; - -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.stereotype.Component; - -import lombok.Data; - -/** - * TODO get configs from DB (console module's work) - */ - -@Deprecated -@Data -@Component -@ConfigurationProperties(prefix = ConfigConst.ADMIN_PROPS_PREFIX) -public class AdminProperties { - - private MetaProperties meta = new MetaProperties(); - private StoreProperties store = new StoreProperties(); - - @Data - public static class MetaProperties { - - private String type = ConfigConst.META_TYPE_NACOS; - private NacosProperties nacos = new NacosProperties(); - private EtcdProperties etcd = new EtcdProperties(); - private int timeoutMs = 5000; - - @Data - public static class NacosProperties { - - private String addr = "127.0.0.1:8848"; - private String namespace = ""; - private boolean authEnabled = false; - private String protocol = "http"; - private String username; - private String password; - private String accessKey; - private String secretKey; - } - - @Data - public static class EtcdProperties { - - private String addr; - } - } - - @Data - public static class StoreProperties { - - private String type = ConfigConst.STORE_TYPE_ROCKETMQ; // TODO should be standalone - private RocketMQProperties rocketmq = new RocketMQProperties(); - private KafkaProperties kafka = new KafkaProperties(); - - @Data - public static class RocketMQProperties { - - private String namesrvAddr; - private String clusterName = ""; - private String accessKey = ""; - private String secretKey = ""; - } - - @Data - public static class KafkaProperties { - - private String namesrvAddr; - private int partitions = 1; - private int replicationFactors = 1; - } - } -} \ No newline at end of file diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/AbstractClientInfo.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/AbstractClientInfo.java new file mode 100644 index 00000000..0a90675f --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/AbstractClientInfo.java @@ -0,0 +1,56 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.core.function.SDK; + +import org.apache.eventmesh.dashboard.common.model.base.BaseSyncBase; +import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateSDKConfig; + +import java.util.Objects; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.Executor; + +import lombok.Setter; + +public abstract class AbstractClientInfo { + + @Setter + private ClientWrapper clientWrapper; + + @Setter + private Executor executor; + + public T getClient() { + return (T) this.clientWrapper.getClientMap().get(this.getSDKTypeEnum()); + } + + protected CompletableFuture completableFuture(Runnable runnable) { + return Objects.nonNull(this.executor) ? CompletableFuture.runAsync(runnable, executor) : CompletableFuture.runAsync(runnable); + } + + public CreateSDKConfig getCreateSDKConfig() { + return this.getCreateSDKConfig(); + } + + public BaseSyncBase getBaseSyncBase() { + return this.getBaseSyncBase(); + } + + + protected abstract SDKTypeEnum getSDKTypeEnum(); +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/AbstractSDKOperation.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/AbstractSDKOperation.java index d9ad2a70..f266323a 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/AbstractSDKOperation.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/AbstractSDKOperation.java @@ -15,15 +15,18 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.core.function.SDK; -public abstract class AbstractSDKOperation implements SDKOperation { +import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateSDKConfig; + + +public abstract class AbstractSDKOperation extends AbstractClientInfo implements SDKOperation { - protected T castClient(Object client) { - try { - return (T) client; - } catch (ClassCastException e) { - throw new IllegalArgumentException("Client is not of the expected type", e); - } + + public SDKTypeEnum getSDKTypeEnum() { + return SDKTypeEnum.PING; } + + } diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/RemotingServiceRuntimeConfig.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/ClientWrapper.java similarity index 73% rename from eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/RemotingServiceRuntimeConfig.java rename to eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/ClientWrapper.java index 2b76a70d..6552f63f 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/RemotingServiceRuntimeConfig.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/ClientWrapper.java @@ -15,10 +15,11 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.core.remoting; +package org.apache.eventmesh.dashboard.core.function.SDK; + +import org.apache.eventmesh.dashboard.common.model.base.BaseSyncBase; import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateSDKConfig; -import org.apache.eventmesh.dashboard.service.remoting.RemotingServiceType; import java.util.HashMap; import java.util.Map; @@ -26,12 +27,13 @@ import lombok.Data; @Data -public class RemotingServiceRuntimeConfig { +public class ClientWrapper { + + private Map clientMap = new HashMap<>(); + private CreateSDKConfig config; - private CreateSDKConfig runtimeConfig; + private BaseSyncBase baseSyncBase; - private CreateSDKConfig storageConfig; - private Map remotingServiceTypeStringMap = new HashMap<>(); } diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/ConfigManage.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/ConfigManage.java new file mode 100644 index 00000000..b8a74003 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/ConfigManage.java @@ -0,0 +1,56 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.core.function.SDK; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.core.function.SDK.config.AbstractCreateSDKConfig; +import org.apache.eventmesh.dashboard.core.function.SDK.config.AbstractMultiCreateSDKConfig; +import org.apache.eventmesh.dashboard.core.function.SDK.config.AbstractSimpleCreateSDKConfig; + +public class ConfigManage { + + private static final ConfigManage configManage = new ConfigManage(); + + public static ConfigManage getInstance() { + return configManage; + } + + private ConfigManage() { + } + + + public AbstractMultiCreateSDKConfig getMultiCreateSDKConfig(ClusterType clusterType, SDKTypeEnum sdkTypeEnum) { + return (AbstractMultiCreateSDKConfig) getCreateSDKConfig(clusterType, sdkTypeEnum); + } + + public AbstractSimpleCreateSDKConfig getSimpleCreateSDKConfig(ClusterType clusterType, SDKTypeEnum sdkTypeEnum) { + return (AbstractSimpleCreateSDKConfig) getCreateSDKConfig(clusterType, sdkTypeEnum); + } + + private AbstractCreateSDKConfig getCreateSDKConfig(ClusterType clusterType, SDKTypeEnum sdkTypeEnum) { + + try { + Class clazz = SDKManage.getInstance().getConfig(clusterType, sdkTypeEnum); + return (AbstractCreateSDKConfig) clazz.newInstance(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/ProtocolType.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/ProtocolType.java new file mode 100644 index 00000000..e10c5ac3 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/ProtocolType.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.core.function.SDK; + +public enum ProtocolType { + + HTTP, + + GRPC, + + TPC, + + PRIVATE, + + ; +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/SDKManage.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/SDKManage.java new file mode 100644 index 00000000..c15b37dc --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/SDKManage.java @@ -0,0 +1,224 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.core.function.SDK; + +import org.apache.eventmesh.dashboard.common.enums.ClusterSyncMetadataEnum; +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.common.model.base.BaseSyncBase; +import org.apache.eventmesh.dashboard.common.model.metadata.RuntimeMetadata; +import org.apache.eventmesh.dashboard.common.util.ClasspathScanner; +import org.apache.eventmesh.dashboard.core.function.SDK.config.AbstractCreateSDKConfig; +import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateSDKConfig; + +import org.apache.commons.lang3.ArrayUtils; + +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; + + +/** + * SDK manager is a singleton to manage all SDK clients, it is a facade to create, delete and get a client. + */ +public class SDKManage { + + /** + * inner key is the unique key of a client, such as (ip + port) they are defined in CreateClientConfig + *

+ * key: SDKTypeEnum value: A map collection is used with key being (ip+port) and value being client. + * + * @see CreateSDKConfig#getUniqueKey() + */ + private final Map clientMap = new ConcurrentHashMap<>(); + /** + * Initialise the SDKOperation object instance according to SDKTypeEnum. + *

+ * key: SDKTypeEnum value: SDKOperation + * + * @see SDKTypeEnum + * @see SDKOperation + */ + private static final Map> CLUSTER_TYPE_MAP_CONCURRENT_HASH_MAP = + new ConcurrentHashMap<>(); + + private static final SDKManage INSTANCE = new SDKManage(); + + + // register all client create operation + static { + Set> interfaceSet = new HashSet<>(); + interfaceSet.add(SDKOperation.class); + ClasspathScanner classpathScanner = + ClasspathScanner.builder().base(SDKManage.class).subPath("/operation/**").interfaceSet(interfaceSet).build(); + try { + List> classList = classpathScanner.getClazz(); + classList.forEach(SDKManage::createSDKMetadataWrapper); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + static void createSDKMetadataWrapper(Class clazz) { + SDKMetadata[] sdkMetadataArray = clazz.getAnnotationsByType(SDKMetadata.class); + if (ArrayUtils.isEmpty(sdkMetadataArray)) { + return; + } + + try { + SDKMetadata sdkMetadata = sdkMetadataArray[0]; + Class multi = getCreateSDKConfigClass(clazz); + for (ClusterType clusterType : sdkMetadata.clusterType()) { + Map map = + CLUSTER_TYPE_MAP_CONCURRENT_HASH_MAP.computeIfAbsent(clusterType, k -> new ConcurrentHashMap<>()); + SDKTypeEnum[] sdkTypeEnums = sdkMetadata.sdkTypeEnum(); + if (Objects.equals(sdkTypeEnums[0], SDKTypeEnum.ALL)) { + sdkTypeEnums = new SDKTypeEnum[] {SDKTypeEnum.ADMIN, SDKTypeEnum.PING, SDKTypeEnum.PRODUCER, SDKTypeEnum.CONSUMER}; + } + for (SDKTypeEnum sdkTypeEnum : sdkTypeEnums) { + SDKMetadataWrapper sdkMetadataWrapper = new SDKMetadataWrapper(); + sdkMetadataWrapper.sdkMetadata = sdkMetadata; + sdkMetadataWrapper.createSDKConfigClass = multi; + sdkMetadataWrapper.abstractSDKOperation = (AbstractSDKOperation) clazz.newInstance(); + map.put(sdkTypeEnum, sdkMetadataWrapper); + } + } + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + private static Class getCreateSDKConfigClass(Class genericClass) { + Type supercType = genericClass.getGenericSuperclass(); + if (supercType instanceof ParameterizedType type) { + Type[] typeArguments = type.getActualTypeArguments(); + for (Type typeArgument : typeArguments) { + Class argument; + if (typeArgument instanceof ParameterizedType parameterizedType) { + argument = (Class) parameterizedType.getRawType(); + } else { + argument = (Class) typeArgument; + } + for (; ; ) { + Class superclass = argument.getSuperclass(); + if (Objects.isNull(superclass)) { + break; + } + if (Objects.equals(superclass, AbstractCreateSDKConfig.class)) { + if (typeArgument instanceof Class) { + return (Class) typeArgument; + } + } + argument = superclass; + } + } + } + return null; + } + + private SDKManage() { + } + + public static synchronized SDKManage getInstance() { + return INSTANCE; + } + + /** + * Create SDK client through (SDKTypeEnum) clientTypeEnum, (CreateSDKConfig) config. + */ + public T createClient(SDKTypeEnum sdkTypeEnum, BaseSyncBase baseSyncBase, CreateSDKConfig config, ClusterType clusterType) { + + try { + + SDKMetadataWrapper sdkMetadataWrapper = CLUSTER_TYPE_MAP_CONCURRENT_HASH_MAP.get(clusterType).get(sdkTypeEnum); + + Object object = sdkMetadataWrapper.abstractSDKOperation.createClient(config); + if (Objects.equals(sdkTypeEnum, SDKTypeEnum.PRODUCER) || Objects.equals(sdkTypeEnum, SDKTypeEnum.CONSUMER)) { + return (T) object; + } + + ClientWrapper wrapper = new ClientWrapper(); + wrapper.setConfig(config); + wrapper.setBaseSyncBase(baseSyncBase); + + wrapper.getClientMap().put(SDKTypeEnum.ADMIN, object); + // all 模式下应该共享一个对象。这里需要优化 + if (Objects.equals(SDKTypeEnum.ADMIN, sdkTypeEnum)) { + object = sdkMetadataWrapper.abstractSDKOperation.createClient(config); + wrapper.getClientMap().put(SDKTypeEnum.PING, object); + } + final String uniqueKey = baseSyncBase.getUnique(); + clientMap.put(uniqueKey, wrapper); + return (T) object; + } catch (Exception e) { + throw new RuntimeException("create client error", e); + } + } + + + public void deleteClient(SDKTypeEnum sdkTypeEnum, String uniqueKey) { + if (Objects.isNull(sdkTypeEnum)) { + this.clientMap.remove(uniqueKey); + } else { + this.clientMap.get(uniqueKey).getClientMap().put(sdkTypeEnum, null); + } + } + + @SuppressWarnings("unchecked") + public T getClient(SDKTypeEnum clientTypeEnum, String uniqueKey) { + return (T) clientMap.get(uniqueKey).getClientMap().get(clientTypeEnum); + } + + public ClientWrapper getClientWrapper(String uniqueKey) { + return clientMap.get(uniqueKey); + } + + public T createAbstractClientInfo(Class clazz, BaseSyncBase baseSyncBase) { + try { + String unique = baseSyncBase.getUnique(); + if (!baseSyncBase.isCluster() && ClusterSyncMetadataEnum.getClusterFramework(baseSyncBase.getClusterType()).isCAP()) { + unique = ((RuntimeMetadata) baseSyncBase).clusterUnique(); + } + AbstractClientInfo abstractClientInfo = (AbstractClientInfo) clazz.newInstance(); + abstractClientInfo.setClientWrapper(clientMap.get(unique)); + return (T) abstractClientInfo; + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + public Class getConfig(ClusterType clusterType, SDKTypeEnum sdkTypeEnum) { + return CLUSTER_TYPE_MAP_CONCURRENT_HASH_MAP.get(clusterType).get(sdkTypeEnum).createSDKConfigClass; + } + + + static class SDKMetadataWrapper { + + private SDKMetadata sdkMetadata; + + private Class createSDKConfigClass; + + private AbstractSDKOperation abstractSDKOperation; + + } +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/SDKManager.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/SDKManager.java deleted file mode 100644 index 823af69e..00000000 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/SDKManager.java +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.core.function.SDK; - -import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateSDKConfig; -import org.apache.eventmesh.dashboard.core.function.SDK.operation.EtcdSDKOperation; -import org.apache.eventmesh.dashboard.core.function.SDK.operation.NacosConfigSDKOperation; -import org.apache.eventmesh.dashboard.core.function.SDK.operation.NacosNamingSDKOperation; -import org.apache.eventmesh.dashboard.core.function.SDK.operation.NacosSDKOperation; -import org.apache.eventmesh.dashboard.core.function.SDK.operation.RedisSDKOperation; -import org.apache.eventmesh.dashboard.core.function.SDK.operation.rocketmq.RocketMQAdminOperation; -import org.apache.eventmesh.dashboard.core.function.SDK.operation.rocketmq.RocketMQProduceSDKOperation; -import org.apache.eventmesh.dashboard.core.function.SDK.operation.rocketmq.RocketMQPushConsumerSDKOperation; -import org.apache.eventmesh.dashboard.core.function.SDK.operation.rocketmq.RocketMQRemotingSDKOperation; -import org.apache.eventmesh.dashboard.core.function.SDK.operation.runtime.RuntimeGrpcConsumerSDKOperation; -import org.apache.eventmesh.dashboard.core.function.SDK.operation.runtime.RuntimeGrpcProducerSDKOperation; -import org.apache.eventmesh.dashboard.core.function.SDK.operation.runtime.RuntimeHttpConsumerSDKOperation; -import org.apache.eventmesh.dashboard.core.function.SDK.operation.runtime.RuntimeHttpProducerSDKOperation; -import org.apache.eventmesh.dashboard.core.function.SDK.operation.runtime.RuntimeSDKOperation; -import org.apache.eventmesh.dashboard.core.function.SDK.operation.runtime.RuntimeTcpCloudEventSDKOperation; -import org.apache.eventmesh.dashboard.core.function.SDK.operation.runtime.RuntimeTcpEventMeshSDKOperation; -import org.apache.eventmesh.dashboard.core.function.SDK.operation.runtime.RuntimeTcpOpenMessageSDKOperation; - -import java.util.AbstractMap.SimpleEntry; -import java.util.Map; -import java.util.Objects; -import java.util.concurrent.ConcurrentHashMap; - - -/** - * SDK manager is a singleton to manage all SDK clients, it is a facade to create, delete and get a client. - */ -public class SDKManager { - - /** - * inner key is the unique key of a client, such as (ip + port) they are defined in CreateClientConfig - *

- * key: SDKTypeEnum value: A map collection is used with key being (ip+port) and value being client. - * - * @see CreateSDKConfig#getUniqueKey() - */ - private static final Map> clientMap = new ConcurrentHashMap<>(); - /** - * Initialise the SDKOperation object instance according to SDKTypeEnum. - *

- * key: SDKTypeEnum value: SDKOperation - * - * @see SDKTypeEnum - * @see SDKOperation - */ - private static final Map> clientCreateOperationMap = new ConcurrentHashMap<>(); - private static volatile SDKManager INSTANCE = null; - - // register all client create operation - static { - for (SDKTypeEnum clientTypeEnum : SDKTypeEnum.values()) { - clientMap.put(clientTypeEnum, new ConcurrentHashMap<>()); - } - // redis - clientCreateOperationMap.put(SDKTypeEnum.STORAGE_REDIS, new RedisSDKOperation()); - - // rocketmq - clientCreateOperationMap.put(SDKTypeEnum.STORAGE_ROCKETMQ_REMOTING, new RocketMQRemotingSDKOperation()); - clientCreateOperationMap.put(SDKTypeEnum.STORAGE_ROCKETMQ_PRODUCER, new RocketMQProduceSDKOperation()); - clientCreateOperationMap.put(SDKTypeEnum.STORAGE_ROCKETMQ_CONSUMER, new RocketMQPushConsumerSDKOperation()); - clientCreateOperationMap.put(SDKTypeEnum.STORAGE_ROCKETMQ_ADMIN, new RocketMQAdminOperation()); - - // nacos - clientCreateOperationMap.put(SDKTypeEnum.META_NACOS, new NacosSDKOperation()); - clientCreateOperationMap.put(SDKTypeEnum.META_NACOS_CONFIG, new NacosConfigSDKOperation()); - clientCreateOperationMap.put(SDKTypeEnum.META_NACOS_NAMING, new NacosNamingSDKOperation()); - - // etcd - clientCreateOperationMap.put(SDKTypeEnum.META_ETCD, new EtcdSDKOperation()); - - // eventmesh_runtime - clientCreateOperationMap.put(SDKTypeEnum.RUNTIME_EVENTMESH_CLIENT, new RuntimeSDKOperation()); - - // eventmesh_runtime_tcp - clientCreateOperationMap.put(SDKTypeEnum.RUNTIME_TCP_CLOUDEVENT_CLIENT, new RuntimeTcpCloudEventSDKOperation()); - clientCreateOperationMap.put(SDKTypeEnum.RUNTIME_TCP_EVENTMESH_CLIENT, new RuntimeTcpEventMeshSDKOperation()); - clientCreateOperationMap.put(SDKTypeEnum.RUNTIME_TCP_OPENMESSAGE_CLIENT, new RuntimeTcpOpenMessageSDKOperation()); - - // eventmesh_runtime_http - clientCreateOperationMap.put(SDKTypeEnum.RUNTIME_HTTP_PRODUCER, new RuntimeHttpProducerSDKOperation()); - clientCreateOperationMap.put(SDKTypeEnum.RUNTIME_HTTP_CONSUMER, new RuntimeHttpConsumerSDKOperation()); - - // eventmesh_runtime_grpc - clientCreateOperationMap.put(SDKTypeEnum.RUNTIME_GRPC_PRODUCER, new RuntimeGrpcProducerSDKOperation()); - clientCreateOperationMap.put(SDKTypeEnum.RUNTIME_GRPC_CONSUMER, new RuntimeGrpcConsumerSDKOperation()); - } - - private SDKManager() { - } - - public static synchronized SDKManager getInstance() { - if (INSTANCE == null) { - synchronized (SDKManager.class) { - if (INSTANCE == null) { - INSTANCE = new SDKManager(); - } - } - } - return INSTANCE; - } - - /** - * Create SDK client through (SDKTypeEnum) clientTypeEnum, (CreateSDKConfig) config. - */ - public SimpleEntry createClient(SDKTypeEnum clientTypeEnum, CreateSDKConfig config) { - - final String uniqueKey = config.getUniqueKey(); - - Map clients = clientMap.get(clientTypeEnum); - - Object client = clients.get(uniqueKey); - SimpleEntry result = new SimpleEntry<>(uniqueKey, client); - if (Objects.isNull(client)) { - SDKOperation clientCreateOperation = clientCreateOperationMap.get(clientTypeEnum); - result = clientCreateOperation.createClient(config); - clients.put(result.getKey(), result.getValue()); - } - try { - return (SimpleEntry) result; - } catch (Exception e) { - throw new RuntimeException("create client error", e); - } - } - - public void deleteClient(SDKTypeEnum clientTypeEnum, String uniqueKey) { - Map clients = clientMap.get(clientTypeEnum); - SDKOperation operation = clientCreateOperationMap.get(clientTypeEnum); - try { - operation.close(clients.get(uniqueKey)); - } catch (Exception e) { - throw new RuntimeException("close client error", e); - } - clients.remove(uniqueKey); - } - - public Object getClient(SDKTypeEnum clientTypeEnum, String uniqueKey) { - return clientMap.get(clientTypeEnum).get(uniqueKey); - } - - // get all client - public Map getClients(SDKTypeEnum clientTypeEnum) { - return clientMap.get(clientTypeEnum); - } -} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/SDKMetadata.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/SDKMetadata.java new file mode 100644 index 00000000..73a1c40a --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/SDKMetadata.java @@ -0,0 +1,62 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.core.function.SDK; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.common.enums.RemotingType; +import org.apache.eventmesh.dashboard.core.function.SDK.config.NullCreateSDKConfig; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + + +/** + * + */ +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface SDKMetadata { + + ClusterType[] clusterType(); + + + RemotingType remotingType(); + + + SDKTypeEnum[] sdkTypeEnum(); + + Class config() default NullCreateSDKConfig.class; + + /** + * @return + */ + ProtocolType protocol() default ProtocolType.PRIVATE; + + /** + * value is {@link ClusterType.RUNTIME } or {@link ClusterType.CLUSTER } + * + * @return + */ + ClusterType dimension() default ClusterType.RUNTIME; + +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/SDKOperation.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/SDKOperation.java index fd4f4cf6..034421c0 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/SDKOperation.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/SDKOperation.java @@ -15,22 +15,21 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.core.function.SDK; import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateSDKConfig; -import java.util.AbstractMap.SimpleEntry; - /** * Operation to create and close a client, the operations will be store in the SDKManager * * @param SDK client */ -public interface SDKOperation { +public interface SDKOperation { - SimpleEntry createClient(CreateSDKConfig clientConfig); + T createClient(C clientConfig) throws Exception; - void close(Object client); + void close(T client) throws Exception; } diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/SDKTypeEnum.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/SDKTypeEnum.java index 4950eb1e..b69fe047 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/SDKTypeEnum.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/SDKTypeEnum.java @@ -15,38 +15,31 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.core.function.SDK; +/** + * TODO + * META 与 RUNTIME 有相同操作,如何确定. + * 同时多协议,如何处理。 + * TPC的优先级最高,那如何确定端口。 + *

+ * TODO 关于订阅与发布 + * 消费组 与 生产组 的 group name 是否随机 + * RocketMQ 的 namespace 如何处理 + * PRODUCER,CONSUMER,操作完之后,是否要删除 生产与消费相关信息 + */ public enum SDKTypeEnum { - RUNTIME, - - STORAGE_ROCKETMQ_REMOTING, - - STORAGE_ROCKETMQ_ADMIN, - - STORAGE_ROCKETMQ_PRODUCER, - - STORAGE_ROCKETMQ_CONSUMER, - - STORAGE_REDIS, - - META_NACOS, - META_NACOS_CONFIG, - - META_NACOS_NAMING, + ALL, - META_ETCD, + PING, - RUNTIME_EVENTMESH_CLIENT, + ADMIN, - RUNTIME_TCP_CLOUDEVENT_CLIENT, - RUNTIME_TCP_EVENTMESH_CLIENT, - RUNTIME_TCP_OPENMESSAGE_CLIENT, + PRODUCER, - RUNTIME_HTTP_PRODUCER, - RUNTIME_HTTP_CONSUMER, + CONSUMER, - RUNTIME_GRPC_PRODUCER, - RUNTIME_GRPC_CONSUMER, + ; } diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/AbstractCreateSDKConfig.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/AbstractCreateSDKConfig.java new file mode 100644 index 00000000..c0682691 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/AbstractCreateSDKConfig.java @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.core.function.SDK.config; + + +import lombok.Data; + +@Data +public abstract class AbstractCreateSDKConfig implements CreateSDKConfig { + + + /** + * true is key + *

+ * false if address + ":" + port + */ + private boolean keyMode = true; + + /** + * cluster id or runtime id + */ + private String key; + + private String namespace; + + private String username; + + private String password; + + private String accessKey; + + private String secretKey; + + private String config; + + + protected abstract String uniqueKey(); + + public String getUniqueKey() { + return this.keyMode ? this.uniqueKey() + this.key : this.doUniqueKey(); + } + + abstract String doUniqueKey(); + +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/AbstractMultiCreateSDKConfig.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/AbstractMultiCreateSDKConfig.java new file mode 100644 index 00000000..5c0c6191 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/AbstractMultiCreateSDKConfig.java @@ -0,0 +1,100 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.core.function.SDK.config; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; + +public class AbstractMultiCreateSDKConfig extends AbstractCreateSDKConfig { + + + private List netAddresseList = new CopyOnWriteArrayList<>(); + + /** + * TODO + * TODO + * TODO 有意义? + * 设定次字段的时候,是为了解决 kafka 老版本操作的时候是 需要操作zk。 目前还没解决这个问题 + */ + private List metaAddressList = new CopyOnWriteArrayList<>(); + + + public boolean isNullAddress() { + return netAddresseList.isEmpty(); + } + + public void addNetAddress(NetAddress netAddress) { + this.netAddresseList.add(netAddress); + } + + public void removeNetAddress(NetAddress netAddress) { + this.netAddresseList.remove(netAddress); + } + + public void addMetaAddress(NetAddress netAddress) { + this.metaAddressList.add(netAddress); + } + + public void removeMetaAddress(NetAddress netAddress) { + this.metaAddressList.remove(netAddress); + } + + + @Override + public String doUniqueKey() { + return this.doUniqueKey(this.netAddresseList); + } + + private String doUniqueKey(List netAddresseList) { + StringBuffer sb = new StringBuffer(); + netAddresseList.forEach(netAddress -> { + sb.append(netAddress.doUniqueKey()); + sb.append(";"); + }); + return sb.toString(); + } + + @Override + protected String uniqueKey() { + return "m_"; + } + + + public String doUniqueKeyByMeta() { + return this.doUniqueKey(this.metaAddressList); + } + + + public String[] getNetAddressesByMeta() { + return this.getNetAddresses(this.metaAddressList); + } + + public String[] getNetAddresses() { + return this.getNetAddresses(this.netAddresseList); + } + + private String[] getNetAddresses(List netAddresseList) { + List netAddresses = new ArrayList<>(); + netAddresseList.forEach(netAddress -> { + netAddresses.add(netAddress.doUniqueKey()); + }); + return netAddresses.toArray(new String[netAddresses.size()]); + } +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/AbstractSimpleCreateSDKConfig.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/AbstractSimpleCreateSDKConfig.java new file mode 100644 index 00000000..27092d29 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/AbstractSimpleCreateSDKConfig.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.core.function.SDK.config; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class AbstractSimpleCreateSDKConfig extends AbstractCreateSDKConfig { + + + private NetAddress netAddress; + + + @Override + protected String uniqueKey() { + return "s_"; + } + + public String doUniqueKey() { + return netAddress.doUniqueKey(); + } +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateEtcdConfig.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateEtcdConfig.java index 2f116e06..a90010a5 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateEtcdConfig.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateEtcdConfig.java @@ -15,26 +15,16 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.core.function.SDK.config; -import lombok.AllArgsConstructor; -import lombok.Builder; import lombok.Data; -import lombok.NoArgsConstructor; +import lombok.EqualsAndHashCode; @Data -@Builder -@AllArgsConstructor -@NoArgsConstructor -public class CreateEtcdConfig implements CreateSDKConfig { - - private String etcdServerAddress; +@EqualsAndHashCode(callSuper = true) +public class CreateEtcdConfig extends AbstractMultiCreateSDKConfig { - @Builder.Default() private int connectTime = 10; - @Override - public String getUniqueKey() { - return etcdServerAddress; - } } diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateJvmCapConfig.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateJvmCapConfig.java new file mode 100644 index 00000000..446996ae --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateJvmCapConfig.java @@ -0,0 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.core.function.SDK.config; + +public class CreateJvmCapConfig extends AbstractMultiCreateSDKConfig { + +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateJvmConfig.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateJvmConfig.java new file mode 100644 index 00000000..30a9363e --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateJvmConfig.java @@ -0,0 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.core.function.SDK.config; + +public class CreateJvmConfig extends AbstractSimpleCreateSDKConfig { + +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateKafkaZkConfig.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateKafkaZkConfig.java new file mode 100644 index 00000000..32f85a15 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateKafkaZkConfig.java @@ -0,0 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.core.function.SDK.config; + +public class CreateKafkaZkConfig extends AbstractMultiCreateSDKConfig { + +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateKakfaConfig.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateKakfaConfig.java new file mode 100644 index 00000000..ca309a7c --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateKakfaConfig.java @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.core.function.SDK.config; + + +import lombok.Data; + +@Data +public class CreateKakfaConfig extends AbstractMultiCreateSDKConfig{ + +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateKubernetesConfig.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateKubernetesConfig.java new file mode 100644 index 00000000..a60f12c4 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateKubernetesConfig.java @@ -0,0 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.core.function.SDK.config; + +public class CreateKubernetesConfig extends AbstractSimpleCreateSDKConfig{ + +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateNacosConfig.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateNacosConfig.java index 7d7effaa..7c640149 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateNacosConfig.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateNacosConfig.java @@ -15,35 +15,18 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.core.function.SDK.config; -import lombok.AllArgsConstructor; -import lombok.Builder; import lombok.Data; -import lombok.NoArgsConstructor; +import lombok.EqualsAndHashCode; @Data -@Builder -@AllArgsConstructor -@NoArgsConstructor -public class CreateNacosConfig implements CreateSDKConfig { - - private String serverAddress = "127.0.0.1:8848"; - - private String namespace = ""; +@EqualsAndHashCode(callSuper = true) +public class CreateNacosConfig extends AbstractSimpleCreateSDKConfig { private String username = "nacos"; - private String password = "nacos"; - - private String accessKey = ""; - - private String secretKey = ""; - - @Override - public String getUniqueKey() { - return serverAddress; - } } diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateRedisConfig.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateRedisConfig.java index fb42f880..0d81035b 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateRedisConfig.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateRedisConfig.java @@ -15,28 +15,16 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.core.function.SDK.config; -import lombok.AllArgsConstructor; -import lombok.Builder; import lombok.Data; -import lombok.NoArgsConstructor; +import lombok.EqualsAndHashCode; @Data -@Builder -@AllArgsConstructor -@NoArgsConstructor -public class CreateRedisConfig implements CreateSDKConfig { - - private String redisUrl; - - private String password; +@EqualsAndHashCode(callSuper = true) +public class CreateRedisConfig extends AbstractSimpleCreateSDKConfig { - @Builder.Default private int timeOut = 10; - @Override - public String getUniqueKey() { - return redisUrl; - } } diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateRemotingConfig.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateRemotingConfig.java new file mode 100644 index 00000000..b39ac019 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateRemotingConfig.java @@ -0,0 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.core.function.SDK.config; + +public class CreateRemotingConfig extends AbstractSimpleCreateSDKConfig{ + +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateRocketmqAdminSDKConfig.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateRocketmqAdminSDKConfig.java index f9d7833a..3f5c4301 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateRocketmqAdminSDKConfig.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateRocketmqAdminSDKConfig.java @@ -15,20 +15,14 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.core.function.SDK.config; import lombok.Data; +import lombok.EqualsAndHashCode; @Data -public class CreateRocketmqAdminSDKConfig implements CreateSDKConfig { - - private String nameServerUrl; - - private String clusterName; - +@EqualsAndHashCode(callSuper = true) +public class CreateRocketmqAdminSDKConfig extends AbstractMultiCreateSDKConfig { - @Override - public String getUniqueKey() { - return nameServerUrl; - } } diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateRocketmqConfig.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateRocketmqConfig.java index 3670d648..a53bb0d4 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateRocketmqConfig.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateRocketmqConfig.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.core.function.SDK.config; import org.apache.rocketmq.client.consumer.listener.MessageListener; diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateRocketmqConsumerSDKConfig.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateRocketmqConsumerSDKConfig.java new file mode 100644 index 00000000..a3cee245 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateRocketmqConsumerSDKConfig.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.core.function.SDK.config; + +import org.apache.rocketmq.remoting.protocol.heartbeat.MessageModel; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class CreateRocketmqConsumerSDKConfig extends AbstractMultiCreateSDKConfig { + + private String consumerGroup; + + private MessageModel messageModel = MessageModel.CLUSTERING; + + //topic + private String topic; + + private String subExpression = "*"; +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateRocketmqProduceSDKConfig.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateRocketmqProduceSDKConfig.java new file mode 100644 index 00000000..b9b85eb3 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateRocketmqProduceSDKConfig.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.core.function.SDK.config; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class CreateRocketmqProduceSDKConfig extends AbstractMultiCreateSDKConfig { + + private String producerGroup; +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateRuntimeConfig.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateRuntimeConfig.java index 7ddfc805..828b1fdb 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateRuntimeConfig.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateRuntimeConfig.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.core.function.SDK.config; import org.apache.eventmesh.common.protocol.tcp.UserAgent; @@ -28,7 +29,7 @@ @Builder @AllArgsConstructor @NoArgsConstructor -public class CreateRuntimeConfig implements CreateSDKConfig { +public class CreateRuntimeConfig extends AbstractSimpleCreateSDKConfig { // 127.0.0.1:10105;127.0.0.2:10105 private String runtimeServerAddress; diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateSDKConfig.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateSDKConfig.java index 23b3c110..4a2d47d7 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateSDKConfig.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateSDKConfig.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.core.function.SDK.config; /** diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateZookeeperConfig.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateZookeeperConfig.java new file mode 100644 index 00000000..6e02d0f9 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/CreateZookeeperConfig.java @@ -0,0 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.core.function.SDK.config; + +public class CreateZookeeperConfig extends AbstractMultiCreateSDKConfig{ + +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/NetAddress.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/NetAddress.java new file mode 100644 index 00000000..93246a6f --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/NetAddress.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.core.function.SDK.config; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode +public class NetAddress { + + + public static NetAddress create(String address, int port) { + NetAddress netAddress = new NetAddress(); + netAddress.address = address; + netAddress.port = port; + return netAddress; + } + + private String address; + + private Integer port; + + + public String doUniqueKey() { + return this.address + ":" + this.port; + } + +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/NullCreateSDKConfig.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/NullCreateSDKConfig.java new file mode 100644 index 00000000..7dce5ea6 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/config/NullCreateSDKConfig.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.core.function.SDK.config; + +public class NullCreateSDKConfig extends AbstractCreateSDKConfig { + + @Override + protected String uniqueKey() { + return "null_"; + } + + @Override + String doUniqueKey() { + return ""; + } +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/EtcdSDKOperation.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/EtcdSDKOperation.java index 29e3fb35..57fc78f2 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/EtcdSDKOperation.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/EtcdSDKOperation.java @@ -15,46 +15,39 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.core.function.SDK.operation; +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.common.enums.RemotingType; import org.apache.eventmesh.dashboard.core.function.SDK.AbstractSDKOperation; +import org.apache.eventmesh.dashboard.core.function.SDK.SDKMetadata; +import org.apache.eventmesh.dashboard.core.function.SDK.SDKTypeEnum; import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateEtcdConfig; -import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateSDKConfig; import java.time.Duration; -import java.util.AbstractMap.SimpleEntry; import io.etcd.jetcd.Client; -import io.etcd.jetcd.KV; -import io.etcd.jetcd.common.exception.EtcdException; import lombok.extern.slf4j.Slf4j; @Slf4j -public class EtcdSDKOperation extends AbstractSDKOperation { - - private static String[] getSplitEndpoints(CreateEtcdConfig etcdConfig) { - return etcdConfig.getEtcdServerAddress().split(";"); - } +@SDKMetadata(clusterType = {ClusterType.EVENTMESH_META_ETCD}, remotingType = RemotingType.EVENT_MESH_ETCD, sdkTypeEnum = {SDKTypeEnum.ADMIN, + SDKTypeEnum.PING}) +public class EtcdSDKOperation extends AbstractSDKOperation { @Override - public SimpleEntry createClient(CreateSDKConfig clientConfig) { - final CreateEtcdConfig etcdConfig = (CreateEtcdConfig) clientConfig; - KV kvClient = null; - try { - final Client client = Client.builder() - .endpoints(getSplitEndpoints(etcdConfig)) - .connectTimeout(Duration.ofSeconds(etcdConfig.getConnectTime())) - .build(); - kvClient = client.getKVClient(); - } catch (EtcdException e) { - log.error("create etcd client failed", e); - } - return new SimpleEntry<>(clientConfig.getUniqueKey(), kvClient); + public Client createClient(CreateEtcdConfig clientConfig) throws Exception { + Client client = Client.builder() + .endpoints(clientConfig.getNetAddresses()) + .connectTimeout(Duration.ofSeconds(clientConfig.getConnectTime())) + .build(); + return client; + } @Override - public void close(Object client) { - castClient(client).close(); + public void close(Client client) throws Exception { + client.close(); } } diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/NacosConfigSDKOperation.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/NacosConfigSDKOperation.java deleted file mode 100644 index b7a6769c..00000000 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/NacosConfigSDKOperation.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.core.function.SDK.operation; - -import org.apache.eventmesh.dashboard.core.function.SDK.AbstractSDKOperation; -import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateNacosConfig; -import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateSDKConfig; - -import java.util.AbstractMap.SimpleEntry; -import java.util.Properties; - -import com.alibaba.nacos.api.NacosFactory; -import com.alibaba.nacos.api.PropertyKeyConst; -import com.alibaba.nacos.api.config.ConfigService; -import com.alibaba.nacos.api.exception.NacosException; - -import lombok.extern.slf4j.Slf4j; - -@Slf4j -public class NacosConfigSDKOperation extends AbstractSDKOperation { - - @Override - public SimpleEntry createClient(CreateSDKConfig clientConfig) { - ConfigService configService = null; - CreateNacosConfig config = (CreateNacosConfig) clientConfig; - try { - Properties properties = new Properties(); - properties.put(PropertyKeyConst.SERVER_ADDR, config.getServerAddress()); - properties.put(PropertyKeyConst.NAMESPACE, config.getNamespace()); - properties.put(PropertyKeyConst.USERNAME, config.getUsername()); - properties.put(PropertyKeyConst.PASSWORD, config.getPassword()); - properties.put(PropertyKeyConst.ACCESS_KEY, config.getAccessKey()); - properties.put(PropertyKeyConst.SECRET_KEY, config.getSecretKey()); - configService = NacosFactory.createConfigService(properties); - } catch (NacosException e) { - log.error("NacosCheck init failed caused by {}", e.getErrMsg()); - } - return new SimpleEntry<>(config.getServerAddress(), configService); - } - - @Override - public void close(Object client) { - try { - castClient(client).shutDown(); - } catch (NacosException e) { - log.error("NacosCheck close failed caused by {}", e.getErrMsg()); - } - } -} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/NacosNamingSDKOperation.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/NacosNamingSDKOperation.java deleted file mode 100644 index ca2d7221..00000000 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/NacosNamingSDKOperation.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.core.function.SDK.operation; - -import org.apache.eventmesh.dashboard.core.function.SDK.AbstractSDKOperation; -import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateNacosConfig; -import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateSDKConfig; - -import java.util.AbstractMap.SimpleEntry; -import java.util.Properties; - -import com.alibaba.nacos.api.NacosFactory; -import com.alibaba.nacos.api.PropertyKeyConst; -import com.alibaba.nacos.api.config.ConfigService; -import com.alibaba.nacos.api.exception.NacosException; -import com.alibaba.nacos.api.naming.NamingService; - -import lombok.extern.slf4j.Slf4j; - -@Slf4j -public class NacosNamingSDKOperation extends AbstractSDKOperation { - - @Override - public SimpleEntry createClient(CreateSDKConfig clientConfig) { - NamingService namingService = null; - CreateNacosConfig config = (CreateNacosConfig) clientConfig; - try { - Properties properties = new Properties(); - properties.put(PropertyKeyConst.SERVER_ADDR, config.getServerAddress()); - properties.put(PropertyKeyConst.NAMESPACE, config.getNamespace()); - properties.put(PropertyKeyConst.USERNAME, config.getUsername()); - properties.put(PropertyKeyConst.PASSWORD, config.getPassword()); - properties.put(PropertyKeyConst.ACCESS_KEY, config.getAccessKey()); - properties.put(PropertyKeyConst.SECRET_KEY, config.getSecretKey()); - namingService = NacosFactory.createNamingService(properties); - } catch (NacosException e) { - log.error("NacosCheck init failed caused by {}", e.getErrMsg()); - } - return new SimpleEntry<>(config.getUniqueKey(), namingService); - } - - @Override - public void close(Object client) { - try { - ((ConfigService) client).shutDown(); - } catch (NacosException e) { - log.error("NacosCheck close failed caused by {}", e.getErrMsg()); - } - } -} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/NacosSDKOperation.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/NacosSDKOperation.java index ba78cbb3..473f5ca0 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/NacosSDKOperation.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/NacosSDKOperation.java @@ -15,42 +15,79 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.core.function.SDK.operation; +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.common.enums.RemotingType; import org.apache.eventmesh.dashboard.core.function.SDK.AbstractSDKOperation; -import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateSDKConfig; +import org.apache.eventmesh.dashboard.core.function.SDK.SDKMetadata; +import org.apache.eventmesh.dashboard.core.function.SDK.SDKTypeEnum; +import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateNacosConfig; import org.apache.eventmesh.dashboard.core.function.SDK.wrapper.NacosSDKWrapper; -import java.util.AbstractMap.SimpleEntry; -import java.util.Objects; +import java.util.Properties; +import com.alibaba.nacos.api.NacosFactory; +import com.alibaba.nacos.api.PropertyKeyConst; import com.alibaba.nacos.api.config.ConfigService; import com.alibaba.nacos.api.naming.NamingService; -public class NacosSDKOperation extends AbstractSDKOperation { +@SDKMetadata(clusterType = {ClusterType.EVENTMESH_META_NACOS}, remotingType = RemotingType.EVENT_MESH_NACOS, sdkTypeEnum = {SDKTypeEnum.ADMIN, + SDKTypeEnum.PING}) +public class NacosSDKOperation extends AbstractSDKOperation { + + + private static Properties createProperties(CreateNacosConfig clientConfig) { + Properties properties = new Properties(); + properties.put(PropertyKeyConst.SERVER_ADDR, clientConfig.doUniqueKey()); + properties.put(PropertyKeyConst.NAMESPACE, clientConfig.getNamespace()); + properties.put(PropertyKeyConst.USERNAME, clientConfig.getUsername()); + properties.put(PropertyKeyConst.PASSWORD, clientConfig.getPassword()); + properties.put(PropertyKeyConst.ACCESS_KEY, clientConfig.getAccessKey()); + properties.put(PropertyKeyConst.SECRET_KEY, clientConfig.getSecretKey()); + return properties; + } private final NacosConfigSDKOperation nacosConfigClientCreateOperation = new NacosConfigSDKOperation(); + private final NacosNamingSDKOperation nacosNamingClientCreateOperation = new NacosNamingSDKOperation(); @Override - public SimpleEntry createClient(CreateSDKConfig createClientConfig) { - SimpleEntry configSimpleEntry = nacosConfigClientCreateOperation.createClient(createClientConfig); - SimpleEntry namingSimpleEntry = nacosNamingClientCreateOperation.createClient(createClientConfig); - if (!Objects.equals(configSimpleEntry.getKey(), namingSimpleEntry.getKey())) { - throw new RuntimeException("Nacos config and naming server address not match"); - } - NacosSDKWrapper nacosClient = new NacosSDKWrapper( - (ConfigService) configSimpleEntry.getValue(), (NamingService) namingSimpleEntry.getValue() - ); - return new SimpleEntry<>(configSimpleEntry.getKey(), nacosClient); + public NacosSDKWrapper createClient(CreateNacosConfig createClientConfig) throws Exception { + ConfigService configSimpleEntry = nacosConfigClientCreateOperation.createClient(createClientConfig); + NamingService namingSimpleEntry = nacosNamingClientCreateOperation.createClient(createClientConfig); + return new NacosSDKWrapper(configSimpleEntry, namingSimpleEntry); } @Override - public void close(Object client) { - try { - castClient(client).shutdown(); - } catch (Exception e) { - throw new RuntimeException("Nacos client close failed", e); + public void close(NacosSDKWrapper client) throws Exception { + client.shutdown(); + } + + public static class NacosConfigSDKOperation extends AbstractSDKOperation { + + @Override + public ConfigService createClient(CreateNacosConfig clientConfig) throws Exception { + return NacosFactory.createConfigService(createProperties(clientConfig)); + } + + @Override + public void close(ConfigService client) throws Exception { + client.shutDown(); + } + } + + public static class NacosNamingSDKOperation extends AbstractSDKOperation { + + @Override + public NamingService createClient(CreateNacosConfig clientConfig) throws Exception { + return NacosFactory.createNamingService(createProperties(clientConfig)); + } + + @Override + public void close(NamingService client) throws Exception { + client.shutDown(); } } } diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RedisSDKOperation.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RedisSDKOperation.java index aba1807b..32131a0b 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RedisSDKOperation.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RedisSDKOperation.java @@ -15,39 +15,41 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.core.function.SDK.operation; +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.common.enums.RemotingType; import org.apache.eventmesh.dashboard.core.function.SDK.AbstractSDKOperation; +import org.apache.eventmesh.dashboard.core.function.SDK.SDKMetadata; +import org.apache.eventmesh.dashboard.core.function.SDK.SDKTypeEnum; import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateRedisConfig; -import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateSDKConfig; import java.time.Duration; -import java.util.AbstractMap.SimpleEntry; import io.lettuce.core.RedisClient; import io.lettuce.core.RedisURI; import io.lettuce.core.api.StatefulRedisConnection; -public class RedisSDKOperation extends AbstractSDKOperation> { + +@SDKMetadata(clusterType = { + ClusterType.STORAGE_REDIS_BROKER}, remotingType = RemotingType.REDIS, sdkTypeEnum = SDKTypeEnum.ALL, config = CreateRedisConfig.class) +public class RedisSDKOperation extends AbstractSDKOperation, CreateRedisConfig> { @Override - public SimpleEntry> createClient(CreateSDKConfig clientConfig) { - CreateRedisConfig redisConfig = (CreateRedisConfig) clientConfig; - String redisUrl = redisConfig.getRedisUrl(); - String clientHost = redisUrl.split(":")[0]; - int clientPort = Integer.parseInt(redisUrl.split(":")[1]); + public StatefulRedisConnection createClient(CreateRedisConfig clientConfig) { RedisURI redisURI = RedisURI.builder() - .withHost(clientHost) - .withPort(clientPort) - .withPassword(redisConfig.getPassword() == null ? "" : redisConfig.getPassword()) - .withTimeout(Duration.ofSeconds(redisConfig.getTimeOut())) + .withHost(clientConfig.getNetAddress().getAddress()) + .withPort(clientConfig.getNetAddress().getPort()) + .withPassword(clientConfig.getPassword() == null ? "" : clientConfig.getPassword()) + .withTimeout(Duration.ofSeconds(clientConfig.getTimeOut())) .build(); RedisClient redisClient = RedisClient.create(redisURI); - return new SimpleEntry<>(clientConfig.getUniqueKey(), redisClient.connect()); + return redisClient.connect(); } @Override - public void close(Object client) { - castClient(client).close(); + public void close(StatefulRedisConnection client) { + client.close(); } } diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/jvm/JvmAdmin.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/jvm/JvmAdmin.java new file mode 100644 index 00000000..b602b5f0 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/jvm/JvmAdmin.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.core.function.SDK.operation.jvm; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.common.enums.RemotingType; +import org.apache.eventmesh.dashboard.core.function.SDK.AbstractSDKOperation; +import org.apache.eventmesh.dashboard.core.function.SDK.SDKMetadata; +import org.apache.eventmesh.dashboard.core.function.SDK.SDKTypeEnum; +import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateJvmConfig; + +@SDKMetadata(clusterType = ClusterType.STORAGE_JVM_BROKER, remotingType = RemotingType.JVM, sdkTypeEnum = SDKTypeEnum.ALL) +public class JvmAdmin extends AbstractSDKOperation { + + @Override + public Object createClient(CreateJvmConfig clientConfig) throws Exception { + return new Object(); + } + + @Override + public void close(Object client) throws Exception { + + } +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/jvm/JvmCapAdmin.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/jvm/JvmCapAdmin.java new file mode 100644 index 00000000..2aa8305a --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/jvm/JvmCapAdmin.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.core.function.SDK.operation.jvm; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.common.enums.RemotingType; +import org.apache.eventmesh.dashboard.core.function.SDK.AbstractSDKOperation; +import org.apache.eventmesh.dashboard.core.function.SDK.SDKMetadata; +import org.apache.eventmesh.dashboard.core.function.SDK.SDKTypeEnum; +import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateJvmCapConfig; + +@SDKMetadata(clusterType = ClusterType.STORAGE_JVM_CAP_BROKER, remotingType = RemotingType.JVM, sdkTypeEnum = SDKTypeEnum.ALL) +public class JvmCapAdmin extends AbstractSDKOperation { + + @Override + public Object createClient(CreateJvmCapConfig clientConfig) throws Exception { + return new Object(); + } + + @Override + public void close(Object client) throws Exception { + + } +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/kafka/KafkaAdminOperation.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/kafka/KafkaAdminOperation.java new file mode 100644 index 00000000..98b0051d --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/kafka/KafkaAdminOperation.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.core.function.SDK.operation.kafka; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.common.enums.RemotingType; +import org.apache.eventmesh.dashboard.core.function.SDK.AbstractSDKOperation; +import org.apache.eventmesh.dashboard.core.function.SDK.SDKMetadata; +import org.apache.eventmesh.dashboard.core.function.SDK.SDKTypeEnum; +import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateKakfaConfig; + +import org.apache.kafka.clients.admin.AdminClient; + +import java.util.Properties; + +@SDKMetadata(clusterType = {ClusterType.STORAGE_KAFKA_BROKER, ClusterType.STORAGE_KAFKA_RAFT}, remotingType = RemotingType.KAFKA, sdkTypeEnum = { + SDKTypeEnum.ADMIN, SDKTypeEnum.PING}) +public class KafkaAdminOperation extends AbstractSDKOperation { + + @Override + public AdminClient createClient(CreateKakfaConfig clientConfig) throws Exception { + Properties props = new Properties(); + AdminClient adminClient = AdminClient.create(props); + return adminClient; + } + + @Override + public void close(AdminClient client) throws Exception { + client.close(); + } +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/exception/EventMeshAdminException.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/kafka/KafkaZkAdminOperation.java similarity index 52% rename from eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/exception/EventMeshAdminException.java rename to eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/kafka/KafkaZkAdminOperation.java index f0ce811c..72decf06 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/exception/EventMeshAdminException.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/kafka/KafkaZkAdminOperation.java @@ -15,26 +15,28 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.common.exception; -import org.apache.eventmesh.dashboard.common.enums.Status; +package org.apache.eventmesh.dashboard.core.function.SDK.operation.kafka; -/** - * EventMeshAdmin Application side exception - */ +import org.apache.eventmesh.dashboard.core.function.SDK.AbstractSDKOperation; +import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateKafkaZkConfig; -public class EventMeshAdminException extends BaseException { +import org.apache.zookeeper.ZooKeeper; - private static final long serialVersionUID = 2002022502005456586L; +/** + * user ZooKeeper or KafkaZkClient or ZookeeperAdmin + * + * @see org.apache.eventmesh.dashboard.core.function.SDK.operation.zookeeper.ZookeeperAdmin + */ +public class KafkaZkAdminOperation extends AbstractSDKOperation { - public EventMeshAdminException(String message) { - super(message); + @Override + public ZooKeeper createClient(CreateKafkaZkConfig clientConfig) throws Exception { + return null; } - /** - * Customized error reporting using enums and exceptions - */ - public EventMeshAdminException(Status status, Throwable cause) { - super(status, cause); + @Override + public void close(ZooKeeper client) throws Exception { + client.close(); } } diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/kubernetes/KubernetesClientOperation.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/kubernetes/KubernetesClientOperation.java new file mode 100644 index 00000000..6b888f17 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/kubernetes/KubernetesClientOperation.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.core.function.SDK.operation.kubernetes; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.common.enums.RemotingType; +import org.apache.eventmesh.dashboard.core.function.SDK.AbstractSDKOperation; +import org.apache.eventmesh.dashboard.core.function.SDK.SDKMetadata; +import org.apache.eventmesh.dashboard.core.function.SDK.SDKTypeEnum; +import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateKubernetesConfig; + +import io.fabric8.kubernetes.client.KubernetesClient; +import io.fabric8.kubernetes.client.KubernetesClientBuilder; + + +@SDKMetadata(clusterType = ClusterType.KUBERNETES_RUNTIME, remotingType = RemotingType.KUBERNETES, sdkTypeEnum = { + SDKTypeEnum.ADMIN, SDKTypeEnum.PING}) +public class KubernetesClientOperation extends AbstractSDKOperation { + + @Override + public KubernetesClient createClient(CreateKubernetesConfig clientConfig) throws Exception { + KubernetesClientBuilder kubernetesClientBuilder = new KubernetesClientBuilder(); + kubernetesClientBuilder.withConfig(this.getBaseSyncBase().getConfig()); + return kubernetesClientBuilder.build(); + } + + @Override + public void close(KubernetesClient client) throws Exception { + + } +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/rocketmq/RocketMQAdminOperation.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/rocketmq/RocketMQAdminOperation.java index f655fe13..4baa7465 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/rocketmq/RocketMQAdminOperation.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/rocketmq/RocketMQAdminOperation.java @@ -15,40 +15,29 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.core.function.SDK.operation.rocketmq; import org.apache.eventmesh.dashboard.core.function.SDK.AbstractSDKOperation; -import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateRocketmqConfig; -import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateSDKConfig; +import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateRocketmqAdminSDKConfig; -import org.apache.rocketmq.client.exception.MQClientException; -import org.apache.rocketmq.client.producer.DefaultMQProducer; import org.apache.rocketmq.tools.admin.DefaultMQAdminExt; -import java.util.AbstractMap.SimpleEntry; - import lombok.extern.slf4j.Slf4j; @Slf4j -public class RocketMQAdminOperation extends AbstractSDKOperation { +public class RocketMQAdminOperation extends AbstractSDKOperation { @Override - public SimpleEntry createClient(CreateSDKConfig clientConfig) { - DefaultMQAdminExt admin = null; - try { - - CreateRocketmqConfig config = (CreateRocketmqConfig) clientConfig; - admin = new DefaultMQAdminExt(); - admin.setNamesrvAddr(config.getNameServerUrl()); - admin.start(); - } catch (MQClientException e) { - log.error("create rocketmq producer failed", e); - } - return new SimpleEntry<>(clientConfig.getUniqueKey(), admin); + public DefaultMQAdminExt createClient(CreateRocketmqAdminSDKConfig clientConfig) throws Exception { + DefaultMQAdminExt admin = new DefaultMQAdminExt(); + admin.setNamesrvAddr(clientConfig.doUniqueKey()); + admin.start(); + return admin; } @Override - public void close(Object client) { - ((DefaultMQProducer) client).shutdown(); + public void close(DefaultMQAdminExt client) throws Exception { + client.shutdown(); } } diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/rocketmq/RocketMQProduceSDKOperation.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/rocketmq/RocketMQProduceSDKOperation.java index a31aede0..81c40ac4 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/rocketmq/RocketMQProduceSDKOperation.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/rocketmq/RocketMQProduceSDKOperation.java @@ -15,39 +15,35 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.core.function.SDK.operation.rocketmq; +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.common.enums.RemotingType; import org.apache.eventmesh.dashboard.core.function.SDK.AbstractSDKOperation; -import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateRocketmqConfig; -import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateSDKConfig; +import org.apache.eventmesh.dashboard.core.function.SDK.SDKMetadata; +import org.apache.eventmesh.dashboard.core.function.SDK.SDKTypeEnum; +import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateRocketmqProduceSDKConfig; -import org.apache.rocketmq.client.exception.MQClientException; import org.apache.rocketmq.client.producer.DefaultMQProducer; -import java.util.AbstractMap.SimpleEntry; - import lombok.extern.slf4j.Slf4j; @Slf4j -public class RocketMQProduceSDKOperation extends AbstractSDKOperation { +@SDKMetadata(clusterType = ClusterType.RUNTIME_ROCKETMQ_BROKER, remotingType = RemotingType.ROCKETMQ, sdkTypeEnum = SDKTypeEnum.PRODUCER) +public class RocketMQProduceSDKOperation extends AbstractSDKOperation { @Override - public SimpleEntry createClient(CreateSDKConfig clientConfig) { - DefaultMQProducer producer = null; - try { - CreateRocketmqConfig config = (CreateRocketmqConfig) clientConfig; - producer = new DefaultMQProducer(config.getProducerGroup()); - producer.setNamesrvAddr(config.getNameServerUrl()); - producer.setCompressMsgBodyOverHowmuch(16); - producer.start(); - } catch (MQClientException e) { - log.error("create rocketmq producer failed", e); - } - return new SimpleEntry<>(clientConfig.getUniqueKey(), producer); + public DefaultMQProducer createClient(CreateRocketmqProduceSDKConfig clientConfig) throws Exception { + DefaultMQProducer producer = new DefaultMQProducer(clientConfig.getProducerGroup()); + producer.setNamesrvAddr(clientConfig.doUniqueKey()); + producer.setCompressMsgBodyOverHowmuch(16); + producer.start(); + return producer; } @Override - public void close(Object client) { - ((DefaultMQProducer) client).shutdown(); + public void close(DefaultMQProducer client) { + client.shutdown(); } } diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/rocketmq/RocketMQPushConsumerSDKOperation.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/rocketmq/RocketMQPushConsumerSDKOperation.java index 37d71c25..055a3d48 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/rocketmq/RocketMQPushConsumerSDKOperation.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/rocketmq/RocketMQPushConsumerSDKOperation.java @@ -15,41 +15,35 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.core.function.SDK.operation.rocketmq; +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.common.enums.RemotingType; import org.apache.eventmesh.dashboard.core.function.SDK.AbstractSDKOperation; -import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateRocketmqConfig; -import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateSDKConfig; +import org.apache.eventmesh.dashboard.core.function.SDK.SDKMetadata; +import org.apache.eventmesh.dashboard.core.function.SDK.SDKTypeEnum; +import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateRocketmqConsumerSDKConfig; import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer; -import org.apache.rocketmq.client.exception.MQClientException; - -import java.util.AbstractMap.SimpleEntry; import lombok.extern.slf4j.Slf4j; @Slf4j -public class RocketMQPushConsumerSDKOperation extends AbstractSDKOperation { +@SDKMetadata(clusterType = ClusterType.RUNTIME_ROCKETMQ_BROKER, remotingType = RemotingType.ROCKETMQ, sdkTypeEnum = SDKTypeEnum.CONSUMER) +public class RocketMQPushConsumerSDKOperation extends AbstractSDKOperation { @Override - public SimpleEntry createClient(CreateSDKConfig clientConfig) { - DefaultMQPushConsumer consumer = null; - try { - CreateRocketmqConfig config = (CreateRocketmqConfig) clientConfig; - consumer = new DefaultMQPushConsumer(config.getConsumerGroup()); - consumer.setMessageModel(config.getMessageModel()); - consumer.setNamesrvAddr(config.getNameServerUrl()); - consumer.subscribe(config.getTopic(), config.getSubExpression()); - //consumer.registerMessageListener(config.getMessageListener()); - consumer.start(); - } catch (MQClientException e) { - log.error("create rocketmq push consumer failed", e); - } - return new SimpleEntry(((CreateRocketmqConfig) clientConfig).getNameServerUrl(), consumer); + public DefaultMQPushConsumer createClient(CreateRocketmqConsumerSDKConfig clientConfig) throws Exception { + DefaultMQPushConsumer consumer = new DefaultMQPushConsumer(clientConfig.getConsumerGroup()); + consumer.setMessageModel(clientConfig.getMessageModel()); + consumer.setNamesrvAddr(clientConfig.doUniqueKey()); + consumer.subscribe(clientConfig.getTopic(), clientConfig.getSubExpression()); + return consumer; } @Override - public void close(Object client) { - ((DefaultMQPushConsumer) client).shutdown(); + public void close(DefaultMQPushConsumer client) { + client.shutdown(); } } diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/rocketmq/RocketMQRemotingSDKOperation.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/rocketmq/RocketMQRemotingSDKOperation.java index 00ad867e..f0e3f6ba 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/rocketmq/RocketMQRemotingSDKOperation.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/rocketmq/RocketMQRemotingSDKOperation.java @@ -15,30 +15,148 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.core.function.SDK.operation.rocketmq; +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.common.enums.RemotingType; import org.apache.eventmesh.dashboard.core.function.SDK.AbstractSDKOperation; -import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateSDKConfig; +import org.apache.eventmesh.dashboard.core.function.SDK.SDKMetadata; +import org.apache.eventmesh.dashboard.core.function.SDK.SDKTypeEnum; +import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateRemotingConfig; +import org.apache.eventmesh.dashboard.core.function.SDK.operation.rocketmq.RocketMQRemotingSDKOperation.DefaultRemotingClient; +import org.apache.rocketmq.remoting.InvokeCallback; +import org.apache.rocketmq.remoting.RPCHook; import org.apache.rocketmq.remoting.RemotingClient; +import org.apache.rocketmq.remoting.exception.RemotingConnectException; +import org.apache.rocketmq.remoting.exception.RemotingSendRequestException; +import org.apache.rocketmq.remoting.exception.RemotingTimeoutException; +import org.apache.rocketmq.remoting.exception.RemotingTooMuchRequestException; import org.apache.rocketmq.remoting.netty.NettyClientConfig; import org.apache.rocketmq.remoting.netty.NettyRemotingClient; +import org.apache.rocketmq.remoting.netty.NettyRequestProcessor; +import org.apache.rocketmq.remoting.protocol.RemotingCommand; -import java.util.AbstractMap.SimpleEntry; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutorService; -public class RocketMQRemotingSDKOperation extends AbstractSDKOperation { +@SDKMetadata(clusterType = {ClusterType.STORAGE_ROCKETMQ_BROKER_MAIN_SLAVE, + ClusterType.STORAGE_ROCKETMQ_NAMESERVER, ClusterType.STORAGE_ROCKETMQ_BROKER_RAFT}, remotingType = RemotingType.ROCKETMQ, + sdkTypeEnum = {SDKTypeEnum.ADMIN, SDKTypeEnum.PING}) +public class RocketMQRemotingSDKOperation extends AbstractSDKOperation { - @Override - public SimpleEntry createClient(CreateSDKConfig clientConfig) { + private RemotingClient remotingClient; + + { + // TODO NettyClientConfig config = new NettyClientConfig(); config.setUseTLS(false); - RemotingClient remotingClient = new NettyRemotingClient(config); + remotingClient = new NettyRemotingClient(config); remotingClient.start(); - return new SimpleEntry<>(clientConfig.getUniqueKey(), remotingClient); + } + + /** + * 是否需要封装下 RemotingClient 没有 addr + * + * @param clientConfig + * @return + */ + @Override + public DefaultRemotingClient createClient(CreateRemotingConfig clientConfig) { + DefaultRemotingClient defaultRemotingClient = new DefaultRemotingClient(); + defaultRemotingClient.remotingClient = this.remotingClient; + defaultRemotingClient.addr = clientConfig.getNetAddress().getAddress(); + return defaultRemotingClient; } @Override - public void close(Object client) { - ((RemotingClient) client).shutdown(); + public void close(DefaultRemotingClient client) { + client.shutdown(); + } + + public static class DefaultRemotingClient { + + private String addr; + + private RemotingClient remotingClient; + + + public void updateNameServerAddressList(List addrs) { + this.remotingClient.updateNameServerAddressList(addrs); + } + + + public List getNameServerAddressList() { + return this.remotingClient.getNameServerAddressList(); + } + + + public List getAvailableNameSrvList() { + return this.remotingClient.getAvailableNameSrvList(); + } + + + public RemotingCommand invokeSync(RemotingCommand request, long timeoutMillis) + throws InterruptedException, RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException { + return this.remotingClient.invokeSync(this.addr, request, timeoutMillis); + } + + + public void invokeAsync(RemotingCommand request, long timeoutMillis, InvokeCallback invokeCallback) + throws InterruptedException, RemotingConnectException, RemotingTooMuchRequestException, RemotingTimeoutException, + RemotingSendRequestException { + this.remotingClient.invokeAsync(this.addr, request, timeoutMillis, invokeCallback); + } + + + public void invokeOneway(RemotingCommand request, long timeoutMillis) + throws InterruptedException, RemotingConnectException, RemotingTooMuchRequestException, RemotingTimeoutException, + RemotingSendRequestException { + this.remotingClient.invokeOneway(this.addr, request, timeoutMillis); + } + + + public void registerProcessor(int requestCode, NettyRequestProcessor processor, ExecutorService executor) { + this.remotingClient.registerProcessor(requestCode, processor, executor); + } + + + public boolean isChannelWritable(String addr) { + return this.remotingClient.isChannelWritable(this.addr); + } + + + public boolean isAddressReachable(String addr) { + return this.remotingClient.isAddressReachable(this.addr); + } + + + public void closeChannels(List addrList) { + this.remotingClient.closeChannels(addrList); + } + + + public void start() { + this.remotingClient.start(); + } + + + public void shutdown() { + List addrList = new ArrayList<>(); + addrList.add(this.addr); + this.closeChannels(addrList); + } + + + public void registerRPCHook(RPCHook rpcHook) { + + } + + + public void clearRPCHook() { + + } } } diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/runtime/RuntimeGrpcConsumerSDKOperation.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/runtime/RuntimeGrpcConsumerSDKOperation.java index 1386020a..67ee0b15 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/runtime/RuntimeGrpcConsumerSDKOperation.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/runtime/RuntimeGrpcConsumerSDKOperation.java @@ -15,40 +15,31 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.core.function.SDK.operation.runtime; import static org.apache.eventmesh.dashboard.core.function.SDK.util.RuntimeSDKOperationUtils.buildEventMeshGrpcConsumerConfig; import org.apache.eventmesh.client.grpc.config.EventMeshGrpcClientConfig; import org.apache.eventmesh.client.grpc.consumer.EventMeshGrpcConsumer; -import org.apache.eventmesh.common.exception.EventMeshException; import org.apache.eventmesh.dashboard.core.function.SDK.AbstractSDKOperation; import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateRuntimeConfig; -import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateSDKConfig; - -import java.util.AbstractMap.SimpleEntry; import lombok.extern.slf4j.Slf4j; @Slf4j -public class RuntimeGrpcConsumerSDKOperation extends AbstractSDKOperation { +public class RuntimeGrpcConsumerSDKOperation extends AbstractSDKOperation { @Override - public SimpleEntry createClient(CreateSDKConfig clientConfig) { - final CreateRuntimeConfig runtimeConfig = (CreateRuntimeConfig) clientConfig; - final EventMeshGrpcClientConfig grpcClientConfig = buildEventMeshGrpcConsumerConfig(runtimeConfig); - EventMeshGrpcConsumer grpcConsumer = null; - try { - grpcConsumer = new EventMeshGrpcConsumer(grpcClientConfig); - grpcConsumer.init(); - } catch (EventMeshException e) { - log.error("create runtime grpc Consumer client failed", e); - } - return new SimpleEntry<>(clientConfig.getUniqueKey(), grpcConsumer); + public EventMeshGrpcConsumer createClient(CreateRuntimeConfig clientConfig) { + final EventMeshGrpcClientConfig grpcClientConfig = buildEventMeshGrpcConsumerConfig(clientConfig); + EventMeshGrpcConsumer grpcConsumer = new EventMeshGrpcConsumer(grpcClientConfig); + grpcConsumer.init(); + return grpcConsumer; } @Override - public void close(Object client) { - castClient(client).close(); + public void close(EventMeshGrpcConsumer client) { + client.close(); } } diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/runtime/RuntimeGrpcProducerSDKOperation.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/runtime/RuntimeGrpcProducerSDKOperation.java index 2c4c8460..7fac2e91 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/runtime/RuntimeGrpcProducerSDKOperation.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/runtime/RuntimeGrpcProducerSDKOperation.java @@ -15,39 +15,31 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.core.function.SDK.operation.runtime; import static org.apache.eventmesh.dashboard.core.function.SDK.util.RuntimeSDKOperationUtils.buildEventMeshGrpcProducerConfig; import org.apache.eventmesh.client.grpc.config.EventMeshGrpcClientConfig; import org.apache.eventmesh.client.grpc.producer.EventMeshGrpcProducer; -import org.apache.eventmesh.common.exception.EventMeshException; import org.apache.eventmesh.dashboard.core.function.SDK.AbstractSDKOperation; import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateRuntimeConfig; -import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateSDKConfig; - -import java.util.AbstractMap.SimpleEntry; import lombok.extern.slf4j.Slf4j; @Slf4j -public class RuntimeGrpcProducerSDKOperation extends AbstractSDKOperation { +public class RuntimeGrpcProducerSDKOperation extends AbstractSDKOperation { @Override - public SimpleEntry createClient(CreateSDKConfig clientConfig) { - final CreateRuntimeConfig runtimeConfig = (CreateRuntimeConfig) clientConfig; - final EventMeshGrpcClientConfig grpcClientConfig = buildEventMeshGrpcProducerConfig(runtimeConfig); - EventMeshGrpcProducer grpcProducer = null; - try { - grpcProducer = new EventMeshGrpcProducer(grpcClientConfig); - } catch (EventMeshException e) { - log.error("create runtime grpc Producer client failed", e); - } - return new SimpleEntry<>(clientConfig.getUniqueKey(), grpcProducer); + public EventMeshGrpcProducer createClient(CreateRuntimeConfig clientConfig) throws Exception { + final EventMeshGrpcClientConfig grpcClientConfig = buildEventMeshGrpcProducerConfig(clientConfig); + EventMeshGrpcProducer grpcProducer = new EventMeshGrpcProducer(grpcClientConfig); + return grpcProducer; + } @Override - public void close(Object client) { - castClient(client).close(); + public void close(EventMeshGrpcProducer client) throws Exception { + client.close(); } } diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/runtime/RuntimeHttpConsumerSDKOperation.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/runtime/RuntimeHttpConsumerSDKOperation.java index 553ed3c7..6dfd1112 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/runtime/RuntimeHttpConsumerSDKOperation.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/runtime/RuntimeHttpConsumerSDKOperation.java @@ -15,39 +15,29 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.core.function.SDK.operation.runtime; import static org.apache.eventmesh.dashboard.core.function.SDK.util.RuntimeSDKOperationUtils.buildEventMeshHttpConsumerConfig; import org.apache.eventmesh.client.http.conf.EventMeshHttpClientConfig; import org.apache.eventmesh.client.http.consumer.EventMeshHttpConsumer; -import org.apache.eventmesh.common.exception.EventMeshException; import org.apache.eventmesh.dashboard.core.function.SDK.AbstractSDKOperation; import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateRuntimeConfig; -import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateSDKConfig; - -import java.util.AbstractMap.SimpleEntry; import lombok.extern.slf4j.Slf4j; @Slf4j -public class RuntimeHttpConsumerSDKOperation extends AbstractSDKOperation { +public class RuntimeHttpConsumerSDKOperation extends AbstractSDKOperation { @Override - public SimpleEntry createClient(CreateSDKConfig clientConfig) { - final CreateRuntimeConfig runtimeConfig = (CreateRuntimeConfig) clientConfig; + public EventMeshHttpConsumer createClient(CreateRuntimeConfig runtimeConfig) { final EventMeshHttpClientConfig httpClientConfig = buildEventMeshHttpConsumerConfig(runtimeConfig); - EventMeshHttpConsumer httpConsumer = null; - try { - httpConsumer = new EventMeshHttpConsumer(httpClientConfig); - } catch (EventMeshException e) { - log.error("create runtime http Consumer client failed", e); - } - return new SimpleEntry<>(clientConfig.getUniqueKey(), httpConsumer); + return new EventMeshHttpConsumer(httpClientConfig); } @Override - public void close(Object client) { - castClient(client).close(); + public void close(EventMeshHttpConsumer client) { + client.close(); } } diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/runtime/RuntimeHttpProducerSDKOperation.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/runtime/RuntimeHttpProducerSDKOperation.java index 6caa0b1a..7d657ddf 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/runtime/RuntimeHttpProducerSDKOperation.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/runtime/RuntimeHttpProducerSDKOperation.java @@ -15,39 +15,31 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.core.function.SDK.operation.runtime; import static org.apache.eventmesh.dashboard.core.function.SDK.util.RuntimeSDKOperationUtils.buildEventMeshHttpProducerConfig; import org.apache.eventmesh.client.http.conf.EventMeshHttpClientConfig; import org.apache.eventmesh.client.http.producer.EventMeshHttpProducer; -import org.apache.eventmesh.common.exception.EventMeshException; import org.apache.eventmesh.dashboard.core.function.SDK.AbstractSDKOperation; import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateRuntimeConfig; -import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateSDKConfig; - -import java.util.AbstractMap.SimpleEntry; import lombok.extern.slf4j.Slf4j; @Slf4j -public class RuntimeHttpProducerSDKOperation extends AbstractSDKOperation { +public class RuntimeHttpProducerSDKOperation extends AbstractSDKOperation { @Override - public SimpleEntry createClient(CreateSDKConfig clientConfig) { - final CreateRuntimeConfig runtimeConfig = (CreateRuntimeConfig) clientConfig; + public EventMeshHttpProducer createClient(CreateRuntimeConfig runtimeConfig) throws Exception { final EventMeshHttpClientConfig httpClientConfig = buildEventMeshHttpProducerConfig(runtimeConfig); - EventMeshHttpProducer httpProducer = null; - try { - httpProducer = new EventMeshHttpProducer(httpClientConfig); - } catch (EventMeshException e) { - log.error("create runtime http Producer client failed", e); - } - return new SimpleEntry<>(clientConfig.getUniqueKey(), httpProducer); + + return new EventMeshHttpProducer(httpClientConfig); + } @Override - public void close(Object client) { - castClient(client).close(); + public void close(EventMeshHttpProducer client) throws Exception { + client.close(); } } diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/runtime/RuntimeSDKOperation.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/runtime/RuntimeSDKOperation.java index a51bb8ad..7be25b50 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/runtime/RuntimeSDKOperation.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/runtime/RuntimeSDKOperation.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.core.function.SDK.operation.runtime; import org.apache.eventmesh.client.grpc.consumer.EventMeshGrpcConsumer; @@ -25,17 +26,19 @@ import org.apache.eventmesh.client.tcp.impl.eventmeshmessage.EventMeshMessageTCPClient; import org.apache.eventmesh.client.tcp.impl.openmessage.OpenMessageTCPClient; import org.apache.eventmesh.common.Constants; +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.common.enums.RemotingType; import org.apache.eventmesh.dashboard.core.function.SDK.AbstractSDKOperation; +import org.apache.eventmesh.dashboard.core.function.SDK.SDKMetadata; +import org.apache.eventmesh.dashboard.core.function.SDK.SDKTypeEnum; import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateRuntimeConfig; -import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateSDKConfig; import org.apache.eventmesh.dashboard.core.function.SDK.wrapper.RuntimeSDKWrapper; -import java.util.AbstractMap.SimpleEntry; - import lombok.extern.slf4j.Slf4j; @Slf4j -public class RuntimeSDKOperation extends AbstractSDKOperation { +@SDKMetadata(clusterType = {ClusterType.EVENTMESH_RUNTIME}, remotingType = RemotingType.EVENT_MESH_RUNTIME, sdkTypeEnum = SDKTypeEnum.ALL) +public class RuntimeSDKOperation extends AbstractSDKOperation { private final RuntimeTcpCloudEventSDKOperation tcpCloudEventSDKOperation = new RuntimeTcpCloudEventSDKOperation(); private final RuntimeTcpEventMeshSDKOperation tcpEventMeshSDKOperation = new RuntimeTcpEventMeshSDKOperation(); @@ -48,33 +51,32 @@ public class RuntimeSDKOperation extends AbstractSDKOperation private final RuntimeGrpcConsumerSDKOperation grpcConsumerSDKOperation = new RuntimeGrpcConsumerSDKOperation(); @Override - public SimpleEntry createClient(CreateSDKConfig clientConfig) { - CreateRuntimeConfig runtimeConfig = (CreateRuntimeConfig) clientConfig; - final String protocol = ((CreateRuntimeConfig) clientConfig).getProtocol(); - final String protocolName = ((CreateRuntimeConfig) clientConfig).getProtocolName(); - final String clientType = ((CreateRuntimeConfig) clientConfig).getClientType(); + public RuntimeSDKWrapper createClient(CreateRuntimeConfig runtimeConfig) throws Exception { + final String protocol = runtimeConfig.getProtocol(); + final String protocolName = runtimeConfig.getProtocolName(); + final String clientType = runtimeConfig.getClientType(); - SimpleEntry cloudSimpleEntry = null; - SimpleEntry eventMeshMessageSimpleEntry = null; - SimpleEntry openMessageSimpleEntry = null; + CloudEventTCPClient cloudSimple = null; + EventMeshMessageTCPClient eventMeshMessageSimple = null; + OpenMessageTCPClient openMessageSimple = null; - SimpleEntry httpProducerSimpleEntry = null; - SimpleEntry httpConsumerSimpleEntry = null; + EventMeshHttpProducer httpProducerSimple = null; + EventMeshHttpConsumer httpConsumerSimple = null; - SimpleEntry grpcProducerSimpleEntry = null; - SimpleEntry grpcConsumerSimpleEntry = null; + EventMeshGrpcProducer grpcProducerSimple = null; + EventMeshGrpcConsumer grpcConsumerSimple = null; switch (protocol) { case Constants.TCP: switch (protocolName) { case Constants.CLOUD_EVENTS_PROTOCOL_NAME: - cloudSimpleEntry = tcpCloudEventSDKOperation.createClient(runtimeConfig); + cloudSimple = tcpCloudEventSDKOperation.createClient(runtimeConfig); break; case Constants.EM_MESSAGE_PROTOCOL_NAME: - eventMeshMessageSimpleEntry = tcpEventMeshSDKOperation.createClient(runtimeConfig); + eventMeshMessageSimple = tcpEventMeshSDKOperation.createClient(runtimeConfig); break; case Constants.OPEN_MESSAGE_PROTOCOL_NAME: - openMessageSimpleEntry = tcpOpenMessageSDKOperation.createClient(runtimeConfig); + openMessageSimple = tcpOpenMessageSDKOperation.createClient(runtimeConfig); break; default: break; @@ -83,10 +85,10 @@ public SimpleEntry createClient(CreateSDKConfig clien case Constants.HTTP: switch (clientType) { case "producer": - httpProducerSimpleEntry = httpProducerSDKOperation.createClient(runtimeConfig); + httpProducerSimple = httpProducerSDKOperation.createClient(runtimeConfig); break; case "consumer": - httpConsumerSimpleEntry = httpConsumerSDKOperation.createClient(runtimeConfig); + httpConsumerSimple = httpConsumerSDKOperation.createClient(runtimeConfig); break; default: break; @@ -95,10 +97,10 @@ public SimpleEntry createClient(CreateSDKConfig clien case Constants.GRPC: switch (clientType) { case "producer": - grpcProducerSimpleEntry = grpcProducerSDKOperation.createClient(runtimeConfig); + grpcProducerSimple = grpcProducerSDKOperation.createClient(runtimeConfig); break; case "consumer": - grpcConsumerSimpleEntry = grpcConsumerSDKOperation.createClient(runtimeConfig); + grpcConsumerSimple = grpcConsumerSDKOperation.createClient(runtimeConfig); break; default: break; @@ -108,20 +110,13 @@ public SimpleEntry createClient(CreateSDKConfig clien log.warn("clients that do not support the current protocol"); break; } - RuntimeSDKWrapper runtimeClient = new RuntimeSDKWrapper( - cloudSimpleEntry != null ? cloudSimpleEntry.getValue() : null, - eventMeshMessageSimpleEntry != null ? eventMeshMessageSimpleEntry.getValue() : null, - openMessageSimpleEntry != null ? openMessageSimpleEntry.getValue() : null, - httpProducerSimpleEntry != null ? httpProducerSimpleEntry.getValue() : null, - httpConsumerSimpleEntry != null ? httpConsumerSimpleEntry.getValue() : null, - grpcProducerSimpleEntry != null ? grpcProducerSimpleEntry.getValue() : null, - grpcConsumerSimpleEntry != null ? grpcConsumerSimpleEntry.getValue() : null - ); - return new SimpleEntry<>(clientConfig.getUniqueKey(), runtimeClient); + return new RuntimeSDKWrapper(cloudSimple, eventMeshMessageSimple, openMessageSimple, httpProducerSimple, httpConsumerSimple, + grpcProducerSimple, grpcConsumerSimple); + } @Override - public void close(Object client) { - castClient(client).close(); + public void close(RuntimeSDKWrapper client) throws Exception { + client.close(); } } diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/runtime/RuntimeTcpCloudEventSDKOperation.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/runtime/RuntimeTcpCloudEventSDKOperation.java index 1b8dd730..0e59aaf0 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/runtime/RuntimeTcpCloudEventSDKOperation.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/runtime/RuntimeTcpCloudEventSDKOperation.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.core.function.SDK.operation.runtime; import static org.apache.eventmesh.dashboard.core.function.SDK.util.RuntimeSDKOperationUtils.buildEventMeshTCPClientConfig; @@ -22,41 +23,28 @@ import org.apache.eventmesh.client.tcp.conf.EventMeshTCPClientConfig; import org.apache.eventmesh.client.tcp.impl.cloudevent.CloudEventTCPClient; -import org.apache.eventmesh.common.exception.EventMeshException; import org.apache.eventmesh.common.protocol.tcp.UserAgent; import org.apache.eventmesh.dashboard.core.function.SDK.AbstractSDKOperation; import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateRuntimeConfig; -import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateSDKConfig; - -import java.util.AbstractMap.SimpleEntry; import lombok.extern.slf4j.Slf4j; @Slf4j -public class RuntimeTcpCloudEventSDKOperation extends AbstractSDKOperation { +public class RuntimeTcpCloudEventSDKOperation extends AbstractSDKOperation { @Override - public SimpleEntry createClient(CreateSDKConfig clientConfig) { - final CreateRuntimeConfig runtimeConfig = (CreateRuntimeConfig) clientConfig; - CloudEventTCPClient cloudEventTCPClient = null; - try { - final UserAgent userAgent = buildUserAgent(runtimeConfig.getUserAgent()); - final EventMeshTCPClientConfig eventMeshTCPClientConfig = buildEventMeshTCPClientConfig( - runtimeConfig.getRuntimeServerAddress(), userAgent); - cloudEventTCPClient = new CloudEventTCPClient(eventMeshTCPClientConfig); - cloudEventTCPClient.init(); - } catch (EventMeshException e) { - log.error("create runtime CloudEvent tcp client failed", e); - } - return new SimpleEntry<>(clientConfig.getUniqueKey(), cloudEventTCPClient); + public CloudEventTCPClient createClient(CreateRuntimeConfig clientConfig) throws Exception { + final UserAgent userAgent = buildUserAgent(clientConfig.getUserAgent()); + final EventMeshTCPClientConfig eventMeshTCPClientConfig = buildEventMeshTCPClientConfig( + clientConfig.getRuntimeServerAddress(), userAgent); + CloudEventTCPClient cloudEventTCPClient = new CloudEventTCPClient(eventMeshTCPClientConfig); + cloudEventTCPClient.init(); + return cloudEventTCPClient; + } @Override - public void close(Object client) { - try { - castClient(client).close(); - } catch (Exception e) { - log.error("close eventmesh runtime tcp client failed"); - } + public void close(CloudEventTCPClient client) throws Exception { + client.close(); } } diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/runtime/RuntimeTcpEventMeshSDKOperation.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/runtime/RuntimeTcpEventMeshSDKOperation.java index e13843b9..3ad0edb8 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/runtime/RuntimeTcpEventMeshSDKOperation.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/runtime/RuntimeTcpEventMeshSDKOperation.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.core.function.SDK.operation.runtime; import static org.apache.eventmesh.dashboard.core.function.SDK.util.RuntimeSDKOperationUtils.buildEventMeshTCPClientConfig; @@ -22,41 +23,27 @@ import org.apache.eventmesh.client.tcp.conf.EventMeshTCPClientConfig; import org.apache.eventmesh.client.tcp.impl.eventmeshmessage.EventMeshMessageTCPClient; -import org.apache.eventmesh.common.exception.EventMeshException; import org.apache.eventmesh.common.protocol.tcp.UserAgent; import org.apache.eventmesh.dashboard.core.function.SDK.AbstractSDKOperation; import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateRuntimeConfig; -import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateSDKConfig; - -import java.util.AbstractMap.SimpleEntry; import lombok.extern.slf4j.Slf4j; @Slf4j -public class RuntimeTcpEventMeshSDKOperation extends AbstractSDKOperation { +public class RuntimeTcpEventMeshSDKOperation extends AbstractSDKOperation { @Override - public SimpleEntry createClient(CreateSDKConfig clientConfig) { - final CreateRuntimeConfig runtimeConfig = (CreateRuntimeConfig) clientConfig; - EventMeshMessageTCPClient eventMeshTCPClient = null; - try { - UserAgent userAgent = buildUserAgent(runtimeConfig.getUserAgent()); - final EventMeshTCPClientConfig eventMeshTCPClientConfig = buildEventMeshTCPClientConfig( - runtimeConfig.getRuntimeServerAddress(), userAgent); - eventMeshTCPClient = new EventMeshMessageTCPClient(eventMeshTCPClientConfig); - eventMeshTCPClient.init(); - } catch (EventMeshException e) { - log.error("create runtime EventMeshMessage tcp client failed", e); - } - return new SimpleEntry<>(clientConfig.getUniqueKey(), eventMeshTCPClient); + public EventMeshMessageTCPClient createClient(CreateRuntimeConfig runtimeConfig) throws Exception { + UserAgent userAgent = buildUserAgent(runtimeConfig.getUserAgent()); + final EventMeshTCPClientConfig eventMeshTCPClientConfig = buildEventMeshTCPClientConfig( + runtimeConfig.getRuntimeServerAddress(), userAgent); + EventMeshMessageTCPClient eventMeshTCPClient = new EventMeshMessageTCPClient(eventMeshTCPClientConfig); + eventMeshTCPClient.init(); + return eventMeshTCPClient; } @Override - public void close(Object client) { - try { - castClient(client).close(); - } catch (Exception e) { - log.error("EventMeshMessage client close failed", e); - } + public void close(EventMeshMessageTCPClient client) throws Exception { + client.close(); } } diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/runtime/RuntimeTcpOpenMessageSDKOperation.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/runtime/RuntimeTcpOpenMessageSDKOperation.java index 5086ce97..7cf8f110 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/runtime/RuntimeTcpOpenMessageSDKOperation.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/runtime/RuntimeTcpOpenMessageSDKOperation.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.core.function.SDK.operation.runtime; import static org.apache.eventmesh.dashboard.core.function.SDK.util.RuntimeSDKOperationUtils.buildEventMeshTCPClientConfig; @@ -25,33 +26,24 @@ import org.apache.eventmesh.common.protocol.tcp.UserAgent; import org.apache.eventmesh.dashboard.core.function.SDK.AbstractSDKOperation; import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateRuntimeConfig; -import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateSDKConfig; - -import java.util.AbstractMap; import lombok.extern.slf4j.Slf4j; @Slf4j -public class RuntimeTcpOpenMessageSDKOperation extends AbstractSDKOperation { +public class RuntimeTcpOpenMessageSDKOperation extends AbstractSDKOperation { @Override - public AbstractMap.SimpleEntry createClient(CreateSDKConfig clientConfig) { - final CreateRuntimeConfig runtimeConfig = (CreateRuntimeConfig) clientConfig; - OpenMessageTCPClient openMessageTCPClient = null; - try { - UserAgent userAgent = buildUserAgent(runtimeConfig.getUserAgent()); - final EventMeshTCPClientConfig eventMeshTCPClientConfig = buildEventMeshTCPClientConfig( - runtimeConfig.getRuntimeServerAddress(), userAgent); - openMessageTCPClient = new OpenMessageTCPClient(eventMeshTCPClientConfig); - openMessageTCPClient.init(); - } catch (Exception e) { - log.error("create runtime eventmesh OpenMessage client failed", e); - } - return new AbstractMap.SimpleEntry<>(clientConfig.getUniqueKey(), openMessageTCPClient); + public OpenMessageTCPClient createClient(CreateRuntimeConfig clientConfig) throws Exception { + UserAgent userAgent = buildUserAgent(clientConfig.getUserAgent()); + final EventMeshTCPClientConfig eventMeshTCPClientConfig = buildEventMeshTCPClientConfig( + clientConfig.getRuntimeServerAddress(), userAgent); + OpenMessageTCPClient openMessageTCPClient = new OpenMessageTCPClient(eventMeshTCPClientConfig); + openMessageTCPClient.init(); + return openMessageTCPClient; } @Override - public void close(Object client) { - castClient(client).close(); + public void close(OpenMessageTCPClient client) throws Exception { + client.close(); } } diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/zookeeper/ZookeeperAdmin.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/zookeeper/ZookeeperAdmin.java new file mode 100644 index 00000000..f51fb777 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/zookeeper/ZookeeperAdmin.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.core.function.SDK.operation.zookeeper; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.common.enums.RemotingType; +import org.apache.eventmesh.dashboard.core.function.SDK.AbstractSDKOperation; +import org.apache.eventmesh.dashboard.core.function.SDK.SDKMetadata; +import org.apache.eventmesh.dashboard.core.function.SDK.SDKTypeEnum; +import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateZookeeperConfig; + +import org.apache.zookeeper.ZooKeeper; + +@SDKMetadata(clusterType = {ClusterType.STORAGE_KAFKA_ZK}, remotingType = RemotingType.KAFKA, sdkTypeEnum = { + SDKTypeEnum.ADMIN, SDKTypeEnum.PING}) +public class ZookeeperAdmin extends AbstractSDKOperation { + + @Override + public ZooKeeper createClient(CreateZookeeperConfig clientConfig) throws Exception { + + return null; + } + + @Override + public void close(ZooKeeper client) throws Exception { + client.close(); + } +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/util/RuntimeSDKOperationUtils.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/util/RuntimeSDKOperationUtils.java index 435949cd..01c5621e 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/util/RuntimeSDKOperationUtils.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/util/RuntimeSDKOperationUtils.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.core.function.SDK.util; import org.apache.eventmesh.client.grpc.config.EventMeshGrpcClientConfig; diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/wrapper/NacosSDKWrapper.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/wrapper/NacosSDKWrapper.java index 617331db..64927b50 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/wrapper/NacosSDKWrapper.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/wrapper/NacosSDKWrapper.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.core.function.SDK.wrapper; import com.alibaba.nacos.api.config.ConfigService; diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/wrapper/RuntimeSDKWrapper.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/wrapper/RuntimeSDKWrapper.java index 9e6370b3..0441cf72 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/wrapper/RuntimeSDKWrapper.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/function/SDK/wrapper/RuntimeSDKWrapper.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.core.function.SDK.wrapper; import org.apache.eventmesh.client.grpc.consumer.EventMeshGrpcConsumer; @@ -24,17 +25,14 @@ import org.apache.eventmesh.client.tcp.impl.cloudevent.CloudEventTCPClient; import org.apache.eventmesh.client.tcp.impl.eventmeshmessage.EventMeshMessageTCPClient; import org.apache.eventmesh.client.tcp.impl.openmessage.OpenMessageTCPClient; -import org.apache.eventmesh.common.exception.EventMeshException; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; -import lombok.extern.slf4j.Slf4j; @Data @AllArgsConstructor @NoArgsConstructor -@Slf4j public class RuntimeSDKWrapper { private CloudEventTCPClient tcpCloudEventClient; @@ -47,25 +45,21 @@ public class RuntimeSDKWrapper { private EventMeshGrpcProducer grpcProducerClient; private EventMeshGrpcConsumer grpcConsumerClient; - public void close() { - try { - if (tcpCloudEventClient != null) { - tcpCloudEventClient.close(); - } else if (tcpEventMeshClient != null) { - tcpEventMeshClient.close(); - } else if (openMessageTCPClient != null) { - openMessageTCPClient.close(); - } else if (httpProducerClient != null) { - httpProducerClient.close(); - } else if (httpConsumerClient != null) { - httpConsumerClient.close(); - } else if (grpcProducerClient != null) { - grpcProducerClient.close(); - } else if (grpcConsumerClient != null) { - grpcConsumerClient.close(); - } - } catch (EventMeshException e) { - log.error("runtime client close failed", e); + public void close() throws Exception { + if (tcpCloudEventClient != null) { + tcpCloudEventClient.close(); + } else if (tcpEventMeshClient != null) { + tcpEventMeshClient.close(); + } else if (openMessageTCPClient != null) { + openMessageTCPClient.close(); + } else if (httpProducerClient != null) { + httpProducerClient.close(); + } else if (httpConsumerClient != null) { + httpConsumerClient.close(); + } else if (grpcProducerClient != null) { + grpcProducerClient.close(); + } else if (grpcConsumerClient != null) { + grpcConsumerClient.close(); } } } diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/gather/jmx/JmxConnector.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/gather/jmx/JmxConnector.java new file mode 100644 index 00000000..914d6408 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/gather/jmx/JmxConnector.java @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.core.gather.jmx; + +import javax.management.remote.JMXConnector; + +public class JmxConnector { + + private JMXConnector jmxConnector; + + private void createJmxConnector() { + /* String jmxUrl = String.format("service:jmx:rmi:///jndi/rmi://%s:%d/jmxrmi", jmxHost, jmxPort); + try { + Map environment = new HashMap(); + if (!ValidateUtils.isBlank(this.jmxConfig.getUsername()) && !ValidateUtils.isBlank(this.jmxConfig.getToken())) { + // fixed by riyuetianmu + environment.put(JMXConnector.CREDENTIALS, new String[] {this.jmxConfig.getUsername(), this.jmxConfig.getToken()}); + } + if (jmxConfig.getOpenSSL() != null && this.jmxConfig.getOpenSSL()) { + environment.put(Context.SECURITY_PROTOCOL, "ssl"); + SslRMIClientSocketFactory clientSocketFactory = new SslRMIClientSocketFactory(); + environment.put(RMIConnectorServer.RMI_CLIENT_SOCKET_FACTORY_ATTRIBUTE, clientSocketFactory); + environment.put("com.sun.jndi.rmi.factory.socket", clientSocketFactory); + } + + jmxConnector = JMXConnectorFactory.connect(new JMXServiceURL(jmxUrl), environment); + LOGGER.info( + "method=createJmxConnector||clientLogIdent={}||jmxHost={}||jmxPort={}||msg=jmx connect success.", + clientLogIdent, jmxHost, jmxPort + ); + return true; + }catch (Exception e){ + + }*/ + } +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/message/MessageManage.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/message/MessageManage.java new file mode 100644 index 00000000..a1e03b31 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/message/MessageManage.java @@ -0,0 +1,112 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.core.message; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.common.util.ClasspathScanner; +import org.apache.eventmesh.dashboard.core.function.SDK.ConfigManage; +import org.apache.eventmesh.dashboard.core.function.SDK.SDKManage; +import org.apache.eventmesh.dashboard.core.function.SDK.SDKTypeEnum; +import org.apache.eventmesh.dashboard.core.function.SDK.config.AbstractMultiCreateSDKConfig; +import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateSDKConfig; +import org.apache.eventmesh.dashboard.core.message.model.AbstractMessageDTO; +import org.apache.eventmesh.dashboard.core.message.model.ConsumerDTO; +import org.apache.eventmesh.dashboard.core.message.model.ProducerDTO; +import org.apache.eventmesh.dashboard.core.message.operate.AbstractConsumerOperate; +import org.apache.eventmesh.dashboard.core.message.operate.AbstractMessageOperate; +import org.apache.eventmesh.dashboard.core.message.operate.ConsumerOperate; +import org.apache.eventmesh.dashboard.core.message.operate.ProducerOperate; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; + +public class MessageManage { + + private static final Map, Class>> MESSAGE_CLASSES = new HashMap<>(); + + static { + Set> interfaceSet = new HashSet<>(); + interfaceSet.add(ProducerOperate.class); + interfaceSet.add(ConsumerOperate.class); + ClasspathScanner classpathScanner = ClasspathScanner.builder().base(SDKManage.class).subPath("/operation").interfaceSet(interfaceSet).build(); + try { + List> classList = classpathScanner.getClazz(); + classList.forEach(MessageManage::createMessageOperate); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + static void createMessageOperate(Class clazz) { + + } + + + private Map, Map> classMapConcurrentHashMap = new ConcurrentHashMap<>(); + + + { + classMapConcurrentHashMap.put(ProducerOperate.class, new ConcurrentHashMap<>()); + classMapConcurrentHashMap.put(ConsumerOperate.class, new ConcurrentHashMap<>()); + } + + public ProducerOperate createProducerOperate(ProducerDTO producerDTO) throws Exception { + return this.createOperate(producerDTO, ProducerOperate.class, SDKTypeEnum.PRODUCER); + } + + public ConsumerOperate createConsumerOperate(ConsumerDTO consumerDTO) throws Exception { + return this.createOperate(consumerDTO, ConsumerOperate.class, SDKTypeEnum.CONSUMER); + } + + private T createOperate(AbstractMessageDTO abstractMessageDTO, Class operateClazz, SDKTypeEnum sdkTypeEnum) throws Exception { + Class clazz = MESSAGE_CLASSES.get(abstractMessageDTO.getClusterType()).get(operateClazz); + + AbstractConsumerOperate abstractConsumerOperate = (AbstractConsumerOperate) clazz.newInstance(); + AbstractMultiCreateSDKConfig abstractMultiCreateSDKConfig = + ConfigManage.getInstance().getMultiCreateSDKConfig(abstractMessageDTO.getClusterType(), sdkTypeEnum); + + CreateSDKConfig consumerConfig = abstractConsumerOperate.createSDKConfig(abstractMultiCreateSDKConfig, null); + // RocketMQ,模式如何处理? + Object client = null; + //SDKManage.getInstance().createClient(sdkTypeEnum, consumerConfig, abstractMessageDTO.getClusterType()); + abstractConsumerOperate.setClient(client); + abstractConsumerOperate.setAbstractMessageDTO(abstractMessageDTO); + + abstractConsumerOperate.start(); + String uuId = java.util.UUID.randomUUID().toString(); + classMapConcurrentHashMap.get(operateClazz).put(uuId, abstractConsumerOperate); + return (T) abstractConsumerOperate; + } + + + public List pull(String uuId) { + ConsumerOperate consumerOperate = (ConsumerOperate) classMapConcurrentHashMap.get(ConsumerOperate.class).get(uuId); + + return consumerOperate.pull(); + } + + public void send(String uuId) { + ProducerOperate producerOperate = (ProducerOperate) classMapConcurrentHashMap.get(ProducerOperate.class).get(uuId); + } +} + diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/message/model/AbstractMessageDTO.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/message/model/AbstractMessageDTO.java new file mode 100644 index 00000000..fa40d8fd --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/message/model/AbstractMessageDTO.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.core.message.model; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.common.model.metadata.QueueMetadata; + +import java.util.List; + +import lombok.Data; + + +@Data +public class AbstractMessageDTO { + + private Long clusterId; + + private ClusterType clusterType; + + private String consumerGroup; + + private String topic; + + private String group; + + private boolean simulate; + + private List queueMetadataList; + +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/message/model/ConsumerDTO.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/message/model/ConsumerDTO.java new file mode 100644 index 00000000..7130a91c --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/message/model/ConsumerDTO.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.core.message.model; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class ConsumerDTO extends AbstractMessageDTO { + + + + +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/message/model/ProducerDTO.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/message/model/ProducerDTO.java new file mode 100644 index 00000000..11325f2d --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/message/model/ProducerDTO.java @@ -0,0 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.core.message.model; + +public class ProducerDTO extends AbstractMessageDTO { + +} diff --git a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/RemotingOperate.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/message/model/SendTDO.java similarity index 87% rename from eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/RemotingOperate.java rename to eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/message/model/SendTDO.java index 24cf7f89..b590f048 100644 --- a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/RemotingOperate.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/message/model/SendTDO.java @@ -15,13 +15,11 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.service.remoting; -public enum RemotingOperate { +package org.apache.eventmesh.dashboard.core.message.model; - ADD, +public class SendTDO { - UPDATE, + private String body; - DELETE; } diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/message/operate/AbstractConsumerOperate.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/message/operate/AbstractConsumerOperate.java new file mode 100644 index 00000000..37bf33dd --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/message/operate/AbstractConsumerOperate.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.core.message.operate; + +import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateSDKConfig; +import org.apache.eventmesh.dashboard.core.message.model.ConsumerDTO; + +import java.util.ArrayList; +import java.util.List; + + +public abstract class AbstractConsumerOperate + extends AbstractMessageOperate implements ConsumerOperate { + + private List data = new ArrayList<>(); + + private int tate; + + + public List pull() { + synchronized (this.data) { + List data = this.data; + this.data = new ArrayList<>(); + return data; + } + } + +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/exception/MetaException.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/message/operate/AbstractMessageOperate.java similarity index 56% rename from eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/exception/MetaException.java rename to eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/message/operate/AbstractMessageOperate.java index b479fc6d..89c86bdb 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/exception/MetaException.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/message/operate/AbstractMessageOperate.java @@ -15,30 +15,28 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.common.exception; -import org.apache.eventmesh.dashboard.common.enums.Status; +package org.apache.eventmesh.dashboard.core.message.operate; + +import org.apache.eventmesh.dashboard.common.model.base.BaseSyncBase; +import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateSDKConfig; +import org.apache.eventmesh.dashboard.core.message.model.AbstractMessageDTO; + +import lombok.Setter; -/** - * Meta side exception with EventMeshAdmin Application - */ -public class MetaException extends BaseException { +@Setter +public abstract class AbstractMessageOperate { - private static final long serialVersionUID = 6246145526338359773L; + private DTO abstractMessageDTO; - public MetaException(String message) { - super(message); - } /** - * Customized error reporting using enums and exceptions + * TODO 不负责, 节点的改变造成的问题 */ - public MetaException(Status status, Throwable cause) { - super(status, cause); - } + private CL client; + + public abstract CreateSDKConfig createSDKConfig(C createSDKConfig, BaseSyncBase baseSyncBase); + - public MetaException(Status status) { - super(status); - } } diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/message/operate/AbstractProducerOperate.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/message/operate/AbstractProducerOperate.java new file mode 100644 index 00000000..54cc45e7 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/message/operate/AbstractProducerOperate.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.core.message.operate; + +import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateSDKConfig; +import org.apache.eventmesh.dashboard.core.message.model.ProducerDTO; + + +public abstract class AbstractProducerOperate + extends AbstractMessageOperate implements ProducerOperate { + + /** + * 是否模拟数据 + */ + private boolean simulate; + + +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/message/operate/ConsumerOperate.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/message/operate/ConsumerOperate.java new file mode 100644 index 00000000..5b76897e --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/message/operate/ConsumerOperate.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.core.message.operate; + +import java.util.List; + +/** + * + */ +public interface ConsumerOperate { + + + void start(); + + void stop(); + + List pull(); +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/message/operate/ProducerOperate.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/message/operate/ProducerOperate.java new file mode 100644 index 00000000..28febf80 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/message/operate/ProducerOperate.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.core.message.operate; + + +/** + * + */ +public interface ProducerOperate { + + + void send(Object data); + +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/meta/connection/EtcdConnectionCore.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/meta/connection/EtcdConnectionCore.java index 0a994bc7..644783c7 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/meta/connection/EtcdConnectionCore.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/meta/connection/EtcdConnectionCore.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.core.meta.connection; import org.apache.eventmesh.dashboard.service.meta.ConnectionCore; diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/meta/connection/NacosConnectionCore.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/meta/connection/NacosConnectionCore.java index 6f026525..ae94f670 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/meta/connection/NacosConnectionCore.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/meta/connection/NacosConnectionCore.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.core.meta.connection; import org.apache.eventmesh.dashboard.service.meta.ConnectionCore; diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/meta/runtime/NacosRuntimeCore.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/meta/runtime/NacosRuntimeCore.java deleted file mode 100644 index 2859c1b5..00000000 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/meta/runtime/NacosRuntimeCore.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.core.meta.runtime; - -import org.apache.eventmesh.dashboard.common.model.metadata.RuntimeMetadata; -import org.apache.eventmesh.dashboard.common.model.remoting.runtime.GetRuntimeRequest; -import org.apache.eventmesh.dashboard.common.model.remoting.runtime.GetRuntimeResponse; -import org.apache.eventmesh.dashboard.common.model.remoting.runtime.GetRuntimeResult; -import org.apache.eventmesh.dashboard.core.function.SDK.SDKManager; -import org.apache.eventmesh.dashboard.core.function.SDK.SDKTypeEnum; -import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateNacosConfig; -import org.apache.eventmesh.dashboard.service.remoting.MetaRemotingService; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.concurrent.CompletableFuture; - -import com.alibaba.nacos.api.exception.NacosException; -import com.alibaba.nacos.api.naming.pojo.Instance; -import com.alibaba.nacos.client.naming.NacosNamingService; - -public class NacosRuntimeCore implements MetaRemotingService { - - @Override - public GetRuntimeResult getRuntime(GetRuntimeRequest getRuntimeRequest) { - CreateNacosConfig createNacosConfig = new CreateNacosConfig(); - createNacosConfig.setServerAddress(getRuntimeRequest.getRegistryAddress()); - NacosNamingService nacosNamingService = (NacosNamingService) SDKManager.getInstance() - .createClient(SDKTypeEnum.META_NACOS_NAMING, createNacosConfig).getValue(); - GetRuntimeResult getRuntimeResult = new GetRuntimeResult(); - - CompletableFuture future = CompletableFuture.supplyAsync(() -> { - try { - Map runtimeMetadataMap = new HashMap<>(); - //If service name or group name is changed, please modify the following code - List protocols = Arrays.asList("GRPC", "HTTP", "TCP"); - - for (String protocol : protocols) { - List instances = - nacosNamingService.getAllInstances("EVENTMESH-runtime-" + protocol, protocol + "-GROUP"); - instances.forEach(instance -> { - if (!runtimeMetadataMap.containsKey(instance.getIp())) { - RuntimeMetadata runtimeMetadata = RuntimeMetadata.builder() - .host(instance.getIp()) - .port(instance.getPort()) - .rack(instance.getClusterName()) - .storageClusterId(0L) - .clusterName(Objects.isNull(instance.getClusterName()) ? instance.getClusterName() : "NORMAL") - .registryAddress(getRuntimeRequest.getRegistryAddress()) - .jmxPort(0) - .endpointMap("") - .build(); - runtimeMetadata.setRegistryAddress(getRuntimeRequest.getRegistryAddress()); - runtimeMetadataMap.put(instance.getIp(), runtimeMetadata); - } - }); - } - - return new GetRuntimeResponse(new ArrayList<>(runtimeMetadataMap.values())); - } catch (NacosException e) { - throw new RuntimeException(e); - } - }); - - getRuntimeResult.setFuture(future); - return getRuntimeResult; - } -} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/meta/subscription/NacosSubscriptionCore.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/meta/subscription/NacosSubscriptionCore.java deleted file mode 100644 index db6d5053..00000000 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/meta/subscription/NacosSubscriptionCore.java +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.core.meta.subscription; - -import static org.apache.eventmesh.dashboard.common.enums.Status.NACOS_EMPTY_RESP_ERR; -import static org.apache.eventmesh.dashboard.common.enums.Status.NACOS_GET_CONFIGS_ERR; -import static org.apache.eventmesh.dashboard.common.enums.Status.NACOS_LOGIN_EMPTY_RESP_ERR; -import static org.apache.eventmesh.dashboard.common.enums.Status.NACOS_LOGIN_ERR; -import static org.apache.eventmesh.dashboard.common.enums.Status.NACOS_SDK_CONFIG_ERR; - -import org.apache.eventmesh.dashboard.common.constant.ConfigConst; -import org.apache.eventmesh.dashboard.common.constant.NacosConst; -import org.apache.eventmesh.dashboard.common.dto.Result; -import org.apache.eventmesh.dashboard.common.exception.EventMeshAdminException; -import org.apache.eventmesh.dashboard.common.exception.MetaException; -import org.apache.eventmesh.dashboard.common.model.SubscriptionInfo; -import org.apache.eventmesh.dashboard.core.config.AdminProperties; -import org.apache.eventmesh.dashboard.service.meta.SubscriptionCore; - -import java.util.ArrayList; -import java.util.Base64; -import java.util.Collections; -import java.util.List; -import java.util.Properties; - -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpHeaders; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.util.LinkedMultiValueMap; -import org.springframework.util.MultiValueMap; -import org.springframework.web.client.RestTemplate; -import org.springframework.web.util.UriComponentsBuilder; - -import com.alibaba.fastjson2.JSON; -import com.alibaba.fastjson2.JSONObject; -import com.alibaba.nacos.api.NacosFactory; -import com.alibaba.nacos.api.PropertyKeyConst; -import com.alibaba.nacos.api.config.ConfigService; - -import lombok.extern.slf4j.Slf4j; - -@Slf4j -public class NacosSubscriptionCore implements SubscriptionCore { - - private static String HTTP_PREFIX = ConfigConst.HTTP_PREFIX; - AdminProperties adminProperties; - Properties nacosProps = new Properties(); - RestTemplate restTemplate = new RestTemplate(); - - public NacosSubscriptionCore(AdminProperties adminProperties) { - this.adminProperties = adminProperties; - - nacosProps.setProperty(PropertyKeyConst.SERVER_ADDR, adminProperties.getMeta().getNacos().getAddr()); - nacosProps.setProperty(PropertyKeyConst.NAMESPACE, adminProperties.getMeta().getNacos().getNamespace()); - if (adminProperties.getMeta().getNacos().isAuthEnabled()) { - if (!adminProperties.getMeta().getNacos().getUsername().isEmpty()) { - nacosProps.setProperty(PropertyKeyConst.USERNAME, adminProperties.getMeta().getNacos().getUsername()); - } - if (!adminProperties.getMeta().getNacos().getPassword().isEmpty()) { - nacosProps.setProperty(PropertyKeyConst.PASSWORD, adminProperties.getMeta().getNacos().getPassword()); - } - if (!adminProperties.getMeta().getNacos().getAccessKey().isEmpty()) { - nacosProps.setProperty(PropertyKeyConst.ACCESS_KEY, adminProperties.getMeta().getNacos().getAccessKey()); - } - if (!adminProperties.getMeta().getNacos().getSecretKey().isEmpty()) { - nacosProps.setProperty(PropertyKeyConst.SECRET_KEY, adminProperties.getMeta().getNacos().getSecretKey()); - } - } - if (adminProperties.getMeta().getNacos().getProtocol().equalsIgnoreCase("https")) { - HTTP_PREFIX = ConfigConst.HTTPS_PREFIX; - } - } - - /** - * Retrieve a specified config with Nacos SDK. - */ - @Override - public String retrieveConfig(String dataId, String group) { - ConfigService configService; - try { - configService = NacosFactory.createConfigService(nacosProps); - } catch (Exception e) { - log.error(NACOS_SDK_CONFIG_ERR.getDesc(), e); - throw new EventMeshAdminException(NACOS_SDK_CONFIG_ERR, e); - } - try { - return configService.getConfig(dataId, group, adminProperties.getMeta().getTimeoutMs()); - } catch (Exception e) { - log.error(NACOS_GET_CONFIGS_ERR.getDesc(), e); - throw new MetaException(NACOS_GET_CONFIGS_ERR, e); - } - } - - /** - * Retrieve a list of configs with Nacos OpenAPI, because Nacos SDK doesn't support listing and fuzzy matching. - *

- * TODO Granularity should be based on subscriptions rather than Runtime; - * retrieve all subscriptions for each Runtime, rather than retrieving subscriptions for each individual Runtime. - */ - @Override - public Result> retrieveConfigs(Integer page, Integer size, String dataId, String group) { - UriComponentsBuilder urlBuilder = UriComponentsBuilder - .fromHttpUrl(HTTP_PREFIX + nacosProps.getProperty(PropertyKeyConst.SERVER_ADDR) + NacosConst.CONFIGS_API) - .queryParam(NacosConst.CONFIGS_REQ_PAGE, page) - .queryParam(NacosConst.CONFIGS_REQ_PAGE_SIZE, size) - .queryParam(NacosConst.CONFIGS_REQ_DATAID, dataId) - .queryParam(NacosConst.CONFIGS_REQ_GROUP, group) - .queryParam(NacosConst.CONFIGS_REQ_SEARCH, "blur"); - - if (adminProperties.getMeta().getNacos().isAuthEnabled()) { - urlBuilder.queryParam(NacosConst.CONFIGS_REQ_TOKEN, loginGetAccessToken()); - } - - ResponseEntity response; - try { - response = restTemplate.getForEntity(urlBuilder.toUriString(), String.class); - } catch (Exception e) { - log.error(NACOS_GET_CONFIGS_ERR.getDesc(), e); - throw new MetaException(NACOS_GET_CONFIGS_ERR, e); - } - if (response.getBody() == null || response.getBody().isEmpty()) { - log.error(NACOS_EMPTY_RESP_ERR.getDesc()); - throw new MetaException(NACOS_EMPTY_RESP_ERR); - } - - JSONObject obj = JSON.parseObject(response.getBody()); - return new Result<>(toSubscriptionInfos(obj), obj.getInteger(NacosConst.CONFIGS_RESP_PAGES)); - } - - private List toSubscriptionInfos(JSONObject obj) { - List subscriptionInfos = new ArrayList<>(); - for (Object pageItem : obj.getJSONArray(NacosConst.CONFIGS_RESP_CONTENT_LIST)) { - JSONObject pageItemObj = (JSONObject) pageItem; - subscriptionInfos.add(toSubscriptionInfo(pageItemObj)); - } - return subscriptionInfos; - } - - private SubscriptionInfo toSubscriptionInfo(JSONObject obj) { - String content = obj.getString(NacosConst.CONFIGS_RESP_CONTENT); - return SubscriptionInfo.builder() - .clientName(obj.getString(NacosConst.CONFIGS_RESP_DATAID)) - .group(obj.getString(NacosConst.CONFIGS_RESP_GROUP)) - // The subscription content of Nacos config should be base64 encoded to protect special characters. - .subscription(Base64.getEncoder().encodeToString(content.getBytes())) - .build(); - } - - /** - * Login if auth enabled and return accessToken. - */ - private String loginGetAccessToken() { - HttpHeaders headers = new HttpHeaders(); - headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); - - MultiValueMap bodyParams = new LinkedMultiValueMap<>(); - bodyParams.put(NacosConst.LOGIN_REQ_USERNAME, Collections.singletonList(nacosProps.getProperty(PropertyKeyConst.USERNAME))); - bodyParams.put(NacosConst.LOGIN_REQ_PASSWORD, Collections.singletonList(nacosProps.getProperty(PropertyKeyConst.PASSWORD))); - - String loginUrl = HTTP_PREFIX + nacosProps.getProperty(PropertyKeyConst.SERVER_ADDR) + NacosConst.LOGIN_API; - HttpEntity> loginRequest = new HttpEntity<>(bodyParams, headers); - ResponseEntity loginResponse; - try { - loginResponse = restTemplate.postForEntity(loginUrl, loginRequest, String.class); - } catch (Exception e) { - log.error(NACOS_LOGIN_ERR.getDesc(), e); - throw new MetaException(NACOS_LOGIN_ERR, e); - } - if (loginResponse.getBody() == null || loginResponse.getBody().isEmpty()) { - log.error(NACOS_LOGIN_EMPTY_RESP_ERR + " Status code: {}", loginResponse.getStatusCode()); - throw new MetaException(NACOS_LOGIN_EMPTY_RESP_ERR + " Status code: " + loginResponse.getStatusCode()); - } - return JSON.parseObject(loginResponse.getBody()).getString(NacosConst.LOGIN_RESP_TOKEN); - } -} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/DataMetadataHandler.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/DataMetadataHandler.java new file mode 100644 index 00000000..4428cc1e --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/DataMetadataHandler.java @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.core.metadata; + +/** + * @param + */ +public interface DataMetadataHandler extends FullMetadataHandler, GetMetadataHandler { + +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/FullMetadataHandler.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/FullMetadataHandler.java new file mode 100644 index 00000000..715d08a9 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/FullMetadataHandler.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.core.metadata; + +import java.util.List; + +/** + * @param + */ +public interface FullMetadataHandler { + + + void handleAll(List addData, List updateData, List deleteData); + + + + default void handleAllObject(List addData, List updateData, List deleteData) { + handleAll((List) addData, (List) updateData, (List) deleteData); + } +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/GetMetadataHandler.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/GetMetadataHandler.java new file mode 100644 index 00000000..9b5ba1ac --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/GetMetadataHandler.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.core.metadata; + +import org.apache.eventmesh.dashboard.common.model.remoting.Global2Request; + +import java.util.List; + +/** + * @param + */ +public interface GetMetadataHandler { + + List getData(); + + default List getData(Global2Request global2Request) { + return getData(); + } +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/MetadataHandler.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/MetadataHandler.java index 86419bd1..a5790d2a 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/MetadataHandler.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/MetadataHandler.java @@ -15,95 +15,15 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.core.metadata; - -import org.apache.eventmesh.dashboard.common.model.remoting.GlobalRequest; -import java.util.List; +package org.apache.eventmesh.dashboard.core.metadata; /** * @param metadata type or entity type, {@code } is the source type of handler, there should be a converter in the handler to convert * {@code } to the target type.

method in this interface should be implemented as async method, if the method is eventmesh manage * operation. */ -public interface MetadataHandler { - - - default void handleAll(List addData, List updateData, List deleteData) { - if (addData != null) { - addData.forEach(this::addMetadata); - } - if (updateData != null) { - updateData.forEach(this::updateMetadata); - } - if (deleteData != null) { - deleteData.forEach(this::deleteMetadata); - } - } - - default void handleAllObject(List addData, List updateData, List deleteData) { - handleAll((List) addData, (List) updateData, (List) deleteData); - } - - //metaData: topic, center, etc. add meta is to create a topic. - void addMetadata(T meta); - - default void addMetadata(List meta) { - if (meta != null) { - meta.forEach(this::addMetadata); - } - } - - default void addMetadataObject(Object meta) { - addMetadata((T) meta); - } - - default void addMetadataObject(List meta) { - if (meta != null) { - meta.forEach(t -> addMetadata((T) t)); - } - } - - default void replaceMetadata(List meta) { - if (meta != null) { - deleteMetadata((List) meta); - addMetadataObject(meta); - } - } - - default void updateMetadata(T meta) { - this.addMetadata(meta); - } - - /** - * If this handler is db handler, do implement this method to improve performance - * - * @param meta - */ - default void updateMetadata(List meta) { - if (meta != null) { - meta.forEach(this::updateMetadata); - } - } - - default void updateMetadataObject(Object meta) { - this.addMetadata((T) meta); - } - - void deleteMetadata(T meta); - - default void deleteMetadata(List meta) { - if (meta != null) { - meta.forEach(this::deleteMetadata); - } - } - - default void deleteMetadataObject(Object meta) { - deleteMetadata((T) meta); - } - - List getData(); +public interface MetadataHandler extends DataMetadataHandler, UpdateMetadataHandler { - List getData(GlobalRequest globalRequest); } diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/MetadataSyncManage.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/MetadataSyncManage.java new file mode 100644 index 00000000..400487f7 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/MetadataSyncManage.java @@ -0,0 +1,279 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.core.metadata; + +import org.apache.eventmesh.dashboard.common.enums.ClusterSyncMetadataEnum; +import org.apache.eventmesh.dashboard.common.enums.ClusterTrusteeshipType; +import org.apache.eventmesh.dashboard.common.enums.ClusterTrusteeshipType.FirstToWhom; +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.common.enums.MetadataType; +import org.apache.eventmesh.dashboard.common.model.ClusterSyncMetadata; +import org.apache.eventmesh.dashboard.common.model.ConvertMetaData; +import org.apache.eventmesh.dashboard.common.model.DatabaseAndMetadataMapper; +import org.apache.eventmesh.dashboard.common.model.base.BaseClusterIdBase; +import org.apache.eventmesh.dashboard.common.model.base.BaseSyncBase; +import org.apache.eventmesh.dashboard.core.metadata.result.MetadataSyncResult; +import org.apache.eventmesh.dashboard.core.metadata.result.MetadataSyncResultHandler; +import org.apache.eventmesh.dashboard.core.remoting.Remoting2Manage; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.LinkedBlockingDeque; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.ScheduledThreadPoolExecutor; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; + +import lombok.Data; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; + +/** + * 启动应该进行差异化对比。进行差异化增量,差异化删除 表 -> increment-> remote -> function -> data -> conver -> request + *

+ * 怎么把 SyncMetadataManage 合进来 + */ +@Slf4j +public class MetadataSyncManage { + + + private final ThreadPoolExecutor dbThreadPoolExecutor = new ThreadPoolExecutor(10, 10, 20, TimeUnit.SECONDS, new LinkedBlockingDeque<>(), + new ThreadFactory() { + final AtomicInteger counter = new AtomicInteger(0); + + @Override + public Thread newThread(Runnable r) { + return new Thread(r, "db-metadata-manager-" + counter.incrementAndGet()); + } + }); + + private final ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(32, 32, 10, TimeUnit.MINUTES, new LinkedBlockingQueue<>(), + new ThreadFactory() { + final AtomicInteger counter = new AtomicInteger(0); + + @Override + public Thread newThread(Runnable r) { + return new Thread(r, "metadata-manager-" + counter.incrementAndGet()); + } + }); + + + private final Remoting2Manage remoting2Manage = Remoting2Manage.getInstance(); + + private final ScheduledThreadPoolExecutor scheduledExecutorService = new ScheduledThreadPoolExecutor(2); + + + /** + * db + */ + private final Map syncMetadataCreateFactoryMap = new HashMap<>(); + + + private final Map> metadataSyncConfigMap = new ConcurrentHashMap<>(); + + private final AtomicInteger atomicInteger = new AtomicInteger(0); + + @Setter + private List> dataMetadataHandlerList; + + + @Setter + private MetadataSyncResultHandler metadataSyncResultHandler; + + + public void init(Integer initialDelay, Integer period, List databaseAndMetadataMapperList) { + + Map, DatabaseAndMetadataMapper> databaseAndMetadataMapperMap = new HashMap<>(); + databaseAndMetadataMapperList.forEach(value -> { + databaseAndMetadataMapperMap.put(value.getDatabaseHandlerClass(), value); + }); + this.init(initialDelay, period, databaseAndMetadataMapperMap); + } + + public void init(Integer initialDelay, Integer period, Map, DatabaseAndMetadataMapper> databaseAndMetadataMapperMap) { + + dataMetadataHandlerList.forEach((v) -> { + Class clazz = v.getClass(); + DatabaseAndMetadataMapper databaseAndMetadataMapper = databaseAndMetadataMapperMap.get(clazz); + if (Objects.isNull(databaseAndMetadataMapper)) { + String className = clazz.getName(); + className = className.substring(0, className.indexOf("$$")); + try { + clazz = Class.forName(className); + databaseAndMetadataMapper = databaseAndMetadataMapperMap.get(clazz); + } catch (ClassNotFoundException e) { + throw new RuntimeException(e); + } + } + if (Objects.isNull(databaseAndMetadataMapper)) { + log.error("can not find databaseAndMetadataMapper for class {}", v); + return; + } + SyncMetadataCreateFactory syncMetadataCreateFactory = new SyncMetadataCreateFactory(); + syncMetadataCreateFactory.setDataMetadataHandler(v); + syncMetadataCreateFactory.setConvertMetaData((ConvertMetaData) databaseAndMetadataMapper.getConvertMetaData()); + syncMetadataCreateFactory.setMetadataType(databaseAndMetadataMapper.getMetaType()); + syncMetadataCreateFactory.setDatabaseAndMetadataMapper(databaseAndMetadataMapper); + + syncMetadataCreateFactoryMap.put(databaseAndMetadataMapper.getMetaType(), syncMetadataCreateFactory); + }); + + scheduledExecutorService.scheduleAtFixedRate(this::run, initialDelay, period, TimeUnit.MILLISECONDS); + } + + public void run() { + final long startTime = System.currentTimeMillis(); + int index = atomicInteger.incrementAndGet(); + if (log.isDebugEnabled()) { + log.debug("{} run , index {}", this.getClass().getSimpleName(), index); + } + CountDownLatch countDownLatch = new CountDownLatch(syncMetadataCreateFactoryMap.size()); + syncMetadataCreateFactoryMap.forEach((k, value) -> { + dbThreadPoolExecutor.execute(() -> { + try { + // 这里可以打印日志 + if (log.isDebugEnabled()) { + log.debug("index {} sync data is {} ", index, k); + } + value.persistence(); + value.loadData(); + if (log.isDebugEnabled()) { + log.debug("index {} sync time {} ", index, (System.currentTimeMillis() - startTime)); + } + } catch (Exception e) { + log.error(e.getMessage(), e); + } finally { + countDownLatch.countDown(); + } + }); + }); + dbThreadPoolExecutor.execute(() -> { + try { + this.metadataSyncResultHandler.persistence(); + if (log.isDebugEnabled()) { + log.debug("index {} , result complete persistence, time {} ", index, (System.currentTimeMillis() - startTime)); + } + } catch (Exception e) { + log.error(e.getMessage(), e); + } + }); + try { + countDownLatch.await(); + } catch (InterruptedException e) { + log.error(e.getMessage(), e); + } + log.info("syc db and result data persistence complete. time:{}", (System.currentTimeMillis() - startTime)); + metadataSyncConfigMap.forEach((key, value) -> { + value.forEach(v -> { + threadPoolExecutor.execute(v); + }); + }); + } + + + public void register(BaseSyncBase baseSyncBase) { + if (Objects.equals(baseSyncBase.getTrusteeshipType(), ClusterTrusteeshipType.NO_TRUSTEESHIP)) { + return; + } + List metadataSyncWrappers = new ArrayList<>(); + List metadataSyncResultList = new ArrayList<>(); + + ClusterType clusterType = baseSyncBase.getClusterType(); + + ClusterSyncMetadata clusterSyncMetadata = ClusterSyncMetadataEnum.getClusterSyncMetadata(clusterType); + List metadataTypeList = clusterSyncMetadata.getMetadataTypeList(); + metadataTypeList.forEach((value -> { + // build MetadataSyncResult + MetadataSyncResult metadataSyncResult = new MetadataSyncResult(); + metadataSyncResult.setMetadataType(value); + metadataSyncResult.setKey(baseSyncBase.getUnique()); + metadataSyncResult.setBaseSyncBase(baseSyncBase); + metadataSyncResultList.add(metadataSyncResult); + + SyncMetadataCreateFactory syncMetadataCreateFactory = syncMetadataCreateFactoryMap.get(value); + // build MetadataSyncConfig + MetadataSyncConfig metadataSyncConfig = new MetadataSyncConfig(); + metadataSyncConfig.setMetadataSyncResult(metadataSyncResult); + metadataSyncConfig.setClusterServiceType(baseSyncBase.getTrusteeshipType()); + metadataSyncConfig.setFirstToWhom(baseSyncBase.getFirstToWhom()); + metadataSyncConfig.setDataBasesHandler(syncMetadataCreateFactory.createDataMetadataHandler(baseSyncBase)); + + DataMetadataHandler object = remoting2Manage.createDataMetadataHandler( + syncMetadataCreateFactory.getDatabaseAndMetadataMapper().getMetadataHandlerClass(), baseSyncBase); + metadataSyncConfig.setClusterService(object); + metadataSyncConfig.setBaseSyncBase(baseSyncBase); + metadataSyncConfig.setMetadataType(value); + + // build MetadataSyncWrapper + MetadataSyncWrapper metadataSyncWrapper = new MetadataSyncWrapper(); + metadataSyncWrapper.setMetadataSyncConfig(metadataSyncConfig); + metadataSyncWrapper.setMetadataSyncResultHandler(metadataSyncResultHandler); + + metadataSyncWrapper.createDifference(); + metadataSyncWrappers.add(metadataSyncWrapper); + + })); + this.metadataSyncConfigMap.put(baseSyncBase.getUnique(), metadataSyncWrappers); + this.metadataSyncResultHandler.register(metadataSyncResultList); + + } + + public void unRegister(BaseSyncBase baseSyncBase) { + this.metadataSyncConfigMap.remove(baseSyncBase.getUnique()); + this.metadataSyncResultHandler.unregister(baseSyncBase); + } + + + @Data + public static class MetadataSyncConfig { + + private MetadataType metadataType; + + private BaseSyncBase baseSyncBase; + + private MetadataSyncResult metadataSyncResult; + + private ClusterTrusteeshipType clusterServiceType; + + /** + * 当 ClusterTrusteeshipType.TRUSTEESHIP_FIND_REVERSE 时,FirstToWhom 为 FirstToWhom.RUNTIME ,无效 + *

+ * 当 ClusterTrusteeshipType.TRUSTEESHIP 时,FirstToWhom 为 FirstToWhom.DASHBOARD ,无效 + */ + private FirstToWhom firstToWhom; + + private DataMetadataHandler dataBasesHandler; + + // 直接映射 api? config 是直接读取整个runtime 里面的数据 + // 还是封装一层? + // 这里如何变简单。直接 remote api? + private DataMetadataHandler clusterService; + + + } + + +} \ No newline at end of file diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/MetadataSyncManager.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/MetadataSyncManager.java deleted file mode 100644 index 481e88bd..00000000 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/MetadataSyncManager.java +++ /dev/null @@ -1,245 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.core.metadata; - -import org.apache.eventmesh.dashboard.common.enums.ClusterTrusteeshipType; -import org.apache.eventmesh.dashboard.common.model.metadata.MetadataConfig; -import org.apache.eventmesh.dashboard.core.remoting.RemotingManager; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.ScheduledThreadPoolExecutor; -import java.util.concurrent.ThreadFactory; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; - -import lombok.Data; -import lombok.Setter; - -/** - * 启动应该进行差异化对比。进行差异化增量,差异化删除 表 -> increment-> remote -> function -> data -> conver -> request - */ -public class MetadataSyncManager { - - private final ScheduledThreadPoolExecutor scheduledExecutorService = new ScheduledThreadPoolExecutor(2); - private final ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(32, 32, 10, TimeUnit.MINUTES, new LinkedBlockingQueue<>(), - new ThreadFactory() { - final AtomicInteger counter = new AtomicInteger(0); - - @Override - public Thread newThread(Runnable r) { - return new Thread(r, "metadata-manager-" + counter.incrementAndGet()); - } - }); - @Setter - private Map, MetadataSyncWrapper> metadataSyncWrapperMap = new HashMap<>(); - @Setter - private RemotingManager remotingManager; - - - public void register(MetadataSyncConfig metadataSyncConfig) { - MetadataSyncWrapper metadataSyncWrapper = new MetadataSyncWrapper(); - metadataSyncWrapper.setMetadataClass(metadataSyncConfig.getMetadataClass()); - metadataSyncWrapper.setEntityClass(metadataSyncConfig.getEntityClass()); - metadataSyncWrapper.setDataBasesHandler(metadataSyncConfig.getDataBasesHandler()); - metadataSyncWrapper.setClusterService(metadataSyncConfig.getClusterService()); - metadataSyncWrapperMap.put(metadataSyncWrapper.getMetadataClass(), metadataSyncWrapper); - } - - public void init(Integer initialDelay, Integer period) { - scheduledExecutorService.scheduleAtFixedRate(this::run, initialDelay, period, TimeUnit.SECONDS); - } - - - public void run() { - for (MetadataSyncWrapper metadataSyncWrapper : metadataSyncWrapperMap.values()) { - // 一个MetadataSyncWrapper 一个线程 - threadPoolExecutor.execute(metadataSyncWrapper); - } - } - - - @Data - public static class MetadataSyncConfig { - - private Class metadataClass; - - private Class entityClass; - - private MetadataHandler dataBasesHandler; - - // 直接映射 api? config 是直接读取整个runtime 里面的数据 - // 还是封装一层? - // 这里如何变简单。直接 remote api? - private MetadataHandler clusterService; - } - - @Data - public class MetadataSyncWrapper implements Runnable { - - private Class metadataClass; - - private Class entityClass; - - private MetadataHandler dataBasesHandler; - - // 直接映射 api? config 是直接读取整个runtime 里面的数据 - // 还是封装一层? - // 这里如何变简单。直接 remote api? - private MetadataHandler clusterService; - - private CountDownLatch countDownLatch = new CountDownLatch(2); - - - private Map clusterData = new HashMap<>(); - - private Map dataBasesData = new HashMap<>(); - - private List toClusterUpdate = new ArrayList<>(); - - - private List toDataUpdate = new ArrayList<>(); - - private List toDelete = new ArrayList<>(); - - private List toInsert = new ArrayList<>(); - - private long lastTime = System.currentTimeMillis(); - - @Override - public void run() { - - try { - // 全程托管,托管都需要,异步 读取 cluster 信息 - threadPoolExecutor.execute(this::syncClusterData); - // 异步 读取数据库信息。是否进行增量处理 - threadPoolExecutor.execute(this::syncDatabasesData); - this.lastTime = System.currentTimeMillis(); - countDownLatch.await(); - // 对读取的数据进行分类, - this.difference(); - // 托管的进行差异化之后。进行写库。 - if (this.toInsert.isEmpty() && this.toClusterUpdate.isEmpty() && this.toDelete.isEmpty() && this.toDataUpdate.isEmpty()) { - return; - } - this.toTrusteeship(); - this.toFullTrusteeship(); - // 全程托管的 cluster 存在,数据库不存在就删除。 进行删除, 新增的直接操作 cluster - - } catch (InterruptedException e) { - throw new RuntimeException(e); - } finally { - countDownLatch = new CountDownLatch(2); - clusterData.clear(); - dataBasesData.clear(); - } - - - } - - public void syncClusterData() { - try { - List metadataConfigList = this.clusterService.getData(); - this.arrange(this.clusterData, metadataConfigList); - } finally { - countDownLatch.countDown(); - } - - } - - public void syncDatabasesData() { - try { - List metadataConfigList = this.dataBasesHandler.getData(); - this.arrange(this.dataBasesData, metadataConfigList); - } finally { - countDownLatch.countDown(); - } - } - - public void arrange(Map data, List metadataConfigList) { - for (MetadataConfig metadataConfig : metadataConfigList) { - data.put(metadataConfig.getUnique(), metadataConfig); - } - } - - /** - * TODO 一定要注意。这个就得是 cluster 的差集。如果要对 database 操作 就要反翻过啦 - */ - public void difference() { - - this.toDataUpdate = new ArrayList<>(); - this.toClusterUpdate = new ArrayList<>(); - this.toDelete = new ArrayList<>(); - this.toInsert = new ArrayList<>(); - Map newClusterData = new HashMap<>(this.clusterData); - Map newDataBasesData = new HashMap<>(this.dataBasesData); - for (Map.Entry entry : newClusterData.entrySet()) { - MetadataConfig serviceObject = newDataBasesData.remove(entry.getKey()); - if (Objects.isNull(serviceObject)) { - toDelete.add(entry.getValue()); - } else { - if (!serviceObject.equals(entry.getValue())) { - this.toClusterUpdate.add(entry.getValue()); - this.toDataUpdate.add(serviceObject); - } - } - } - this.toInsert = new ArrayList<>(newDataBasesData.values()); - - } - - public void toTrusteeship() { - // 如果 update 中 cluster 与 databases 数据不一致。 以谁为主 - // - this.dataBasesHandler.updateMetadata(this.filterTrusteeship(this.toClusterUpdate)); - this.dataBasesHandler.addMetadata(this.filterTrusteeship(this.toDelete)); - } - - public void toFullTrusteeship() { - // - this.clusterService.addMetadata(this.filterFullTrusteeship(this.toInsert)); - this.clusterService.addMetadata(this.filterFullTrusteeship(this.toDataUpdate)); - this.clusterService.deleteMetadata(this.filterTrusteeship(this.toDelete)); - } - - private List filterFullTrusteeship(List metadataConfigList) { - return this.filter(metadataConfigList, ClusterTrusteeshipType.FIRE_AND_FORGET_TRUSTEESHIP); - } - - private List filterTrusteeship(List metadataConfigList) { - return this.filter(metadataConfigList, ClusterTrusteeshipType.TRUSTEESHIP); - } - - private List filter(List metadataConfigList, ClusterTrusteeshipType clusterTrusteeshipType) { - List newMetadataConfigList = new ArrayList<>(); - for (MetadataConfig metadataConfig : metadataConfigList) { - if (remotingManager.isClusterTrusteeshipType(metadataConfig.getClusterId(), clusterTrusteeshipType)) { - newMetadataConfigList.add(metadataConfig); - } - } - return newMetadataConfigList; - } - } - -} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/MetadataSyncWrapper.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/MetadataSyncWrapper.java new file mode 100644 index 00000000..80c04943 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/MetadataSyncWrapper.java @@ -0,0 +1,176 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.core.metadata; + +import org.apache.eventmesh.dashboard.common.enums.ClusterTrusteeshipType; +import org.apache.eventmesh.dashboard.common.enums.ClusterTrusteeshipType.FirstToWhom; +import org.apache.eventmesh.dashboard.common.model.base.BaseSyncBase; +import org.apache.eventmesh.dashboard.core.metadata.MetadataSyncManage.MetadataSyncConfig; +import org.apache.eventmesh.dashboard.core.metadata.difference.BodyDataDifference; +import org.apache.eventmesh.dashboard.core.metadata.difference.BothDifference; +import org.apache.eventmesh.dashboard.core.metadata.difference.BufferDifference; +import org.apache.eventmesh.dashboard.core.metadata.difference.NotDifference; +import org.apache.eventmesh.dashboard.core.metadata.result.MetadataSyncResult; +import org.apache.eventmesh.dashboard.core.metadata.result.MetadataSyncResultHandler; + +import java.util.Objects; +import java.util.Random; + +import lombok.Data; +import lombok.extern.slf4j.Slf4j; + +@Data +@Slf4j +public class MetadataSyncWrapper implements Runnable { + + private MetadataSyncResultHandler metadataSyncResultHandler; + + private MetadataSyncConfig metadataSyncConfig; + + private BaseSyncBase baseSyncBase; + + private NotDifference notDifference; + + private BodyDataDifference bodyDataDifference; + + private BufferDifference bufferDifference; + + private BothDifference bothDifference; + + + private volatile boolean check = false; + + private long intervalTime; + + private long checkTime; + + private int fistSyncRetry = 0; + + + public void createDifference() { + this.baseSyncBase = this.metadataSyncConfig.getBaseSyncBase(); + if (this.readOnly()) { + NotDifference notDifference = new NotDifference(); + notDifference.setSourceHandler(this.metadataSyncConfig.getClusterService()); + notDifference.setTargetHandler(this.metadataSyncConfig.getDataBasesHandler()); + this.notDifference = notDifference; + return; + } + this.intervalTime = 1000 * 60 * 60 + new Random().nextInt(10000); + + this.checkTime = System.currentTimeMillis() - intervalTime; + BodyDataDifference bodyDataDifference = new BodyDataDifference(); + bodyDataDifference.setSourceHandler(this.metadataSyncConfig.getClusterService()); + bodyDataDifference.setTargetHandler(this.metadataSyncConfig.getDataBasesHandler()); + this.bodyDataDifference = bodyDataDifference; + + BufferDifference bufferDifference = new BufferDifference(); + bufferDifference.setSourceHandler(this.metadataSyncConfig.getDataBasesHandler()); + bufferDifference.setTargetHandler(this.metadataSyncConfig.getClusterService()); + this.bufferDifference = bufferDifference; + + BothDifference bothDifference = new BothDifference(); + if (this.metadataSyncConfig.getClusterServiceType().isSelf()) { + bothDifference.setSourceHandler(this.metadataSyncConfig.getDataBasesHandler()); + bothDifference.setTargetHandler(this.metadataSyncConfig.getClusterService()); + } else { + bothDifference.setSourceHandler(this.metadataSyncConfig.getClusterService()); + bothDifference.setTargetHandler(this.metadataSyncConfig.getDataBasesHandler()); + } + this.bufferDifference = bufferDifference; + } + + + @Override + public void run() { + MetadataSyncResult metadataSyncResult = this.metadataSyncConfig.getMetadataSyncResult(); + try { + long lastTime = System.currentTimeMillis(); + if (this.fistSyncRetry >= 5) { + log.error("baseSyncBase {} fistSyncRetry 5", baseSyncBase.getId()); + } + if (this.readOnly()) { + this.notDifference.difference(); + } else if (this.check()) { + this.bothDifference.difference(); + } else if (this.isSyncClusterData()) { + this.bufferDifference.difference(); + } else if (this.isSyncDatabasesData()) { + this.bodyDataDifference.difference(); + } + if (Objects.equals(baseSyncBase.getFirstSyncState(), FirstToWhom.UNDER_WAY)) { + baseSyncBase.setFirstSyncState(FirstToWhom.COMPLETE); + metadataSyncResult.setFirstToWhom(FirstToWhom.COMPLETE); + } + } catch (Exception e) { + // 失败三次,停止同步吗? + if (Objects.equals(baseSyncBase.getFirstSyncState(), FirstToWhom.UNDER_WAY)) { + this.fistSyncRetry++; + baseSyncBase.setFirstSyncState(FirstToWhom.WAIT_START); + metadataSyncResult.setFirstToWhom(FirstToWhom.FAIL); + } + log.error(e.getMessage(), e); + } finally { + this.metadataSyncResultHandler.handleMetadataSyncResult(metadataSyncResult); + } + } + + + private boolean readOnly() { + return this.metadataSyncConfig.getMetadataType().isReadOnly(); + } + + private boolean check() { + if (!this.check) { + return false; + } + if (System.currentTimeMillis() < this.checkTime) { + return false; + } + this.checkTime = System.currentTimeMillis() + this.intervalTime; + return true; + } + + + private boolean isSyncClusterData() { + if (Objects.equals(baseSyncBase.getFirstToWhom(), FirstToWhom.RUNTIME) + && Objects.equals(baseSyncBase.getFirstSyncState(), FirstToWhom.WAIT_START)) { + baseSyncBase.setFirstSyncState(FirstToWhom.UNDER_WAY); + return true; + } + if (Objects.equals(baseSyncBase.getTrusteeshipType(), ClusterTrusteeshipType.SELF)) { + return true; + } + return Objects.equals(baseSyncBase.getTrusteeshipType(), ClusterTrusteeshipType.TRUSTEESHIP); + + } + + private boolean isSyncDatabasesData() { + if (Objects.equals(baseSyncBase.getFirstToWhom(), FirstToWhom.DASHBOARD) + && !Objects.equals(baseSyncBase.getFirstSyncState(), FirstToWhom.WAIT_START)) { + baseSyncBase.setFirstSyncState(FirstToWhom.UNDER_WAY); + return true; + } + if (Objects.equals(baseSyncBase.getTrusteeshipType(), ClusterTrusteeshipType.TRUSTEESHIP_FIND)) { + return true; + } + return Objects.equals(baseSyncBase.getTrusteeshipType(), ClusterTrusteeshipType.TRUSTEESHIP_FIND_REVERSE); + } + +} \ No newline at end of file diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/SyncMetadataCreateFactory.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/SyncMetadataCreateFactory.java new file mode 100644 index 00000000..260f95e9 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/SyncMetadataCreateFactory.java @@ -0,0 +1,140 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.core.metadata; + +import org.apache.eventmesh.dashboard.common.enums.ClusterFramework; +import org.apache.eventmesh.dashboard.common.enums.ClusterSyncMetadataEnum; +import org.apache.eventmesh.dashboard.common.enums.MetadataType; +import org.apache.eventmesh.dashboard.common.model.ConvertMetaData; +import org.apache.eventmesh.dashboard.common.model.DatabaseAndMetadataMapper; +import org.apache.eventmesh.dashboard.common.model.base.BaseClusterIdBase; +import org.apache.eventmesh.dashboard.common.model.base.BaseRuntimeIdBase; +import org.apache.eventmesh.dashboard.common.model.base.BaseSyncBase; +import org.apache.eventmesh.dashboard.common.model.metadata.RuntimeMetadata; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.concurrent.ConcurrentHashMap; + +import lombok.Getter; +import lombok.Setter; + +/** + * MetadataHandler。 读写行为 每个 runtime or cluster 。所有 MetadataType 的 MetadataHandler 已经关系 从 runtime(Cluster) -> 读 -> createDataMetadataHandler 缓存 -> 定时写 + * 从 db 定时读 发动 -> SyncMetadataCreateFactory -> createDataMetadataHandler 获得 runtime 或则 cluster 维度数据,在写入 runtime 1000个节点,进行一千次db操作, db直接费了。 + */ +public class SyncMetadataCreateFactory { + + @Setter + private DataMetadataHandler dataMetadataHandler; + + @Setter + private MetadataType metadataType; + + @Getter + @Setter + private ConvertMetaData convertMetaData; + + + @Getter + @Setter + private DatabaseAndMetadataMapper databaseAndMetadataMapper; + + private final Map> runtimeMetadataMap = new ConcurrentHashMap<>(); + + private final Map> clusterMetadataMap = new ConcurrentHashMap<>(); + + private List addData = new ArrayList<>(); + + private List updateData = new ArrayList<>(); + + private List deleteData = new ArrayList<>(); + + public void loadData() { + // TODO 加载的时候, 目前永远不会加载 Runtime + if (metadataType.isReadOnly()) { + return; + } + + dataMetadataHandler.getData().forEach(data -> { + BaseRuntimeIdBase baseRuntimeIdBase = (BaseRuntimeIdBase) this.convertMetaData.toMetaData(data); + ClusterFramework clusterFramework = + ClusterSyncMetadataEnum.getClusterFramework(baseRuntimeIdBase.getClusterType()); + if (clusterFramework.isCAP()) { + this.clusterMetadataMap.computeIfAbsent(baseRuntimeIdBase.getClusterId(), (value) -> new ArrayList<>()).add(baseRuntimeIdBase); + } else { + this.runtimeMetadataMap.computeIfAbsent(baseRuntimeIdBase.getRuntimeId(), (value) -> new ArrayList<>()).add(baseRuntimeIdBase); + } + }); + + } + + public void persistence() { + if (this.deleteData.isEmpty() && this.updateData.isEmpty() && this.clusterMetadataMap.isEmpty()) { + return; + } + this.dataMetadataHandler.handleAll(this.addData, this.updateData, this.deleteData); + this.addData = new ArrayList<>(); + this.updateData = new ArrayList<>(); + this.deleteData = new ArrayList<>(); + } + + public MetadataHandler createDataMetadataHandler(BaseSyncBase baseSyncBase) { + Map> mapetadataMap = + Objects.equals(baseSyncBase.getClass(), RuntimeMetadata.class) ? this.runtimeMetadataMap : this.clusterMetadataMap; + + return new MetadataHandler() { + @Override + public void addMetadata(BaseClusterIdBase meta) { + SyncMetadataCreateFactory.this.addData.add(SyncMetadataCreateFactory.this.convertMetaData.toEntity(meta)); + } + + @Override + public void deleteMetadata(BaseClusterIdBase meta) { + SyncMetadataCreateFactory.this.deleteData.add(SyncMetadataCreateFactory.this.convertMetaData.toEntity(meta)); + } + + @Override + public void updateMetadata(BaseClusterIdBase meta) { + SyncMetadataCreateFactory.this.updateData.add(meta); + } + + @Override + public void handleAll(List addData, List updateData, List deleteData) { + this.addAll(SyncMetadataCreateFactory.this.addData, addData); + this.addAll(SyncMetadataCreateFactory.this.updateData, updateData); + this.addAll(SyncMetadataCreateFactory.this.deleteData, deleteData); + } + + private void addAll(List persistenceData, List handleData) { + handleData.forEach(data -> { + persistenceData.add(SyncMetadataCreateFactory.this.convertMetaData.toEntity(data)); + }); + } + + @Override + public List getData() { + return mapetadataMap.remove(baseSyncBase.getId()); + } + + }; + } +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/UpdateMetadataHandler.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/UpdateMetadataHandler.java new file mode 100644 index 00000000..90c07559 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/UpdateMetadataHandler.java @@ -0,0 +1,73 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.core.metadata; + +import java.util.List; + +/** + * + */ +public interface UpdateMetadataHandler { + + + //metaData: topic, center, etc. add meta is to create a topic. + void addMetadata(T meta); + + default void addMetadata(List meta) { + if (meta != null) { + meta.forEach(this::addMetadata); + } + } + + default void addMetadataObject(List meta) { + if (meta != null) { + meta.forEach(t -> addMetadata((T) t)); + } + } + + default void replaceMetadata(List meta) { + if (meta != null) { + deleteMetadata((List) meta); + addMetadataObject(meta); + } + } + + default void updateMetadata(T meta) { + this.addMetadata(meta); + } + + /** + * If this handler is db handler, do implement this method to improve performance + * + * @param meta + */ + default void updateMetadata(List meta) { + if (meta != null) { + meta.forEach(this::updateMetadata); + } + } + + void deleteMetadata(T meta); + + default void deleteMetadata(List meta) { + if (meta != null) { + meta.forEach(this::deleteMetadata); + } + } +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/cluster/AbstractMetadataHandler.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/cluster/AbstractMetadataHandler.java deleted file mode 100644 index 939dd8ad..00000000 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/cluster/AbstractMetadataHandler.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.core.metadata.cluster; - -import org.apache.eventmesh.dashboard.common.enums.ClusterTrusteeshipType; -import org.apache.eventmesh.dashboard.core.metadata.MetadataHandler; -import org.apache.eventmesh.dashboard.core.remoting.RemotingManager; - -import java.util.ArrayList; -import java.util.List; - -import lombok.Setter; - -public abstract class AbstractMetadataHandler implements MetadataHandler, RemotingManager.RemotingRequestWrapper { - - - protected S request; - @Setter - private RemotingManager remotingManager; - - public void init() { - this.request = (S) remotingManager.getProxyObject(); - } - - - /** - * 同步的时候,只同步runtime 的数据,还是会同步 storage 的数据。这个可以进行配置。 - * - * @return - */ - @Override - public List getData() { - List remotingWrapperList = new ArrayList<>(); - remotingWrapperList.addAll( - remotingManager.getEventMeshClusterDO(ClusterTrusteeshipType.TRUSTEESHIP, ClusterTrusteeshipType.FIRE_AND_FORGET_TRUSTEESHIP)); - remotingWrapperList.addAll( - remotingManager.getStorageCluster(ClusterTrusteeshipType.TRUSTEESHIP, ClusterTrusteeshipType.FIRE_AND_FORGET_TRUSTEESHIP)); - return remotingManager.request(this, - remotingManager.getEventMeshClusterDO(ClusterTrusteeshipType.TRUSTEESHIP, ClusterTrusteeshipType.FIRE_AND_FORGET_TRUSTEESHIP)); - } - -} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/cluster/AclSyncFromClusterService.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/cluster/AclSyncFromClusterService.java deleted file mode 100644 index 98ec6aad..00000000 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/cluster/AclSyncFromClusterService.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.core.metadata.cluster; - -import org.apache.eventmesh.dashboard.common.model.metadata.AclMetadata; -import org.apache.eventmesh.dashboard.common.model.remoting.GlobalRequest; -import org.apache.eventmesh.dashboard.common.model.remoting.GlobalResult; -import org.apache.eventmesh.dashboard.common.model.remoting.acl.GetAclsRequest; -import org.apache.eventmesh.dashboard.service.remoting.AclRemotingService; - -import java.util.List; - -import org.springframework.stereotype.Service; - -import lombok.Setter; - -@Service -public class AclSyncFromClusterService extends AbstractMetadataHandler { - - @Setter - private AclRemotingService aclRemotingService; - - @Override - public void addMetadata(AclMetadata meta) { - - } - - @Override - public void deleteMetadata(AclMetadata meta) { - - } - - - @Override - public List getData(GlobalRequest globalRequest) { - GetAclsRequest getAclsRequest = new GetAclsRequest(); - getAclsRequest.setClusterId(globalRequest.getClusterId()); - return (List) this.request(this.request, getAclsRequest).getData(); - } - - - @Override - public GlobalResult request(AclRemotingService key, GetAclsRequest getAclsRequest) { - return key.getAllAcls(getAclsRequest); - } -} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/cluster/GroupSyncFromClusterService.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/cluster/GroupSyncFromClusterService.java deleted file mode 100644 index bae1ad1b..00000000 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/cluster/GroupSyncFromClusterService.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.core.metadata.cluster; - -import org.apache.eventmesh.dashboard.common.model.metadata.GroupMetadata; -import org.apache.eventmesh.dashboard.common.model.remoting.GlobalRequest; -import org.apache.eventmesh.dashboard.common.model.remoting.GlobalResult; -import org.apache.eventmesh.dashboard.common.model.remoting.group.GetGroupsRequest; -import org.apache.eventmesh.dashboard.core.remoting.RemotingManager; -import org.apache.eventmesh.dashboard.service.remoting.GroupRemotingService; - -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -@Service -public class GroupSyncFromClusterService extends AbstractMetadataHandler { - - @Autowired - private RemotingManager remotingManager; - - @Override - public void addMetadata(GroupMetadata meta) { - - } - - @Override - public void deleteMetadata(GroupMetadata meta) { - - } - - @Override - public List getData() { - List eventMeshGroupList = this.remotingManager.request(this, remotingManager.getEventMeshClusterDO()); - //List rocketMQMeshGroupList = this.remotingManager.request(this,remotingManager.getRocketMQClusterDO() ); - //eventMeshGroupList.addAll(rocketMQMeshGroupList); - return eventMeshGroupList; - } - - @Override - public List getData(GlobalRequest globalRequest) { - return null; - } - - @Override - public GlobalResult request(GroupRemotingService groupRemotingService, GetGroupsRequest key) { - return null; - } -} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/cluster/RuntimeSyncFromClusterService.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/cluster/RuntimeSyncFromClusterService.java deleted file mode 100644 index f9d32491..00000000 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/cluster/RuntimeSyncFromClusterService.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.core.metadata.cluster; - -import org.apache.eventmesh.dashboard.common.model.metadata.RuntimeMetadata; -import org.apache.eventmesh.dashboard.common.model.remoting.GlobalRequest; -import org.apache.eventmesh.dashboard.common.model.remoting.GlobalResult; -import org.apache.eventmesh.dashboard.common.model.remoting.runtime.GetRuntimeRequest; -import org.apache.eventmesh.dashboard.service.remoting.RuntimeRemotingService; - -import java.util.List; - -import org.springframework.stereotype.Service; - -import lombok.extern.slf4j.Slf4j; - -@Slf4j -@Service -public class RuntimeSyncFromClusterService extends AbstractMetadataHandler { - - - @Override - public void addMetadata(RuntimeMetadata meta) { - - } - - @Override - public void deleteMetadata(RuntimeMetadata meta) { - - } - - @Override - public List getData(GlobalRequest globalRequest) { - GetRuntimeRequest getRuntimeRequest = new GetRuntimeRequest(); - getRuntimeRequest.setClusterId(globalRequest.getClusterId()); - return (List) this.request(this.request, getRuntimeRequest).getData(); - } - - @Override - public GlobalResult request(RuntimeRemotingService runtimeRemotingService, GetRuntimeRequest key) { - return runtimeRemotingService.getRuntimeMetadata(key); - } -} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/difference/AbstractBothDifference.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/difference/AbstractBothDifference.java new file mode 100644 index 00000000..5ea6c5a1 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/difference/AbstractBothDifference.java @@ -0,0 +1,64 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.core.metadata.difference; + +import org.apache.eventmesh.dashboard.common.model.base.BaseClusterIdBase; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +public abstract class AbstractBothDifference extends AbstractBufferDifference { + + + protected Map difference(List sourcetList, List targetList) { + Map targetAllData = new HashMap<>(); + targetList.forEach((value) -> { + targetAllData.put(value.nodeUnique(), value); + }); + return this.difference(sourcetList, targetAllData); + } + + /** + * database 与 cluster 求结果 + */ + protected Map difference(List sourcetList, Map targetAllData) { + if (sourcetList.isEmpty()) { + return targetAllData; + } + Map newAllData = new HashMap<>(); + sourcetList.forEach((value) -> { + String key = value.nodeUnique(); + BaseClusterIdBase oldValue = this.allData.remove(key); + if (Objects.isNull(oldValue)) { + this.insertData.add(value); + newAllData.put(key, value); + } else if (!Objects.equals(oldValue, value)) { + this.updateData.add(value); + newAllData.put(key, value); + } else { + newAllData.put(key, value); + } + + }); + this.deleteData.addAll(this.allData.values()); + return newAllData; + } +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/difference/AbstractBufferDifference.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/difference/AbstractBufferDifference.java new file mode 100644 index 00000000..eaf3b702 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/difference/AbstractBufferDifference.java @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.core.metadata.difference; + +import org.apache.eventmesh.dashboard.common.model.base.BaseClusterIdBase; +import org.apache.eventmesh.dashboard.core.metadata.DataMetadataHandler; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import lombok.Getter; +import lombok.Setter; + +public abstract class AbstractBufferDifference extends AbstractDifference implements DataMetadataHandler { + + @Getter + @Setter + protected Map allData = new HashMap<>(); + + + public void handleAll(List addData, List updateData, List deleteData) { + this.targetHandler.handleAll(addData, updateData, deleteData); + } + + /** + * BothDifference 是否进行一次识别 + * + * @return + */ + public List getData() { + return new ArrayList<>(allData.values()); + } +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/difference/AbstractDifference.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/difference/AbstractDifference.java new file mode 100644 index 00000000..dcce7f7a --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/difference/AbstractDifference.java @@ -0,0 +1,75 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.core.metadata.difference; + +import org.apache.eventmesh.dashboard.common.model.base.BaseClusterIdBase; +import org.apache.eventmesh.dashboard.core.metadata.DataMetadataHandler; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import lombok.Setter; + +public abstract class AbstractDifference implements Difference { + + + protected Map allData = new HashMap<>(); + + + protected List deleteData = new ArrayList<>(); + + protected List insertData = new ArrayList<>(); + + protected List updateData = new ArrayList<>(); + + @Setter + protected DataMetadataHandler sourceHandler; + + @Setter + protected DataMetadataHandler targetHandler; + + + @Override + public void difference() { + try { + this.doDifference(); + targetHandler.handleAll(this.insertData, this.updateData, this.deleteData); + } catch (Exception e) { + // TODO + } finally { + this.closeUpdate(); + } + } + + public void closeAll() { + this.allData.clear(); + } + + public void closeUpdate() { + this.deleteData.clear(); + this.updateData.clear(); + this.insertData.clear(); + } + + + abstract void doDifference(); + +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/difference/BodyDataDifference.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/difference/BodyDataDifference.java new file mode 100644 index 00000000..35faa6a5 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/difference/BodyDataDifference.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.core.metadata.difference; + + +import org.apache.eventmesh.dashboard.common.model.base.BaseClusterIdBase; + +import java.util.List; + +public class BodyDataDifference extends AbstractBufferDifference { + + + @Override + void doDifference() { + List objectList = sourceHandler.getData(); + if (objectList.isEmpty()) { + return; + } + objectList.forEach((value) -> { + String key = value.nodeUnique(); + if (value.isInsert()) { + this.insertData.add(value); + this.allData.put(key, value); + } else if (value.isUpdate()) { + this.updateData.add(value); + this.allData.put(key, value); + } else if (value.isDelete()) { + this.deleteData.add(value); + this.allData.remove(key); + } + }); + + } +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/difference/BothDifference.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/difference/BothDifference.java new file mode 100644 index 00000000..c8a23762 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/difference/BothDifference.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.core.metadata.difference; + +import org.apache.eventmesh.dashboard.common.model.base.BaseClusterIdBase; + +import org.apache.commons.collections4.CollectionUtils; + +import java.util.List; + +public class BothDifference extends AbstractBothDifference { + + @Override + void doDifference() { + List sourcetList = sourceHandler.getData(); + List targetList = targetHandler.getData(); + if (CollectionUtils.isEmpty(sourcetList)) { + /** + * TODO + * 有这种极端环境吗? + * 两边都删除 缓存为空 + * + */ + this.deleteData.addAll(targetList); + } else if (targetList.isEmpty()) { + // TODO 全量加入缓存 + this.insertData.addAll(sourcetList); + targetList.forEach((value) -> { + this.allData.put(value.nodeUnique(), value); + }); + } + this.allData = this.difference(sourcetList, targetList); + } +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/difference/BufferDifference.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/difference/BufferDifference.java new file mode 100644 index 00000000..6f77a453 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/difference/BufferDifference.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.core.metadata.difference; + +import org.apache.eventmesh.dashboard.common.model.base.BaseClusterIdBase; + +import java.util.List; + +public class BufferDifference extends AbstractBothDifference { + + + @Override + void doDifference() { + List sourcetList = sourceHandler.getData(); + this.difference(sourcetList, allData); + } +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/difference/Difference.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/difference/Difference.java new file mode 100644 index 00000000..733b33e3 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/difference/Difference.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.core.metadata.difference; + +/** + * + */ +public interface Difference { + + + void difference(); + +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/difference/NotDifference.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/difference/NotDifference.java new file mode 100644 index 00000000..05421206 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/difference/NotDifference.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.core.metadata.difference; + +import org.apache.eventmesh.dashboard.common.model.base.BaseClusterIdBase; + +import java.util.List; + +public class NotDifference extends AbstractDifference { + + @Override + void doDifference() { + List bothDifferenceList = this.sourceHandler.getData(); + this.insertData.addAll(bothDifferenceList); + } +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/request/RuntimeDataRequest.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/request/RuntimeDataRequest.java new file mode 100644 index 00000000..f8236094 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/request/RuntimeDataRequest.java @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.core.metadata.request; + +@Deprecated +public class RuntimeDataRequest { + + + private Long runtimeId; + +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/result/MetadataSyncResult.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/result/MetadataSyncResult.java new file mode 100644 index 00000000..fab2ded3 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/result/MetadataSyncResult.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.core.metadata.result; + +import org.apache.eventmesh.dashboard.common.enums.ClusterTrusteeshipType; +import org.apache.eventmesh.dashboard.common.enums.ClusterTrusteeshipType.FirstToWhom; +import org.apache.eventmesh.dashboard.common.enums.MetadataType; +import org.apache.eventmesh.dashboard.common.enums.SyncErrorType; +import org.apache.eventmesh.dashboard.common.model.base.BaseSyncBase; + +import lombok.Data; + + +@Data +public class MetadataSyncResult { + + private String key; + + private BaseSyncBase baseSyncBase; + + private MetadataType metadataType; + + private ClusterTrusteeshipType clusterTrusteeshipType; + + private SyncErrorType syncErrorType; + + private FirstToWhom firstToWhom = FirstToWhom.NOT; + + private boolean success = false; + + +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/result/MetadataSyncResultHandler.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/result/MetadataSyncResultHandler.java new file mode 100644 index 00000000..2ade5706 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/result/MetadataSyncResultHandler.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.core.metadata.result; + +import org.apache.eventmesh.dashboard.common.model.base.BaseSyncBase; + +import java.util.List; + +/** + * + */ +public interface MetadataSyncResultHandler { + + + void register(List metadataSyncResults); + + void unregister(BaseSyncBase baseSyncBase); + + void handleMetadataSyncResult(MetadataSyncResult metadataSyncResult); + + void persistence(); + + +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/AbstractRemotingService.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/AbstractRemotingService.java index f15ee089..1db0f487 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/AbstractRemotingService.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/AbstractRemotingService.java @@ -15,85 +15,21 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.core.remoting; - -import org.apache.eventmesh.dashboard.common.model.metadata.RuntimeMetadata; -import org.apache.eventmesh.dashboard.core.cluster.ClusterDO; -import org.apache.eventmesh.dashboard.core.cluster.ColonyDO; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import com.alibaba.fastjson.JSONObject; +package org.apache.eventmesh.dashboard.core.remoting; -import lombok.Setter; +import org.apache.eventmesh.dashboard.core.function.SDK.AbstractClientInfo; +import org.apache.eventmesh.dashboard.core.function.SDK.SDKTypeEnum; /** * 默认是一个集群,操作是基于集群操作还是单个操作 */ -public abstract class AbstractRemotingService { - - @Setter - protected ColonyDO colonyDO; - - protected ClusterDO clusterDO; +public abstract class AbstractRemotingService extends AbstractClientInfo { - public void init() { - this.clusterDO = colonyDO.getClusterDO(); - this.createConfig(); - this.doInit(); - } - - public abstract void createConfig(); - - public List getMeta() { - List list = new ArrayList<>(); - for (ColonyDO c : colonyDO.getMetaColonyDOList().values()) { - for (RuntimeMetadata runtimeMetadata : c.getClusterDO().getRuntimeMap().values()) { - list.add(runtimeMetadata.getHost() + ":" + runtimeMetadata.getPort()); - } - } - return list; - } - - public String getMetaString() { - StringBuilder sb = new StringBuilder(); - List list = new ArrayList<>(); - for (ColonyDO c : colonyDO.getMetaColonyDOList().values()) { - for (RuntimeMetadata runtimeMetadata : c.getClusterDO().getRuntimeMap().values()) { - sb.append(runtimeMetadata.getHost() + ":" + runtimeMetadata.getPort()); - sb.append(";"); - } - } - return sb.substring(0, sb.length() - 1); + @Override + protected SDKTypeEnum getSDKTypeEnum() { + return SDKTypeEnum.ADMIN; } - public void update() { - - } - - public Long getClusterId() { - return clusterDO.getClusterInfo().getClusterId(); - } - - public Long getId() { - return clusterDO.getClusterInfo().getId(); - } - - public T toDataOjbect(Object object, Class clazz) { - if (object instanceof JSONObject) { - JSONObject jsonObject = (JSONObject) object; - return (T) jsonObject.toJavaObject(clazz); - } else if (object instanceof String) { - return (T) JSONObject.parseObject((String) object, clazz); - } else if (object instanceof Map) { - return null; - } - return null; - } - - - protected abstract void doInit(); } diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/Remoting2Manage.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/Remoting2Manage.java new file mode 100644 index 00000000..e05592ad --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/Remoting2Manage.java @@ -0,0 +1,228 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.core.remoting; + +import org.apache.eventmesh.dashboard.common.annotation.RemotingServiceMapper; +import org.apache.eventmesh.dashboard.common.annotation.RemotingServiceMethodMapper; +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.common.model.base.BaseClusterIdBase; +import org.apache.eventmesh.dashboard.common.model.base.BaseSyncBase; +import org.apache.eventmesh.dashboard.common.model.remoting.AbstractGlobal2Request; +import org.apache.eventmesh.dashboard.common.model.remoting.GlobalResult; +import org.apache.eventmesh.dashboard.common.model.remoting.RemotingActionType; +import org.apache.eventmesh.dashboard.common.util.ClasspathScanner; +import org.apache.eventmesh.dashboard.core.function.SDK.SDKManage; +import org.apache.eventmesh.dashboard.core.metadata.DataMetadataHandler; + +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.ArrayUtils; + +import java.lang.reflect.Method; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.concurrent.ConcurrentHashMap; + +import lombok.extern.slf4j.Slf4j; + + +@Slf4j +public class Remoting2Manage { + + private static final Remoting2Manage INSTANCE = new Remoting2Manage(); + + private static final Map, RemotingServiceMetadataWrapper>> REMOTING_SERVICE_METADATA_WRAPPER_MAP = new HashMap<>(); + + private static final Map, Map> CLASS_METHOD_MAPPER = new HashMap<>(); + + static { + ClasspathScanner classpathScanner = ClasspathScanner.builder().base(Remoting2Manage.class).subPath("/**").build(); + try { + classpathScanner.getClazz().forEach(Remoting2Manage::registerService); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + public static void registerService(Class clazz) { + if (ArrayUtils.isEmpty(clazz.getInterfaces())) { + return; + } + if (Objects.isNull(clazz.getSuperclass())) { + return; + } + RemotingServiceMapper remotingServiceMapper = clazz.getSuperclass().getAnnotation(RemotingServiceMapper.class); + if (Objects.isNull(remotingServiceMapper)) { + return; + } + final Class interfaces = clazz.getInterfaces()[0]; + + final Map, RemotingServiceMetadataWrapper> remotingServiceMetadataWrapperMap = + REMOTING_SERVICE_METADATA_WRAPPER_MAP.computeIfAbsent(remotingServiceMapper.clusterType(), k -> new ConcurrentHashMap<>()); + + RemotingServiceMetadataWrapper remotingServiceMetadataWrapper = new RemotingServiceMetadataWrapper(); + remotingServiceMetadataWrapper.clusterType = remotingServiceMapper.clusterType(); + remotingServiceMetadataWrapper.remotingServiceType = clazz; + remotingServiceMetadataWrapper.remotingServiceMapper = remotingServiceMapper; + remotingServiceMetadataWrapper.targetClass = interfaces; + remotingServiceMetadataWrapperMap.put(interfaces, remotingServiceMetadataWrapper); + + Map actionMap = CLASS_METHOD_MAPPER.get(interfaces); + if (Objects.isNull(actionMap)) { + actionMap = new HashMap<>(); + CLASS_METHOD_MAPPER.put(interfaces, actionMap); + Method[] methods = interfaces.getMethods(); + for (Method method : methods) { + RemotingServiceMethodMapper remotingServiceMethodMappers = method.getAnnotation(RemotingServiceMethodMapper.class); + if (Objects.isNull(remotingServiceMethodMappers)) { + continue; + } + RemotingServiceMethodMapperWrapper remotingServiceMethodMapperWrapper = new RemotingServiceMethodMapperWrapper(); + remotingServiceMethodMapperWrapper.remotingServiceMethod = method; + + for (RemotingActionType remotingActionType : remotingServiceMethodMappers.value()) { + actionMap.put(remotingActionType, remotingServiceMethodMapperWrapper); + } + + Class[] clazzs = method.getParameterTypes(); + if (ArrayUtils.isNotEmpty(clazzs)) { + remotingServiceMethodMapperWrapper.parameterTypes = clazzs[0]; + } + } + + } + remotingServiceMetadataWrapper.actionMap = actionMap; + + } + + + public static Remoting2Manage getInstance() { + return INSTANCE; + } + + private Remoting2Manage() {} + + /** + * @param clazz Remoting Service + * @param baseSyncBase baseSyncBase + * @return RemotingService + */ + public DataMetadataHandler createDataMetadataHandler(Class clazz, BaseSyncBase baseSyncBase) { + RemotingServiceMetadataWrapper remotingServiceMetadataWrapper = + REMOTING_SERVICE_METADATA_WRAPPER_MAP.get(baseSyncBase.getClusterType()).get(clazz); + AbstractRemotingService proxyObject = + SDKManage.getInstance().createAbstractClientInfo(remotingServiceMetadataWrapper.remotingServiceType, baseSyncBase); + RemotingService remotingService = new RemotingService<>(); + remotingService.execution = proxyObject; + remotingService.wrapper = remotingServiceMetadataWrapper; + return remotingService; + } + + + @SuppressWarnings("unchecked") + public static class RemotingService implements DataMetadataHandler { + + private RemotingServiceMetadataWrapper wrapper; + + private Object execution; + + @Override + public void handleAll(List addData, List updateData, List deleteData) { + this.execute(addData, RemotingActionType.ADD); + this.execute(addData, RemotingActionType.UPDATE); + this.execute(addData, RemotingActionType.DELETE); + } + + private void execute(List data, RemotingActionType remotingActionType) { + if (CollectionUtils.isEmpty(data)) { + return; + } + data.forEach((value) -> { + this.execution(value, remotingActionType); + }); + } + + @SuppressWarnings("unchecked") + private Object execution(T object, RemotingActionType remotingActionType) { + RemotingServiceMethodMapperWrapper methodMapper = wrapper.actionMap.get(remotingActionType); + Object arg = null; + try { + if (Objects.nonNull(methodMapper.parameterTypes)) { + AbstractGlobal2Request request = + (AbstractGlobal2Request) methodMapper.parameterTypes.newInstance(); + request.setMetaData(object); + arg = request; + } + GlobalResult result = (GlobalResult) methodMapper.remotingServiceMethod.invoke(execution, arg); + if (Objects.isNull(result)) { + log.error(" result is null, service is {} action is {} , arg is {}", wrapper.remotingServiceType.getSimpleName(), + remotingActionType, object); + if (Objects.equals(RemotingActionType.QUEUE_ALL, remotingActionType)) { + return Collections.EMPTY_LIST; + } + return null; + } + return result.getData(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + @Override + public List getData() { + return (List) this.execution(null, RemotingActionType.QUEUE_ALL); + + } + } + + + static class RemotingServiceMetadataWrapper { + + private RemotingServiceMapper remotingServiceMapper; + + private ClusterType clusterType; + + private Class targetClass; + + /** + * 通过这个找到 + */ + private Class remotingServiceType; + + private Map actionMap; + } + + static class RemotingServiceMethodMapperWrapper { + + private RemotingServiceMethodMapper remotingServiceMethodMapper; + + private Method remotingServiceMethod; + + private Method targetMethod; + + private String targetMethodName; + + private Class parameterTypes; + + + } + +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/RemotingManager.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/RemotingManager.java deleted file mode 100644 index 8e95d5a9..00000000 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/RemotingManager.java +++ /dev/null @@ -1,391 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.core.remoting; - -import org.apache.eventmesh.dashboard.common.enums.ClusterTrusteeshipType; -import org.apache.eventmesh.dashboard.common.enums.ClusterType; -import org.apache.eventmesh.dashboard.common.enums.RemotingType; -import org.apache.eventmesh.dashboard.common.model.metadata.ClusterMetadata; -import org.apache.eventmesh.dashboard.common.model.metadata.ClusterRelationshipMetadata; -import org.apache.eventmesh.dashboard.common.model.metadata.RuntimeMetadata; -import org.apache.eventmesh.dashboard.common.model.remoting.GlobalRequest; -import org.apache.eventmesh.dashboard.common.model.remoting.GlobalResult; -import org.apache.eventmesh.dashboard.common.model.remoting.RemotingAction; -import org.apache.eventmesh.dashboard.core.cluster.ClusterDO; -import org.apache.eventmesh.dashboard.core.cluster.ColonyDO; -import org.apache.eventmesh.dashboard.core.remoting.rocketmq.RocketMQAclRemotingService; -import org.apache.eventmesh.dashboard.core.remoting.rocketmq.RocketMQClientRemotingService; -import org.apache.eventmesh.dashboard.core.remoting.rocketmq.RocketMQConfigRemotingService; -import org.apache.eventmesh.dashboard.core.remoting.rocketmq.RocketMQGroupRemotingService; -import org.apache.eventmesh.dashboard.core.remoting.rocketmq.RocketMQOffsetRemotingService; -import org.apache.eventmesh.dashboard.core.remoting.rocketmq.RocketMQSubscriptionRemotingService; -import org.apache.eventmesh.dashboard.core.remoting.rocketmq.RocketMQTopicRemotingService; -import org.apache.eventmesh.dashboard.core.remoting.rocketmq.RocketMQUserRemotingService; -import org.apache.eventmesh.dashboard.service.remoting.RemotingIntegrationService; - -import java.lang.reflect.InvocationHandler; -import java.lang.reflect.Method; -import java.lang.reflect.ParameterizedType; -import java.lang.reflect.Proxy; -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.atomic.AtomicBoolean; - -import lombok.Data; -import lombok.Getter; - - -/** - * - */ -public class RemotingManager { - - - private final Map>> remotingServiceClasses = new HashMap<>(); - - /** - * key clusterId - */ - private final Map remotingWrapperMap = new ConcurrentHashMap<>(); - - @Getter - private final Object proxyObject; - - - /** - * Long key is clusterId - */ - private final Map colonyDOMap = new HashMap<>(); - - private final AtomicBoolean loading = new AtomicBoolean(true); - - - { - for (RemotingType remotingType : RemotingType.values()) { - remotingServiceClasses.put(remotingType, new ArrayList<>()); - } - this.registerService(RemotingType.ROCKETMQ, RocketMQAclRemotingService.class, RocketMQConfigRemotingService.class, - RocketMQClientRemotingService.class, RocketMQGroupRemotingService.class, RocketMQOffsetRemotingService.class, - RocketMQSubscriptionRemotingService.class, RocketMQTopicRemotingService.class, RocketMQUserRemotingService.class); - - this.registerService(RemotingType.EVENT_MESH_RUNTIME, RocketMQAclRemotingService.class, RocketMQConfigRemotingService.class, - RocketMQClientRemotingService.class, RocketMQGroupRemotingService.class, RocketMQOffsetRemotingService.class, - RocketMQSubscriptionRemotingService.class, RocketMQTopicRemotingService.class, RocketMQUserRemotingService.class); - - RemotingServiceHandler remotingServiceHandler = new RemotingServiceHandler(); - Class[] clazzList = new Class[] {RemotingIntegrationService.class}; - proxyObject = Proxy.newProxyInstance(this.getClass().getClassLoader(), clazzList, remotingServiceHandler); - } - - public void registerService(RemotingType remotingType, Class... clazzs) { - List> serviceList = this.remotingServiceClasses.get(remotingType); - Collections.addAll(serviceList, clazzs); - } - - - public void registerColony(ColonyDO colonyDO) throws Exception { - if (loading.get()) { - return; - } - - if (colonyDO.getClusterDO().getClusterInfo().getClusterType().isMainCluster()) { - ClusterType clusterType = colonyDO.getClusterDO().getClusterInfo().getClusterType(); - RemotingType remotingType = clusterType.getRemotingType(); - List> remotingServersClassList = remotingServiceClasses.get(remotingType); - Map, Object> remotingServersMap = new HashMap<>(); - for (Class clazz : remotingServersClassList) { - AbstractRemotingService abstractRemotingService = (AbstractRemotingService) clazz.newInstance(); - abstractRemotingService.setColonyDO(colonyDO); - abstractRemotingService.init(); - remotingServersMap.put(clazz.getInterfaces()[0], abstractRemotingService); - } - RemotingWrapper remotingWrapper = new RemotingWrapper(); - remotingWrapper.setColonyDO(colonyDO); - remotingWrapper.setObject(remotingServersMap); - this.remotingWrapperMap.put(colonyDO.getClusterId(), remotingWrapper); - } else { - this.updateColony(colonyDO); - } - - } - - public void updateColony(ColonyDO colonyDO) { - RemotingWrapper remotingWrapper = this.getMainRemotingWrapper(colonyDO); - /* - There is a delay - */ - if (Objects.isNull(remotingWrapper)) { - return; - } - ColonyDO mainColonyDO = this.getMainColonyDO(colonyDO); - for (Object object : remotingWrapper.getObject().values()) { - AbstractRemotingService abstractRemotingService = (AbstractRemotingService) object; - abstractRemotingService.setColonyDO(mainColonyDO); - abstractRemotingService.update(); - } - } - - public RemotingWrapper getMainRemotingWrapper(ColonyDO colonyDO) { - Long clusterId = - colonyDO.getClusterDO().getClusterInfo().getClusterType().isMainCluster() ? colonyDO.getClusterId() : colonyDO.getSuperiorId(); - if (Objects.isNull(clusterId)) { - return null; - } - return remotingWrapperMap.get(clusterId); - } - - public ColonyDO getMainColonyDO(ColonyDO colonyDO) { - Long clusterId = - colonyDO.getClusterDO().getClusterInfo().getClusterType().isMainCluster() ? colonyDO.getClusterId() : colonyDO.getSuperiorId(); - return colonyDOMap.get(clusterId); - } - - public void unregister(ColonyDO colonyDO) { - remotingWrapperMap.remove(colonyDO.getClusterId()); - } - - public void loadingCompleted() throws Exception { - this.loading.set(false); - for (ColonyDO colonyDO : colonyDOMap.values()) { - if (colonyDO.getClusterDO().getClusterInfo().getClusterType().isMainCluster()) { - this.registerColony(colonyDO); - } - } - } - - - /** - * 解除完关系,才能删除 - * - * @param clusterEntityList - */ - public void cacheCluster(List clusterEntityList) { - for (ClusterMetadata cluster : clusterEntityList) { - Long clusterId = cluster.getId(); - if (cluster.getStatus() == 1) { - ColonyDO colonyDO = colonyDOMap.remove(cluster.getClusterId()); - this.unregister(colonyDO); - continue; - } - ColonyDO colonyDO = this.colonyDOMap.computeIfAbsent(clusterId, key -> { - ColonyDO newColonyDO = new ColonyDO(); - ClusterDO newClusterDO = new ClusterDO(); - newColonyDO.setClusterDO(newClusterDO); - return newColonyDO; - }); - if (Objects.isNull(colonyDO.getClusterDO().getClusterInfo())) { - colonyDO.getClusterDO().setClusterInfo(cluster); - - try { - this.registerColony(colonyDO); - } catch (Exception e) { - throw new RuntimeException(e); - } - - } else { - colonyDO.getClusterDO().setClusterInfo(cluster); - this.updateColony(colonyDO); - } - } - } - - public void cacheRuntime(List runtimeMeatadataList) { - for (RuntimeMetadata runtimeMetadata : runtimeMeatadataList) { - ColonyDO colonyDO = this.colonyDOMap.get(runtimeMetadata.getClusterId()); - if (Objects.equals(runtimeMetadata.getStatus(), 1)) { - colonyDO.getClusterDO().getRuntimeMap().put(runtimeMetadata.getId(), runtimeMetadata); - } else { - colonyDO.getClusterDO().getRuntimeMap().remove(runtimeMetadata.getId()); - } - } - } - - /** - * 解除关系是解除关系,不是删除 - * - * @param clusterRelationshipEntityList - */ - public void cacheClusterRelationship(List clusterRelationshipEntityList) { - for (ClusterRelationshipMetadata clusterRelationshipEntity : clusterRelationshipEntityList) { - ClusterType relationshipType = clusterRelationshipEntity.getRelationshipType(); - ColonyDO colonyDO = this.colonyDOMap.get(clusterRelationshipEntity.getClusterId()); - if (Objects.equals(relationshipType.getAssemblyNodeType(), ClusterType.META)) { - this.relationship(colonyDO, colonyDO.getMetaColonyDOList(), clusterRelationshipEntity); - } else if (Objects.equals(relationshipType.getAssemblyNodeType(), ClusterType.RUNTIME)) { - this.relationship(colonyDO, colonyDO.getRuntimeColonyDOList(), clusterRelationshipEntity); - } else if (Objects.equals(relationshipType.getAssemblyNodeType(), ClusterType.STORAGE)) { - this.relationship(colonyDO, colonyDO.getStorageColonyDOList(), clusterRelationshipEntity); - } - } - } - - private void relationship(ColonyDO colonyDO, Map clusterDOList, ClusterRelationshipMetadata clusterRelationshipMetadata) { - if (Objects.equals(clusterRelationshipMetadata.getStatus(), 2)) { - clusterDOList.remove(clusterRelationshipMetadata.getRelationshipId()); - } else { - ColonyDO relationshiCcolonyDO = this.colonyDOMap.get(clusterRelationshipMetadata.getRelationshipId()); - clusterDOList.put(clusterRelationshipMetadata.getRelationshipId(), relationshiCcolonyDO); - relationshiCcolonyDO.setSuperiorId(colonyDO.getClusterId()); - } - this.updateColony(colonyDO); - } - - public List getEventMeshClusterDO(ClusterTrusteeshipType... clusterTrusteeshipType) { - return this.filterer(ClusterType.EVENTMESH, clusterTrusteeshipType); - } - - public List getMetaNacosClusterDO(ClusterTrusteeshipType... clusterTrusteeshipType) { - return this.filterer(ClusterType.EVENTMESH_META_ETCD, clusterTrusteeshipType); - } - - public List getMetaEtcdClusterDO(ClusterTrusteeshipType... clusterTrusteeshipType) { - return this.filterer(ClusterType.EVENTMESH_META_NACOS, clusterTrusteeshipType); - } - - public List getRocketMQClusterDO(ClusterTrusteeshipType... clusterTrusteeshipType) { - return this.filterer(ClusterType.STORAGE_ROCKETMQ, clusterTrusteeshipType); - } - - public List getStorageCluster(ClusterTrusteeshipType... clusterTrusteeshipType) { - List list = new ArrayList<>(); - for (ClusterType clusterType : ClusterType.STORAGE_TYPES) { - list.addAll(this.filterer(clusterType, clusterTrusteeshipType)); - } - return list; - } - - - public boolean isClusterTrusteeshipType(Long clusterId, ClusterTrusteeshipType clusterTrusteeshipType) { - ColonyDO colonyDO = this.colonyDOMap.get(clusterId); - if (Objects.isNull(colonyDO)) { - return false; - } - return Objects.equals(colonyDO.getClusterDO().getClusterInfo().getTrusteeshipType(), clusterTrusteeshipType); - } - - - private List filterer(ClusterType clusterType, ClusterTrusteeshipType... clusterTrusteeshipTypes) { - Set clusterTrusteeshipType = new HashSet<>(); - clusterTrusteeshipType.addAll(Arrays.asList(clusterTrusteeshipTypes)); - List remotingWrapperList = new ArrayList<>(); - for (RemotingWrapper remotingWrapper : remotingWrapperMap.values()) { - ClusterMetadata clusterMetadata = remotingWrapper.getColonyDO().getClusterDO().getClusterInfo(); - if (Objects.equals(clusterMetadata.getClusterType(), clusterType)) { - if (clusterTrusteeshipType.contains(clusterMetadata.getTrusteeshipType())) { - remotingWrapperList.add(remotingWrapper); - } - } - } - return remotingWrapperList; - } - - - public T request(RemotingRequestWrapper remotingRequestWrapper, List remotingWrapperList) { - List resultData = new ArrayList<>(); - - Class clazz = remotingRequestWrapper.getClass(); - Type superclass = clazz.getGenericSuperclass(); - Class globalRequestClass = null; - Class executeClass = null; - if (superclass instanceof ParameterizedType) { - ParameterizedType parameterizedType = (ParameterizedType) superclass; - Type[] actualTypeArguments = parameterizedType.getActualTypeArguments(); - executeClass = (Class) actualTypeArguments[0]; - globalRequestClass = (Class) actualTypeArguments[1]; - } - RemotingRequestWrapper remotingRequestWrapper1 = (RemotingRequestWrapper) remotingRequestWrapper; - for (RemotingWrapper remotingWrapper : remotingWrapperList) { - try { - GlobalRequest globalRequest = globalRequestClass.newInstance(); - globalRequest.setClusterId(remotingWrapper.getColonyDO().getClusterId()); - GlobalResult globalResult = remotingRequestWrapper1.request(globalRequest, executeClass); - if (globalResult.getData() instanceof List) { - resultData.addAll((List) globalResult.getData()); - } else { - resultData.add(globalResult.getData()); - } - } catch (Exception e) { - //TODO There should be no abnormal occurrence of InstantiationException, IllegalAccessException, Exception - // - } - } - return (T) resultData; - - } - - /** - * @param - * @param - */ - public interface RemotingRequestWrapper { - - GlobalResult request(T t, RE key); - } - - @Data - public static class RemotingWrapper { - - private ColonyDO colonyDO; - - private Map, Object> object = new HashMap<>(); - } - - - public class RemotingServiceHandler implements InvocationHandler { - - @Override - public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { - - GlobalRequest globalRequest = (GlobalRequest) args[0]; - Long clusterId = globalRequest.getClusterId(); - // ClusterDO - RemotingWrapper remotingWrapper = remotingWrapperMap.get(clusterId); - // 完整执行对象 - Class declaringClass = method.getDeclaringClass(); - Object object = remotingWrapper.getObject().get(declaringClass); - if (Objects.isNull(object)) { - return null; - } - - Method currentMethod = object.getClass().getMethod(method.getName(), method.getParameterTypes()); - RemotingAction annotations = currentMethod.getAnnotation(RemotingAction.class); - if (Objects.nonNull(annotations)) { - if (!annotations.support()) { - ColonyDO colonyDO = remotingWrapper.getColonyDO(); - Map colonyDOMap1 = colonyDO.getStorageColonyDOList(); - for (ColonyDO c : colonyDOMap1.values()) { - RemotingWrapper newRemotingWrapper = remotingWrapperMap.get(c.getClusterId()); - Object newObject = newRemotingWrapper.getObject().get(declaringClass); - return method.invoke(newObject, args); - } - } - } - return method.invoke(object, args); - - } - } -} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/RemotingProxyBatchException.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/RemotingProxyBatchException.java new file mode 100644 index 00000000..a25d9392 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/RemotingProxyBatchException.java @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.core.remoting; + +public class RemotingProxyBatchException extends RuntimeException { + + public RemotingProxyBatchException(String message) { + + } + +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/RemotingResultType.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/RemotingResultType.java new file mode 100644 index 00000000..7b54c191 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/RemotingResultType.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.core.remoting; + +/** + * return 错误结果 throw 处理,上层怎么处理 + */ +public enum RemotingResultType { + + + ERROR_THROW_EXCEPTION, + + RETURN_ERROR_THROW_EXCEPTION, + + +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/jvm/AbstractJvmRemotingService.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/jvm/AbstractJvmRemotingService.java new file mode 100644 index 00000000..b0d36531 --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/jvm/AbstractJvmRemotingService.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.core.remoting.jvm; + +import org.apache.eventmesh.dashboard.common.annotation.RemotingServiceMapper; +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.core.remoting.AbstractRemotingService; + +@RemotingServiceMapper(clusterType = ClusterType.STORAGE_JVM_BROKER) +public abstract class AbstractJvmRemotingService extends AbstractRemotingService { + + +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/jvm/JvmAclRemotingService.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/jvm/JvmAclRemotingService.java new file mode 100644 index 00000000..ea33d05c --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/jvm/JvmAclRemotingService.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.core.remoting.jvm; + +import org.apache.eventmesh.dashboard.common.model.remoting.acl.CreateAclRequest; +import org.apache.eventmesh.dashboard.common.model.remoting.acl.CreateAclResult; +import org.apache.eventmesh.dashboard.common.model.remoting.acl.DeleteAclRequest; +import org.apache.eventmesh.dashboard.common.model.remoting.acl.DeleteAclResult; +import org.apache.eventmesh.dashboard.common.model.remoting.acl.GetAcls2Request; +import org.apache.eventmesh.dashboard.common.model.remoting.acl.GetAclsResult; +import org.apache.eventmesh.dashboard.service.remoting.AclRemotingService; + + +public class JvmAclRemotingService extends AbstractJvmRemotingService implements AclRemotingService { + + + @Override + public CreateAclResult createAcl(CreateAclRequest createAclRequest) { + //this.defaultMQAdminExt.createAndUpdatePlainAccessConfig(); + return null; + } + + @Override + public DeleteAclResult deleteAcl(DeleteAclRequest deleteAclRequest) { + return null; + } + + @Override + public GetAclsResult getAllAcls(GetAcls2Request getAclsRequest) { + return null; + } +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/jvm/JvmClientRemotingService.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/jvm/JvmClientRemotingService.java new file mode 100644 index 00000000..32ee1d7e --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/jvm/JvmClientRemotingService.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.core.remoting.jvm; + + + +import org.apache.eventmesh.dashboard.common.model.metadata.ClientMetadata; +import org.apache.eventmesh.dashboard.service.remoting.ClientRemotingService; + +import java.util.List; + + +public class JvmClientRemotingService extends AbstractJvmRemotingService implements ClientRemotingService { + + @Override + public List getClientList() { + return null; + } +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/cluster/ConfigSyncFromClusterService.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/jvm/JvmConfigRemotingService.java similarity index 50% rename from eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/cluster/ConfigSyncFromClusterService.java rename to eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/jvm/JvmConfigRemotingService.java index b8ffab6f..483cf87a 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/cluster/ConfigSyncFromClusterService.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/jvm/JvmConfigRemotingService.java @@ -15,56 +15,32 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.core.metadata.cluster; -import org.apache.eventmesh.dashboard.common.model.metadata.ConfigMetadata; -import org.apache.eventmesh.dashboard.common.model.remoting.GlobalRequest; -import org.apache.eventmesh.dashboard.common.model.remoting.GlobalResult; -import org.apache.eventmesh.dashboard.common.model.remoting.config.GetConfigRequest; -import org.apache.eventmesh.dashboard.service.remoting.ConfigRemotingService; - -import java.util.List; - -import org.springframework.stereotype.Service; +package org.apache.eventmesh.dashboard.core.remoting.jvm; -import lombok.Setter; -import lombok.extern.slf4j.Slf4j; - -@Slf4j -@Service -public class ConfigSyncFromClusterService extends AbstractMetadataHandler { - - @Setter - ConfigRemotingService configRemotingService; - - @Override - public void addMetadata(ConfigMetadata meta) { - } +import org.apache.eventmesh.dashboard.common.model.remoting.BaseGlobalResult; +import org.apache.eventmesh.dashboard.common.model.remoting.config.AddConfigRequest; +import org.apache.eventmesh.dashboard.common.model.remoting.config.GetConfigRequest; +import org.apache.eventmesh.dashboard.common.model.remoting.topic.GetTopics2Request; +import org.apache.eventmesh.dashboard.common.model.remoting.topic.GetTopicsResult; +import org.apache.eventmesh.dashboard.service.remoting.ConfigRemotingService; - @Override - public void deleteMetadata(ConfigMetadata meta) { - } +public class JvmConfigRemotingService extends AbstractJvmRemotingService implements ConfigRemotingService { @Override - public List getData() { - // topic - // group - // runtime - // broker - + public BaseGlobalResult addConfig(AddConfigRequest addConfigRequest) { return null; } @Override - public List getData(GlobalRequest globalRequest) { + public GetTopicsResult getConfig(GetConfigRequest getConfigRequest) { return null; } - @Override - public GlobalResult request(ConfigRemotingService configRemotingService, GetConfigRequest key) { + public GetTopicsResult getAllTopics(GetTopics2Request getTopicsRequest) { return null; } } diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/jvm/JvmGroupRemotingService.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/jvm/JvmGroupRemotingService.java new file mode 100644 index 00000000..9f9ad4ce --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/jvm/JvmGroupRemotingService.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.core.remoting.jvm; + + +import org.apache.eventmesh.dashboard.common.model.remoting.BaseGlobalResult; +import org.apache.eventmesh.dashboard.common.model.remoting.Global2Request; +import org.apache.eventmesh.dashboard.common.model.remoting.group.GetGroupResult; +import org.apache.eventmesh.dashboard.common.model.remoting.group.GetGroupsRequest; +import org.apache.eventmesh.dashboard.service.remoting.GroupRemotingService; + + +public class JvmGroupRemotingService extends AbstractJvmRemotingService implements GroupRemotingService { + + @Override + public GetGroupResult getAllGroups(GetGroupsRequest getGroupsRequest) { + return null; + } + + @Override + public BaseGlobalResult deleteGroup(Global2Request global2Request) { + return null; + } +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/jvm/JvmOffsetRemotingService.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/jvm/JvmOffsetRemotingService.java new file mode 100644 index 00000000..2069e58f --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/jvm/JvmOffsetRemotingService.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + + +package org.apache.eventmesh.dashboard.core.remoting.jvm; + + + +import org.apache.eventmesh.dashboard.common.model.remoting.offset.GetOffsetRequest; +import org.apache.eventmesh.dashboard.common.model.remoting.offset.GetOffsetResult; +import org.apache.eventmesh.dashboard.common.model.remoting.offset.ResetOffsetRequest; +import org.apache.eventmesh.dashboard.common.model.remoting.offset.ResetOffsetResult; +import org.apache.eventmesh.dashboard.service.remoting.OffsetRemotingService; + + +public class JvmOffsetRemotingService extends AbstractJvmRemotingService implements OffsetRemotingService { + + @Override + public GetOffsetResult getOffset(GetOffsetRequest getOffsetRequest) { + return null; + } + + @Override + public ResetOffsetResult resetOffset(ResetOffsetRequest resetOffsetRequest) { + return null; + } +} diff --git a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeTcpOpenMessageSDKOperationTest.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/jvm/JvmSubscriptionRemotingService.java similarity index 58% rename from eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeTcpOpenMessageSDKOperationTest.java rename to eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/jvm/JvmSubscriptionRemotingService.java index 66083179..b03a5210 100644 --- a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeTcpOpenMessageSDKOperationTest.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/jvm/JvmSubscriptionRemotingService.java @@ -15,22 +15,19 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.core.function.SDK.operation; +package org.apache.eventmesh.dashboard.core.remoting.jvm; -import org.apache.eventmesh.dashboard.core.function.SDK.operation.runtime.RuntimeTcpOpenMessageSDKOperation; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.Timeout; +import org.apache.eventmesh.dashboard.common.model.remoting.subscription.GetSubscriptionRequest; +import org.apache.eventmesh.dashboard.common.model.remoting.subscription.GetSubscriptionResult; +import org.apache.eventmesh.dashboard.service.remoting.SubscriptionRemotingService; -@Timeout(value = 5) -public class RuntimeTcpOpenMessageSDKOperationTest { - private final RuntimeTcpOpenMessageSDKOperation tcpOpenMessageSDKOperation = new RuntimeTcpOpenMessageSDKOperation(); +public class JvmSubscriptionRemotingService extends AbstractJvmRemotingService implements SubscriptionRemotingService { - @Test - void testCreateClient() { - // todo no impl + @Override + public GetSubscriptionResult getSubscription(GetSubscriptionRequest request) { + return null; } - } diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/jvm/JvmTopicRemotingService.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/jvm/JvmTopicRemotingService.java new file mode 100644 index 00000000..33579f2a --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/jvm/JvmTopicRemotingService.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.core.remoting.jvm; + +import org.apache.eventmesh.dashboard.common.model.remoting.topic.CreateTopic2Request; +import org.apache.eventmesh.dashboard.common.model.remoting.topic.CreateTopicResult; +import org.apache.eventmesh.dashboard.common.model.remoting.topic.DeleteTopicRequest; +import org.apache.eventmesh.dashboard.common.model.remoting.topic.DeleteTopicResult; +import org.apache.eventmesh.dashboard.common.model.remoting.topic.GetTopics2Request; +import org.apache.eventmesh.dashboard.common.model.remoting.topic.GetTopicsResult; +import org.apache.eventmesh.dashboard.service.remoting.TopicRemotingService; + + + +public class JvmTopicRemotingService extends AbstractJvmRemotingService implements TopicRemotingService { + + @Override + public CreateTopicResult createTopic(CreateTopic2Request createTopicRequest) { + CreateTopicResult createTopicResult = new CreateTopicResult(); + //this.defaultMQAdminExt.createAndUpdateTopicConfig(master, topicConfig); + return null; + } + + @Override + public DeleteTopicResult deleteTopic(DeleteTopicRequest deleteTopicRequest) { + DeleteTopicResult deleteTopicResult = new DeleteTopicResult(); + //this.defaultMQAdminExt.deleteTopic(deleteTopicRequest.getTopicMetadata().getTopicName(), null); + return null; + } + + @Override + public GetTopicsResult getAllTopics(GetTopics2Request getTopicsRequest) + throws Exception { + + return null; + } +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/jvm/JvmUserRemotingService.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/jvm/JvmUserRemotingService.java new file mode 100644 index 00000000..69b5542f --- /dev/null +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/jvm/JvmUserRemotingService.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.core.remoting.jvm; + +import org.apache.eventmesh.dashboard.common.model.remoting.user.CreateUserRequest; +import org.apache.eventmesh.dashboard.common.model.remoting.user.DeleterUserRequest; +import org.apache.eventmesh.dashboard.common.model.remoting.user.GetUserRequest; +import org.apache.eventmesh.dashboard.common.model.remoting.user.GetUserResult; +import org.apache.eventmesh.dashboard.service.remoting.UserRemotingService; + + +public class JvmUserRemotingService extends AbstractJvmRemotingService implements UserRemotingService { + + @Override + public CreateUserRequest createInstanceUser(CreateUserRequest request) { + return null; + } + + @Override + public DeleterUserRequest deleteInstanceUser(DeleterUserRequest request) { + return null; + } + + @Override + public GetUserResult getInstanceUser(GetUserRequest request) { + return null; + } +} diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/AbstractRocketMQRemotingService.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/AbstractRocketMQRemotingService.java index 124ea575..f67b4a8a 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/AbstractRocketMQRemotingService.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/AbstractRocketMQRemotingService.java @@ -15,98 +15,17 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.core.remoting.rocketmq; -import org.apache.eventmesh.dashboard.common.model.remoting.GlobalResult; -import org.apache.eventmesh.dashboard.core.function.SDK.SDKManager; -import org.apache.eventmesh.dashboard.core.function.SDK.SDKTypeEnum; -import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateRocketmqConfig; import org.apache.eventmesh.dashboard.core.remoting.AbstractRemotingService; import org.apache.rocketmq.tools.admin.DefaultMQAdminExt; -import org.apache.rocketmq.tools.command.CommandUtil; - -import java.util.AbstractMap; -import java.util.Objects; -import java.util.Set; /** * rocketmq 其他不同的是。 以nameservier 为主。那么可以多集群。一个eventmesh 可以操作多个集群 */ -public abstract class AbstractRocketMQRemotingService extends AbstractRemotingService { - - - protected DefaultMQAdminExt defaultMQAdminExt; - - protected CreateRocketmqConfig createRocketmqConfig; - - - @Override - public void createConfig() { - createRocketmqConfig = new CreateRocketmqConfig(); - createRocketmqConfig.setNameServerUrl(this.getMetaString()); - } - - @Override - protected void doInit() { - AbstractMap.SimpleEntry clientSimple = - SDKManager.getInstance().createClient(SDKTypeEnum.STORAGE_ROCKETMQ_ADMIN, createRocketmqConfig); - this.defaultMQAdminExt = clientSimple.getValue(); - } - - protected T cluster(GlobalResult t, Function function) { - try { - - /*for(ColonyDO clusterDO : this.cache.getClusterDOList()){ - for(RuntimeMetadata runtimeMetadata : clusterDO.getRuntimeEntityList()){ - - } - }*/ - - Set masterSet = - CommandUtil.fetchMasterAddrByClusterName(defaultMQAdminExt, createRocketmqConfig.getClusterName()); - for (String masterName : masterSet) { - Object newResult = function.apply(masterName, t); - if (Objects.nonNull(newResult)) { - return (T) newResult; - } - } - t.setCode(200); - } catch (Exception exception) { - t.setCode(400); - t.setErrorMessages(exception.getMessage()); - t.setThrowable(exception); - } finally { - return (T) t; - } - } - - ; - - protected T clusterName(GlobalResult t, Function function) { - try { - - Object newResult = function.apply(createRocketmqConfig.getClusterName(), t); - if (Objects.nonNull(newResult)) { - return (T) newResult; - } - t.setCode(200); - } catch (Exception exception) { - t.setCode(400); - t.setErrorMessages(exception.getMessage()); - t.setThrowable(exception); - } finally { - return (T) t; - } - } - - /** - * @param - */ - protected interface Function { - - T apply(String masterName, T t) throws Exception; - } +public abstract class AbstractRocketMQRemotingService extends AbstractRemotingService { } diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/RocketMQAclRemotingService.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/RocketMQAclRemotingService.java index 00b52719..af61e29c 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/RocketMQAclRemotingService.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/RocketMQAclRemotingService.java @@ -15,13 +15,14 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.core.remoting.rocketmq; import org.apache.eventmesh.dashboard.common.model.remoting.acl.CreateAclRequest; import org.apache.eventmesh.dashboard.common.model.remoting.acl.CreateAclResult; import org.apache.eventmesh.dashboard.common.model.remoting.acl.DeleteAclRequest; import org.apache.eventmesh.dashboard.common.model.remoting.acl.DeleteAclResult; -import org.apache.eventmesh.dashboard.common.model.remoting.acl.GetAclsRequest; +import org.apache.eventmesh.dashboard.common.model.remoting.acl.GetAcls2Request; import org.apache.eventmesh.dashboard.common.model.remoting.acl.GetAclsResult; import org.apache.eventmesh.dashboard.service.remoting.AclRemotingService; @@ -40,7 +41,7 @@ public DeleteAclResult deleteAcl(DeleteAclRequest deleteAclRequest) { } @Override - public GetAclsResult getAllAcls(GetAclsRequest getAclsRequest) { + public GetAclsResult getAllAcls(GetAcls2Request getAclsRequest) { return null; } } diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/RocketMQClientRemotingService.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/RocketMQClientRemotingService.java index f64f4fb7..f39ed2bd 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/RocketMQClientRemotingService.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/RocketMQClientRemotingService.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.core.remoting.rocketmq; import org.apache.eventmesh.dashboard.common.model.metadata.ClientMetadata; diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/RocketMQConfigRemotingService.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/RocketMQConfigRemotingService.java index 60d72cef..7690d3ac 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/RocketMQConfigRemotingService.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/RocketMQConfigRemotingService.java @@ -15,12 +15,13 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.core.remoting.rocketmq; import org.apache.eventmesh.dashboard.common.model.remoting.BaseGlobalResult; import org.apache.eventmesh.dashboard.common.model.remoting.config.AddConfigRequest; import org.apache.eventmesh.dashboard.common.model.remoting.config.GetConfigRequest; -import org.apache.eventmesh.dashboard.common.model.remoting.topic.GetTopicsRequest; +import org.apache.eventmesh.dashboard.common.model.remoting.topic.GetTopics2Request; import org.apache.eventmesh.dashboard.common.model.remoting.topic.GetTopicsResult; import org.apache.eventmesh.dashboard.service.remoting.ConfigRemotingService; @@ -37,7 +38,7 @@ public GetTopicsResult getConfig(GetConfigRequest getConfigRequest) { } @Override - public GetTopicsResult getAllTopics(GetTopicsRequest getTopicsRequest) { + public GetTopicsResult getAllTopics(GetTopics2Request getTopicsRequest) { return null; } } diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/RocketMQGroupRemotingService.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/RocketMQGroupRemotingService.java index 50094447..57ef4c29 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/RocketMQGroupRemotingService.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/RocketMQGroupRemotingService.java @@ -15,8 +15,11 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.core.remoting.rocketmq; +import org.apache.eventmesh.dashboard.common.model.remoting.BaseGlobalResult; +import org.apache.eventmesh.dashboard.common.model.remoting.Global2Request; import org.apache.eventmesh.dashboard.common.model.remoting.group.GetGroupResult; import org.apache.eventmesh.dashboard.common.model.remoting.group.GetGroupsRequest; import org.apache.eventmesh.dashboard.service.remoting.GroupRemotingService; @@ -27,4 +30,9 @@ public class RocketMQGroupRemotingService extends AbstractRocketMQRemotingServic public GetGroupResult getAllGroups(GetGroupsRequest getGroupsRequest) { return null; } + + @Override + public BaseGlobalResult deleteGroup(Global2Request global2Request) { + return null; + } } diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/RocketMQOffsetRemotingService.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/RocketMQOffsetRemotingService.java index f3ae2927..8a67b37a 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/RocketMQOffsetRemotingService.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/RocketMQOffsetRemotingService.java @@ -16,6 +16,7 @@ */ + package org.apache.eventmesh.dashboard.core.remoting.rocketmq; import org.apache.eventmesh.dashboard.common.model.remoting.offset.GetOffsetRequest; diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/RocketMQSubscriptionRemotingService.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/RocketMQSubscriptionRemotingService.java index 66729a0e..e1950a7a 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/RocketMQSubscriptionRemotingService.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/RocketMQSubscriptionRemotingService.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.core.remoting.rocketmq; import org.apache.eventmesh.dashboard.common.model.remoting.subscription.GetSubscriptionRequest; diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/RocketMQTopicRemotingService.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/RocketMQTopicRemotingService.java index 8eaf7032..154a5a95 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/RocketMQTopicRemotingService.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/RocketMQTopicRemotingService.java @@ -15,21 +15,21 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.core.remoting.rocketmq; import org.apache.eventmesh.dashboard.common.enums.RemotingType; import org.apache.eventmesh.dashboard.common.model.metadata.TopicMetadata; import org.apache.eventmesh.dashboard.common.model.remoting.RemotingAction; -import org.apache.eventmesh.dashboard.common.model.remoting.topic.CreateTopicRequest; +import org.apache.eventmesh.dashboard.common.model.remoting.topic.CreateTopic2Request; import org.apache.eventmesh.dashboard.common.model.remoting.topic.CreateTopicResult; import org.apache.eventmesh.dashboard.common.model.remoting.topic.DeleteTopicRequest; import org.apache.eventmesh.dashboard.common.model.remoting.topic.DeleteTopicResult; -import org.apache.eventmesh.dashboard.common.model.remoting.topic.GetTopicsRequest; +import org.apache.eventmesh.dashboard.common.model.remoting.topic.GetTopics2Request; import org.apache.eventmesh.dashboard.common.model.remoting.topic.GetTopicsResponse; import org.apache.eventmesh.dashboard.common.model.remoting.topic.GetTopicsResult; import org.apache.eventmesh.dashboard.service.remoting.TopicRemotingService; -import org.apache.rocketmq.common.TopicConfig; import org.apache.rocketmq.remoting.protocol.body.TopicConfigSerializeWrapper; import java.util.ArrayList; @@ -43,39 +43,33 @@ public class RocketMQTopicRemotingService extends AbstractRocketMQRemotingServic @Resource @Override @RemotingAction(support = false, substitution = RemotingType.STORAGE) - public CreateTopicResult createTopic(CreateTopicRequest createTopicRequest) { + public CreateTopicResult createTopic(CreateTopic2Request createTopicRequest) { CreateTopicResult createTopicResult = new CreateTopicResult(); - TopicConfig topicConfig = this.toDataOjbect(createTopicRequest.getTopicMetadata().getTopicConfig(), TopicConfig.class); - return this.cluster(createTopicResult, (master, result) -> { - this.defaultMQAdminExt.createAndUpdateTopicConfig(master, topicConfig); - return null; - }); + //this.defaultMQAdminExt.createAndUpdateTopicConfig(master, topicConfig); + return null; } @Override public DeleteTopicResult deleteTopic(DeleteTopicRequest deleteTopicRequest) { DeleteTopicResult deleteTopicResult = new DeleteTopicResult(); - return this.clusterName(deleteTopicResult, (master, result) -> { - this.defaultMQAdminExt.deleteTopic(deleteTopicRequest.getTopicMetadata().getTopicName(), master); - return null; - }); + //this.defaultMQAdminExt.deleteTopic(deleteTopicRequest.getTopicMetadata().getTopicName(), null); + return null; } @Override - public GetTopicsResult getAllTopics(GetTopicsRequest getTopicsRequest) { + public GetTopicsResult getAllTopics(GetTopics2Request getTopicsRequest) + throws Exception { GetTopicsResult getTopicsResult = new GetTopicsResult(); GetTopicsResponse getTopicsResponse = new GetTopicsResponse(); List list = new ArrayList<>(); getTopicsResult.setData(getTopicsResponse); - return this.cluster(getTopicsResult, (master, result) -> { - TopicConfigSerializeWrapper topicConfigSerializeWrapper = this.defaultMQAdminExt.getAllTopicConfig(master, 3000); - if (!topicConfigSerializeWrapper.getTopicConfigTable().isEmpty()) { - topicConfigSerializeWrapper.getTopicConfigTable().forEach((k, v) -> { - TopicMetadata topicMetadata = new TopicMetadata(); - //topicMetadata.setClusterId(); - }); - } - return null; - }); + TopicConfigSerializeWrapper topicConfigSerializeWrapper = this.getClient().getAllTopicConfig(null, 3000); + if (!topicConfigSerializeWrapper.getTopicConfigTable().isEmpty()) { + topicConfigSerializeWrapper.getTopicConfigTable().forEach((k, v) -> { + TopicMetadata topicMetadata = new TopicMetadata(); + //topicMetadata.setClusterId(); + }); + } + return null; } } diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/RocketMQUserRemotingService.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/RocketMQUserRemotingService.java index 4568eca9..169793c0 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/RocketMQUserRemotingService.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/RocketMQUserRemotingService.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.core.remoting.rocketmq; import org.apache.eventmesh.dashboard.common.model.remoting.user.CreateUserRequest; diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/store/RocketmqTopicCore.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/store/RocketmqTopicCore.java deleted file mode 100644 index e1f9bac8..00000000 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/store/RocketmqTopicCore.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.core.store; - -import org.apache.eventmesh.dashboard.core.function.SDK.SDKManager; -import org.apache.eventmesh.dashboard.core.function.SDK.SDKTypeEnum; -import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateSDKConfig; -import org.apache.eventmesh.dashboard.service.dto.RocketmqProperties; -import org.apache.eventmesh.dashboard.service.dto.TopicProperties; -import org.apache.eventmesh.dashboard.service.store.TopicCore; - -import org.apache.commons.lang3.StringUtils; -import org.apache.rocketmq.common.TopicConfig; -import org.apache.rocketmq.common.TopicFilterType; -import org.apache.rocketmq.common.constant.PermName; -import org.apache.rocketmq.remoting.CommandCustomHeader; -import org.apache.rocketmq.remoting.RemotingClient; -import org.apache.rocketmq.remoting.protocol.RemotingCommand; -import org.apache.rocketmq.remoting.protocol.RequestCode; -import org.apache.rocketmq.remoting.protocol.body.TopicConfigSerializeWrapper; -import org.apache.rocketmq.remoting.protocol.header.CreateTopicRequestHeader; -import org.apache.rocketmq.remoting.protocol.header.DeleteTopicRequestHeader; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.ConcurrentMap; - -import org.springframework.beans.BeanUtils; -import org.springframework.stereotype.Service; - -import lombok.extern.slf4j.Slf4j; - -@Slf4j -@Service -public class RocketmqTopicCore implements TopicCore { - - private final RocketmqProperties rocketmqProperties; - - public RocketmqTopicCore(RocketmqProperties rocketmqProperties) { - this.rocketmqProperties = rocketmqProperties; - } - - private RemotingClient createRemotingClient(String brokerUrl) { - CreateSDKConfig createSDKConfig = () -> brokerUrl; - - SDKManager.getInstance().createClient(SDKTypeEnum.STORAGE_ROCKETMQ_REMOTING, createSDKConfig); - return (RemotingClient) SDKManager.getInstance().getClient(SDKTypeEnum.STORAGE_ROCKETMQ_REMOTING, brokerUrl); - } - - @Override - public Boolean createTopic(String topicName) { - String namesrvAddr = rocketmqProperties.getNamesrvAddr(); - long requestTimeoutMillis = rocketmqProperties.getRequestTimeoutMillis(); - if (StringUtils.isEmpty(namesrvAddr)) { - log.info("RocketmqTopicCore-createTopic failed, missing brokerUrl"); - return Boolean.FALSE; - } - - RemotingClient remotingClient = (RemotingClient) SDKManager.getInstance().getClient(SDKTypeEnum.STORAGE_ROCKETMQ_REMOTING, namesrvAddr); - if (remotingClient == null) { - remotingClient = createRemotingClient(namesrvAddr); - } - try { - CreateTopicRequestHeader requestHeader = new CreateTopicRequestHeader(); - requestHeader.setTopic(topicName); - requestHeader.setTopicFilterType(TopicFilterType.SINGLE_TAG.name()); - requestHeader.setPerm(PermName.PERM_READ | PermName.PERM_WRITE); - - RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.UPDATE_AND_CREATE_TOPIC, requestHeader); - RemotingCommand response = remotingClient.invokeSync(namesrvAddr, request, requestTimeoutMillis); - log.info("Rocketmq create topic result:" + response.toString()); - return response.getCode() == 0; - } catch (Exception e) { - log.error("RocketmqTopicCore-createTopic failed.", e); - } - return Boolean.FALSE; - } - - @Override - public List getTopics() { - String namesrvAddr = rocketmqProperties.getNamesrvAddr(); - long requestTimeoutMillis = rocketmqProperties.getRequestTimeoutMillis(); - if (StringUtils.isEmpty(namesrvAddr)) { - log.info("RocketmqTopicCore-getTopics failed, missing brokerUrl"); - return new ArrayList<>(); - } - - RemotingClient remotingClient = (RemotingClient) SDKManager.getInstance().getClient(SDKTypeEnum.STORAGE_ROCKETMQ_REMOTING, namesrvAddr); - if (remotingClient == null) { - remotingClient = createRemotingClient(namesrvAddr); - } - List topicConfigList = new ArrayList<>(); - try { - RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_ALL_TOPIC_CONFIG, (CommandCustomHeader) null); - RemotingCommand response = remotingClient.invokeSync(namesrvAddr, request, requestTimeoutMillis); - TopicConfigSerializeWrapper allTopicConfig = TopicConfigSerializeWrapper.decode(response.getBody(), TopicConfigSerializeWrapper.class); - ConcurrentMap topicConfigTable = allTopicConfig.getTopicConfigTable(); - topicConfigList = new ArrayList<>(topicConfigTable.values()); - } catch (Exception e) { - log.error("RocketmqTopicCore-createTopic failed.", e); - } - - return topicConfig2TopicProperties(topicConfigList); - } - - @Override - public Boolean deleteTopic(String topicName) { - String namesrvAddr = rocketmqProperties.getNamesrvAddr(); - long requestTimeoutMillis = rocketmqProperties.getRequestTimeoutMillis(); - if (StringUtils.isEmpty(namesrvAddr)) { - log.info("RocketmqTopicCore-deleteTopic failed, missing brokerUrl"); - return Boolean.FALSE; - } - - RemotingClient remotingClient = (RemotingClient) SDKManager.getInstance().getClient(SDKTypeEnum.STORAGE_ROCKETMQ_REMOTING, namesrvAddr); - if (remotingClient == null) { - remotingClient = createRemotingClient(namesrvAddr); - } - try { - DeleteTopicRequestHeader deleteTopicRequestHeader = new DeleteTopicRequestHeader(); - deleteTopicRequestHeader.setTopic(topicName); - RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.DELETE_TOPIC_IN_BROKER, null); - RemotingCommand response = remotingClient.invokeSync(namesrvAddr, request, requestTimeoutMillis); - - log.info("Rocketmq delete topic result:" + response.toString()); - return response.getCode() == 0; - } catch (Exception e) { - log.error("RocketmqTopicCore-createTopic failed.", e); - } - return Boolean.FALSE; - } - - public List topicConfig2TopicProperties(List topicConfigList) { - ArrayList topicPropertiesList = new ArrayList<>(); - for (TopicConfig topicConfig : topicConfigList) { - TopicProperties topicProperties = new TopicProperties(); - BeanUtils.copyProperties(topicConfig, topicProperties); - topicPropertiesList.add(topicProperties); - } - return topicPropertiesList; - } -} diff --git a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/SDKManageTest.java b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/SDKManageTest.java new file mode 100644 index 00000000..da9e1f3c --- /dev/null +++ b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/SDKManageTest.java @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.core.function.SDK; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.common.model.base.BaseSyncBase; +import org.apache.eventmesh.dashboard.common.model.metadata.RuntimeMetadata; +import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateJvmCapConfig; +import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateJvmConfig; + +import org.junit.Test; + +public class SDKManageTest { + + SDKManage sdkManage = SDKManage.getInstance(); + + public static BaseSyncBase createJvm() { + SDKTypeEnum sdkTypeEnum = SDKTypeEnum.ADMIN; + BaseSyncBase baseSyncBase = new RuntimeMetadata(); + baseSyncBase.setId(1L); + baseSyncBase.setClusterType(ClusterType.STORAGE_JVM_BROKER); + CreateJvmConfig config = new CreateJvmConfig(); + config.setKey(baseSyncBase.getId().toString()); + SDKManage.getInstance().createClient(sdkTypeEnum, baseSyncBase, config, baseSyncBase.getClusterType()); + return baseSyncBase; + } + + public static BaseSyncBase createJvmCap() { + SDKTypeEnum sdkTypeEnum = SDKTypeEnum.ADMIN; + BaseSyncBase baseSyncBase = new RuntimeMetadata(); + baseSyncBase.setId(1L); + baseSyncBase.setClusterType(ClusterType.STORAGE_JVM_CAP_BROKER); + CreateJvmCapConfig config = new CreateJvmCapConfig(); + config.setKey(baseSyncBase.getId().toString()); + SDKManage.getInstance().createClient(sdkTypeEnum, baseSyncBase, config, baseSyncBase.getClusterType()); + return baseSyncBase; + } + + @Test + public void test_createJVMSDK() { + createJvm(); + } + + @Test + public void test_createJVMCapSDK() { + createJvmCap(); + } + +} diff --git a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/SDKManagerTest.java b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/SDKManagerTest.java deleted file mode 100644 index 5c3a1012..00000000 --- a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/SDKManagerTest.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.core.function.SDK; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; - -import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateRedisConfig; - -import java.lang.reflect.Field; -import java.util.Map; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.Timeout; - -import lombok.extern.slf4j.Slf4j; - - -@Slf4j -@Timeout(value = 10) -class SDKManagerTest { - - private String redisKey; - - @BeforeEach - void setUp() { - try { - CreateRedisConfig createRedisConfig = CreateRedisConfig.builder() - .redisUrl("localhost:6379") - .password("") - .timeOut(30) - .build(); - redisKey = SDKManager.getInstance().createClient(SDKTypeEnum.STORAGE_REDIS, createRedisConfig).getKey(); - } catch (Exception e) { - log.warn("SDK manager test init failed, possible reason: redis-server is offline. {}", this.getClass().getSimpleName(), e); - } - } - - @Test - public void testGetClient() { - try { - Object redisClient = SDKManager.getInstance().getClient(SDKTypeEnum.STORAGE_REDIS, redisKey); - assertNotNull(redisClient); - } catch (Exception e) { - log.warn("SDK manager test failed, possible reason: redis-server is offline. {}", this.getClass().getSimpleName(), e); - } - } - - @Test - public void testGetSameClient() { - try { - SDKManager sdkManager = SDKManager.getInstance(); - Object redisClient = sdkManager.getClient(SDKTypeEnum.STORAGE_REDIS, redisKey); - assertNotNull(redisClient); - Class sdkManagerClass = sdkManager.getClass(); - Field clientMapField = sdkManagerClass.getDeclaredField("clientMap"); - clientMapField.setAccessible(true); - Map> clientMap = (Map>) clientMapField.get(sdkManager); - assertEquals(1, clientMap.get(SDKTypeEnum.STORAGE_REDIS).size()); - } catch (Exception e) { - log.warn("SDK manager test failed, possible reason: redis-server is offline. {}", this.getClass().getSimpleName(), e); - } - } -} \ No newline at end of file diff --git a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/Test1.java b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/Test1.java new file mode 100644 index 00000000..cd6addbc --- /dev/null +++ b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/Test1.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.core.function.SDK; + +import org.apache.eventmesh.dashboard.common.util.ClasspathScanner; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.junit.Test; + +public class Test1 { + + + + + @Test + public void ClasspathScannerTest() throws Exception { + Set> interfaceSet = new HashSet<>(); + interfaceSet.add(SDKOperation.class); + ClasspathScanner classpathScanner = ClasspathScanner.builder().base(SDKManage.class).subPath("/operation").interfaceSet(interfaceSet).build(); + List> classList = classpathScanner.getClazz(); + classList.size(); + } + + @Test + public void sdkManageTest() throws Exception { + SDKManage.getInstance(); + } +} diff --git a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/EtcdSDKCreateOperationTest.java b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/EtcdSDKCreateOperationTest.java deleted file mode 100644 index badbd6b8..00000000 --- a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/EtcdSDKCreateOperationTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.core.function.SDK.operation; - -import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateEtcdConfig; - -import java.util.AbstractMap.SimpleEntry; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.Timeout; - -import io.etcd.jetcd.KV; - -import lombok.extern.slf4j.Slf4j; - -@Slf4j -@Timeout(value = 5) -public class EtcdSDKCreateOperationTest { - - private static final String url = "http://localhost:2379"; - private final EtcdSDKOperation etcdSDKOperation = new EtcdSDKOperation(); - - @Test - void testCreateClient() { - final CreateEtcdConfig etcdConfig = CreateEtcdConfig.builder() - .etcdServerAddress(url) - .connectTime(5) - .build(); - SimpleEntry simpleEntry = null; - try { - simpleEntry = etcdSDKOperation.createClient(etcdConfig); - Assertions.assertEquals(url, simpleEntry.getKey()); - simpleEntry.getValue().close(); - } catch (Exception e) { - log.error("create etcd client failed", e); - if (simpleEntry != null) { - simpleEntry.getValue().close(); - } - } - } -} diff --git a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/NacosNamingSDKOperationTest.java b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/NacosNamingSDKOperationTest.java deleted file mode 100644 index 54ae2a96..00000000 --- a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/NacosNamingSDKOperationTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.core.function.SDK.operation; - -import org.apache.eventmesh.dashboard.core.function.SDK.SDKManager; -import org.apache.eventmesh.dashboard.core.function.SDK.SDKTypeEnum; -import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateNacosConfig; - -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.Timeout; - -import com.alibaba.nacos.api.exception.NacosException; -import com.alibaba.nacos.api.naming.NamingService; - -import lombok.extern.slf4j.Slf4j; - -@Slf4j -@Timeout(value = 5) -class NacosNamingSDKOperationTest { - - private NacosNamingSDKOperation nacosNamingSDKOperation = new NacosNamingSDKOperation(); - - @Test - public void testCreateNamingService() throws NacosException, InterruptedException { - try { - CreateNacosConfig createClientConfig = new CreateNacosConfig(); - createClientConfig.setServerAddress("127.0.0.1:8848"); - createClientConfig.setUsername("nacos"); - createClientConfig.setPassword("nacos"); - NamingService namingService = (NamingService) SDKManager.getInstance().createClient(SDKTypeEnum.META_NACOS_NAMING, createClientConfig) - .getValue(); - namingService.registerInstance("eventmesh-dashboard-sdk-nacos-test", "192.168.11.11", 8888, - "eventmesh-dashboard-sdk-nacos-test-cluster-name"); - namingService.deregisterInstance("eventmesh-dashboard-sdk-nacos-test", "192.168.11.11", 8888, - "eventmesh-dashboard-sdk-nacos-test-cluster-name"); - } catch (Exception e) { - log.error("create nacos naming service failed", e); - } - } -} \ No newline at end of file diff --git a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RedisSDKOperationTest.java b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RedisSDKOperationTest.java deleted file mode 100644 index 4ef9a7e5..00000000 --- a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RedisSDKOperationTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.core.function.SDK.operation; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateRedisConfig; - -import java.util.AbstractMap.SimpleEntry; - -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.Timeout; - -import io.lettuce.core.api.StatefulRedisConnection; - -import lombok.extern.slf4j.Slf4j; - -@Slf4j -@Timeout(value = 5) -class RedisSDKOperationTest { - - private final RedisSDKOperation redisClientCreateOperation = new RedisSDKOperation(); - - @Test - void testCreateClient() { - CreateRedisConfig createClientConfig = CreateRedisConfig.builder() - .redisUrl("localhost:6379") - .password("") - .timeOut(5) - .build(); - SimpleEntry> simpleEntry = null; - try { - simpleEntry = redisClientCreateOperation.createClient(createClientConfig); - assertEquals("localhost:6379", simpleEntry.getKey()); - String response = simpleEntry.getValue().sync().ping(); - log.info("response:{}", response); - simpleEntry.getValue().close(); - } catch (Exception e) { - log.error("create redis client failed", e); - if (simpleEntry != null) { - simpleEntry.getValue().close(); - } - } - } -} \ No newline at end of file diff --git a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeGrpcConsumerSDKOperationTest.java b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeGrpcConsumerSDKOperationTest.java deleted file mode 100644 index c348c532..00000000 --- a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeGrpcConsumerSDKOperationTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.core.function.SDK.operation; - -import org.apache.eventmesh.client.grpc.consumer.EventMeshGrpcConsumer; -import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateRuntimeConfig; -import org.apache.eventmesh.dashboard.core.function.SDK.operation.runtime.RuntimeGrpcConsumerSDKOperation; - -import java.util.AbstractMap.SimpleEntry; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.Timeout; - -import lombok.extern.slf4j.Slf4j; - -@Slf4j -@Timeout(value = 5) -public class RuntimeGrpcConsumerSDKOperationTest { - - private final RuntimeGrpcConsumerSDKOperation grpcConsumerSDKOperation = new RuntimeGrpcConsumerSDKOperation(); - - @Test - void testCreateClient() { - SimpleEntry grpcConsumerSimpleEntry = null; - try { - final CreateRuntimeConfig runtimeConfig = CreateRuntimeConfig.builder() - .runtimeServerAddress("127.0.0.1:10205") - .consumerGroup("EventMeshTest-consumerGroup") - .env("test") - .idc("idc") - .sys("1234") - .build(); - grpcConsumerSimpleEntry = grpcConsumerSDKOperation.createClient(runtimeConfig); - Assertions.assertEquals("127.0.0.1:10205", grpcConsumerSimpleEntry.getKey()); - grpcConsumerSimpleEntry.getValue().close(); - } catch (Exception e) { - log.error("create runtime GRPC consumer client failed", e); - if (grpcConsumerSimpleEntry != null) { - grpcConsumerSimpleEntry.getValue().close(); - } - } - } -} diff --git a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeGrpcProducerSDKOperationTest.java b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeGrpcProducerSDKOperationTest.java deleted file mode 100644 index 86e18a2c..00000000 --- a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeGrpcProducerSDKOperationTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.core.function.SDK.operation; - -import org.apache.eventmesh.client.grpc.producer.EventMeshGrpcProducer; -import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateRuntimeConfig; -import org.apache.eventmesh.dashboard.core.function.SDK.operation.runtime.RuntimeGrpcProducerSDKOperation; - -import java.util.AbstractMap.SimpleEntry; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.Timeout; - -import lombok.extern.slf4j.Slf4j; - -@Slf4j -@Timeout(value = 5) -public class RuntimeGrpcProducerSDKOperationTest { - - private final RuntimeGrpcProducerSDKOperation grpcProducerSDKOperation = new RuntimeGrpcProducerSDKOperation(); - - @Test - void testCreateClient() { - SimpleEntry grpcProducerSimpleEntry = null; - try { - final CreateRuntimeConfig runtimeConfig = CreateRuntimeConfig.builder() - .runtimeServerAddress("127.0.0.1:10205") - .producerGroup("EventMeshTest-producerGroup") - .env("test") - .idc("idc") - .sys("1234") - .build(); - grpcProducerSimpleEntry = grpcProducerSDKOperation.createClient(runtimeConfig); - Assertions.assertEquals("127.0.0.1:10205", grpcProducerSimpleEntry.getKey()); - grpcProducerSimpleEntry.getValue().close(); - } catch (Exception e) { - log.error("create runtime GRPC producer client failed", e); - if (grpcProducerSimpleEntry != null) { - grpcProducerSimpleEntry.getValue().close(); - } - } - } -} diff --git a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeHttpConsumerSDKOperationTest.java b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeHttpConsumerSDKOperationTest.java deleted file mode 100644 index ec62b11d..00000000 --- a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeHttpConsumerSDKOperationTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.core.function.SDK.operation; - -import org.apache.eventmesh.client.http.consumer.EventMeshHttpConsumer; -import org.apache.eventmesh.common.utils.IPUtils; -import org.apache.eventmesh.common.utils.ThreadUtils; -import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateRuntimeConfig; -import org.apache.eventmesh.dashboard.core.function.SDK.operation.runtime.RuntimeHttpConsumerSDKOperation; - -import java.util.AbstractMap.SimpleEntry; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.Timeout; - -import lombok.extern.slf4j.Slf4j; - -@Slf4j -@Timeout(value = 5) -public class RuntimeHttpConsumerSDKOperationTest { - - private final RuntimeHttpConsumerSDKOperation httpConsumerSDKOperation = new RuntimeHttpConsumerSDKOperation(); - - @Test - void testCreateClient() { - SimpleEntry httpConsumerSimpleEntry = null; - try { - final CreateRuntimeConfig runtimeConfig = CreateRuntimeConfig.builder() - .runtimeServerAddress("127.0.0.1:10105") - .consumerGroup("EventMeshTest-consumerGroup") - .env("test") - .idc("idc") - .ip(IPUtils.getLocalAddress()) - .sys("1234") - .pid(String.valueOf(ThreadUtils.getPID())) - .username("eventmesh") - .password("123456") - .build(); - httpConsumerSimpleEntry = httpConsumerSDKOperation.createClient(runtimeConfig); - Assertions.assertEquals("127.0.0.1:10105", httpConsumerSimpleEntry.getKey()); - httpConsumerSimpleEntry.getValue().close(); - } catch (Exception e) { - log.error("create runtime GRPC consumer client failed", e); - if (httpConsumerSimpleEntry != null) { - httpConsumerSimpleEntry.getValue().close(); - } - } - } -} diff --git a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeHttpProducerSDKOperationTest.java b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeHttpProducerSDKOperationTest.java deleted file mode 100644 index 8bdf4718..00000000 --- a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeHttpProducerSDKOperationTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.core.function.SDK.operation; - -import org.apache.eventmesh.client.http.producer.EventMeshHttpProducer; -import org.apache.eventmesh.common.utils.IPUtils; -import org.apache.eventmesh.common.utils.ThreadUtils; -import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateRuntimeConfig; -import org.apache.eventmesh.dashboard.core.function.SDK.operation.runtime.RuntimeHttpProducerSDKOperation; - -import java.util.AbstractMap.SimpleEntry; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.Timeout; - -import lombok.extern.slf4j.Slf4j; - -@Slf4j -@Timeout(value = 5) -public class RuntimeHttpProducerSDKOperationTest { - - private final RuntimeHttpProducerSDKOperation httpProducerSDKOperation = new RuntimeHttpProducerSDKOperation(); - - @Test - void testCreateClient() { - SimpleEntry httpProducerSimpleEntry = null; - try { - final CreateRuntimeConfig runtimeConfig = CreateRuntimeConfig.builder() - .runtimeServerAddress("127.0.0.1:10105") - .producerGroup("EventMeshTest-producerGroup") - .env("test") - .idc("idc") - .ip(IPUtils.getLocalAddress()) - .sys("1234") - .pid(String.valueOf(ThreadUtils.getPID())) - .username("eventmesh") - .password("123456") - .build(); - httpProducerSimpleEntry = httpProducerSDKOperation.createClient(runtimeConfig); - Assertions.assertEquals("127.0.0.1:10105", httpProducerSimpleEntry.getKey()); - httpProducerSimpleEntry.getValue().close(); - } catch (Exception e) { - log.error("create runtime EventMesh HTTP producer client failed", e); - if (httpProducerSimpleEntry != null) { - httpProducerSimpleEntry.getValue().close(); - } - } - } -} diff --git a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeSDKOperationTest.java b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeSDKOperationTest.java deleted file mode 100644 index 5966bb3f..00000000 --- a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeSDKOperationTest.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.core.function.SDK.operation; - -import org.apache.eventmesh.client.tcp.common.EventMeshCommon; -import org.apache.eventmesh.common.Constants; -import org.apache.eventmesh.common.protocol.tcp.UserAgent; -import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateRuntimeConfig; -import org.apache.eventmesh.dashboard.core.function.SDK.operation.runtime.RuntimeSDKOperation; -import org.apache.eventmesh.dashboard.core.function.SDK.wrapper.RuntimeSDKWrapper; - -import java.util.AbstractMap.SimpleEntry; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.Timeout; - -import lombok.extern.slf4j.Slf4j; - -@Slf4j -@Timeout(value = 5) -class RuntimeSDKOperationTest { - - private final RuntimeSDKOperation runtimeSDKOperation = new RuntimeSDKOperation(); - - @Test - void testCreateClient() { - SimpleEntry sdkWrapperSimpleEntry = null; - try { - final UserAgent userAgent = UserAgent.builder() - .env("test") - .host("localhost") - .password("123456") - .username("eventmesh") - .group("EventmeshTestGroup") - .path("/") - .port(8366) - .subsystem("502") - .pid(32894) - .version("2.1") - .idc("A") - .purpose(EventMeshCommon.USER_AGENT_PURPOSE_PUB) - .build(); - final CreateRuntimeConfig runtimeConfig = CreateRuntimeConfig.builder() - .runtimeServerAddress("127.0.0.1:10000") - .protocol("TCP") - .protocolName(Constants.EM_MESSAGE_PROTOCOL_NAME) - .userAgent(userAgent) - .build(); - sdkWrapperSimpleEntry = runtimeSDKOperation.createClient(runtimeConfig); - Assertions.assertEquals("127.0.0.1:10000", sdkWrapperSimpleEntry.getKey()); - Assertions.assertNotNull(sdkWrapperSimpleEntry.getValue().getTcpEventMeshClient()); - sdkWrapperSimpleEntry.getValue().close(); - } catch (Exception e) { - log.error("create runtime client failed", e); - if (sdkWrapperSimpleEntry != null) { - sdkWrapperSimpleEntry.getValue().close(); - } - } - } -} \ No newline at end of file diff --git a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeTcpCloudEventSDKOperationTest.java b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeTcpCloudEventSDKOperationTest.java deleted file mode 100644 index f3fa14d6..00000000 --- a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeTcpCloudEventSDKOperationTest.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.core.function.SDK.operation; - -import org.apache.eventmesh.client.tcp.common.EventMeshCommon; -import org.apache.eventmesh.client.tcp.impl.cloudevent.CloudEventTCPClient; -import org.apache.eventmesh.common.protocol.tcp.UserAgent; -import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateRuntimeConfig; -import org.apache.eventmesh.dashboard.core.function.SDK.operation.runtime.RuntimeTcpCloudEventSDKOperation; - -import java.util.AbstractMap.SimpleEntry; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.Timeout; - -import lombok.extern.slf4j.Slf4j; - -@Slf4j -@Timeout(value = 5) -public class RuntimeTcpCloudEventSDKOperationTest { - - private final RuntimeTcpCloudEventSDKOperation runtimeTCPPushSDKOperation = new RuntimeTcpCloudEventSDKOperation(); - - @Test - void testCreateClient() { - SimpleEntry simpleEntry = null; - try { - final UserAgent userAgent = UserAgent.builder() - .env("test") - .host("localhost") - .password("123456") - .username("eventmesh") - .group("EventmeshTestGroup") - .path("/") - .port(8366) - .subsystem("502") - .pid(32894) - .version("2.1") - .idc("A") - .purpose(EventMeshCommon.USER_AGENT_PURPOSE_PUB) - .build(); - log.info("{}", userAgent); - final CreateRuntimeConfig runtimeConfig = CreateRuntimeConfig.builder() - .runtimeServerAddress("127.0.0.1:10000") - .userAgent(userAgent) - .build(); - log.info("{}", runtimeConfig); - simpleEntry = runtimeTCPPushSDKOperation.createClient(runtimeConfig); - Assertions.assertEquals("127.0.0.1:10000", simpleEntry.getKey()); - simpleEntry.getValue().close(); - } catch (Exception e) { - log.error("create runtime tcp CloudEvent client failed", e); - if (simpleEntry != null) { - simpleEntry.getValue().close(); - } - } - } -} diff --git a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeTcpEventMeshSDKOperationTest.java b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeTcpEventMeshSDKOperationTest.java deleted file mode 100644 index 1dc74957..00000000 --- a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/function/SDK/operation/RuntimeTcpEventMeshSDKOperationTest.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.core.function.SDK.operation; - -import org.apache.eventmesh.client.tcp.common.EventMeshCommon; -import org.apache.eventmesh.client.tcp.impl.eventmeshmessage.EventMeshMessageTCPClient; -import org.apache.eventmesh.common.protocol.tcp.UserAgent; -import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateRuntimeConfig; -import org.apache.eventmesh.dashboard.core.function.SDK.operation.runtime.RuntimeTcpEventMeshSDKOperation; - -import java.util.AbstractMap.SimpleEntry; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.Timeout; - -import lombok.extern.slf4j.Slf4j; - -@Slf4j -@Timeout(value = 5) -public class RuntimeTcpEventMeshSDKOperationTest { - - private final RuntimeTcpEventMeshSDKOperation eventMeshSDKOperation = new RuntimeTcpEventMeshSDKOperation(); - - @Test - void testCreateClient() { - SimpleEntry simpleEntry = null; - try { - final UserAgent userAgent = UserAgent.builder() - .env("test") - .host("localhost") - .password("123456") - .username("eventmesh") - .group("EventmeshTestGroup") - .path("/") - .port(8365) - .subsystem("501") - .pid(32893) - .version("2.1") - .idc("A") - .purpose(EventMeshCommon.USER_AGENT_PURPOSE_PUB) - .build(); - log.info("userAgent {}", userAgent); - final CreateRuntimeConfig runtimeConfig = CreateRuntimeConfig.builder() - .runtimeServerAddress("127.0.0.1:10000") - .userAgent(userAgent) - .build(); - log.info("{}", runtimeConfig); - simpleEntry = eventMeshSDKOperation.createClient(runtimeConfig); - Assertions.assertEquals("127.0.0.1:10000", simpleEntry.getKey()); - simpleEntry.getValue().close(); - } catch (Exception e) { - log.error("create runtime tcp EventMeshMessage client failed", e); - if (simpleEntry != null) { - simpleEntry.getValue().close(); - } - } - } -} diff --git a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/meta/runtime/NacosRuntimeCoreTest.java b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/meta/runtime/NacosRuntimeCoreTest.java deleted file mode 100644 index 9b7bf0ef..00000000 --- a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/meta/runtime/NacosRuntimeCoreTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.core.meta.runtime; - -import org.apache.eventmesh.dashboard.common.model.remoting.runtime.GetRuntimeRequest; - -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.Timeout; - -import lombok.extern.slf4j.Slf4j; - -@Slf4j -@Timeout(value = 5) -class NacosRuntimeCoreTest { - - private NacosRuntimeCore nacosRuntimeCore = new NacosRuntimeCore(); - - @Test - public void testGetRuntime() throws InterruptedException { - try { - GetRuntimeRequest getRuntimeRequest = new GetRuntimeRequest(); - getRuntimeRequest.setRegistryAddress("127.0.0.1:8848"); - nacosRuntimeCore.getRuntime(getRuntimeRequest).getFuture().thenAccept( - getRuntimeResponse -> { - log.info("testGetRuntime success, the first cluster name is {}", - getRuntimeResponse.getRuntimeMetadataList().get(0).getClusterName()); - } - ); - } catch (Exception e) { - log.error("testGetRuntime failed", e); - } - Thread.sleep(1000); - } -} \ No newline at end of file diff --git a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/metadata/MetadataSyncManagerTest.java b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/metadata/MetadataSyncManagerTest.java index 3b7f0092..64680ca8 100644 --- a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/metadata/MetadataSyncManagerTest.java +++ b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/metadata/MetadataSyncManagerTest.java @@ -15,122 +15,104 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.core.metadata; import org.apache.eventmesh.dashboard.common.enums.ClusterTrusteeshipType; -import org.apache.eventmesh.dashboard.common.model.metadata.RuntimeMetadata; -import org.apache.eventmesh.dashboard.core.remoting.RemotingManager; +import org.apache.eventmesh.dashboard.common.enums.MetadataType; +import org.apache.eventmesh.dashboard.common.model.ConvertMetaData; +import org.apache.eventmesh.dashboard.common.model.DatabaseAndMetadataMapper; +import org.apache.eventmesh.dashboard.common.model.base.BaseSyncBase; +import org.apache.eventmesh.dashboard.core.function.SDK.SDKManageTest; +import org.apache.eventmesh.dashboard.core.metadata.result.MetadataSyncResultHandler; +import org.apache.eventmesh.dashboard.core.remoting.Remoting2Manage; +import org.apache.eventmesh.dashboard.service.remoting.AclRemotingService; +import org.apache.eventmesh.dashboard.service.remoting.TopicRemotingService; import org.apache.commons.lang3.reflect.FieldUtils; -import java.lang.reflect.Field; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Objects; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.Mockito; import org.mockito.junit.MockitoJUnitRunner; +@SuppressWarnings("unchecked") @RunWith(MockitoJUnitRunner.class) public class MetadataSyncManagerTest { - private MetadataSyncManager metadataSyncManager = new MetadataSyncManager(); + private Map syncMetadataCreateFactoryMap; - private Map, MetadataSyncManager.MetadataSyncWrapper> metadataSyncWrapperMap; + private Map> metadataSyncConfigMap; - @Mock - private RemotingManager remotingManager; + private MetadataSyncManage metadataSyncManage = new MetadataSyncManage(); + + private Remoting2Manage remotingManage = Remoting2Manage.getInstance(); - @Mock - private MetadataHandler dataBasesHandler; @Mock - private MetadataHandler clusterHandler; + private MetadataSyncResultHandler defaultMetadataSyncResultHandler; - private List databasesList = new ArrayList<>(); - private List clusterList = new ArrayList<>(); + + private BaseSyncBase baseSyncBase = SDKManageTest.createJvm(); @Before - public void init() throws IllegalAccessException { - MetadataSyncManager.MetadataSyncConfig metadataSyncConfig = new MetadataSyncManager.MetadataSyncConfig(); - metadataSyncConfig.setDataBasesHandler(dataBasesHandler); - metadataSyncConfig.setClusterService(clusterHandler); - metadataSyncConfig.setMetadataClass(RuntimeMetadata.class); - metadataSyncManager.setRemotingManager(this.remotingManager); - metadataSyncManager.register(metadataSyncConfig); + public void init() throws Exception { + this.syncMetadataCreateFactoryMap = + (Map) FieldUtils.readDeclaredField(this.metadataSyncManage, "syncMetadataCreateFactoryMap", + true); + + this.metadataSyncConfigMap = + (Map>) FieldUtils.readDeclaredField(this.metadataSyncManage, "metadataSyncConfigMap", + true); + metadataSyncManage.setMetadataSyncResultHandler(this.defaultMetadataSyncResultHandler); + + List> dataMetadataHandlerList = new ArrayList<>(); + DataMetadataHandler dataMetadataHandler = remotingManage.createDataMetadataHandler(AclRemotingService.class, baseSyncBase); + + dataMetadataHandlerList.add(dataMetadataHandler); + metadataSyncManage.setDataMetadataHandlerList(dataMetadataHandlerList); - Field metadataSyncWrapperMapField = FieldUtils.getField(MetadataSyncManager.class, "metadataSyncWrapperMap", true); - metadataSyncWrapperMap = (Map, MetadataSyncManager.MetadataSyncWrapper>) metadataSyncWrapperMapField.get(metadataSyncManager); + Map, DatabaseAndMetadataMapper> databaseAndMetadataMapperMap = new HashMap<>(); + DatabaseAndMetadataMapper databaseAndMetadataMapper = + DatabaseAndMetadataMapper.builder().metaType(MetadataType.TOPIC).databaseHandlerClass(dataMetadataHandler.getClass()) + .metadataHandlerClass(TopicRemotingService.class).convertMetaData(new MockConvertMetaData()).build(); + databaseAndMetadataMapperMap.put(databaseAndMetadataMapper.getDatabaseHandlerClass(), databaseAndMetadataMapper); + + metadataSyncManage.init(100, 50000, databaseAndMetadataMapperMap); } @Test - public void test_sync_mock() { - // - // ClusterTrusteeshipType.FIRE_AND_FORGET_TRUSTEESHIP 3 - // databases cluster - // A 5 3 2 - // B 3 5 -2 - // C 5(2) 5(2) 2 - // ClusterTrusteeshipType.TRUSTEESHIP 3 - // databases cluster - // E 5 5 0 - // F 3 5 -2 - // G 5 3 2 - - this.mock_data(1, 5, 3); - this.mock_data(2, 3, 5); - this.mock_data(3, 5, 5); - this.mock_data(5, 5, 3); - this.mock_data(6, 3, 5); - this.mock_data(7, 5, 5); - MetadataSyncManager.MetadataSyncWrapper metadataSyncWrapper = this.metadataSyncWrapperMap.get(RuntimeMetadata.class); - Mockito.when(this.dataBasesHandler.getData()).thenReturn(this.databasesList); - Mockito.when(this.clusterHandler.getData()).thenReturn(this.clusterList); - Mockito.when(this.remotingManager.isClusterTrusteeshipType(Mockito.anyLong(), Mockito.any())).thenAnswer((invocation) -> { - Long clusterId = (Long) invocation.getArgument(0); - ClusterTrusteeshipType clusterTrusteeshipType = (ClusterTrusteeshipType) invocation.getArgument(1); - if (Objects.equals(clusterTrusteeshipType, ClusterTrusteeshipType.FIRE_AND_FORGET_TRUSTEESHIP) && clusterId < 4) { - return true; - } - if (Objects.equals(clusterTrusteeshipType, ClusterTrusteeshipType.TRUSTEESHIP) && clusterId > 4) { - return true; - } - return false; - }); - - metadataSyncWrapper.run(); + public void test() throws InterruptedException { + baseSyncBase.setTrusteeshipType(ClusterTrusteeshipType.SELF); + baseSyncBase.setFirstToWhom(baseSyncBase.getFirstToWhom()); + metadataSyncManage.register(baseSyncBase); + Thread.sleep(1000000L); + System.out.println("test"); } - private void mock_data(long clusterId, int databasesCount, int clusterCount) { - int index = databasesCount > clusterCount ? databasesCount : clusterCount; - for (int i = 0; i < index; i++) { - RuntimeMetadata runtimeMetadata = new RuntimeMetadata(); - runtimeMetadata.setClusterId(clusterId); - runtimeMetadata.setPort(i); - runtimeMetadata.setHost(clusterId + "." + i + ""); - if (i < databasesCount) { - this.databasesList.add(runtimeMetadata); - } - if (i < clusterCount) { - if (databasesCount == clusterCount) { - if (i == 0 || i == 1) { - runtimeMetadata = new RuntimeMetadata(); - runtimeMetadata.setClusterId(clusterId); - runtimeMetadata.setPort(i); - runtimeMetadata.setHost(clusterId + ".." + i + " " + i); - } - } - this.clusterList.add(runtimeMetadata); - } + + + static class MockConvertMetaData implements ConvertMetaData { + + @Override + public Object toEntity(Object meta) { + return meta; + } + + @Override + public Object toMetaData(Object entity) { + return entity; } } + } diff --git a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/metadata/MetadataSyncWrapperTest.java b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/metadata/MetadataSyncWrapperTest.java new file mode 100644 index 00000000..7a611b37 --- /dev/null +++ b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/metadata/MetadataSyncWrapperTest.java @@ -0,0 +1,95 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.core.metadata; + + +import org.apache.eventmesh.dashboard.common.enums.MetadataType; +import org.apache.eventmesh.dashboard.common.model.base.BaseClusterIdBase; +import org.apache.eventmesh.dashboard.common.model.base.BaseSyncBase; +import org.apache.eventmesh.dashboard.core.function.SDK.SDKManageTest; +import org.apache.eventmesh.dashboard.core.metadata.MetadataSyncManage.MetadataSyncConfig; +import org.apache.eventmesh.dashboard.core.metadata.result.MetadataSyncResult; +import org.apache.eventmesh.dashboard.core.metadata.result.MetadataSyncResultHandler; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; + +@RunWith(MockitoJUnitRunner.class) +public class MetadataSyncWrapperTest { + + @Mock + private MetadataSyncResultHandler metadataSyncResultHandler; + + @Mock + private DataMetadataHandler dataBasesHandler; + + @Mock + private DataMetadataHandler clusterService; + + + private BaseSyncBase baseSyncBase = SDKManageTest.createJvm(); + + + private MetadataSyncWrapper metadataSyncWrapper = new MetadataSyncWrapper(); + + + @Before + public void init() throws InstantiationException, IllegalAccessException { + + MetadataSyncConfig metadataSyncConfig = new MetadataSyncConfig(); + metadataSyncConfig.setBaseSyncBase(baseSyncBase); + metadataSyncConfig.setMetadataType(MetadataType.TOPIC); + metadataSyncConfig.setMetadataSyncResult(new MetadataSyncResult()); + metadataSyncConfig.setDataBasesHandler(dataBasesHandler); + metadataSyncConfig.setClusterService(clusterService); + + metadataSyncWrapper.setMetadataSyncConfig(metadataSyncConfig); + metadataSyncWrapper.setMetadataSyncResultHandler(metadataSyncResultHandler); + + metadataSyncWrapper.createDifference(); + } + + @Test + public void test_readOnly() { + + } + + @Test + public void test_firstToWhom() { + + } + + @Test + public void test_check() { + + } + + @Test + public void test_isSyncClusterData() { + + } + + @Test + public void test_isSyncDatabasesData() { + + } +} diff --git a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/remoting/Remoting2ManageTest.java b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/remoting/Remoting2ManageTest.java new file mode 100644 index 00000000..56770659 --- /dev/null +++ b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/remoting/Remoting2ManageTest.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.core.remoting; + +import org.apache.eventmesh.dashboard.common.model.base.BaseClusterIdBase; +import org.apache.eventmesh.dashboard.common.model.base.BaseSyncBase; +import org.apache.eventmesh.dashboard.core.function.SDK.SDKManageTest; +import org.apache.eventmesh.dashboard.core.metadata.DataMetadataHandler; +import org.apache.eventmesh.dashboard.service.remoting.AclRemotingService; + +import org.junit.Test; + +public class Remoting2ManageTest { + + Remoting2Manage remoting2Manage = Remoting2Manage.getInstance(); + + @Test + public void test() { + System.out.println(remoting2Manage); + } + + + @Test + public void test_createDataMetadataHandler() { + BaseSyncBase baseSyncBase = SDKManageTest.createJvm(); + DataMetadataHandler dataMetadataHandler = + remoting2Manage.createDataMetadataHandler(AclRemotingService.class, baseSyncBase); + dataMetadataHandler.getData(); + } + + +} diff --git a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/remoting/RemotingManagerTest.java b/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/remoting/RemotingManagerTest.java deleted file mode 100644 index cc168244..00000000 --- a/eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/remoting/RemotingManagerTest.java +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.eventmesh.dashboard.core.remoting; - -import org.apache.eventmesh.dashboard.common.enums.ClusterType; -import org.apache.eventmesh.dashboard.common.model.metadata.ClusterMetadata; -import org.apache.eventmesh.dashboard.common.model.metadata.ClusterRelationshipMetadata; -import org.apache.eventmesh.dashboard.common.model.remoting.topic.CreateTopicRequest; -import org.apache.eventmesh.dashboard.service.remoting.RemotingIntegrationService; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.atomic.AtomicLong; - -import org.junit.Test; - -public class RemotingManagerTest { - - private RemotingManager remotingManager = new RemotingManager(); - - - @Test - public void init_test() { - RemotingIntegrationService proxyObject = (RemotingIntegrationService) remotingManager.getProxyObject(); - - CreateTopicRequest createTopicRequest = new CreateTopicRequest(); - createTopicRequest.setClusterId(1L); - - proxyObject.createTopic(createTopicRequest); - - } - - @Test - public void mock_overall_logic() { - List clusterRelationshipMetadataList = new ArrayList<>(); - AtomicLong clusterId = new AtomicLong(1); - List clusterMetadataList = new ArrayList<>(); - - // 两个 eventmesh 集群 - ClusterMetadata eventMeshCluster1 = new ClusterMetadata(); - eventMeshCluster1.setClusterType(ClusterType.EVENTMESH_CLUSTER); - eventMeshCluster1.setId(clusterId.incrementAndGet()); - clusterMetadataList.add(eventMeshCluster1); - - ClusterMetadata eventMeshCluster2 = new ClusterMetadata(); - eventMeshCluster2.setClusterType(ClusterType.EVENTMESH_CLUSTER); - eventMeshCluster2.setId(clusterId.incrementAndGet()); - clusterMetadataList.add(eventMeshCluster2); - - // 两个注册中心 - ClusterMetadata eventMeshMetaNacos1 = new ClusterMetadata(); - eventMeshMetaNacos1.setClusterType(ClusterType.EVENTMESH_META_NACOS); - eventMeshMetaNacos1.setId(clusterId.incrementAndGet()); - clusterMetadataList.add(eventMeshMetaNacos1); - this.relationship(clusterRelationshipMetadataList, eventMeshCluster1, eventMeshMetaNacos1); - this.relationship(clusterRelationshipMetadataList, eventMeshCluster2, eventMeshMetaNacos1); - - ClusterMetadata eventMeshMetaNacos2 = new ClusterMetadata(); - eventMeshMetaNacos2.setClusterType(ClusterType.EVENTMESH_META_NACOS); - eventMeshMetaNacos2.setId(clusterId.incrementAndGet()); - clusterMetadataList.add(eventMeshMetaNacos2); - this.relationship(clusterRelationshipMetadataList, eventMeshCluster1, eventMeshMetaNacos2); - this.relationship(clusterRelationshipMetadataList, eventMeshCluster2, eventMeshMetaNacos2); - - // 2个 eventmesh runtime - ClusterMetadata eventMeshRuntime1 = new ClusterMetadata(); - eventMeshRuntime1.setClusterType(ClusterType.EVENTMESH_RUNTIME); - eventMeshRuntime1.setId(clusterId.incrementAndGet()); - clusterMetadataList.add(eventMeshRuntime1); - this.relationship(clusterRelationshipMetadataList, eventMeshCluster1, eventMeshRuntime1); - - ClusterMetadata eventMeshRuntime2 = new ClusterMetadata(); - eventMeshRuntime2.setClusterType(ClusterType.EVENTMESH_RUNTIME); - eventMeshRuntime2.setId(clusterId.incrementAndGet()); - clusterMetadataList.add(eventMeshRuntime2); - this.relationship(clusterRelationshipMetadataList, eventMeshCluster2, eventMeshRuntime2); - - // 两个个 rocketmq 集群 - ClusterMetadata rocketMCluster = new ClusterMetadata(); - rocketMCluster.setClusterType(ClusterType.STORAGE_ROCKETMQ_CLUSTER); - rocketMCluster.setId(clusterId.incrementAndGet()); - clusterMetadataList.add(rocketMCluster); - this.relationship(clusterRelationshipMetadataList, eventMeshCluster1, rocketMCluster); - - ClusterMetadata rocketMCluster1 = new ClusterMetadata(); - rocketMCluster1.setClusterType(ClusterType.STORAGE_ROCKETMQ_CLUSTER); - rocketMCluster1.setId(clusterId.incrementAndGet()); - clusterMetadataList.add(rocketMCluster1); - this.relationship(clusterRelationshipMetadataList, eventMeshCluster2, rocketMCluster1); - - // 2个 rocketmq broker 集群 - ClusterMetadata rocketBroker = new ClusterMetadata(); - rocketBroker.setClusterType(ClusterType.STORAGE_ROCKETMQ_BROKER); - rocketBroker.setId(clusterId.incrementAndGet()); - clusterMetadataList.add(rocketBroker); - this.relationship(clusterRelationshipMetadataList, rocketMCluster, rocketBroker); - - ClusterMetadata rocketBroker1 = new ClusterMetadata(); - rocketBroker1.setClusterType(ClusterType.STORAGE_ROCKETMQ_BROKER); - rocketBroker1.setId(clusterId.incrementAndGet()); - clusterMetadataList.add(rocketBroker1); - this.relationship(clusterRelationshipMetadataList, rocketMCluster1, rocketBroker1); - - // 两个 nameservier - ClusterMetadata rocketMQNameserver = new ClusterMetadata(); - rocketMQNameserver.setClusterType(ClusterType.STORAGE_ROCKETMQ_NAMESERVER); - rocketMQNameserver.setId(clusterId.incrementAndGet()); - clusterMetadataList.add(rocketMQNameserver); - this.relationship(clusterRelationshipMetadataList, rocketBroker, rocketMQNameserver); - this.relationship(clusterRelationshipMetadataList, rocketBroker1, rocketMQNameserver); - - ClusterMetadata rocketMQNameserver1 = new ClusterMetadata(); - rocketMQNameserver1.setClusterType(ClusterType.STORAGE_ROCKETMQ_NAMESERVER); - rocketMQNameserver1.setId(clusterId.incrementAndGet()); - clusterMetadataList.add(rocketMQNameserver1); - this.relationship(clusterRelationshipMetadataList, rocketBroker, rocketMQNameserver1); - this.relationship(clusterRelationshipMetadataList, rocketBroker1, rocketMQNameserver1); - - try { - remotingManager.cacheCluster(clusterMetadataList); - remotingManager.cacheClusterRelationship(clusterRelationshipMetadataList); - remotingManager.loadingCompleted(); - - RemotingIntegrationService proxyObject = (RemotingIntegrationService) remotingManager.getProxyObject(); - CreateTopicRequest createTopicRequest = new CreateTopicRequest(); - createTopicRequest.setClusterId(9L); - proxyObject.createTopic(createTopicRequest); - - } catch (Exception e) { - throw new RuntimeException(e); - } - - - } - - - private void relationship(List clusterRelationshipMetadataList, ClusterMetadata clusterMetadata, - ClusterMetadata relationship) { - clusterMetadata.setStatus(0); - relationship.setStatus(0); - - ClusterRelationshipMetadata clusterRelationshipMetadata = new ClusterRelationshipMetadata(); - clusterRelationshipMetadata.setClusterType(clusterMetadata.getClusterType()); - clusterRelationshipMetadata.setClusterId(clusterMetadata.getId()); - clusterRelationshipMetadata.setRelationshipId(relationship.getId()); - clusterRelationshipMetadata.setRelationshipType(relationship.getClusterType()); - clusterRelationshipMetadataList.add(clusterRelationshipMetadata); - } - - -} diff --git a/eventmesh-dashboard-observe/pom.xml b/eventmesh-dashboard-observe/pom.xml index 07c2ac94..b74059f9 100644 --- a/eventmesh-dashboard-observe/pom.xml +++ b/eventmesh-dashboard-observe/pom.xml @@ -16,6 +16,7 @@ ~ limitations under the License. --> + diff --git a/eventmesh-dashboard-service/pom.xml b/eventmesh-dashboard-service/pom.xml index c5c2be22..a57008bd 100644 --- a/eventmesh-dashboard-service/pom.xml +++ b/eventmesh-dashboard-service/pom.xml @@ -31,7 +31,7 @@ eventmesh-dashboard-service - 1.8 + 17 UTF-8 diff --git a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/dto/RocketmqProperties.java b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/dto/RocketmqProperties.java index b17e9af5..258820b0 100644 --- a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/dto/RocketmqProperties.java +++ b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/dto/RocketmqProperties.java @@ -15,11 +15,13 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.service.dto; import lombok.Data; @Data +@Deprecated public class RocketmqProperties { private String namesrvAddr; diff --git a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/dto/TopicProperties.java b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/dto/TopicProperties.java index 4eedc694..c9ab7469 100644 --- a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/dto/TopicProperties.java +++ b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/dto/TopicProperties.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.service.dto; import lombok.Data; @@ -24,6 +25,7 @@ */ @Data +@Deprecated public class TopicProperties { private String topicName; diff --git a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/meta/ConnectionCore.java b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/meta/ConnectionCore.java index 818c6b35..5a79e886 100644 --- a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/meta/ConnectionCore.java +++ b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/meta/ConnectionCore.java @@ -15,13 +15,14 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.service.meta; /** * "Connection" refers to the subscription relationship between connectors. It focuses on the configuration deployed on the source and sink connectors * themselves, reported by the connector. */ - +@Deprecated public interface ConnectionCore { } diff --git a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/operation/connector/ConnectorOptService.java b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/operation/connector/ConnectorOptService.java index b2c451f0..d97a64bc 100644 --- a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/operation/connector/ConnectorOptService.java +++ b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/operation/connector/ConnectorOptService.java @@ -15,11 +15,13 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.service.operation.connector; /** * k8s operation service */ +@Deprecated public interface ConnectorOptService { void createConnector(); diff --git a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/operation/connector/RuntimeOptService.java b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/operation/connector/RuntimeOptService.java index 6b8d5ecf..3939e7c9 100644 --- a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/operation/connector/RuntimeOptService.java +++ b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/operation/connector/RuntimeOptService.java @@ -15,11 +15,13 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.service.operation.connector; /** * k8s operation service */ +@Deprecated public interface RuntimeOptService { void createRuntime(); diff --git a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/AclRemotingService.java b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/AclRemotingService.java index 3f999861..0dcf942c 100644 --- a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/AclRemotingService.java +++ b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/AclRemotingService.java @@ -15,13 +15,16 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.service.remoting; +import org.apache.eventmesh.dashboard.common.annotation.RemotingServiceMethodMapper; +import org.apache.eventmesh.dashboard.common.model.remoting.RemotingActionType; import org.apache.eventmesh.dashboard.common.model.remoting.acl.CreateAclRequest; import org.apache.eventmesh.dashboard.common.model.remoting.acl.CreateAclResult; import org.apache.eventmesh.dashboard.common.model.remoting.acl.DeleteAclRequest; import org.apache.eventmesh.dashboard.common.model.remoting.acl.DeleteAclResult; -import org.apache.eventmesh.dashboard.common.model.remoting.acl.GetAclsRequest; +import org.apache.eventmesh.dashboard.common.model.remoting.acl.GetAcls2Request; import org.apache.eventmesh.dashboard.common.model.remoting.acl.GetAclsResult; /** @@ -29,9 +32,12 @@ */ public interface AclRemotingService { + @RemotingServiceMethodMapper({RemotingActionType.ADD, RemotingActionType.UPDATE}) CreateAclResult createAcl(CreateAclRequest createAclRequest); + @RemotingServiceMethodMapper(RemotingActionType.DELETE) DeleteAclResult deleteAcl(DeleteAclRequest deleteAclRequest); - GetAclsResult getAllAcls(GetAclsRequest getAclsRequest); + @RemotingServiceMethodMapper(RemotingActionType.QUEUE_ALL) + GetAclsResult getAllAcls(GetAcls2Request getAclsRequest); } diff --git a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/ClientRemotingService.java b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/ClientRemotingService.java index 44d7a3d5..3fb59ae3 100644 --- a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/ClientRemotingService.java +++ b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/ClientRemotingService.java @@ -15,10 +15,13 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.service.remoting; +import org.apache.eventmesh.dashboard.common.annotation.RemotingServiceMethodMapper; import org.apache.eventmesh.dashboard.common.model.metadata.ClientMetadata; +import org.apache.eventmesh.dashboard.common.model.remoting.RemotingActionType; import java.util.List; @@ -27,6 +30,6 @@ */ public interface ClientRemotingService { - // get consumer only for now + @RemotingServiceMethodMapper(RemotingActionType.QUEUE_ALL) List getClientList(); } diff --git a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/ConfigRemotingService.java b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/ConfigRemotingService.java index e38954fc..e7e1046b 100644 --- a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/ConfigRemotingService.java +++ b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/ConfigRemotingService.java @@ -15,14 +15,17 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.service.remoting; +import org.apache.eventmesh.dashboard.common.annotation.RemotingServiceMethodMapper; import org.apache.eventmesh.dashboard.common.model.remoting.BaseGlobalResult; +import org.apache.eventmesh.dashboard.common.model.remoting.RemotingActionType; import org.apache.eventmesh.dashboard.common.model.remoting.config.AddConfigRequest; import org.apache.eventmesh.dashboard.common.model.remoting.config.DeleteConfigRequest; import org.apache.eventmesh.dashboard.common.model.remoting.config.GetConfigRequest; import org.apache.eventmesh.dashboard.common.model.remoting.config.UpdateConfigRequest; -import org.apache.eventmesh.dashboard.common.model.remoting.topic.GetTopicsRequest; +import org.apache.eventmesh.dashboard.common.model.remoting.topic.GetTopics2Request; import org.apache.eventmesh.dashboard.common.model.remoting.topic.GetTopicsResult; /** @@ -31,17 +34,20 @@ public interface ConfigRemotingService { + @RemotingServiceMethodMapper({RemotingActionType.ADD, RemotingActionType.UPDATE}) BaseGlobalResult addConfig(AddConfigRequest addConfigRequest); default BaseGlobalResult updateConfig(UpdateConfigRequest updateConfigRequest) { return addConfig(updateConfigRequest); } + @RemotingServiceMethodMapper(RemotingActionType.DELETE) default BaseGlobalResult deleteConfig(DeleteConfigRequest deleteConfigRequest) { return addConfig(deleteConfigRequest); } GetTopicsResult getConfig(GetConfigRequest getConfigRequest); - GetTopicsResult getAllTopics(GetTopicsRequest getTopicsRequest); + @RemotingServiceMethodMapper(RemotingActionType.QUEUE_ALL) + GetTopicsResult getAllTopics(GetTopics2Request getTopicsRequest); } diff --git a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/ConnectorRemotingService.java b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/ConnectorRemotingService.java index 1164b380..f41fdd77 100644 --- a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/ConnectorRemotingService.java +++ b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/ConnectorRemotingService.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.service.remoting; import org.apache.eventmesh.dashboard.common.model.remoting.connector.CreateConnectorRequest; diff --git a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/ConsumeOffsetRemotingService.java b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/ConsumeOffsetRemotingService.java new file mode 100644 index 00000000..06ac8667 --- /dev/null +++ b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/ConsumeOffsetRemotingService.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.service.remoting; + +import org.apache.eventmesh.dashboard.common.model.metadata.ConsumeOffsetMetadata; +import org.apache.eventmesh.dashboard.common.model.metadata.TopicMetadata; + +import java.util.List; + +/** + * + */ +public interface ConsumeOffsetRemotingService { + + + List getConsumeOffsetMetadata(TopicMetadata topicMetadata); +} diff --git a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/GroupRemotingService.java b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/GroupRemotingService.java index 2540746d..b4df9127 100644 --- a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/GroupRemotingService.java +++ b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/GroupRemotingService.java @@ -15,8 +15,13 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.service.remoting; +import org.apache.eventmesh.dashboard.common.annotation.RemotingServiceMethodMapper; +import org.apache.eventmesh.dashboard.common.model.remoting.BaseGlobalResult; +import org.apache.eventmesh.dashboard.common.model.remoting.Global2Request; +import org.apache.eventmesh.dashboard.common.model.remoting.RemotingActionType; import org.apache.eventmesh.dashboard.common.model.remoting.group.GetGroupResult; import org.apache.eventmesh.dashboard.common.model.remoting.group.GetGroupsRequest; @@ -25,5 +30,9 @@ */ public interface GroupRemotingService { + @RemotingServiceMethodMapper(RemotingActionType.QUEUE_ALL) GetGroupResult getAllGroups(GetGroupsRequest getGroupsRequest); + + @RemotingServiceMethodMapper(RemotingActionType.DELETE) + BaseGlobalResult deleteGroup(Global2Request global2Request); } diff --git a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/MetaRemotingService.java b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/MetaRemotingService.java index de9876d1..e00cefeb 100644 --- a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/MetaRemotingService.java +++ b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/MetaRemotingService.java @@ -15,9 +15,12 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.service.remoting; -import org.apache.eventmesh.dashboard.common.model.remoting.runtime.GetRuntimeRequest; +import org.apache.eventmesh.dashboard.common.annotation.RemotingServiceMethodMapper; +import org.apache.eventmesh.dashboard.common.model.remoting.RemotingActionType; +import org.apache.eventmesh.dashboard.common.model.remoting.runtime.GetRuntime2Request; import org.apache.eventmesh.dashboard.common.model.remoting.runtime.GetRuntimeResult; /** @@ -25,5 +28,6 @@ */ public interface MetaRemotingService { - GetRuntimeResult getRuntime(GetRuntimeRequest getRuntimeRequest); + @RemotingServiceMethodMapper(RemotingActionType.QUEUE_ALL) + GetRuntimeResult getRuntime(GetRuntime2Request getRuntimeRequest); } diff --git a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/OffsetRemotingService.java b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/OffsetRemotingService.java index 4e2d3659..2fc5145f 100644 --- a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/OffsetRemotingService.java +++ b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/OffsetRemotingService.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.service.remoting; import org.apache.eventmesh.dashboard.common.model.remoting.offset.GetOffsetRequest; @@ -27,6 +28,7 @@ */ public interface OffsetRemotingService { + GetOffsetResult getOffset(GetOffsetRequest getOffsetRequest); ResetOffsetResult resetOffset(ResetOffsetRequest resetOffsetRequest); diff --git a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/RemotingIntegrationService.java b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/RemotingIntegrationService.java index 0f117427..6891f9d6 100644 --- a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/RemotingIntegrationService.java +++ b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/RemotingIntegrationService.java @@ -15,11 +15,13 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.service.remoting; /** * */ +@Deprecated public interface RemotingIntegrationService extends AclRemotingService, ClientRemotingService, ConfigRemotingService, ConnectorRemotingService, GroupRemotingService, MetaRemotingService, OffsetRemotingService, SubscriptionRemotingService, TopicRemotingService, UserRemotingService { diff --git a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/SubscriptionRemotingService.java b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/SubscriptionRemotingService.java index 887c1f8f..26631396 100644 --- a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/SubscriptionRemotingService.java +++ b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/SubscriptionRemotingService.java @@ -15,8 +15,11 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.service.remoting; +import org.apache.eventmesh.dashboard.common.annotation.RemotingServiceMethodMapper; +import org.apache.eventmesh.dashboard.common.model.remoting.RemotingActionType; import org.apache.eventmesh.dashboard.common.model.remoting.subscription.GetSubscriptionRequest; import org.apache.eventmesh.dashboard.common.model.remoting.subscription.GetSubscriptionResult; @@ -25,6 +28,7 @@ */ public interface SubscriptionRemotingService { + @RemotingServiceMethodMapper(RemotingActionType.QUEUE_ALL) GetSubscriptionResult getSubscription(GetSubscriptionRequest request); } diff --git a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/RuntimeRemotingService.java b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/TopicOffsetRemotingService.java similarity index 73% rename from eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/RuntimeRemotingService.java rename to eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/TopicOffsetRemotingService.java index b673c27a..efc980d1 100644 --- a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/RuntimeRemotingService.java +++ b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/TopicOffsetRemotingService.java @@ -17,13 +17,16 @@ package org.apache.eventmesh.dashboard.service.remoting; -import org.apache.eventmesh.dashboard.common.model.remoting.runtime.GetRuntimeRequest; -import org.apache.eventmesh.dashboard.common.model.remoting.runtime.GetRuntimeResult; +import org.apache.eventmesh.dashboard.common.model.metadata.TopicMetadata; +import org.apache.eventmesh.dashboard.common.model.metadata.TopicOffsetMetadata; + +import java.util.List; /** - * + * */ -public interface RuntimeRemotingService { +public interface TopicOffsetRemotingService { + - GetRuntimeResult getRuntimeMetadata(GetRuntimeRequest request); + List getTopicOffsetMetadata(TopicMetadata topicMetadata); } diff --git a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/TopicRemotingService.java b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/TopicRemotingService.java index 00b255cf..dd389cfb 100644 --- a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/TopicRemotingService.java +++ b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/TopicRemotingService.java @@ -15,13 +15,16 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.service.remoting; -import org.apache.eventmesh.dashboard.common.model.remoting.topic.CreateTopicRequest; +import org.apache.eventmesh.dashboard.common.annotation.RemotingServiceMethodMapper; +import org.apache.eventmesh.dashboard.common.model.remoting.RemotingActionType; +import org.apache.eventmesh.dashboard.common.model.remoting.topic.CreateTopic2Request; import org.apache.eventmesh.dashboard.common.model.remoting.topic.CreateTopicResult; import org.apache.eventmesh.dashboard.common.model.remoting.topic.DeleteTopicRequest; import org.apache.eventmesh.dashboard.common.model.remoting.topic.DeleteTopicResult; -import org.apache.eventmesh.dashboard.common.model.remoting.topic.GetTopicsRequest; +import org.apache.eventmesh.dashboard.common.model.remoting.topic.GetTopics2Request; import org.apache.eventmesh.dashboard.common.model.remoting.topic.GetTopicsResult; /** @@ -29,10 +32,14 @@ */ public interface TopicRemotingService { - CreateTopicResult createTopic(CreateTopicRequest createTopicRequest); + @RemotingServiceMethodMapper({RemotingActionType.ADD, RemotingActionType.UPDATE}) + CreateTopicResult createTopic(CreateTopic2Request createTopicRequest); + @RemotingServiceMethodMapper(RemotingActionType.DELETE) DeleteTopicResult deleteTopic(DeleteTopicRequest deleteTopicRequest); - GetTopicsResult getAllTopics(GetTopicsRequest getTopicsRequest); + @RemotingServiceMethodMapper(RemotingActionType.QUEUE_ALL) + GetTopicsResult getAllTopics(GetTopics2Request getTopicsRequest) + throws Exception; } diff --git a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/UserRemotingService.java b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/UserRemotingService.java index 5f5e18d3..b5913817 100644 --- a/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/UserRemotingService.java +++ b/eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/UserRemotingService.java @@ -15,8 +15,11 @@ * limitations under the License. */ + package org.apache.eventmesh.dashboard.service.remoting; +import org.apache.eventmesh.dashboard.common.annotation.RemotingServiceMethodMapper; +import org.apache.eventmesh.dashboard.common.model.remoting.RemotingActionType; import org.apache.eventmesh.dashboard.common.model.remoting.user.CreateUserRequest; import org.apache.eventmesh.dashboard.common.model.remoting.user.DeleterUserRequest; import org.apache.eventmesh.dashboard.common.model.remoting.user.GetUserRequest; @@ -27,9 +30,12 @@ */ public interface UserRemotingService { + @RemotingServiceMethodMapper({RemotingActionType.ADD, RemotingActionType.UPDATE}) CreateUserRequest createInstanceUser(CreateUserRequest request); + @RemotingServiceMethodMapper(RemotingActionType.DELETE) DeleterUserRequest deleteInstanceUser(DeleterUserRequest request); + @RemotingServiceMethodMapper(RemotingActionType.QUEUE_ALL) GetUserResult getInstanceUser(GetUserRequest request); } diff --git a/pom.xml b/pom.xml index afcb7a87..67bf47ee 100644 --- a/pom.xml +++ b/pom.xml @@ -71,8 +71,8 @@ - 8 - 8 + 17 + 17 UTF-8 2.7.18 2.3.2 @@ -148,8 +148,8 @@ maven-compiler-plugin 3.7.0 - 1.8 - 1.8 + 17 + 17 UTF-8 none From 9a3ce004066b6423abe22536234575308cc2d8c4 Mon Sep 17 00:00:00 2001 From: jie Date: Fri, 9 May 2025 21:11:39 +0800 Subject: [PATCH 02/11] =?UTF-8?q?fix(*):1.=20=E6=8F=90=E5=8D=87=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E7=89=88=E6=9C=AC=202.=20=E6=B7=BB=E5=8A=A0=E5=8D=8F?= =?UTF-8?q?=E8=AE=AE=E5=A4=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 2 +- README.zh-CN.md | 11 +++++++++- .../main/resources/eventmesh-dashboard.jmx | 18 ++++++++++++++++ .../src/main/resources/logback.xml | 21 +++++++++++++------ .../kubernetes/EventMesh-runtime-refer.yaml | 17 +++++++++++++++ .../kubernetes/EventMesh-runtime.yaml | 17 +++++++++++++++ .../kubernetes/RocketMQ-broker-refer.yaml | 18 ++++++++++++++++ .../resources/kubernetes/RocketMQ-broker.yaml | 17 +++++++++++++++ .../RocketMQ-nameservice-refer.yaml | 17 +++++++++++++++ .../kubernetes/RocketMQ-nameservice.yaml | 17 +++++++++++++++ pom.xml | 7 +++---- 11 files changed, 150 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 69ada699..81cf585f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,7 +34,7 @@ jobs: fail-fast: false matrix: os: [ ubuntu-latest ] - java: [ 8, 11 ] + java: [ 17 ] language: [ 'java' ] runs-on: ${{ matrix.os }} diff --git a/README.zh-CN.md b/README.zh-CN.md index cb9f70c0..ccb82a83 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -94,4 +94,13 @@ docker run -d --name eventmesh-dashboard -p 8080:8080 yourname/eventmesh-dashboa 2. 配置协议头工具 license-eye。 1. 检查命令:license-eye header check 2. 使用命令:license-eye header fix - 3. 下载地址: https://skywalking.apache.org/downloads/ \ No newline at end of file + 3. 下载地址: https://skywalking.apache.org/downloads/ + + +### 提交代码前 +在项目根目录执行下面命令 +``` +license-eye -v info -c .licenserc.yaml header check +./mvnw -B package -DskipTests --file pom.xml +./mvnw -B test --file pom.xml +``` \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.jmx b/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.jmx index 57f546b4..24226780 100644 --- a/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.jmx +++ b/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.jmx @@ -1,3 +1,21 @@ + + + diff --git a/eventmesh-dashboard-console/src/main/resources/logback.xml b/eventmesh-dashboard-console/src/main/resources/logback.xml index 4c874927..6dede9ad 100644 --- a/eventmesh-dashboard-console/src/main/resources/logback.xml +++ b/eventmesh-dashboard-console/src/main/resources/logback.xml @@ -1,12 +1,21 @@ - + diff --git a/eventmesh-dashboard-console/src/test/resources/kubernetes/EventMesh-runtime-refer.yaml b/eventmesh-dashboard-console/src/test/resources/kubernetes/EventMesh-runtime-refer.yaml index 3628a86f..3c65fb63 100644 --- a/eventmesh-dashboard-console/src/test/resources/kubernetes/EventMesh-runtime-refer.yaml +++ b/eventmesh-dashboard-console/src/test/resources/kubernetes/EventMesh-runtime-refer.yaml @@ -1,3 +1,20 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + apiVersion: apps/v1 kind: Deployment metadata: diff --git a/eventmesh-dashboard-console/src/test/resources/kubernetes/EventMesh-runtime.yaml b/eventmesh-dashboard-console/src/test/resources/kubernetes/EventMesh-runtime.yaml index 9429cd39..67f8bdd3 100644 --- a/eventmesh-dashboard-console/src/test/resources/kubernetes/EventMesh-runtime.yaml +++ b/eventmesh-dashboard-console/src/test/resources/kubernetes/EventMesh-runtime.yaml @@ -1,3 +1,20 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + apiVersion: apps/v1 kind: Deployment metadata: diff --git a/eventmesh-dashboard-console/src/test/resources/kubernetes/RocketMQ-broker-refer.yaml b/eventmesh-dashboard-console/src/test/resources/kubernetes/RocketMQ-broker-refer.yaml index 0461ab4d..5826f6f9 100644 --- a/eventmesh-dashboard-console/src/test/resources/kubernetes/RocketMQ-broker-refer.yaml +++ b/eventmesh-dashboard-console/src/test/resources/kubernetes/RocketMQ-broker-refer.yaml @@ -1,3 +1,21 @@ +# +# 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. +# + + apiVersion: apps/v1 kind: Deployment metadata: diff --git a/eventmesh-dashboard-console/src/test/resources/kubernetes/RocketMQ-broker.yaml b/eventmesh-dashboard-console/src/test/resources/kubernetes/RocketMQ-broker.yaml index 3846b1a6..02ebe9af 100644 --- a/eventmesh-dashboard-console/src/test/resources/kubernetes/RocketMQ-broker.yaml +++ b/eventmesh-dashboard-console/src/test/resources/kubernetes/RocketMQ-broker.yaml @@ -1,3 +1,20 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + apiVersion: apps/v1 kind: Deployment metadata: diff --git a/eventmesh-dashboard-console/src/test/resources/kubernetes/RocketMQ-nameservice-refer.yaml b/eventmesh-dashboard-console/src/test/resources/kubernetes/RocketMQ-nameservice-refer.yaml index e31876b9..d91fb445 100644 --- a/eventmesh-dashboard-console/src/test/resources/kubernetes/RocketMQ-nameservice-refer.yaml +++ b/eventmesh-dashboard-console/src/test/resources/kubernetes/RocketMQ-nameservice-refer.yaml @@ -1,3 +1,20 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + apiVersion: apps/v1 kind: Deployment metadata: diff --git a/eventmesh-dashboard-console/src/test/resources/kubernetes/RocketMQ-nameservice.yaml b/eventmesh-dashboard-console/src/test/resources/kubernetes/RocketMQ-nameservice.yaml index e31876b9..d91fb445 100644 --- a/eventmesh-dashboard-console/src/test/resources/kubernetes/RocketMQ-nameservice.yaml +++ b/eventmesh-dashboard-console/src/test/resources/kubernetes/RocketMQ-nameservice.yaml @@ -1,3 +1,20 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + apiVersion: apps/v1 kind: Deployment metadata: diff --git a/pom.xml b/pom.xml index 67bf47ee..bcf45f19 100644 --- a/pom.xml +++ b/pom.xml @@ -73,6 +73,7 @@ 17 17 + 17 UTF-8 2.7.18 2.3.2 @@ -218,11 +219,9 @@ org.apache.maven.plugins maven-surefire-plugin - 2.20.1 + 3.5.3 - -Xmx512m -XX:PermSize=128m - -XX:MaxPermSize=128m - + -Xmx1024m -XX:MaxPermSize=256m true **/*Test*.java From 890e082161883b7338b1cf68770b0cf719da6471 Mon Sep 17 00:00:00 2001 From: "jie@apache.org" <2732554140@qq.com> Date: Fri, 18 Jul 2025 02:16:11 +0800 Subject: [PATCH 03/11] =?UTF-8?q?fix(console):1.=20=E8=AE=BE=E8=AE=A1=20re?= =?UTF-8?q?port=20=E6=A8=A1=E5=9D=97=202.=20=E5=BC=80=20es=EF=BC=8Copen?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=EF=BC=8C3.=20=E5=BC=80=E5=8F=91=20report=20?= =?UTF-8?q?=E5=9F=BA=E6=9C=AC=E6=A0=87=E5=87=86=204.=20=E5=BC=80=E5=8F=91?= =?UTF-8?q?=20iotdb=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.zh-CN.md | 2 +- eventmesh-dashboard-agent/pom.xml | 74 ++++ .../dashboard/agent/AgentActionClient.java | 31 ++ .../dashboard/agent/AgentController.java | 138 ++++++++ .../agent/config/AbstractConfigHandler.java | 62 ++++ .../dashboard/agent/config/ConfigHandler.java | 26 ++ .../agent/config/ConfigHandlerManage.java | 39 +++ .../RocketMQNameSerivceConfigHandler.java | 28 ++ .../agent/model/AgentCheckRuntimeVO.java | 27 ++ .../agent/model/AgentStartActionVO.java | 33 ++ .../src/main/resources/logback.xml | 45 +++ .../agent/config/TestConfigHandler.java | 56 +++ .../common/enums/ClusterTrusteeshipType.java | 1 + .../common/util/ClasspathScanner.java | 11 +- eventmesh-dashboard-console/pom.xml | 48 +++ .../config/FunctionManagerConfigs.java | 70 ---- ...ervice.java => ClusterAbilityService.java} | 13 +- .../console/controller/ReportController.java | 61 ++++ .../agent/AgentActionController.java | 129 +++++++ .../controller/agent/AgentCheckRuntimeVO.java | 27 ++ .../agent/AgentStartActionVO.java} | 21 +- .../controller/cluster/DetailsController.java | 2 + .../controller/cluster/HomeController.java | 64 +++- .../controller/function/ConfigController.java | 31 +- .../controller/message/GroupController.java | 10 +- .../controller/message/TopicController.java | 28 +- .../dashboard/console/entity/BaseEntity.java | 61 ---- .../console/entity/cluster/AclEntity.java | 5 +- .../console/entity/function/ConfigEntity.java | 5 + .../entity/function/ConfigGatherEntity.java | 5 +- .../console/entity/message/GroupEntity.java | 6 +- .../console/entity/message/TopicEntity.java | 6 +- .../function/report/AbstractReportEngine.java | 137 ++++++++ .../console/function/report/ReportConfig.java | 29 ++ .../console/function/report/ReportEngine.java | 41 +++ .../function/report/ReportHandler.java | 22 ++ .../function/report/ReportHandlerManage.java | 109 ++++++ .../function/report/ReportViewType.java | 51 +++ .../annotation/AbstractReportMetaHandler.java | 39 +++ .../report/annotation/ReportMeta.java | 48 +++ .../report/annotation/ReportMetaData.java | 60 ++++ .../ElasticsearchReportEngine.java | 98 ++++++ .../elasticsearch/SearchScriptMeta.java | 26 ++ .../script/GeneralSearchScriptMeta.java | 66 ++++ .../report/iotdb/IotDBReportEngine.java | 257 ++++++++++++++ .../report/iotdb/IotDBReportMetaHandler.java | 159 +++++++++ .../report/model/GeneralReportDO.java | 67 ++++ .../report/model/MultiGeneralReportDO.java | 34 ++ .../report/model/SingleGeneralReportDO.java} | 31 +- .../function/report/model/base/ClusterId.java | 32 ++ .../function/report/model/base/GroupId.java | 47 +++ .../report/model/base/OrganizationId.java | 31 ++ .../function/report/model/base/RuntimeId.java | 49 +++ .../report/model/base/SubscribeId.java | 51 +++ .../function/report/model/base/Time.java | 29 ++ .../function/report/model/base/TopicId.java | 46 +++ .../model/metrics/AbstractMetricsDO.java | 54 +++ .../report/model/metrics/InputMetricsDO.java | 52 +++ ...ketmqConsumerGroupCreateExecutionTime.java | 49 +++ .../rocketmq/RocketmqConsumerGroupNumber.java | 36 ++ .../RocketmqConsumerInflightMessages.java | 36 ++ .../rocketmq/RocketmqConsumerLagLatency.java | 30 ++ .../RocketmqConsumerQueueingLatency.java | 30 ++ .../RocketmqConsumerReadyMessages.java | 36 ++ .../model/rocketmq/RocketmqMessageSize.java | 52 +++ .../rocketmq/RocketmqMessagesInTotal.java | 39 +++ .../rocketmq/RocketmqMessagesOutTotal.java | 41 +++ .../model/rocketmq/RocketmqRpcLatency.java | 58 ++++ .../RocketmqSendToDlqMessagesTotal.java | 30 ++ .../RocketmqStorageDispatchBehindBytes.java | 31 ++ .../RocketmqStorageFlushBehindBytes.java | 30 ++ .../RocketmqStorageMessageReserveTime.java | 30 ++ .../RocketmqThreadPoolWartermark.java | 30 ++ .../rocketmq/RocketmqThroughputInTotal.java | 35 ++ .../rocketmq/RocketmqThroughputOutTotal.java | 35 ++ .../RocketmqTopicCreateExecutionTime.java | 51 +++ .../model/rocketmq/RocketmqTopicNumber.java | 30 ++ .../opensearch/OpensearchReportEngine.java | 133 +++++++ .../console/mapper/cluster/RuntimeMapper.java | 2 +- .../console/mapper/function/ConfigMapper.java | 60 ++-- .../console/mapper/message/GroupMapper.java | 36 +- ...mberMapper.java => GroupMemberMapper.java} | 26 +- .../console/mapper/message/OffsetMapper.java | 25 ++ .../console/mapper/message/TopicMapper.java | 12 +- .../agent/AgentActionControllerMapper.java | 29 ++ .../cluster/GroupControllerMapper.java | 2 + .../message/ConfigControllerMapper.java | 33 ++ .../message/TopicControllerMapper.java | 2 + .../dashboard/console/modle/IdDTO.java | 3 + ...ueryClusterByOrganizationIdAndTypeDTO.java | 4 +- .../modle/dto/agent/AgentStartActionDTO.java | 33 ++ .../modle/dto/agent/AgentStartActionVO.java | 31 ++ .../modle/dto/config/GetConfigsListDTO.java | 4 +- .../config/QueryByInstanceIdDTO.java} | 18 +- .../console/modle/vo/RuntimeIdDTO.java | 2 + .../service/function/ConfigService.java | 3 +- .../function/Impl/ConfigServiceImpl.java | 35 +- .../console/service/message/GroupService.java | 19 +- .../service/message/OffsetService.java | 22 ++ .../message/impl/GroupMemberServiceImp.java | 22 +- .../message/impl/GroupServiceImpl.java | 52 +-- .../message/impl/OffsetServiceImpl.java | 42 +++ .../message/impl/TopicServiceImpl.java | 15 +- .../spring/support/RuntimeDeployService.java | 10 +- .../main/resources/eventmesh-dashboard.jmx | 30 +- .../main/resources/eventmesh-dashboard.sql | 68 ++-- .../main/resources/report/elasticsearch.yaml | 77 +++++ .../main/resources/report/report-RocketMQ.sql | 327 ++++++++++++++++++ .../databuild/BuildFullDataMapper.java | 94 +++++ .../console/databuild/BuildFullSceneData.java | 2 + .../console/databuild/BuildMessageData.java | 165 +++++++++ .../console/function/report/DataIdModel.java | 141 ++++++++ .../function/report/DataValueModel.java | 69 ++++ .../report/ReportHandlerManageTest.java | 55 +++ .../console/function/report/RocketMQ.txt | 54 +++ .../report/elasticsearch/DataModel.java | 60 ++++ .../ElasticsearchReportEngineTest.java | 131 +++++++ .../report/iotdb/IotDBReportEngineTest.java | 124 +++++++ .../OpensearchReportEngineTest.java | 54 +++ .../mapper/message/TopicEntityMapperTest.java | 5 +- .../support/RuntimeDeployServiceTest.java | 1 + .../kubernetes/EventMesh-runtime.yaml | 1 + pom.xml | 3 +- 123 files changed, 5215 insertions(+), 460 deletions(-) create mode 100644 eventmesh-dashboard-agent/pom.xml create mode 100644 eventmesh-dashboard-agent/src/main/java/org/apache/eventmesh/dashboard/agent/AgentActionClient.java create mode 100644 eventmesh-dashboard-agent/src/main/java/org/apache/eventmesh/dashboard/agent/AgentController.java create mode 100644 eventmesh-dashboard-agent/src/main/java/org/apache/eventmesh/dashboard/agent/config/AbstractConfigHandler.java create mode 100644 eventmesh-dashboard-agent/src/main/java/org/apache/eventmesh/dashboard/agent/config/ConfigHandler.java create mode 100644 eventmesh-dashboard-agent/src/main/java/org/apache/eventmesh/dashboard/agent/config/ConfigHandlerManage.java create mode 100644 eventmesh-dashboard-agent/src/main/java/org/apache/eventmesh/dashboard/agent/config/handler/RocketMQNameSerivceConfigHandler.java create mode 100644 eventmesh-dashboard-agent/src/main/java/org/apache/eventmesh/dashboard/agent/model/AgentCheckRuntimeVO.java create mode 100644 eventmesh-dashboard-agent/src/main/java/org/apache/eventmesh/dashboard/agent/model/AgentStartActionVO.java create mode 100644 eventmesh-dashboard-agent/src/main/resources/logback.xml create mode 100644 eventmesh-dashboard-agent/src/test/java/org/apache/eventmesh/dashboard/agent/config/TestConfigHandler.java delete mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/config/FunctionManagerConfigs.java rename eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/{ClusterAbitityService.java => ClusterAbilityService.java} (83%) create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/ReportController.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/agent/AgentActionController.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/agent/AgentCheckRuntimeVO.java rename eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/{modle/dto/config/DetailConfigsVO.java => controller/agent/AgentStartActionVO.java} (65%) delete mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/BaseEntity.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/AbstractReportEngine.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/ReportConfig.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/ReportEngine.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/ReportHandler.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/ReportHandlerManage.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/ReportViewType.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/annotation/AbstractReportMetaHandler.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/annotation/ReportMeta.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/annotation/ReportMetaData.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/elasticsearch/ElasticsearchReportEngine.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/elasticsearch/SearchScriptMeta.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/elasticsearch/script/GeneralSearchScriptMeta.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/iotdb/IotDBReportEngine.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/iotdb/IotDBReportMetaHandler.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/GeneralReportDO.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/MultiGeneralReportDO.java rename eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/{entity/StoreEntity.java => function/report/model/SingleGeneralReportDO.java} (62%) create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/base/ClusterId.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/base/GroupId.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/base/OrganizationId.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/base/RuntimeId.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/base/SubscribeId.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/base/Time.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/base/TopicId.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/metrics/AbstractMetricsDO.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/metrics/InputMetricsDO.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqConsumerGroupCreateExecutionTime.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqConsumerGroupNumber.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqConsumerInflightMessages.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqConsumerLagLatency.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqConsumerQueueingLatency.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqConsumerReadyMessages.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqMessageSize.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqMessagesInTotal.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqMessagesOutTotal.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqRpcLatency.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqSendToDlqMessagesTotal.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqStorageDispatchBehindBytes.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqStorageFlushBehindBytes.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqStorageMessageReserveTime.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqThreadPoolWartermark.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqThroughputInTotal.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqThroughputOutTotal.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqTopicCreateExecutionTime.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqTopicNumber.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/opensearch/OpensearchReportEngine.java rename eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/message/{OprGroupMemberMapper.java => GroupMemberMapper.java} (84%) create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/message/OffsetMapper.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/agent/AgentActionControllerMapper.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/message/ConfigControllerMapper.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/agent/AgentStartActionDTO.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/agent/AgentStartActionVO.java rename eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/{entity/DefaultConfigKey.java => modle/function/config/QueryByInstanceIdDTO.java} (73%) create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/OffsetService.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/impl/OffsetServiceImpl.java create mode 100644 eventmesh-dashboard-console/src/main/resources/report/elasticsearch.yaml create mode 100644 eventmesh-dashboard-console/src/main/resources/report/report-RocketMQ.sql create mode 100644 eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/databuild/BuildFullDataMapper.java create mode 100644 eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/databuild/BuildMessageData.java create mode 100644 eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/report/DataIdModel.java create mode 100644 eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/report/DataValueModel.java create mode 100644 eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/report/ReportHandlerManageTest.java create mode 100644 eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/report/RocketMQ.txt create mode 100644 eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/report/elasticsearch/DataModel.java create mode 100644 eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/report/elasticsearch/ElasticsearchReportEngineTest.java create mode 100644 eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/report/iotdb/IotDBReportEngineTest.java create mode 100644 eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/report/opensearch/OpensearchReportEngineTest.java diff --git a/README.zh-CN.md b/README.zh-CN.md index ccb82a83..f500d0d2 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -16,7 +16,7 @@ EventMesh Dashboard 每周开发例会文档:https://docs.qq.com/doc/DQmhVbklU ### 环境 -- JDK 8/11 +- JDK 17 - Maven 3.9.x - Spring Boot 2.7.x diff --git a/eventmesh-dashboard-agent/pom.xml b/eventmesh-dashboard-agent/pom.xml new file mode 100644 index 00000000..e8bafe12 --- /dev/null +++ b/eventmesh-dashboard-agent/pom.xml @@ -0,0 +1,74 @@ + + 4.0.0 + + org.apache.eventmesh.dashboard + eventmesh-dashboard + 0.0.1-SNAPSHOT + + + eventmesh-dashboard-agent + jar + + eventmesh-dashboard-agent + http://maven.apache.org + + + UTF-8 + 8 + 8 + 8 + 1.5.13 + 2.0.9 + + + + + org.slf4j + jcl-over-slf4j + ${slf4j.version} + + + ch.qos.logback + logback-access + + + + ch.qos.logback + logback-classic + + + ch.qos.logback + logback-core + + + org.projectlombok + lombok + + + junit + junit + 4.13.1 + test + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.7.0 + + 8 + 8 + UTF-8 + + none + + + + + + + + diff --git a/eventmesh-dashboard-agent/src/main/java/org/apache/eventmesh/dashboard/agent/AgentActionClient.java b/eventmesh-dashboard-agent/src/main/java/org/apache/eventmesh/dashboard/agent/AgentActionClient.java new file mode 100644 index 00000000..a12f900d --- /dev/null +++ b/eventmesh-dashboard-agent/src/main/java/org/apache/eventmesh/dashboard/agent/AgentActionClient.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.eventmesh.dashboard.agent; + +import org.apache.eventmesh.dashboard.agent.model.AgentCheckRuntimeVO; +import org.apache.eventmesh.dashboard.agent.model.AgentStartActionVO; + +import java.util.Map; + +public interface AgentActionClient { + + + AgentStartActionVO agentStartAction(Map data); + + AgentCheckRuntimeVO agentCheckRuntime(Map data); +} diff --git a/eventmesh-dashboard-agent/src/main/java/org/apache/eventmesh/dashboard/agent/AgentController.java b/eventmesh-dashboard-agent/src/main/java/org/apache/eventmesh/dashboard/agent/AgentController.java new file mode 100644 index 00000000..35ec8687 --- /dev/null +++ b/eventmesh-dashboard-agent/src/main/java/org/apache/eventmesh/dashboard/agent/AgentController.java @@ -0,0 +1,138 @@ +/* + * 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.agent; + +import org.apache.eventmesh.dashboard.agent.config.ConfigHandler; +import org.apache.eventmesh.dashboard.agent.config.ConfigHandlerManage; +import org.apache.eventmesh.dashboard.agent.model.AgentCheckRuntimeVO; +import org.apache.eventmesh.dashboard.agent.model.AgentStartActionVO; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.concurrent.atomic.AtomicBoolean; + +import lombok.extern.slf4j.Slf4j; + +@Slf4j +public class AgentController { + + + public static void main(String[] args) { + AgentController agentController = new AgentController(); + agentController.start(); + } + + private final ConfigHandlerManage configHandlerManage = new ConfigHandlerManage(); + + private AgentActionClient agentActionClient; + + private final List waitTime = new ArrayList<>(); + + { + for (int i = 1; i < 4; i++) { + waitTime.add(50L); + waitTime.add(200L); + waitTime.add(500L); + waitTime.add(1000L); + waitTime.add(3000L); + } + Collections.sort(waitTime); + + } + + public void start() { + String consoleAddress = System.getenv("eventmesh.agent.console"); + if (Objects.isNull(consoleAddress)) { + log.error("eventmesh.agent.console is null"); + return; + } + + String clusterId = System.getenv("eventmesh.agent.clusterId"); + if (Objects.isNull(clusterId)) { + log.error("eventmesh.agent.clusterId is null"); + return; + } + + String runtimeId = System.getenv("eventmesh.agent.runtimeId"); + if (Objects.isNull(runtimeId)) { + log.error("eventmesh.agent.runtimeId is null"); + return; + } + String runtimeHome = System.getenv("eventmesh.agent.runtimeHome"); + if (Objects.isNull(runtimeHome)) { + log.error("eventmesh.agent.runtimeHome is null"); + return; + } + File file = new File(runtimeHome); + if (file.exists() && !file.isDirectory()) { + log.error("eventmesh.agent.runtimeHome is not a directory"); + return; + } + + Map data = new HashMap<>(); + data.put("clusterId", clusterId); + data.put("runtimeId", runtimeId); + AgentStartActionVO agentStartActionVO = agentActionClient.agentStartAction(data); + + // 得到 clusterType 对应的执行对象 + ConfigHandler configHandler = null; + try { + configHandler = this.configHandlerManage.getConfigHandler(agentStartActionVO.getClusterType()); + } catch (Exception e) { + throw new RuntimeException(e); + } + if (Objects.isNull(configHandler)) { + log.error("configHandler is null"); + return; + } + + configHandler.handler(); + + if (!agentStartActionVO.isCheck()) { + log.info("agentStartActionVO.isCheck is false"); + log.info("agent ok"); + return; + } + + AtomicBoolean success = new AtomicBoolean(false); + // 请求 是否可以启动 + waitTime.forEach(waitTime -> { + + try { + AgentCheckRuntimeVO vo = agentActionClient.agentCheckRuntime(data); + if(vo.isSuccess()) { + success.set(true); + log.info("agentCheckRuntime success time {}", waitTime); + return; + } + Thread.sleep(waitTime); + } catch (Exception e) { + log.error("agentStartAction error", e); + } + }); + if (!success.get()) { + log.info("check is fail"); + } + + } +} diff --git a/eventmesh-dashboard-agent/src/main/java/org/apache/eventmesh/dashboard/agent/config/AbstractConfigHandler.java b/eventmesh-dashboard-agent/src/main/java/org/apache/eventmesh/dashboard/agent/config/AbstractConfigHandler.java new file mode 100644 index 00000000..f37cdd4c --- /dev/null +++ b/eventmesh-dashboard-agent/src/main/java/org/apache/eventmesh/dashboard/agent/config/AbstractConfigHandler.java @@ -0,0 +1,62 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.eventmesh.dashboard.agent.config; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.util.Map; + +public abstract class AbstractConfigHandler implements ConfigHandler { + + protected String runtimeHome; + + + public void setRuntimeHome(String runtimeHome) { + this.runtimeHome = runtimeHome; + } + + protected void readConfigFile(String configFile, String fileType,Map configData) throws IOException { + File file = new File(configFile); + if (file.exists()) { + Path source = Paths.get(configFile); + Path target = Paths.get(configFile + ".copy." + System.currentTimeMillis()); + Files.copy(source, target, StandardCopyOption.REPLACE_EXISTING); + if(!file.delete()){ + throw new IOException(String.format("delete file %s failed", file.getAbsolutePath())); + } + } + if(!file.createNewFile()){ + throw new RuntimeException("file is exist"); + } + try(FileOutputStream fos = new FileOutputStream(file)){ + StringBuffer stringBuffer = new StringBuffer(); + configData.forEach( (k,v)->{ + stringBuffer.append(k).append('=').append(v).append(System.lineSeparator()); + }); + fos.write(stringBuffer.toString().getBytes()); + fos.flush(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } +} diff --git a/eventmesh-dashboard-agent/src/main/java/org/apache/eventmesh/dashboard/agent/config/ConfigHandler.java b/eventmesh-dashboard-agent/src/main/java/org/apache/eventmesh/dashboard/agent/config/ConfigHandler.java new file mode 100644 index 00000000..d813239c --- /dev/null +++ b/eventmesh-dashboard-agent/src/main/java/org/apache/eventmesh/dashboard/agent/config/ConfigHandler.java @@ -0,0 +1,26 @@ +/* + * 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.agent.config; + +public interface ConfigHandler { + + + + void handler(); + +} diff --git a/eventmesh-dashboard-agent/src/main/java/org/apache/eventmesh/dashboard/agent/config/ConfigHandlerManage.java b/eventmesh-dashboard-agent/src/main/java/org/apache/eventmesh/dashboard/agent/config/ConfigHandlerManage.java new file mode 100644 index 00000000..9a5d96f0 --- /dev/null +++ b/eventmesh-dashboard-agent/src/main/java/org/apache/eventmesh/dashboard/agent/config/ConfigHandlerManage.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.agent.config; + +import org.apache.eventmesh.dashboard.agent.config.handler.RocketMQNameSerivceConfigHandler; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +public class ConfigHandlerManage { + + private Map> configHandlerMap = new ConcurrentHashMap<>(); + + { + this.configHandlerMap.put("", RocketMQNameSerivceConfigHandler.class); + } + + + public ConfigHandler getConfigHandler(String clusterType) throws InstantiationException, IllegalAccessException { + Class clazz = configHandlerMap.get(clusterType); + return (ConfigHandler)clazz.newInstance(); + } + +} diff --git a/eventmesh-dashboard-agent/src/main/java/org/apache/eventmesh/dashboard/agent/config/handler/RocketMQNameSerivceConfigHandler.java b/eventmesh-dashboard-agent/src/main/java/org/apache/eventmesh/dashboard/agent/config/handler/RocketMQNameSerivceConfigHandler.java new file mode 100644 index 00000000..b3c6f307 --- /dev/null +++ b/eventmesh-dashboard-agent/src/main/java/org/apache/eventmesh/dashboard/agent/config/handler/RocketMQNameSerivceConfigHandler.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.eventmesh.dashboard.agent.config.handler; + +import org.apache.eventmesh.dashboard.agent.config.AbstractConfigHandler; + +public class RocketMQNameSerivceConfigHandler extends AbstractConfigHandler { + + @Override + public void handler() { + + } +} diff --git a/eventmesh-dashboard-agent/src/main/java/org/apache/eventmesh/dashboard/agent/model/AgentCheckRuntimeVO.java b/eventmesh-dashboard-agent/src/main/java/org/apache/eventmesh/dashboard/agent/model/AgentCheckRuntimeVO.java new file mode 100644 index 00000000..dbedbfa3 --- /dev/null +++ b/eventmesh-dashboard-agent/src/main/java/org/apache/eventmesh/dashboard/agent/model/AgentCheckRuntimeVO.java @@ -0,0 +1,27 @@ +/* + * 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.agent.model; + + +import lombok.Data; + +@Data +public class AgentCheckRuntimeVO { + + private boolean success; +} diff --git a/eventmesh-dashboard-agent/src/main/java/org/apache/eventmesh/dashboard/agent/model/AgentStartActionVO.java b/eventmesh-dashboard-agent/src/main/java/org/apache/eventmesh/dashboard/agent/model/AgentStartActionVO.java new file mode 100644 index 00000000..deb72a92 --- /dev/null +++ b/eventmesh-dashboard-agent/src/main/java/org/apache/eventmesh/dashboard/agent/model/AgentStartActionVO.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.agent.model; + +import java.util.Map; + +import lombok.Data; + +@Data +public class AgentStartActionVO { + + private String clusterType; + + private Map configMap; + + private boolean check; + +} diff --git a/eventmesh-dashboard-agent/src/main/resources/logback.xml b/eventmesh-dashboard-agent/src/main/resources/logback.xml new file mode 100644 index 00000000..6dede9ad --- /dev/null +++ b/eventmesh-dashboard-agent/src/main/resources/logback.xml @@ -0,0 +1,45 @@ + + + + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %magenta(%-5level) %green(%logger{60}):%blue(%line) - %msg%n + + + + + + ${user.home}/logs/eventmesh-dashboard/eventmesh-dashboard-%d{yyyy-MM-dd}.%i.log + + 10485760 + + 10 + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{60}:%line - %msg%n + UTF-8 + + + + + + + + + \ No newline at end of file diff --git a/eventmesh-dashboard-agent/src/test/java/org/apache/eventmesh/dashboard/agent/config/TestConfigHandler.java b/eventmesh-dashboard-agent/src/test/java/org/apache/eventmesh/dashboard/agent/config/TestConfigHandler.java new file mode 100644 index 00000000..ca11dc35 --- /dev/null +++ b/eventmesh-dashboard-agent/src/test/java/org/apache/eventmesh/dashboard/agent/config/TestConfigHandler.java @@ -0,0 +1,56 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.eventmesh.dashboard.agent.config; + +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +import org.junit.Test; + +public class TestConfigHandler { + + AbstractConfigHandler abstractConfigHandler = new AbstractConfigHandler() { + + @Override + public void handler() { + + } + }; + + + @Test + public void test() throws URISyntaxException, IOException { + Map map = new HashMap<>(); + + for (int i = 0; i < 20; i++) { + map.put("key" + i, "value" + i); + } + URI uri = Objects.requireNonNull(TestConfigHandler.class.getClassLoader().getResource("")).toURI(); + Path resourcePath = Paths.get(uri); + abstractConfigHandler.setRuntimeHome(resourcePath.toFile().getAbsolutePath()); + String fileName = resourcePath.toFile().getAbsolutePath() + "/config.properties"; + abstractConfigHandler.readConfigFile(fileName, "", map); + } + +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ClusterTrusteeshipType.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ClusterTrusteeshipType.java index 66daa531..49c949ee 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ClusterTrusteeshipType.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ClusterTrusteeshipType.java @@ -124,6 +124,7 @@ public enum TrusteeshipArrangeType { ClusterTrusteeshipType(String type, List clusterTypeList) { this.type = type; + this.clusterTypeList = clusterTypeList; } diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/util/ClasspathScanner.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/util/ClasspathScanner.java index 1ab9fc71..15af28f4 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/util/ClasspathScanner.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/util/ClasspathScanner.java @@ -52,6 +52,8 @@ public class ClasspathScanner { private Set> interfaceSet; + private Set> annotationSet; + private String designation; @@ -71,9 +73,16 @@ public List> getClazz() throws Exception { if (Modifier.isAbstract(clazz.getModifiers())) { continue; } + if(Objects.isNull(this.interfaceSet)){ + resourcesList.add(clazz); + continue; + } + if (this.includeInterface(clazz)) { resourcesList.add(clazz); + continue; } + Class[] innerClass = clazz.getDeclaredClasses(); if (ArrayUtils.isEmpty(innerClass)) { continue; @@ -88,7 +97,7 @@ public List> getClazz() throws Exception { } private boolean excludeTest(Resource resource) throws IOException { - return resource.getFile().getPath().indexOf("/target/test-classes/") != -1; + return resource.getFile().getPath().contains("/target/test-classes/"); } private Class createClass(Resource resource) throws IOException, ClassNotFoundException { diff --git a/eventmesh-dashboard-console/pom.xml b/eventmesh-dashboard-console/pom.xml index bfe4dc2f..efe36328 100644 --- a/eventmesh-dashboard-console/pom.xml +++ b/eventmesh-dashboard-console/pom.xml @@ -125,6 +125,54 @@ 0.1.20 + + org.apache.velocity + velocity-engine-core + 2.4.1 + + + org.apache.iotdb + iotdb-session + 2.0.3 + + + org.apache.iotdb + iotdb-jdbc + 2.0.3 + + + + + + + + + + + + + + jakarta.json + jakarta.json-api + 2.1.3 + + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + 2.17.1 + + + org.opensearch.client + opensearch-rest-client + 2.18.0 + + + + org.opensearch.client + opensearch-java + 2.15.0 + + org.springframework.boot diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/config/FunctionManagerConfigs.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/config/FunctionManagerConfigs.java deleted file mode 100644 index fed7d4f7..00000000 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/config/FunctionManagerConfigs.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.apache.eventmesh.dashboard.console.config; - -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.stereotype.Component; - -import lombok.Data; - -@Data -@Component -@ConfigurationProperties(prefix = "function") -public class FunctionManagerConfigs { - - private HealthCheck healthCheck = new HealthCheck(); - private Sync sync = new Sync(); - - @Data - public static class HealthCheck { - - private DoCheck doCheck = new DoCheck(); - private UpdateConfig updateConfig = new UpdateConfig(); - - @Data - public static class DoCheck { - - private int initialDelay = 60; - private int period = 60; - } - - @Data - public static class UpdateConfig { - - private int initialDelay = 30; - private int period = 60; - } - } - - @Data - public static class Sync { - - private boolean enable; - private ToDb toDb = new ToDb(); - - private int initialDelay = 120; - private int period = 60; - - @Data - public static class ToDb { - - private Boolean runtime; - } - } -} \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/ClusterAbitityService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/ClusterAbilityService.java similarity index 83% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/ClusterAbitityService.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/ClusterAbilityService.java index 112a8898..cb902f19 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/ClusterAbitityService.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/ClusterAbilityService.java @@ -22,7 +22,6 @@ import org.apache.eventmesh.dashboard.common.enums.ClusterSyncMetadataEnum; import org.apache.eventmesh.dashboard.console.entity.base.BaseClusterIdEntity; import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; -import org.apache.eventmesh.dashboard.console.mapstruct.cluster.ClusterControllerMapper; import org.apache.eventmesh.dashboard.console.modle.ClusterIdDTO; import org.apache.eventmesh.dashboard.console.service.cluster.ClusterService; @@ -34,7 +33,7 @@ @Component -public class ClusterAbitityService { +public class ClusterAbilityService { @Autowired @@ -56,12 +55,14 @@ public class ClusterAbitityService { private boolean forceConsistent = false; - public boolean isCAP(ClusterIdDTO clusterIdDTO) { - ClusterEntity clusterEntity = this.clusterService.queryClusterById(ClusterControllerMapper.INSTANCE.toClusterEntity(clusterIdDTO)); - return this.isCAP(clusterEntity); + public boolean isCap(ClusterIdDTO clusterIdDTO) { + ClusterEntity clusterEntity = new ClusterEntity(); + clusterEntity.setId(clusterIdDTO.getClusterId()); + clusterEntity = this.clusterService.queryClusterById(clusterEntity); + return this.isCapByEntity(clusterEntity); } - public boolean isCAP(BaseClusterIdEntity baseClusterIdEntity) { + public boolean isCapByEntity(BaseClusterIdEntity baseClusterIdEntity) { ClusterFramework clusterFramework = ClusterSyncMetadataEnum.getClusterFramework(baseClusterIdEntity.getClusterType()); return clusterFramework.isCAP(); } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/ReportController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/ReportController.java new file mode 100644 index 00000000..58eb4bef --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/ReportController.java @@ -0,0 +1,61 @@ +/* + * 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.function.report.ReportHandlerManage; +import org.apache.eventmesh.dashboard.console.function.report.model.MultiGeneralReportDO; +import org.apache.eventmesh.dashboard.console.function.report.model.SingleGeneralReportDO; + +import java.util.ArrayList; +import java.util.List; + +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("report") +public class ReportController { + + + private ReportHandlerManage reportHandlerManage; + + @RequestMapping("reportByHome") + public void reportByHome(@RequestBody MultiGeneralReportDO multiGeneralReportDO) { + // + List singleGeneralReportDOList = new ArrayList<>(); + multiGeneralReportDO.getReportNameList().forEach(reportName -> { + SingleGeneralReportDO singleGeneralReportDO = new SingleGeneralReportDO(); + singleGeneralReportDOList.add(singleGeneralReportDO); + + + }); + + singleGeneralReportDOList.forEach(singleGeneralReportDO -> { + + }); + } + + public void reportBySingle(@RequestBody SingleGeneralReportDO singleGeneralReportDO) { + + } + + public void reportByMulti() { + } + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/agent/AgentActionController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/agent/AgentActionController.java new file mode 100644 index 00000000..2abb6cc1 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/agent/AgentActionController.java @@ -0,0 +1,129 @@ +/* + * 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.agent; + + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.common.enums.MetadataType; +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; +import org.apache.eventmesh.dashboard.console.entity.function.ConfigEntity; +import org.apache.eventmesh.dashboard.console.modle.DO.runtime.QueryRuntimeByBigExpandClusterDO; +import org.apache.eventmesh.dashboard.console.modle.dto.agent.AgentStartActionDTO; +import org.apache.eventmesh.dashboard.console.service.cluster.ClusterService; +import org.apache.eventmesh.dashboard.console.service.cluster.RuntimeService; +import org.apache.eventmesh.dashboard.console.service.function.ConfigService; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +import javax.validation.Valid; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import io.swagger.v3.oas.annotations.parameters.RequestBody; + + +@RestController +@RequestMapping("/agent/") +public class AgentActionController { + + @Autowired + private ConfigService configService; + + @Autowired + private ClusterService clusterService; + + @Autowired + private RuntimeService runtimeService; + + @PostMapping("agentStartAction") + public AgentStartActionVO agentStartAction(@RequestBody @Valid AgentStartActionDTO data) { + + ClusterEntity clusterEntity = new ClusterEntity(); + clusterEntity.setId(data.getClusterId()); + + clusterEntity = this.clusterService.queryClusterById(clusterEntity); + + RuntimeEntity runtimeEntity = new RuntimeEntity(); + runtimeEntity.setId(data.getRuntimeId()); + runtimeEntity = this.runtimeService.queryRuntimeEntityById(runtimeEntity); + + if (!Objects.equals(runtimeEntity.getClusterId(), clusterEntity.getId())) { + + } + + AgentStartActionVO agentStartActionVO = new AgentStartActionVO(); + agentStartActionVO.setClusterType(clusterEntity.getClusterType().toString()); + agentStartActionVO.setCheck(clusterEntity.getClusterType().isMeta()); + + ConfigEntity configEntity = new ConfigEntity(); + configEntity.setInstanceId(clusterEntity.getId()); + configEntity.setInstanceType(MetadataType.CLUSTER); + List configEntityList = this.configService.queryByInstanceId(configEntity); + Map configMap = new HashMap(); + configEntityList.forEach(config -> { + configMap.put(config.getConfigName(), config.getConfigValue()); + }); + + configEntity = new ConfigEntity(); + configEntity.setInstanceId(runtimeEntity.getId()); + configEntity.setInstanceType(MetadataType.RUNTIME); + this.configService.queryByInstanceId(configEntity); + configEntityList.forEach(config -> { + configMap.put(config.getConfigName(), config.getConfigValue()); + }); + + agentStartActionVO.setConfigMap(configMap); + + return agentStartActionVO; + + } + + + @PostMapping("agentCheckRuntime") + public AgentCheckRuntimeVO agentCheckRuntime(@RequestBody @Valid AgentStartActionDTO data) { + ClusterEntity clusterEntity = new ClusterEntity(); + clusterEntity.setId(data.getClusterId()); + clusterEntity = this.clusterService.queryClusterById(clusterEntity); + + AgentCheckRuntimeVO agentCheckRuntimeVO = new AgentCheckRuntimeVO(); + + QueryRuntimeByBigExpandClusterDO queryRuntimeByBigExpandClusterDO = + QueryRuntimeByBigExpandClusterDO.builder().followClusterId(clusterEntity.getId()) + .queryClusterTypeList(clusterEntity.getClusterType().getMetaClusterType()).build(); + + List runtimeEntityList = this.runtimeService.queryMetaRuntimeByStorageClusterId(queryRuntimeByBigExpandClusterDO); + + if (clusterEntity.getClusterType().isEventMethRuntime()) { + queryRuntimeByBigExpandClusterDO = + QueryRuntimeByBigExpandClusterDO.builder().followClusterId(clusterEntity.getId()) + .storageMetaClusterTypeList(ClusterType.getStorageMetaRuntimeCluster()).build(); + //如果是 eventmesh 集群,name需要查询 存储集群的 runtime 是否启动 + // 如果识别 meta 的可用度 + runtimeEntityList = this.runtimeService.queryRuntimeByBigExpandCluster(queryRuntimeByBigExpandClusterDO); + } + + return agentCheckRuntimeVO; + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/agent/AgentCheckRuntimeVO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/agent/AgentCheckRuntimeVO.java new file mode 100644 index 00000000..462b1b6a --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/agent/AgentCheckRuntimeVO.java @@ -0,0 +1,27 @@ +/* + * 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.agent; + +import lombok.Data; + +@Data +public class AgentCheckRuntimeVO { + + private boolean success; + +} 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/controller/agent/AgentStartActionVO.java similarity index 65% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/config/DetailConfigsVO.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/agent/AgentStartActionVO.java index 10e05e91..2e28874a 100644 --- 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/controller/agent/AgentStartActionVO.java @@ -6,7 +6,7 @@ * (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 + * 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, @@ -15,26 +15,21 @@ * limitations under the License. */ +package org.apache.eventmesh.dashboard.console.controller.agent; -package org.apache.eventmesh.dashboard.console.modle.dto.config; +import java.util.Map; -import lombok.AllArgsConstructor; import lombok.Data; -import lombok.NoArgsConstructor; -@NoArgsConstructor -@AllArgsConstructor -@Data -public class DetailConfigsVO { - private String configName; +@Data +public class AgentStartActionVO { - private String configValue; - private String defaultValue; + private String clusterType; - private Integer isModify; + private Map configMap; - private Integer alreadyUpdate; + private boolean check; } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/DetailsController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/DetailsController.java index ca84a3df..06ca6619 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/DetailsController.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/DetailsController.java @@ -54,4 +54,6 @@ public void storageRuntimeDetails(ClusterIdDTO clusterIdDTO) { } + + } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/HomeController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/HomeController.java index 11861dc9..0f0ea307 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/HomeController.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/HomeController.java @@ -20,15 +20,30 @@ import org.apache.eventmesh.dashboard.console.service.cluster.ClusterService; +import org.apache.eventmesh.dashboard.console.service.message.GroupService; +import org.apache.eventmesh.dashboard.console.service.message.OffsetService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/home") public class HomeController { + @Autowired private ClusterService clusterService; + @Autowired + private GroupService groupService; + + + @Autowired + private OffsetService offsetService; - public void clusterHome(){ + public void clusterHome() { // 运维事件 // runtime 集群 以及 @@ -40,14 +55,16 @@ public void clusterHome(){ // kubernetes 列表。 本集群 没有或则资源不够,找上级集群。如果有多个上级 // 下面的是否需要展示 + // client // group 列表 topic 列表。是否需要在 home 展示 // 连接 + } - public void runtimeHome(){ + public void runtimeHome() { // 在哪个 cluster // 在哪一个 kubernetes @@ -65,11 +82,14 @@ public void runtimeHome(){ // 连接 统计数据 // 实例资源统计数据 + } - public void groupHome(){ - // cluster + public void groupHome() { + // group io out + + // topic // topic @@ -78,16 +98,46 @@ public void groupHome(){ // } - public void topicHome(){ + public void queueHome(){ + // out io + // offset + } + + public void groupSingleHome() { + // group all io out + // offset + // + } + + public void topicHome() { + // topic io out + // topic offset , 消费 offset + // topic 数量 报表 + } + + public void topicSingleHome() { + // 运维异常统计 + // topic offset + + // topic 队列信息 + + // topic 关系图 + + // 获得 生产与消费数量,以及活跃组,正常组,非正常组。可以从 消费者offset + // topic 状态,依据 offset 的变化,在 topic 表里面 + + // 获得 client + + // 获得 获得 topic io out } - public void clientHome(){ + public void clientHome() { } - public void userHome(){ + public void userHome() { } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/function/ConfigController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/function/ConfigController.java index ef38b02e..ddb60a6e 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/function/ConfigController.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/function/ConfigController.java @@ -19,51 +19,38 @@ package org.apache.eventmesh.dashboard.console.controller.function; import org.apache.eventmesh.dashboard.console.entity.function.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.mapstruct.message.ConfigControllerMapper; import org.apache.eventmesh.dashboard.console.modle.dto.config.UpdateConfigDTO; +import org.apache.eventmesh.dashboard.console.modle.function.config.QueryByInstanceIdDTO; import org.apache.eventmesh.dashboard.console.service.function.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.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController +@RequestMapping(("/user/config")) public class ConfigController { + private static final ConfigControllerMapper INSTANCE = ConfigControllerMapper.INSTANCE; + @Autowired private ConfigService configService; @PostMapping("/cluster/config/updateConfigs") public String updateConfigsByTypeAndId(@Validated @RequestBody UpdateConfigDTO updateConfigDTO) { - 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; + @PostMapping("/queryByInstanceId") + public List queryByInstanceId(@Validated @RequestBody QueryByInstanceIdDTO queryByInstanceIdDTO) { + return configService.queryByInstanceId(INSTANCE.queryByInstanceId(queryByInstanceIdDTO)); } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/message/GroupController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/message/GroupController.java index d1d58026..4ce3612a 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/message/GroupController.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/message/GroupController.java @@ -21,6 +21,7 @@ import org.apache.eventmesh.dashboard.console.entity.message.GroupEntity; +import org.apache.eventmesh.dashboard.console.entity.message.TopicEntity; import org.apache.eventmesh.dashboard.console.mapstruct.cluster.GroupControllerMapper; import org.apache.eventmesh.dashboard.console.modle.IdDTO; import org.apache.eventmesh.dashboard.console.modle.vo.RuntimeIdDTO; @@ -39,7 +40,7 @@ * */ @RestController -@RequestMapping("group") +@RequestMapping("/user/group") public class GroupController { @@ -51,6 +52,13 @@ public List queryGroupListByClusterId(@RequestBody @Validated Runti return groupService.getGroupByClusterId(GroupControllerMapper.INSTANCE.queryGroupListByClusterId(runtimeIdDTO)); } + @PostMapping("queryGroupListByTopicId") + public List queryGroupListByTopicId(@RequestBody @Validated IdDTO idDTO) { + TopicEntity topicEntity = new TopicEntity(); + topicEntity.setId(idDTO.getId()); + return groupService.queryGroupListByTopicId(topicEntity); + } + @PostMapping("deleteGroupById") public Integer deleteGroupById(@RequestBody @Validated IdDTO idDTO) { return groupService.deleteGroup(GroupControllerMapper.INSTANCE.deleteGroupById(idDTO)); diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/message/TopicController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/message/TopicController.java index 5a63bd12..5b6b9bd1 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/message/TopicController.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/message/TopicController.java @@ -21,7 +21,7 @@ import org.apache.eventmesh.dashboard.common.model.metadata.ClusterMetadata; import org.apache.eventmesh.dashboard.common.model.metadata.RuntimeMetadata; -import org.apache.eventmesh.dashboard.console.controller.ClusterAbitityService; +import org.apache.eventmesh.dashboard.console.controller.ClusterAbilityService; import org.apache.eventmesh.dashboard.console.domain.metadata.ClusterMetadataDomain; import org.apache.eventmesh.dashboard.console.domain.metadata.ClusterOperationHandler; import org.apache.eventmesh.dashboard.console.entity.message.TopicEntity; @@ -44,8 +44,11 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; + @RestController -@RequestMapping("topic") +@RequestMapping("/user/topic") public class TopicController { @Autowired @@ -53,7 +56,7 @@ public class TopicController { @Autowired - private ClusterAbitityService clusterAbitityService; + private ClusterAbilityService clusterAbilityService; @Autowired private ClusterMetadataDomain clusterMetadataDomain; @@ -65,17 +68,24 @@ public class TopicController { @PostMapping("/queryTopicListByClusterId") public List queryTopicListByClusterId(@Validated @RequestBody GetTopicListDTO getTopicListDTO) { // cap 的直接查询 - if (this.clusterAbitityService.isCAP(getTopicListDTO)) { - topicService.getTopicListToFront(TopicControllerMapper.INSTANCE.queryTopicListByClusterId(getTopicListDTO)); + Page page = PageHelper.getLocalPage(); + PageHelper.clearPage(); + System.out.println(page.getPageNum()); + boolean isCap = this.clusterAbilityService.isCap(getTopicListDTO); + PageHelper.startPage(page.getPageNum(), page.getPageSize()).setOrderBy(page.getOrderBy()); + if (isCap) { + return topicService.getTopicListToFront(TopicControllerMapper.INSTANCE.queryTopicListByClusterId(getTopicListDTO)); } // 非 CAP 另外查询 return topicService.getTopicListToFront(TopicControllerMapper.INSTANCE.queryTopicListByClusterId(getTopicListDTO)); } - @PostMapping("queryTopicListById ") + + + @PostMapping("queryTopicListById") public TopicEntity queryTopicById(@Validated @RequestBody RuntimeIdDTO runtimeIdDTO) { TopicEntity topicEntity = topicService.selectTopicById(TopicControllerMapper.INSTANCE.queryTopicListById(runtimeIdDTO)); - if (this.clusterAbitityService.isCAP(topicEntity)) { + if (this.clusterAbilityService.isCapByEntity(topicEntity)) { return topicEntity; } // @@ -104,8 +114,6 @@ public void handler(ClusterMetadata clusterDO) { } }); - - topicService.queryRuntimeByBaseSyncEntity(queryList); return null; } @@ -113,7 +121,7 @@ public void handler(ClusterMetadata clusterDO) { @GetMapping("deleteTopic") public Integer deleteTopic(@Validated @RequestBody IdDTO idDTO) { TopicEntity topicEntity = this.topicService.selectTopicById(TopicControllerMapper.INSTANCE.deleteTopic(idDTO)); - if (this.clusterAbitityService.isCAP(topicEntity)) { + if (this.clusterAbilityService.isCapByEntity(topicEntity)) { return this.topicService.deleteTopicById(topicEntity); } // 通过 clusterId,runtime id, topic name 删除 diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/BaseEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/BaseEntity.java deleted file mode 100644 index 874a48fd..00000000 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/BaseEntity.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.apache.eventmesh.dashboard.console.entity; - -import org.apache.eventmesh.dashboard.common.enums.ClusterType; - -import java.io.Serializable; -import java.time.LocalDateTime; - -import io.swagger.v3.oas.annotations.media.Schema; - -import lombok.Data; -import lombok.EqualsAndHashCode; - -/** - * Base Entity provide some basic fields that every Eventmesh Dashboard Entity would have - *

- * 12 broker -> 12 queue , 11 queue , 1broker 没有 队列。 副本,随机出现在一个 broker - */ -@Data -@EqualsAndHashCode(callSuper = false) -@Schema(name = "BaseEntity", description = "Base entity") -@Deprecated -public class BaseEntity implements Serializable { - - private static final long serialVersionUID = -2697805837923579585L; - /** - * Primary key - */ - @Schema(name = "id", description = "primary key") - protected Long id; - - /** - * 集群id,不是 eventmesh集群id。 - */ - protected Long clusterId; - - protected ClusterType clusterType; - - protected LocalDateTime createTime; - - protected LocalDateTime updateTime; - - private Integer status; -} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/AclEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/AclEntity.java index b300b6d5..3d92bf81 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/AclEntity.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/AclEntity.java @@ -18,14 +18,14 @@ package org.apache.eventmesh.dashboard.console.entity.cluster; -import org.apache.eventmesh.dashboard.console.entity.BaseEntity; +import org.apache.eventmesh.dashboard.console.entity.base.BaseIdEntity;; import lombok.Data; import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = true, exclude = "status") -public class AclEntity extends BaseEntity { +public class AclEntity extends BaseIdEntity { private static final long serialVersionUID = 6057071983428111947L; @@ -47,6 +47,5 @@ public class AclEntity extends BaseEntity { private Integer patternType; - private Integer status; } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/function/ConfigEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/function/ConfigEntity.java index e1c23d2c..c29b1f80 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/function/ConfigEntity.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/function/ConfigEntity.java @@ -29,6 +29,7 @@ public class ConfigEntity extends BaseClusterIdEntity { + private String businessType; private Long retrospectId; @@ -46,6 +47,10 @@ public class ConfigEntity extends BaseClusterIdEntity { private String configValue; + private String configValueType; + + private String configValueRange; + private String startVersion; private String eventmeshVersion; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/function/ConfigGatherEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/function/ConfigGatherEntity.java index 3b050285..f1de996c 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/function/ConfigGatherEntity.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/function/ConfigGatherEntity.java @@ -18,9 +18,10 @@ package org.apache.eventmesh.dashboard.console.entity.function; -import org.apache.eventmesh.dashboard.console.entity.BaseEntity; -public class ConfigGatherEntity extends BaseEntity { +import org.apache.eventmesh.dashboard.console.entity.base.BaseIdEntity; + +public class ConfigGatherEntity extends BaseIdEntity { private String name; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/message/GroupEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/message/GroupEntity.java index d4ce306c..dc867507 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/message/GroupEntity.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/message/GroupEntity.java @@ -29,10 +29,8 @@ public class GroupEntity extends BaseRuntimeIdEntity { private String name; - private Integer memberCount; - - private String members; - private Integer type; + private String ownType; + } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/message/TopicEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/message/TopicEntity.java index 699a9700..674cdf64 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/message/TopicEntity.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/message/TopicEntity.java @@ -38,7 +38,9 @@ public class TopicEntity extends BaseRuntimeIdEntity { /** * */ - private Long numQueue; + private Integer readQueueNum; + + private Integer writeQueueNum; /** * 副本个数 @@ -55,7 +57,7 @@ public class TopicEntity extends BaseRuntimeIdEntity { */ private String attributes; - private String order; + private Integer order; @Schema(description = "time to live in milliseconds, -2 unknown, -1 no limit;", example = "1000") private Long retentionMs; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/AbstractReportEngine.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/AbstractReportEngine.java new file mode 100644 index 00000000..12c76adc --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/AbstractReportEngine.java @@ -0,0 +1,137 @@ +/* + * 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.function.report; + +import org.apache.eventmesh.dashboard.console.function.report.annotation.AbstractReportMetaHandler; +import org.apache.eventmesh.dashboard.console.function.report.annotation.ReportMeta; +import org.apache.eventmesh.dashboard.console.function.report.model.SingleGeneralReportDO; + +import org.apache.ibatis.mapping.BoundSql; +import org.apache.ibatis.mapping.SqlSource; +import org.apache.ibatis.scripting.xmltags.XMLLanguageDriver; +import org.apache.ibatis.session.Configuration; +import org.apache.velocity.VelocityContext; +import org.apache.velocity.app.VelocityEngine; +import org.apache.velocity.runtime.RuntimeConstants; +import org.apache.velocity.runtime.resource.loader.StringResourceLoader; +import org.apache.velocity.runtime.resource.util.StringResourceRepository; +import org.apache.velocity.runtime.resource.util.StringResourceRepositoryImpl; + +import java.io.StringWriter; +import java.lang.reflect.Field; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.concurrent.ConcurrentHashMap; + +import lombok.Getter; +import lombok.Setter; + +@Setter +public abstract class AbstractReportEngine implements ReportEngine { + + + protected ReportConfig reportConfig; + + private VelocityEngine velocityEngine; + + private Configuration configuration = new Configuration(); + + private Map> stringSqlSourceMap = new HashMap<>(); + + protected XMLLanguageDriver xmlLanguageDriver = new XMLLanguageDriver(); + + private Class reportClass; + + private StringResourceRepository resourceLoader = new StringResourceRepositoryImpl(); + + @Getter + private Map reportMetaHandlerMap = new HashMap<>(); + + private Map> reportSQL = new ConcurrentHashMap<>(); + + public void init() { + this.createVelocity(); + + this.doInit(); + } + + protected abstract void doInit(); + + private void createVelocity() { + VelocityEngine velocityEngine = new VelocityEngine(); + velocityEngine.setProperty(RuntimeConstants.RESOURCE_LOADER, "report"); + velocityEngine.setProperty("resource.loader.report.class", StringResourceLoader.class.getName()); + velocityEngine.setProperty("resource.loader.report.repository.name", "report"); + velocityEngine.setProperty("resource.loader.report.repository.static", false); + velocityEngine.setApplicationAttribute("report", resourceLoader); + velocityEngine.init(); + this.velocityEngine = velocityEngine; + } + + + protected String querySentence(SingleGeneralReportDO singleGeneralReportDO) { + VelocityContext velocityContext = new VelocityContext(); + velocityContext.put("data", singleGeneralReportDO); + StringWriter stringWriter = new StringWriter(); + this.velocityEngine.getTemplate("").merge(velocityContext, stringWriter); + return stringWriter.toString(); + } + + @Override + public void createReportHandler(ReportMeta reportMeta, List fieldList) { + AbstractReportMetaHandler abstractReportMetaHandler = this.doCreateReportHandler(reportMeta, fieldList); + this.reportMetaHandlerMap.put(reportMeta.reportName(), abstractReportMetaHandler); + } + + protected abstract AbstractReportMetaHandler doCreateReportHandler(ReportMeta reportMeta, List fieldList); + + protected String buildSql(String reportName, String type, Object value) { + SqlSource sqlSource = this.buildSqlSource(reportName, type); + BoundSql boundSql = sqlSource.getBoundSql(value); + return boundSql.getSql(); + } + + protected SqlSource buildSqlSource(String reportName, String type) { + Map sourceMap = this.stringSqlSourceMap.computeIfAbsent(reportName, k -> new ConcurrentHashMap<>()); + return sourceMap.computeIfAbsent(type, (k) -> { + String sql = this.createSql(reportName, type); + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append(""); + + return this.xmlLanguageDriver.createSqlSource(configuration, stringBuilder.toString(), null); + }); + } + + protected String createSql(String reportName, String type) { + AbstractReportMetaHandler handler = this.reportMetaHandlerMap.get(reportName); + + String sql; + if (Objects.equals("insert", type)) { + sql = handler.insert(); + } else if (Objects.equals(ReportViewType.CREATE_TABLE.getName(), type)) { + sql = handler.createTable(); + } else { + sql = handler.query(type); + } + return sql; + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/ReportConfig.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/ReportConfig.java new file mode 100644 index 00000000..ea5b0694 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/ReportConfig.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.eventmesh.dashboard.console.function.report; + +import lombok.Data; + +@Data +public class ReportConfig { + + private String engineType; + + private String engineAddress; + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/ReportEngine.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/ReportEngine.java new file mode 100644 index 00000000..6f92ec90 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/ReportEngine.java @@ -0,0 +1,41 @@ +/* + * 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.function.report; + +import org.apache.eventmesh.dashboard.console.function.report.annotation.ReportMeta; +import org.apache.eventmesh.dashboard.console.function.report.model.SingleGeneralReportDO; + +import java.lang.reflect.Field; +import java.util.List; +import java.util.Map; +import java.util.concurrent.CompletableFuture; + + +public interface ReportEngine { + + CompletableFuture>> query(SingleGeneralReportDO singleGeneralReportDO); + + + + void createReport(String tableName); + + void batchInsert(String tableName , List data); + + + void createReportHandler(ReportMeta reportMeta, List fieldList); +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/ReportHandler.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/ReportHandler.java new file mode 100644 index 00000000..4dabe511 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/ReportHandler.java @@ -0,0 +1,22 @@ +/* + * 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.function.report; + +public interface ReportHandler { + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/ReportHandlerManage.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/ReportHandlerManage.java new file mode 100644 index 00000000..44321d0a --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/ReportHandlerManage.java @@ -0,0 +1,109 @@ +/* + * 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.function.report; + +import org.apache.eventmesh.dashboard.common.util.ClasspathScanner; +import org.apache.eventmesh.dashboard.console.function.report.annotation.ReportMeta; +import org.apache.eventmesh.dashboard.console.function.report.model.SingleGeneralReportDO; + +import org.apache.commons.lang3.reflect.FieldUtils; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; + +import lombok.Setter; + +/** + * TODO 功能点 + * 1. 同时提供总量 与 分组的统计 + * 2. 同时提供 量与百分比, value 后面自带百分比? + * 3. 提供排序 + * 4. 过滤。默认过滤掉。0。 可以指定过滤掉值的 + * 1. 比如 topic ,消费组 + * 2. 给 过滤总量值 + * 5. 指定维度 + * 1. message_type + * 2. protocol_type + * 3. request_code + * 4. response_code + * 5. invocation_status + * 6. name + * 6. 时间维度 15秒,分,15分,30分,1小时,3小时,6小时,12小时,天,月, + * 7. 分组:时间分组 + * 2. 按照 id 与。 id 维度是固定的 + * 3. 按照 类型维度 + * 4. + * 8. 支持批量获得,两个获得 + * 1. 批量与单个是否共用一个 接口? + * 2. 如果同时支持批量与单个,那么 前端需要提供连个 + */ +public class ReportHandlerManage { + + + @Setter + private ReportEngine reportEngine; + + public void init() { + ClasspathScanner classpathScanner = + ClasspathScanner.builder().base(ReportHandlerManage.class).subPath("/model/**").build(); + try { + List> classList = classpathScanner.getClazz(); + classList.forEach(this::handler); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + private void handler(Class clazz) { + ReportMeta reportMeta = clazz.getAnnotation(ReportMeta.class); + if (Objects.isNull(reportMeta)) { + return; + } + List list = new ArrayList<>(FieldUtils.getAllFieldsList(clazz)); + Collections.reverse(list); + this.reportEngine.createReportHandler(reportMeta, list); + } + + public Map>> queryResultIsMap(List singleGeneralReportDOList) { + Map>>> completableFutures = new HashMap<>(singleGeneralReportDOList.size()); + singleGeneralReportDOList.forEach(reportDO -> { + CompletableFuture>> completableFuture = reportEngine.query(reportDO); + completableFutures.put(reportDO.getReportType(), completableFuture); + }); + Map>> resultMap = new HashMap<>(singleGeneralReportDOList.size()); + completableFutures.forEach((key, completableFuture) -> { + try { + List> singleData = completableFuture.get(); + resultMap.put(key, singleData); + } catch (InterruptedException | ExecutionException e) { + throw new RuntimeException(e); + } + + }); + + return resultMap; + } + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/ReportViewType.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/ReportViewType.java new file mode 100644 index 00000000..6efc501a --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/ReportViewType.java @@ -0,0 +1,51 @@ +/* + * 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.function.report; + +public enum ReportViewType { + + + INSERT("insert"), + + CREATE_TABLE("create_table"), + + COUNTER("counter"), + + GAUGE("gauge"), + + HISTOGRAM("histogram"), + + HISTOGRAM_COUNTER("histogram_counter"), + + SUMMARY("summary"), + + ; + + + private String name; + + + ReportViewType(String name) { + this.name = name; + } + + + public String getName() { + return name; + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/annotation/AbstractReportMetaHandler.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/annotation/AbstractReportMetaHandler.java new file mode 100644 index 00000000..5ee4867e --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/annotation/AbstractReportMetaHandler.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.function.report.annotation; + +import java.lang.reflect.Field; +import java.util.List; + +import lombok.Setter; + +@Setter +public abstract class AbstractReportMetaHandler { + + protected ReportMeta reportMeta; + + protected List fieldList; + + + public abstract String insert(); + + public abstract String query(String type); + + public abstract String createTable(); + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/annotation/ReportMeta.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/annotation/ReportMeta.java new file mode 100644 index 00000000..a3bf1fbb --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/annotation/ReportMeta.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.eventmesh.dashboard.console.function.report.annotation; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.console.function.report.ReportViewType; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +/** + * id 为 tag + * time 为 time + * value 开头为 数据 + * + * + */ +@Retention(RetentionPolicy.RUNTIME) +public @interface ReportMeta { + + ClusterType clusterType(); + + String reportName(); + + ReportViewType defaultViewType(); + + ReportViewType[] reportViewTypes() default {}; + + String tableName(); + + String comment(); + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/annotation/ReportMetaData.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/annotation/ReportMetaData.java new file mode 100644 index 00000000..911e85ef --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/annotation/ReportMetaData.java @@ -0,0 +1,60 @@ +/* + * 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.function.report.annotation; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.console.function.report.ReportViewType; + +import lombok.Data; + + +/** + * 组件类型,report名,数据类型,类名(因为采集模块),表名,默认展示类型,可以展示类型, + * + */ +@Data +public class ReportMetaData { + + + private ClusterType clusterType; + + /** + * + */ + private String reportName; + + + private String dataType; + + + private Class clazz; + + + private String tableName; + + /** + * counter histogram gauge + */ + private ReportViewType reportViewType; + + + private ReportViewType reportViewTypes; + + + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/elasticsearch/ElasticsearchReportEngine.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/elasticsearch/ElasticsearchReportEngine.java new file mode 100644 index 00000000..a13c1866 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/elasticsearch/ElasticsearchReportEngine.java @@ -0,0 +1,98 @@ +/* + * 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.function.report.elasticsearch; + + +import org.apache.eventmesh.dashboard.console.function.report.AbstractReportEngine; +import org.apache.eventmesh.dashboard.console.function.report.annotation.AbstractReportMetaHandler; +import org.apache.eventmesh.dashboard.console.function.report.annotation.ReportMeta; +import org.apache.eventmesh.dashboard.console.function.report.model.SingleGeneralReportDO; + +import java.lang.reflect.Field; +import java.util.List; +import java.util.Map; +import java.util.concurrent.CompletableFuture; + +public class ElasticsearchReportEngine extends AbstractReportEngine { + + @Override + protected void doInit() { + + } + + @Override + protected AbstractReportMetaHandler doCreateReportHandler(ReportMeta reportMeta, List fieldList) { + return null; + } + + @Override + public CompletableFuture>> query(SingleGeneralReportDO singleGeneralReportDO) { + return null; + } + + @Override + public void createReport(String tableName) { + + } + + @Override + public void batchInsert(String tableName, List data) { + + } + +// private ElasticsearchClient esClient; +// +// +// +// public void handler() throws IOException { +// ScriptsPainlessExecuteRequest.Builder builder = new ScriptsPainlessExecuteRequest.Builder(); +// Script.Builder script = new Script.Builder(); +// +// ScriptSource.Builder scriptSourceBuilder = new ScriptSource.Builder(); +// scriptSourceBuilder.scriptString(""); +// script.source(scriptSourceBuilder.build()); +// builder.script(script.build()); +// +// esClient.scriptsPainlessExecute(builder.build()); +// } +// +// @Override +// protected void doInit() { +// try { +// URL url = new URL(this.reportConfig.getEngineAddress()); +// HttpHost httpHost = new HttpHost(url.getHost(), url.getPort(), url.getProtocol()); +// RestClient restClient = RestClient.builder(httpHost).build(); +// this.esClient = new ElasticsearchClient( +// new RestClientTransport(restClient, new JacksonJsonpMapper()) +// ); +// } catch (MalformedURLException e) { +// throw new RuntimeException(e); +// } +// +// } +// +// @Override +// public CompletableFuture>> query(SingleGeneralReportDO singleGeneralReportDO) { +// return null; +// } +// +// @Override +// public void batchInsert(String tableName, Map data) { +// +// } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/elasticsearch/SearchScriptMeta.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/elasticsearch/SearchScriptMeta.java new file mode 100644 index 00000000..b9ecd52e --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/elasticsearch/SearchScriptMeta.java @@ -0,0 +1,26 @@ +/* + * 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.function.report.elasticsearch; + +public interface SearchScriptMeta { + + + String type(); + + String script(); +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/elasticsearch/script/GeneralSearchScriptMeta.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/elasticsearch/script/GeneralSearchScriptMeta.java new file mode 100644 index 00000000..48e37d96 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/elasticsearch/script/GeneralSearchScriptMeta.java @@ -0,0 +1,66 @@ +/* + * 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.function.report.elasticsearch.script; + +import org.apache.eventmesh.dashboard.console.function.report.elasticsearch.SearchScriptMeta; + +public class GeneralSearchScriptMeta implements SearchScriptMeta { + + @Override + public String type() { + return ""; + } + + @Override + public String script() { + return """ + { + "size": 0, + "query": { + "bool": { + "must": [ + { "term": { "clusterPhyId": { "value": %d }}}, + { "range": { "timestamp": { "gte": %d, "lte": %d } } } + ] + } + }, + "aggs": { + "hist": { + "terms": { + "field": "brokerId", + "collect_mode": "breadth_first" + }, + "aggs": { + "hist": { + "date_histogram": { + "field": "timestamp", + "fixed_interval": "%s", + "time_zone": "Asia/Shanghai", + "min_doc_count": 0 + }, + "aggs": { + %s + } + } + } + } + } + } + """; + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/iotdb/IotDBReportEngine.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/iotdb/IotDBReportEngine.java new file mode 100644 index 00000000..bfafcb47 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/iotdb/IotDBReportEngine.java @@ -0,0 +1,257 @@ +/* + * 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.function.report.iotdb; + +import org.apache.eventmesh.dashboard.console.function.report.AbstractReportEngine; +import org.apache.eventmesh.dashboard.console.function.report.ReportViewType; +import org.apache.eventmesh.dashboard.console.function.report.annotation.AbstractReportMetaHandler; +import org.apache.eventmesh.dashboard.console.function.report.annotation.ReportMeta; +import org.apache.eventmesh.dashboard.console.function.report.model.SingleGeneralReportDO; + +import org.apache.iotdb.isession.ITableSession; +import org.apache.iotdb.isession.SessionDataSet; +import org.apache.iotdb.isession.pool.ITableSessionPool; +import org.apache.iotdb.session.pool.TableSessionPoolBuilder; + +import java.lang.reflect.Field; +import java.sql.Connection; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.concurrent.CompletableFuture; + +import com.alibaba.druid.pool.DruidDataSource; + +import lombok.Getter; + +/** + * 组件类型,report名,数据类型,类名(因为采集模块),表名,默认展示类型,可以展示类型, + */ +public class IotDBReportEngine extends AbstractReportEngine { + + private ITableSessionPool iTableSessionPool; + + private DruidDataSource dataSource; + + /** + * + */ + @Getter + private String sql = """ + select + + + organization_id, + + + cluster_id + + + runtime_id, + + + topic_id, + + + group_id, + + + queue_id, + + + subscription_id, + + + + + ${fun}( value ) + + + value + + + + + ${fun}( value ) + + + value + + + + + ${fun}( value ) + + + value + + + + + + + + + from ${table} + where + + organization_id = ${organizationId} and + + + cluster_id = ${clusterId} and + + + runtime_id = ${runtimeId} and + + + topic_id = ${topicId} and + + + group_id = ${groupId} and + + + queue_id = ${queueId} and + + + subscription_id = ${subscriptionId} and + + re >= ${startTime} and re < ${endTime} + + group by ([${startTime}, ${endTime}), ${interval}) + + + , organization_id + + + , cluster_id + + + , runtime_id + + + , topic_id + + + , group_id + + + , queue_id + + + , subscription_id + + + """; + + @Override + protected void doInit() { + TableSessionPoolBuilder tableSessionPoolBuilder = new TableSessionPoolBuilder(); + tableSessionPoolBuilder.nodeUrls(Arrays.stream(this.reportConfig.getEngineAddress().split(";")).toList()); + tableSessionPoolBuilder.maxSize(100); + tableSessionPoolBuilder.user("root"); + tableSessionPoolBuilder.password("root"); + tableSessionPoolBuilder.database("eventmesh_dashboard"); + + this.iTableSessionPool = tableSessionPoolBuilder.build(); + + + try{ + DruidDataSource dataSource = new DruidDataSource(); + dataSource.setUrl("jdbc:iotdb://127.0.0.1:6667/eventmesh_dashboard?sql_dialect=table"); + dataSource.setDriverClassName("org.apache.iotdb.jdbc.IoTDBDriver"); + dataSource.setUsername("root"); + dataSource.setPassword("root"); + dataSource.setMaxActive(200); + dataSource.setInitialSize(50); + dataSource.setMaxWait(1000*60*60*24); + dataSource.init(); + this.dataSource = dataSource; + }catch (Exception e) { + if(this.dataSource != null) { + this.dataSource.close(); + } + throw new RuntimeException(e); + } + } + + @Override + protected AbstractReportMetaHandler doCreateReportHandler(ReportMeta reportMeta, List fieldList) { + IotDBReportMetaHandler iotDBReportMetaHandler = new IotDBReportMetaHandler(); + iotDBReportMetaHandler.setReportMeta(reportMeta); + iotDBReportMetaHandler.setFieldList(fieldList); + return iotDBReportMetaHandler; + } + + @Override + public CompletableFuture>> query(SingleGeneralReportDO singleGeneralReportDO) { + return CompletableFuture.supplyAsync(() -> { + try (ITableSession session = this.iTableSessionPool.getSession()) { + String sql = this.buildSql(singleGeneralReportDO.getReportName(), singleGeneralReportDO.getReportType(), singleGeneralReportDO); + + try (SessionDataSet sds = session.executeQueryStatement(sql, 3000)) { + sds.getColumnNames(); + } + } catch (Exception e) { + throw new RuntimeException(e); + } + return null; + }); + + } + + @Override + public void createReport(String tableName) { + if(Objects.equals(tableName , "*")){ + this.getReportMetaHandlerMap().keySet().forEach(key -> { + String sql = this.buildSql(key, ReportViewType.CREATE_TABLE.getName(), null); + try (ITableSession session = this.iTableSessionPool.getSession()) { + Connection connection = this.dataSource.getConnection(); + connection.setAutoCommit(true); + connection.createStatement().execute(sql); + //session.executeNonQueryStatement(sql); + } catch (Exception e) { + throw new RuntimeException(e); + } + }); + return; + } + String sql = this.buildSql(tableName, ReportViewType.CREATE_TABLE.getName(), null); + try (ITableSession session = this.iTableSessionPool.getSession()) { + Connection connection = this.dataSource.getConnection(); + connection.setAutoCommit(true); + connection.createStatement().execute(sql); + //session.executeNonQueryStatement(sql); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + @Override + public void batchInsert(String tableName, List data) { + String sql = this.buildSql(tableName, ReportViewType.INSERT.getName(), (Object) data); + try (ITableSession session = this.iTableSessionPool.getSession()) { + Connection connection = this.dataSource.getConnection(); + connection.setAutoCommit(true); + connection.prepareStatement(sql).execute(); + //session.executeNonQueryStatement(sql); + } catch (Exception e) { + throw new RuntimeException(e); + } + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/iotdb/IotDBReportMetaHandler.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/iotdb/IotDBReportMetaHandler.java new file mode 100644 index 00000000..d1691074 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/iotdb/IotDBReportMetaHandler.java @@ -0,0 +1,159 @@ +/* + * 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.function.report.iotdb; + +import org.apache.eventmesh.dashboard.console.function.report.annotation.AbstractReportMetaHandler; + +import java.lang.reflect.Field; +import java.time.LocalDateTime; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +import com.google.common.base.CaseFormat; + +public class IotDBReportMetaHandler extends AbstractReportMetaHandler { + + + public String insert() { + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append("insert into "); + stringBuilder.append(this.reportMeta.tableName()); + stringBuilder.append(" ("); + this.fieldList.forEach(field -> { + String key = CaseFormat.LOWER_CAMEL.to(com.google.common.base.CaseFormat.LOWER_UNDERSCORE, field.getName()); + stringBuilder.append(key).append(","); + }); + stringBuilder.deleteCharAt(stringBuilder.length() - 1).append(" ) values \r\n"); + stringBuilder.append(" \r\n ("); + this.fieldList.forEach(field -> { + if(field.getName().endsWith("Id") || !(Number.class.isAssignableFrom(field.getType()))){ + stringBuilder.append("'${item.").append(field.getName()).append("}'"); + }else { + stringBuilder.append("${item.").append(field.getName()).append("}"); + } + + stringBuilder.append(","); + }); + stringBuilder.deleteCharAt(stringBuilder.length() - 1).append(")\r\n").append(" "); + return stringBuilder.toString(); + } + + public String query(String type) { + Map map = new HashMap<>(); + this.fieldList.forEach(field -> { + map.put(field.getName(), field); + }); + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append("select ") + .append("\r\n date_bin(${_parameter.interval}, time) as time , ") + .append("\r\n time , "); + stringBuilder.append("\r\n "); + this.fieldList.forEach(field -> { + String filedName = field.getName(); + if(Objects.equals(filedName,"time")){ + return; + } + String key = CaseFormat.LOWER_CAMEL.to(com.google.common.base.CaseFormat.LOWER_UNDERSCORE, filedName); + if (filedName.startsWith("value")) { + stringBuilder.append("\r\n ,").append(key).append("") + .append("\r\n ,${_parameter.selectFun}(").append(key).append(")"); + } else if (key.endsWith("_id")) { + stringBuilder.append("\r\n "); + stringBuilder.append(" ,") + .append(key).append(',').append(key.replace("id", "name")); + String typeField = filedName.replace("Id","Type"); + if(map.containsKey(typeField)){ + stringBuilder.append(",").append(key.replace("id", "type")); + } + stringBuilder.append(" "); + }else { + if (key.endsWith("_name")) { + return; + } +// stringBuilder.append("\r\n ,"); +// stringBuilder.append(key); + } + }); + stringBuilder.append("\r\n "); + stringBuilder.append("\r\nfrom ").append(this.reportMeta.tableName()).append("\r\n where \r\n") + .append(" time > ${startTime} and time < ${endTime} \r\n"); + this.fieldList.forEach(field -> { + String filedName = field.getName(); + if (filedName.endsWith("Id")) { + String key = CaseFormat.LOWER_CAMEL.to(com.google.common.base.CaseFormat.LOWER_UNDERSCORE, filedName); + stringBuilder.append("\r\n ").append(" and "). + append(key).append("='${_parameter.").append(field.getName()).append("}' "); + } + }); + stringBuilder.append("\r\n "); + stringBuilder.append("\r\n group by time, \r\n "); + this.fieldList.forEach(field -> { + String filedName = field.getName(); + String key = CaseFormat.LOWER_CAMEL.to(com.google.common.base.CaseFormat.LOWER_UNDERSCORE, filedName); + if (filedName.endsWith("Id")) { + stringBuilder.append("\r\n "); + stringBuilder.append(",") + .append(key).append(" , ").append(key.replace("id", "name")); + String typeField = filedName.replace("Id","Type"); + if(map.containsKey(typeField)){ + stringBuilder.append(",").append(key.replace("id", "type")); + } + stringBuilder.append(" "); + } + }); + stringBuilder.append("\r\n ").append("\r\n "); + return stringBuilder.toString(); + } + + public String createTable() { + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append("create table "); + stringBuilder.append(this.reportMeta.tableName()); + stringBuilder.append(" (\r\n "); + this.fieldList.forEach(field -> { + String filedName = field.getName(); + String key = CaseFormat.LOWER_CAMEL.to(com.google.common.base.CaseFormat.LOWER_UNDERSCORE, filedName); + stringBuilder.append(key); + if (field.getType() == long.class || field.getType() == Long.class) { + stringBuilder.append(key.endsWith("_id") ? " string " : " int64 "); + } else if (field.getType() == float.class || field.getType() == Float.class) { + stringBuilder.append(" float "); + } else if (field.getType() == String.class) { + stringBuilder.append(" string "); + } else if (field.getType() == LocalDateTime.class) { + stringBuilder.append(" timestamp "); + } + + if (Objects.equals(filedName, "time")) { + stringBuilder.append(" time,"); + } else if (filedName.endsWith("Id")) { + stringBuilder.append(" tag,"); + } else if (filedName.startsWith("value")) { + stringBuilder.append(" field,"); + + } else { + stringBuilder.append(" attribute,"); + } + stringBuilder.append("\r\n "); + }); + stringBuilder.deleteCharAt(stringBuilder.length() - 7); + stringBuilder.append(")comment ' ").append(reportMeta.comment()).append("'"); + return stringBuilder.toString(); + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/GeneralReportDO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/GeneralReportDO.java new file mode 100644 index 00000000..745a5578 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/GeneralReportDO.java @@ -0,0 +1,67 @@ +/* + * 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.function.report.model; + +import java.time.LocalDateTime; + +import lombok.Data; + +@Data +public class GeneralReportDO { + + private Long organizationId; + + private Long clustersId; + + private String reportName; + + private String reportType; + + private Long runtimeId; + + private String runtimeType; + + private Long topicId; + + private Long groupId; + + /** + * 查询条件 与 分组条件 + */ + private LocalDateTime startTime; + + /** + * 查询条件 与 分组条件 + */ + private LocalDateTime endTime; + + /** + * 分组的时间间隔 + */ + private String interval; + + private String selectFun; + + /** + * + */ + private String orderFun; + + + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/MultiGeneralReportDO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/MultiGeneralReportDO.java new file mode 100644 index 00000000..4241e150 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/MultiGeneralReportDO.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.function.report.model; + +import java.util.List; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class MultiGeneralReportDO extends GeneralReportDO { + + + private List reportNameList; + + + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/StoreEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/SingleGeneralReportDO.java similarity index 62% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/StoreEntity.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/SingleGeneralReportDO.java index a8046f83..5352402d 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/StoreEntity.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/SingleGeneralReportDO.java @@ -6,7 +6,7 @@ * (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 + * 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, @@ -15,38 +15,25 @@ * limitations under the License. */ - -package org.apache.eventmesh.dashboard.console.entity; - +package org.apache.eventmesh.dashboard.console.function.report.model; import lombok.Data; import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = true) -@Deprecated -public class StoreEntity extends BaseEntity { - - private Long clusterId; +public class SingleGeneralReportDO extends GeneralReportDO { /** - * @see org.apache.eventmesh.dashboard.common.enums.StoreType + * 二级维度,是在原有的数据上进行整理。 + * 对 order 与 分页,不关系 */ - private Integer storeType; - - private String host; - - private String topicList; - - private Short diffType; - - private Integer port; + private String twoLevelGroup; - private Integer jmxPort; + private String order; - private String rack; + private Integer limit; - private String endpointMap; + private Integer offset; - private Long startTimestamp; } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/base/ClusterId.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/base/ClusterId.java new file mode 100644 index 00000000..16cfff11 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/base/ClusterId.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.function.report.model.base; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class ClusterId extends OrganizationId { + + + private Long clustersId; + + private String clustersName; + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/base/GroupId.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/base/GroupId.java new file mode 100644 index 00000000..e81f9283 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/base/GroupId.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.function.report.model.base; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class GroupId extends RuntimeId{ + + + private Long groupId; + + private String groupName; + + @Data + @EqualsAndHashCode(callSuper = true) + public static class GroupLongValue extends GroupId{ + + private Long value; + + } + + @Data + @EqualsAndHashCode(callSuper = true) + public static class GroupFloatValue extends GroupId{ + + private Float value; + + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/base/OrganizationId.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/base/OrganizationId.java new file mode 100644 index 00000000..fc3669f2 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/base/OrganizationId.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.eventmesh.dashboard.console.function.report.model.base; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class OrganizationId extends Time { + + private Long organizationId; + + private String organizationName; + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/base/RuntimeId.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/base/RuntimeId.java new file mode 100644 index 00000000..c1a3767e --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/base/RuntimeId.java @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.eventmesh.dashboard.console.function.report.model.base; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class RuntimeId extends ClusterId{ + + private Long runtimeId; + + private String runtimeName; + + private String runtimeType; + + + @Data + @EqualsAndHashCode(callSuper = true) + public static class RuntimeLongValue extends RuntimeId{ + + private Long value; + + } + + @Data + @EqualsAndHashCode(callSuper = true) + public static class RuntimeFloatValue extends RuntimeId{ + + private Float value; + + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/base/SubscribeId.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/base/SubscribeId.java new file mode 100644 index 00000000..9031566b --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/base/SubscribeId.java @@ -0,0 +1,51 @@ +/* + * 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.function.report.model.base; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class SubscribeId extends RuntimeId{ + + private Long topicId; + + private String topicName; + + private Long groupId; + + private String groupName; + + + @Data + @EqualsAndHashCode(callSuper = true) + public static class LongValue extends SubscribeId{ + + private Long value; + + } + + @Data + @EqualsAndHashCode(callSuper = true) + public static class FloatValue extends SubscribeId{ + + private Float value; + + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/base/Time.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/base/Time.java new file mode 100644 index 00000000..587e31b2 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/base/Time.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.eventmesh.dashboard.console.function.report.model.base; + +import java.time.LocalDateTime; + +import lombok.Data; + +@Data +public class Time { + + private LocalDateTime time; + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/base/TopicId.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/base/TopicId.java new file mode 100644 index 00000000..f6479499 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/base/TopicId.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.function.report.model.base; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +public class TopicId extends RuntimeId{ + + + private Long topicId; + + private String topicName; + + @Data + @EqualsAndHashCode(callSuper = true) + public static class TopicLongValue extends TopicId{ + + private Long value; + + } + + @Data + @EqualsAndHashCode(callSuper = true) + public static class TopicFloatValue extends TopicId{ + + private Float value; + + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/metrics/AbstractMetricsDO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/metrics/AbstractMetricsDO.java new file mode 100644 index 00000000..2c29cfd6 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/metrics/AbstractMetricsDO.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.function.report.model.metrics; + +import org.apache.eventmesh.dashboard.console.modle.vo.RuntimeIdDTO; + +import java.time.LocalDateTime; + +import lombok.Data; +import lombok.EqualsAndHashCode; + + +@Data +@EqualsAndHashCode(callSuper = true) +public class AbstractMetricsDO extends RuntimeIdDTO { + + private String clusterName; + + private String runtimeName; + + private String runtimeType; + + private Long groupId; + + private String groupName; + + private Long subscribeId; + + private Long topicId; + + private String topicName; + + private String topicType; + + private LocalDateTime recordTime; + + private Long value; + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/metrics/InputMetricsDO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/metrics/InputMetricsDO.java new file mode 100644 index 00000000..a0b74268 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/metrics/InputMetricsDO.java @@ -0,0 +1,52 @@ +/* + * 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.function.report.model.metrics; + +import java.time.LocalDateTime; + +public class InputMetricsDO { + + private Long organizationId; + + private Long clusterId; + + private String clusterName; + + private Long runtimeId; + + private String runtimeName; + + private String runtimeType; + + private Long groupId; + + private String groupName; + + private Long subscribeId; + + private Long topicId; + + private String topicName; + + private String topicType; + + private LocalDateTime recordTime; + + private Long value; + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqConsumerGroupCreateExecutionTime.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqConsumerGroupCreateExecutionTime.java new file mode 100644 index 00000000..421f0ef1 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqConsumerGroupCreateExecutionTime.java @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.eventmesh.dashboard.console.function.report.model.rocketmq; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.console.function.report.ReportViewType; +import org.apache.eventmesh.dashboard.console.function.report.annotation.ReportMeta; +import org.apache.eventmesh.dashboard.console.function.report.model.base.RuntimeId; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +@ReportMeta(clusterType = ClusterType.STORAGE_ROCKETMQ, reportName = "rocketmq_consumer_group_create_execution_time", + defaultViewType = ReportViewType.HISTOGRAM, tableName = "rocketmq_consumer_group_create_execution_time", + comment = "创建消费者组执行耗时") +public class RocketmqConsumerGroupCreateExecutionTime extends RuntimeId { + + private String invocationStatus; + + private Long valueLe10ms; + + private Long valueLe100ms; + + private Long valueLe1s; + + private Long valueLe3s; + + private Long valueLe5s; + + private Long valueLeOverflow; + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqConsumerGroupNumber.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqConsumerGroupNumber.java new file mode 100644 index 00000000..a55c23a5 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqConsumerGroupNumber.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.eventmesh.dashboard.console.function.report.model.rocketmq; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.console.function.report.ReportViewType; +import org.apache.eventmesh.dashboard.console.function.report.annotation.ReportMeta; +import org.apache.eventmesh.dashboard.console.function.report.model.base.RuntimeId.RuntimeLongValue; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +@ReportMeta(clusterType = ClusterType.STORAGE_ROCKETMQ, reportName = "rocketmq_consumer_group_number", + defaultViewType = ReportViewType.GAUGE, tableName = "rocketmq_consumer_group_number", + comment = "消费者组数量") +public class RocketmqConsumerGroupNumber extends RuntimeLongValue { + +} + diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqConsumerInflightMessages.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqConsumerInflightMessages.java new file mode 100644 index 00000000..8870378e --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqConsumerInflightMessages.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.eventmesh.dashboard.console.function.report.model.rocketmq; + + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.console.function.report.ReportViewType; +import org.apache.eventmesh.dashboard.console.function.report.annotation.ReportMeta; +import org.apache.eventmesh.dashboard.console.function.report.model.base.SubscribeId.LongValue; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +@ReportMeta(clusterType = ClusterType.STORAGE_ROCKETMQ, reportName = "rocketmq_consumer_inflight_messages", + defaultViewType = ReportViewType.GAUGE, tableName = "rocketmq_consumer_inflight_messages", + comment = "处理中消息量") +public class RocketmqConsumerInflightMessages extends LongValue { + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqConsumerLagLatency.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqConsumerLagLatency.java new file mode 100644 index 00000000..a254a4f7 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqConsumerLagLatency.java @@ -0,0 +1,30 @@ +/* + * 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.function.report.model.rocketmq; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.console.function.report.ReportViewType; +import org.apache.eventmesh.dashboard.console.function.report.annotation.ReportMeta; +import org.apache.eventmesh.dashboard.console.function.report.model.base.SubscribeId.LongValue; + +@ReportMeta(clusterType = ClusterType.STORAGE_ROCKETMQ, reportName = "rocketmq_consumer_lag_latency", + defaultViewType = ReportViewType.GAUGE, tableName = "rocketmq_consumer_lag_latency", + comment = "消费处理延迟时间") +public class RocketmqConsumerLagLatency extends LongValue { + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqConsumerQueueingLatency.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqConsumerQueueingLatency.java new file mode 100644 index 00000000..3bd8ce9f --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqConsumerQueueingLatency.java @@ -0,0 +1,30 @@ +/* + * 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.function.report.model.rocketmq; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.console.function.report.ReportViewType; +import org.apache.eventmesh.dashboard.console.function.report.annotation.ReportMeta; +import org.apache.eventmesh.dashboard.console.function.report.model.base.SubscribeId.LongValue; + +@ReportMeta(clusterType = ClusterType.STORAGE_ROCKETMQ, reportName = "rocketmq_consumer_queueing_latency", + defaultViewType = ReportViewType.GAUGE, tableName = "rocketmq_consumer_queueing_latency", + comment = "已就绪消息排队延迟时间") +public class RocketmqConsumerQueueingLatency extends LongValue { + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqConsumerReadyMessages.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqConsumerReadyMessages.java new file mode 100644 index 00000000..29389f16 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqConsumerReadyMessages.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.eventmesh.dashboard.console.function.report.model.rocketmq; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.console.function.report.ReportViewType; +import org.apache.eventmesh.dashboard.console.function.report.annotation.ReportMeta; +import org.apache.eventmesh.dashboard.console.function.report.model.base.SubscribeId; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +@ReportMeta(clusterType = ClusterType.STORAGE_ROCKETMQ, reportName = "rocketmq_consumer_ready_messages", + defaultViewType = ReportViewType.GAUGE, tableName = "rocketmq_consumer_ready_messages", + comment = "已就绪消息量") +public class RocketmqConsumerReadyMessages extends SubscribeId { + + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqMessageSize.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqMessageSize.java new file mode 100644 index 00000000..267eb12c --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqMessageSize.java @@ -0,0 +1,52 @@ +/* + * 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.function.report.model.rocketmq; + + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.console.function.report.ReportViewType; +import org.apache.eventmesh.dashboard.console.function.report.annotation.ReportMeta; +import org.apache.eventmesh.dashboard.console.function.report.model.base.TopicId; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +@ReportMeta(clusterType = ClusterType.STORAGE_ROCKETMQ, reportName = "rocketmq_message_size", + defaultViewType = ReportViewType.HISTOGRAM, tableName = "rocketmq_message_size", + comment = "消息大小的分布情况,发送成功时统计") +public class RocketmqMessageSize extends TopicId { + + private String messageType; + + private Float le1kb; + + private Float le4kb; + + private Float le512kb; + + private Float le1mb; + + private Float le2mb; + + private Float le4mb; + + private Float leOverflow; + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqMessagesInTotal.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqMessagesInTotal.java new file mode 100644 index 00000000..292b9112 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqMessagesInTotal.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.function.report.model.rocketmq; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.console.function.report.ReportViewType; +import org.apache.eventmesh.dashboard.console.function.report.annotation.ReportMeta; +import org.apache.eventmesh.dashboard.console.function.report.model.base.TopicId.TopicLongValue; + +import lombok.Data; +import lombok.EqualsAndHashCode; + + +@Data +@EqualsAndHashCode(callSuper = true) +@ReportMeta(clusterType = ClusterType.STORAGE_ROCKETMQ, reportName = "rocketmq_messages_in_total", + defaultViewType = ReportViewType.GAUGE, tableName = "rocketmq_messages_in_total", + comment = "消息生产数量") +public class RocketmqMessagesInTotal extends TopicLongValue { + + private String messageType; + + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqMessagesOutTotal.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqMessagesOutTotal.java new file mode 100644 index 00000000..ef8cffaa --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqMessagesOutTotal.java @@ -0,0 +1,41 @@ +/* + * 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.function.report.model.rocketmq; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.console.function.report.ReportViewType; +import org.apache.eventmesh.dashboard.console.function.report.annotation.ReportMeta; +import org.apache.eventmesh.dashboard.console.function.report.model.base.SubscribeId; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +@ReportMeta(clusterType = ClusterType.STORAGE_ROCKETMQ, reportName = "rocketmq_messages_out_total", + defaultViewType = ReportViewType.COUNTER, tableName = "rocketmq_messages_out_total", + comment = "已就绪消息量") +public class RocketmqMessagesOutTotal extends SubscribeId { + + private Long topicNum; + + private Long minOffset; + + private Long maxOffset; + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqRpcLatency.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqRpcLatency.java new file mode 100644 index 00000000..ec72e170 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqRpcLatency.java @@ -0,0 +1,58 @@ +/* + * 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.function.report.model.rocketmq; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.console.function.report.ReportViewType; +import org.apache.eventmesh.dashboard.console.function.report.annotation.ReportMeta; +import org.apache.eventmesh.dashboard.console.function.report.model.base.SubscribeId.LongValue; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +@ReportMeta(clusterType = ClusterType.STORAGE_ROCKETMQ, reportName = "rocketmq_rpc_latency", + defaultViewType = ReportViewType.HISTOGRAM, tableName = "rocketmq_rpc_latency", + comment = "rpc 调用耗时") +public class RocketmqRpcLatency extends LongValue { + + + private String protocolType; + + private String requestCode; + + private String responseCode; + + private Long le1ms; + + private Long le3ms; + + private Long le5ms; + + private Long le10ms; + + private Long le100ms; + + private Long le1s; + + private Long le3s; + + private Long leOverflow; + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqSendToDlqMessagesTotal.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqSendToDlqMessagesTotal.java new file mode 100644 index 00000000..81ebf752 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqSendToDlqMessagesTotal.java @@ -0,0 +1,30 @@ +/* + * 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.function.report.model.rocketmq; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.console.function.report.ReportViewType; +import org.apache.eventmesh.dashboard.console.function.report.annotation.ReportMeta; +import org.apache.eventmesh.dashboard.console.function.report.model.base.SubscribeId.LongValue; + +@ReportMeta(clusterType = ClusterType.STORAGE_ROCKETMQ, reportName = "rocketmq_send_to_dlq_messages_total", + defaultViewType = ReportViewType.COUNTER, tableName = "rocketmq_send_to_dlq_messages_total", + comment = "处理中消息量") +public class RocketmqSendToDlqMessagesTotal extends LongValue { + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqStorageDispatchBehindBytes.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqStorageDispatchBehindBytes.java new file mode 100644 index 00000000..7155f6c9 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqStorageDispatchBehindBytes.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.eventmesh.dashboard.console.function.report.model.rocketmq; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.console.function.report.ReportViewType; +import org.apache.eventmesh.dashboard.console.function.report.annotation.ReportMeta; +import org.apache.eventmesh.dashboard.console.function.report.model.base.RuntimeId.RuntimeLongValue; + +@ReportMeta(clusterType = ClusterType.STORAGE_ROCKETMQ, reportName = "rocketmq_storage_dispatch_behind_bytes", + defaultViewType = ReportViewType.GAUGE, tableName = "rocketmq_storage_dispatch_behind_bytes", + comment = "dispatch 落后大小") +public class RocketmqStorageDispatchBehindBytes extends RuntimeLongValue { + + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqStorageFlushBehindBytes.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqStorageFlushBehindBytes.java new file mode 100644 index 00000000..31ecf4ab --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqStorageFlushBehindBytes.java @@ -0,0 +1,30 @@ +/* + * 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.function.report.model.rocketmq; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.console.function.report.ReportViewType; +import org.apache.eventmesh.dashboard.console.function.report.annotation.ReportMeta; +import org.apache.eventmesh.dashboard.console.function.report.model.base.RuntimeId.RuntimeLongValue; + +@ReportMeta(clusterType = ClusterType.STORAGE_ROCKETMQ, reportName = "rocketmq_storage_flush_behind_bytes", + defaultViewType = ReportViewType.GAUGE, tableName = "rocketmq_storage_flush_behind_bytes", + comment = "刷盘落后大小") +public class RocketmqStorageFlushBehindBytes extends RuntimeLongValue { + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqStorageMessageReserveTime.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqStorageMessageReserveTime.java new file mode 100644 index 00000000..be9096b9 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqStorageMessageReserveTime.java @@ -0,0 +1,30 @@ +/* + * 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.function.report.model.rocketmq; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.console.function.report.ReportViewType; +import org.apache.eventmesh.dashboard.console.function.report.annotation.ReportMeta; +import org.apache.eventmesh.dashboard.console.function.report.model.base.RuntimeId; + +@ReportMeta(clusterType = ClusterType.STORAGE_ROCKETMQ, reportName = "rocketmq_storage_message_reserve_time", + defaultViewType = ReportViewType.GAUGE, tableName = "rocketmq_storage_message_reserve_time", + comment = "储存层消息保存时间") +public class RocketmqStorageMessageReserveTime extends RuntimeId { + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqThreadPoolWartermark.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqThreadPoolWartermark.java new file mode 100644 index 00000000..d3e87205 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqThreadPoolWartermark.java @@ -0,0 +1,30 @@ +/* + * 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.function.report.model.rocketmq; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.console.function.report.ReportViewType; +import org.apache.eventmesh.dashboard.console.function.report.annotation.ReportMeta; +import org.apache.eventmesh.dashboard.console.function.report.model.base.RuntimeId.RuntimeLongValue; + +@ReportMeta(clusterType = ClusterType.STORAGE_ROCKETMQ, reportName = "rocketmq_thread_pool_wartermark", + defaultViewType = ReportViewType.GAUGE, tableName = "rocketmq_thread_pool_wartermark", + comment = "线程池排队数") +public class RocketmqThreadPoolWartermark extends RuntimeLongValue { + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqThroughputInTotal.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqThroughputInTotal.java new file mode 100644 index 00000000..36cf15e1 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqThroughputInTotal.java @@ -0,0 +1,35 @@ +/* + * 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.function.report.model.rocketmq; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.console.function.report.ReportViewType; +import org.apache.eventmesh.dashboard.console.function.report.annotation.ReportMeta; +import org.apache.eventmesh.dashboard.console.function.report.model.base.SubscribeId.LongValue; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +@ReportMeta(clusterType = ClusterType.STORAGE_ROCKETMQ, reportName = "rocketmq_throughput_in_total", + defaultViewType = ReportViewType.COUNTER, tableName = "rocketmq_throughput_in_total", + comment = "消息生产流入服务端的吞吐量") +public class RocketmqThroughputInTotal extends LongValue { + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqThroughputOutTotal.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqThroughputOutTotal.java new file mode 100644 index 00000000..d27c3f47 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqThroughputOutTotal.java @@ -0,0 +1,35 @@ +/* + * 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.function.report.model.rocketmq; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.console.function.report.ReportViewType; +import org.apache.eventmesh.dashboard.console.function.report.annotation.ReportMeta; +import org.apache.eventmesh.dashboard.console.function.report.model.base.SubscribeId.LongValue; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +@ReportMeta(clusterType = ClusterType.STORAGE_ROCKETMQ, reportName = "rocketmq_throughput_out_total", + defaultViewType = ReportViewType.COUNTER, tableName = "rocketmq_throughput_out_total", + comment = "消息消费从服务端流出的吞吐量") +public class RocketmqThroughputOutTotal extends LongValue { + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqTopicCreateExecutionTime.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqTopicCreateExecutionTime.java new file mode 100644 index 00000000..dbcf8939 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqTopicCreateExecutionTime.java @@ -0,0 +1,51 @@ +/* + * 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.function.report.model.rocketmq; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.console.function.report.ReportViewType; +import org.apache.eventmesh.dashboard.console.function.report.annotation.ReportMeta; +import org.apache.eventmesh.dashboard.console.function.report.model.base.RuntimeId; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +@ReportMeta(clusterType = ClusterType.STORAGE_ROCKETMQ, reportName = "rocketmq_topic_create_execution_time", + defaultViewType = ReportViewType.HISTOGRAM, tableName = "rocketmq_topic_create_execution_time", + comment = "创建主题执行耗时") +public class RocketmqTopicCreateExecutionTime extends RuntimeId { + + private String invocationStatus; + + private boolean isSystem; + + private Long valueLe10ms; + + private Long valueLe100ms; + + private Long valueLe1s; + + private Long valueLe3s; + + private Long valueLe5s; + + private Long valueLeOverflow; + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqTopicNumber.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqTopicNumber.java new file mode 100644 index 00000000..a6b10ae7 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqTopicNumber.java @@ -0,0 +1,30 @@ +/* + * 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.function.report.model.rocketmq; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.console.function.report.ReportViewType; +import org.apache.eventmesh.dashboard.console.function.report.annotation.ReportMeta; +import org.apache.eventmesh.dashboard.console.function.report.model.base.RuntimeId.RuntimeLongValue; + +@ReportMeta(clusterType = ClusterType.STORAGE_ROCKETMQ, reportName = "rocketmq_topic_number", + defaultViewType = ReportViewType.GAUGE, tableName = "rocketmq_topic_number", + comment = "主题数量") +public class RocketmqTopicNumber extends RuntimeLongValue { + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/opensearch/OpensearchReportEngine.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/opensearch/OpensearchReportEngine.java new file mode 100644 index 00000000..f7d4f48e --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/opensearch/OpensearchReportEngine.java @@ -0,0 +1,133 @@ +/* + * 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.function.report.opensearch; + + +import org.apache.eventmesh.dashboard.console.function.report.AbstractReportEngine; +import org.apache.eventmesh.dashboard.console.function.report.annotation.AbstractReportMetaHandler; +import org.apache.eventmesh.dashboard.console.function.report.annotation.ReportMeta; +import org.apache.eventmesh.dashboard.console.function.report.model.SingleGeneralReportDO; + +import org.apache.http.Header; +import org.apache.http.HttpHost; +import org.apache.http.message.BasicHeader; + +import java.io.IOException; +import java.lang.reflect.Field; +import java.net.MalformedURLException; +import java.net.URL; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.List; +import java.util.Map; +import java.util.TimeZone; +import java.util.concurrent.CompletableFuture; + +import org.opensearch.client.RestClient; +import org.opensearch.client.json.jackson.JacksonJsonpMapper; +import org.opensearch.client.opensearch.OpenSearchClient; +import org.opensearch.client.opensearch._types.Script; +import org.opensearch.client.opensearch.core.BulkRequest; +import org.opensearch.client.opensearch.core.ScriptsPainlessExecuteRequest; +import org.opensearch.client.transport.OpenSearchTransport; +import org.opensearch.client.transport.rest_client.RestClientTransport; + +import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer; +import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; + +public class OpensearchReportEngine extends AbstractReportEngine { + + private OpenSearchClient client; + + + public void handler() throws IOException { + ScriptsPainlessExecuteRequest.Builder builder = new ScriptsPainlessExecuteRequest.Builder(); + Script.Builder script = new Script.Builder(); + + //script.source(scriptSourceBuilder.build()); + //builder.script(script.build()); + + //client.scriptsPainlessExecute(builder.build()); + } + + @Override + protected void doInit() { + try { + URL url = new URL(this.reportConfig.getEngineAddress()); + HttpHost httpHost = new HttpHost(url.getHost(), url.getPort(),url.getProtocol()); + RestClient restClient = RestClient.builder(httpHost) + .setDefaultHeaders(new Header[] { + new BasicHeader("Accept", "application/json"), + new BasicHeader("Content-Type", "application/json") + }).build(); + final OpenSearchTransport transport = new RestClientTransport(restClient, this.createMapper()); + client = new OpenSearchClient(transport); + } catch (MalformedURLException e) { + throw new RuntimeException(e); + } + } + + @Override + protected AbstractReportMetaHandler doCreateReportHandler(ReportMeta reportMeta, List fieldList) { + return null; + } + + public JacksonJsonpMapper createMapper() { + JacksonJsonpMapper jacksonJsonpMapper = new JacksonJsonpMapper(); + // 注册Java8时间模块 + JavaTimeModule module = new JavaTimeModule(); + // 配置序列化格式 + module.addSerializer(LocalDateTime.class, + new LocalDateTimeSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); + module.addDeserializer(LocalDateTime.class, + new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); + jacksonJsonpMapper.objectMapper().registerModule(module); + + // 禁用时间戳格式 + jacksonJsonpMapper.objectMapper().disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); + // 设置时区 + jacksonJsonpMapper.objectMapper().setTimeZone(TimeZone.getTimeZone("GMT+8")); + return jacksonJsonpMapper; + } + + @Override + public CompletableFuture>> query(SingleGeneralReportDO singleGeneralReportDO) { + return null; + } + + @Override + public void createReport(String tableName) { + + } + + @Override + public void batchInsert(String tableName, List data) { + BulkRequest.Builder bulkRequestBuilder = new BulkRequest.Builder(); +// try { +// data.forEach((k, v) -> { +// bulkRequestBuilder.operations((op) -> op +// .index(idx -> idx.index(tableName).id(k).document(v))); +// }); +// this.client.bulk(bulkRequestBuilder.build()); +// } catch (IOException e) { +// throw new RuntimeException(e); +// } + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/RuntimeMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/RuntimeMapper.java index f2f7a3fb..921ce5b1 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/RuntimeMapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/cluster/RuntimeMapper.java @@ -121,7 +121,7 @@ select relationship_id from cluster_relationship where cluster_id in( @Select("select COUNT(*) from runtime where cluster_id=#{clusterId} AND status=1") Integer getRuntimeNumByCluster(RuntimeEntity runtimeEntity); - @Select("select * from runtime where update_time = #{updateTime} and status=1") + @Select("select * from runtime where update_time >= #{updateTime} and status=1") List queryByUpdateTime(RuntimeEntity runtimeEntity); diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/function/ConfigMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/function/ConfigMapper.java index ce1542d6..d98742c4 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/function/ConfigMapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/function/ConfigMapper.java @@ -36,30 +36,23 @@ @Mapper public interface ConfigMapper extends SyncDataHandlerMapper { - @Select({ - ""}) + @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(); @@ -67,16 +60,19 @@ public interface ConfigMapper extends SyncDataHandlerMapper { @Select("SELECT * FROM config WHERE instance_type=#{instanceType} AND instance_id=#{instanceId}") List selectConfigsByInstance(ConfigEntity configEntity); - @Insert({ - ""}) + @Insert(""" + + """) @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") void batchInsert(List configEntityList); diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/message/GroupMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/message/GroupMapper.java index 8b6130d0..3863b8de 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/message/GroupMapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/message/GroupMapper.java @@ -19,6 +19,7 @@ package org.apache.eventmesh.dashboard.console.mapper.message; import org.apache.eventmesh.dashboard.console.entity.message.GroupEntity; +import org.apache.eventmesh.dashboard.console.entity.message.TopicEntity; import org.apache.eventmesh.dashboard.console.mapper.SyncDataHandlerMapper; import org.apache.ibatis.annotations.Insert; @@ -35,6 +36,16 @@ @Mapper public interface GroupMapper extends SyncDataHandlerMapper { + + @Select(""" + select * from `group` where name in( + select group_name from group_member where topic_name = ( + select topic.topic_name from topic where id=#{id} + ) + ) + """) + List queryGroupListByTopicId(TopicEntity topicEntity); + @Select("SELECT * FROM `group` WHERE cluster_id=#{clusterId} AND name=#{name} AND type=0 ") GroupEntity selectGroupByNameAndClusterId(GroupEntity groupEntity); @@ -77,19 +88,24 @@ public interface GroupMapper extends SyncDataHandlerMapper { List selectGroup(GroupEntity groupEntity); - @Insert({ - ""}) + @Insert(""" + + """) @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") void batchInsert(List groupEntities); - @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") + @Insert(""" + + """) @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") void addGroup(GroupEntity groupEntity); diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/message/OprGroupMemberMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/message/GroupMemberMapper.java similarity index 84% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/message/OprGroupMemberMapper.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/message/GroupMemberMapper.java index 0e81b136..ae808e4a 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/message/OprGroupMemberMapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/message/GroupMemberMapper.java @@ -34,7 +34,7 @@ **/ @Mapper -public interface OprGroupMemberMapper { +public interface GroupMemberMapper { @Deprecated @@ -92,20 +92,24 @@ public interface OprGroupMemberMapper { @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") SubscriptionEntity deleteGroupMember(SubscriptionEntity subscriptionEntity); - @Insert({ - ""}) + @Insert(""" + + """) @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") void batchInsert(List groupMemberEntities); - @Insert("insert into group_member (cluster_id, topic_name, group_name, eventmesh_user,state)" - + " values (#{clusterId},#{topicName},#{groupName},#{eventMeshUser},#{state})" - + "ON DUPLICATE KEY UPDATE status=0") + @Insert(""" + insert into + group_member (organization_id , cluster_id, topic_name, group_name, eventmesh_user) + values (#{organizationId},#{clusterId},#{topicName},#{groupName},#{eventMeshUser}) + on duplicate key update status=0 + """) @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") void addGroupMember(SubscriptionEntity subscriptionEntity); diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/message/OffsetMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/message/OffsetMapper.java new file mode 100644 index 00000000..2e133c51 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/message/OffsetMapper.java @@ -0,0 +1,25 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.eventmesh.dashboard.console.mapper.message; + +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface OffsetMapper { + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/message/TopicMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/message/TopicMapper.java index 50703e74..48ccae5e 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/message/TopicMapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/message/TopicMapper.java @@ -88,10 +88,12 @@ public interface TopicMapper extends SyncDataHandlerMapper { @Insert(""" """) @@ -99,8 +101,10 @@ insert into topic (cluster_id, topic_name, retention_ms, topic_type, description void batchInsert(List topicEntities); @Insert(""" - insert into topic (cluster_id , topic_name , retention_ms , topic_type , description, create_progress) - values (#{clusterId} ,#{topicName},#{retentionMs},#{topicType},#{description},#{createProgress}) + insert into topic (cluster_id,runtime_id,topic_name,topic_type, read_queue_num, write_queue_num, replication_factor, + `order` , description, create_progress,retention_ms) + values (#{clusterId},#{runtimeId},#{topicName},#{topicType},#{readQueueNum},#{writeQueueNum},#{replicationFactor} + ,#{order},#{description},#{createProgress},#{retentionMs}) on duplicate key update status = 1 """) @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/agent/AgentActionControllerMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/agent/AgentActionControllerMapper.java new file mode 100644 index 00000000..2bc383dd --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/agent/AgentActionControllerMapper.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.eventmesh.dashboard.console.mapstruct.agent; + +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +@Mapper +public interface AgentActionControllerMapper { + + AgentActionControllerMapper INSTANCE = Mappers.getMapper(AgentActionControllerMapper.class); + + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/cluster/GroupControllerMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/cluster/GroupControllerMapper.java index 402692bf..abd88eca 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/cluster/GroupControllerMapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/cluster/GroupControllerMapper.java @@ -22,11 +22,13 @@ import org.apache.eventmesh.dashboard.console.modle.IdDTO; import org.apache.eventmesh.dashboard.console.modle.vo.RuntimeIdDTO; +import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; /** * */ +@Mapper public interface GroupControllerMapper { GroupControllerMapper INSTANCE = Mappers.getMapper(GroupControllerMapper.class); diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/message/ConfigControllerMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/message/ConfigControllerMapper.java new file mode 100644 index 00000000..1bcbec46 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/message/ConfigControllerMapper.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.mapstruct.message; + +import org.apache.eventmesh.dashboard.console.entity.function.ConfigEntity; +import org.apache.eventmesh.dashboard.console.modle.function.config.QueryByInstanceIdDTO; + +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +@Mapper +public interface ConfigControllerMapper { + + ConfigControllerMapper INSTANCE = Mappers.getMapper(ConfigControllerMapper.class); + + ConfigEntity queryByInstanceId(QueryByInstanceIdDTO queryByInstanceIdDTO); + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/message/TopicControllerMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/message/TopicControllerMapper.java index 19bfd5bf..9fa6c953 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/message/TopicControllerMapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/message/TopicControllerMapper.java @@ -24,11 +24,13 @@ import org.apache.eventmesh.dashboard.console.modle.dto.topic.GetTopicListDTO; import org.apache.eventmesh.dashboard.console.modle.vo.RuntimeIdDTO; +import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; /** * */ +@Mapper public interface TopicControllerMapper { TopicControllerMapper INSTANCE = Mappers.getMapper(TopicControllerMapper.class); diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/IdDTO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/IdDTO.java index a6e38089..10dd4270 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/IdDTO.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/IdDTO.java @@ -18,10 +18,13 @@ package org.apache.eventmesh.dashboard.console.modle; +import javax.validation.constraints.NotNull; + import lombok.Data; @Data public class IdDTO { + @NotNull private Long id; } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/cluster/QueryClusterByOrganizationIdAndTypeDTO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/cluster/QueryClusterByOrganizationIdAndTypeDTO.java index 31c34c48..3c72515d 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/cluster/QueryClusterByOrganizationIdAndTypeDTO.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/cluster/cluster/QueryClusterByOrganizationIdAndTypeDTO.java @@ -19,7 +19,7 @@ package org.apache.eventmesh.dashboard.console.modle.cluster.cluster; import org.apache.eventmesh.dashboard.common.enums.ClusterType; -import org.apache.eventmesh.dashboard.console.modle.ClusterIdDTO; +import org.apache.eventmesh.dashboard.console.modle.OrganizationIdDTO; import javax.validation.constraints.NotNull; @@ -28,7 +28,7 @@ @Data @EqualsAndHashCode(callSuper = true) -public class QueryClusterByOrganizationIdAndTypeDTO extends ClusterIdDTO { +public class QueryClusterByOrganizationIdAndTypeDTO extends OrganizationIdDTO { @NotNull private ClusterType clusterType; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/agent/AgentStartActionDTO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/agent/AgentStartActionDTO.java new file mode 100644 index 00000000..28f6d521 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/agent/AgentStartActionDTO.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.agent; + +import javax.validation.constraints.NotNull; + +import lombok.Data; + +@Data +public class AgentStartActionDTO { + + @NotNull + private Long clusterId; + + @NotNull + private Long runtimeId; + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/agent/AgentStartActionVO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/agent/AgentStartActionVO.java new file mode 100644 index 00000000..d3100782 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/dto/agent/AgentStartActionVO.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.eventmesh.dashboard.console.modle.dto.agent; + +import java.util.Map; + +import lombok.Data; + +@Data +public class AgentStartActionVO { + + private Map properties; + + private boolean wait; + +} 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 index 93b0c792..abc31842 100644 --- 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 @@ -18,6 +18,8 @@ package org.apache.eventmesh.dashboard.console.modle.dto.config; +import org.apache.eventmesh.dashboard.common.enums.MetadataType; + import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; @@ -31,7 +33,7 @@ public class GetConfigsListDTO { private Long instanceId; - private Integer instanceType; + private MetadataType instanceType; private String configName; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/DefaultConfigKey.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/function/config/QueryByInstanceIdDTO.java similarity index 73% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/DefaultConfigKey.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/function/config/QueryByInstanceIdDTO.java index 49d740e5..3f60a355 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/DefaultConfigKey.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/function/config/QueryByInstanceIdDTO.java @@ -6,7 +6,7 @@ * (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 + * 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, @@ -15,21 +15,19 @@ * limitations under the License. */ +package org.apache.eventmesh.dashboard.console.modle.function.config; -package org.apache.eventmesh.dashboard.console.entity; +import org.apache.eventmesh.dashboard.common.enums.MetadataType; - -import lombok.AllArgsConstructor; import lombok.Data; -import lombok.NoArgsConstructor; -@NoArgsConstructor -@AllArgsConstructor @Data -@Deprecated -public class DefaultConfigKey { +public class QueryByInstanceIdDTO { + + private Long instanceId; - private String businessType; + private MetadataType instanceType; private String configName; + } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/vo/RuntimeIdDTO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/vo/RuntimeIdDTO.java index 62fccd87..afc1ea56 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/vo/RuntimeIdDTO.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/vo/RuntimeIdDTO.java @@ -29,4 +29,6 @@ public class RuntimeIdDTO extends ClusterIdDTO { private Long runtimeId; + private String runtimeName; + } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/ConfigService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/ConfigService.java index 5b3ab842..76480894 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/ConfigService.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/ConfigService.java @@ -21,7 +21,6 @@ import org.apache.eventmesh.dashboard.console.entity.function.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; @@ -34,7 +33,7 @@ public interface ConfigService { List queryByClusterAndInstanceId(ConfigEntity configEntity); - List selectToFront(Long instanceId, Integer type, GetConfigsListDTO getConfigsListDTO); + List queryByInstanceId(ConfigEntity configEntity); void updateConfigsByInstanceId(String name, Long clusterId, Integer instanceType, Long instanceId, List changeConfigDTOList); diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/Impl/ConfigServiceImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/Impl/ConfigServiceImpl.java index 38b19c5b..3b95cd3e 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/Impl/ConfigServiceImpl.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/function/Impl/ConfigServiceImpl.java @@ -19,11 +19,9 @@ package org.apache.eventmesh.dashboard.console.service.function.Impl; import org.apache.eventmesh.dashboard.console.annotation.EmLog; -import org.apache.eventmesh.dashboard.console.entity.DefaultConfigKey; import org.apache.eventmesh.dashboard.console.entity.function.ConfigEntity; import org.apache.eventmesh.dashboard.console.mapper.function.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.function.ConfigService; @@ -46,7 +44,7 @@ public class ConfigServiceImpl implements ConfigService { @Autowired ConfigMapper configMapper; - private Map defaultConfigCache = new HashMap<>(); + private Map defaultConfigCache = new HashMap<>(); @EmLog(OprTarget = "Runtime", OprType = "UpdateConfigs") @@ -196,35 +194,15 @@ public List selectByInstanceIdAndType(Long instanceId, Integer typ return configMapper.selectByInstanceId(config); } - 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 List selectToFront(Long instanceId, Integer type, GetConfigsListDTO getConfigsListDTO) { - ConfigEntity config = new ConfigEntity(); - config.setInstanceId(instanceId); - config.setInstanceType(null); - config = this.setSearchCriteria(getConfigsListDTO, config); - return configMapper.getConfigsToFrontWithDynamic(config); + public List queryByInstanceId(ConfigEntity configEntity) { + return configMapper.getConfigsToFrontWithDynamic(configEntity); } public void addDefaultConfigToCache() { List configEntityList = configMapper.selectAllDefaultConfig(); configEntityList.forEach(n -> { - DefaultConfigKey defaultConfigKey = new DefaultConfigKey(n.getBusinessType(), n.getConfigName()); - defaultConfigCache.putIfAbsent(defaultConfigKey, n.getConfigValue()); }); } @@ -235,12 +213,7 @@ public Map selectDefaultConfig(String businessType, Long instanc this.addDefaultConfigToCache(); } ConcurrentHashMap stringStringConcurrentHashMap = new ConcurrentHashMap<>(); - defaultConfigCache.forEach((k, v) -> { - if (k.getBusinessType().equals(businessType)) { - stringStringConcurrentHashMap.put(k.getConfigName(), v); - } - }); - return stringStringConcurrentHashMap; + return null; } } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/GroupService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/GroupService.java index 3d5b7a12..1b4c3585 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/GroupService.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/GroupService.java @@ -19,7 +19,7 @@ package org.apache.eventmesh.dashboard.console.service.message; import org.apache.eventmesh.dashboard.console.entity.message.GroupEntity; -import org.apache.eventmesh.dashboard.console.entity.message.SubscriptionEntity; +import org.apache.eventmesh.dashboard.console.entity.message.TopicEntity; import java.util.List; @@ -29,26 +29,15 @@ public interface GroupService { - @Deprecated - List selectAll(); - void batchInsert(List groupEntities); + List queryGroupListByTopicId(TopicEntity topicEntity); List getGroupByClusterId(GroupEntity groupEntity); - void addGroup(GroupEntity groupEntity); + void batchInsert(List groupEntities); - @Deprecated - void updateGroup(GroupEntity groupEntity); + void addGroup(GroupEntity groupEntity); Integer deleteGroup(GroupEntity groupEntity); - @Deprecated - GroupEntity selectGroup(GroupEntity groupEntity); - - @Deprecated - Integer insertMemberToGroup(SubscriptionEntity subscriptionEntity); - - @Deprecated - Integer deleteMemberFromGroup(SubscriptionEntity subscriptionEntity); } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/OffsetService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/OffsetService.java new file mode 100644 index 00000000..d14ff3d9 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/OffsetService.java @@ -0,0 +1,22 @@ +/* + * 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.message; + +public interface OffsetService { + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/impl/GroupMemberServiceImp.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/impl/GroupMemberServiceImp.java index b3c6a80c..8bb8ff61 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/impl/GroupMemberServiceImp.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/impl/GroupMemberServiceImp.java @@ -21,7 +21,7 @@ import org.apache.eventmesh.dashboard.console.annotation.EmLog; import org.apache.eventmesh.dashboard.console.entity.message.GroupEntity; import org.apache.eventmesh.dashboard.console.entity.message.SubscriptionEntity; -import org.apache.eventmesh.dashboard.console.mapper.message.OprGroupMemberMapper; +import org.apache.eventmesh.dashboard.console.mapper.message.GroupMemberMapper; import org.apache.eventmesh.dashboard.console.service.message.GroupMemberService; import java.util.List; @@ -33,43 +33,43 @@ public class GroupMemberServiceImp implements GroupMemberService { @Autowired - OprGroupMemberMapper oprGroupMemberMapper; + GroupMemberMapper groupMemberMapper; @Override public List selectAll() { - return oprGroupMemberMapper.selectAll(); + return groupMemberMapper.selectAll(); } @Override public void batchInsert(List groupMemberEntities) { - oprGroupMemberMapper.batchInsert(groupMemberEntities); + groupMemberMapper.batchInsert(groupMemberEntities); } @Override @EmLog(OprType = "View", OprTarget = "GroupMember") public List getGroupMemberByClusterId(SubscriptionEntity subscriptionEntity) { - return oprGroupMemberMapper.getGroupByClusterId(subscriptionEntity); + return groupMemberMapper.getGroupByClusterId(subscriptionEntity); } @Override @EmLog(OprType = "add", OprTarget = "GroupMember") public void addGroupMember(SubscriptionEntity subscriptionEntity) { - oprGroupMemberMapper.addGroupMember(subscriptionEntity); + groupMemberMapper.addGroupMember(subscriptionEntity); } @Override public void updateGroupMember(SubscriptionEntity subscriptionEntity) { - oprGroupMemberMapper.updateGroupMember(subscriptionEntity); + groupMemberMapper.updateGroupMember(subscriptionEntity); } @Override public SubscriptionEntity deleteGroupMember(SubscriptionEntity subscriptionEntity) { - return oprGroupMemberMapper.deleteGroupMember(subscriptionEntity); + return groupMemberMapper.deleteGroupMember(subscriptionEntity); } @Override public SubscriptionEntity selectGroupMemberById(SubscriptionEntity subscriptionEntity) { - return oprGroupMemberMapper.selectGroupMemberById(subscriptionEntity); + return groupMemberMapper.selectGroupMemberById(subscriptionEntity); } @Override @@ -78,12 +78,12 @@ public List selectGroupMemberByGroup(GroupEntity groupEntity subscriptionEntity.setGroupName(groupEntity.getName()); subscriptionEntity.setClusterId(groupEntity.getClusterId()); //Obtain a member who meets the conditions of a group - return oprGroupMemberMapper.selectMember(subscriptionEntity); + return groupMemberMapper.selectMember(subscriptionEntity); } @Override public List selectAllMemberByTopic(SubscriptionEntity subscriptionEntity) { - List groupMemberEntities = oprGroupMemberMapper.selectMember(subscriptionEntity); + List groupMemberEntities = groupMemberMapper.selectMember(subscriptionEntity); return groupMemberEntities; } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/impl/GroupServiceImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/impl/GroupServiceImpl.java index 6c744905..fed902ff 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/impl/GroupServiceImpl.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/impl/GroupServiceImpl.java @@ -20,12 +20,11 @@ import org.apache.eventmesh.dashboard.console.annotation.EmLog; import org.apache.eventmesh.dashboard.console.entity.message.GroupEntity; -import org.apache.eventmesh.dashboard.console.entity.message.SubscriptionEntity; +import org.apache.eventmesh.dashboard.console.entity.message.TopicEntity; import org.apache.eventmesh.dashboard.console.mapper.message.GroupMapper; import org.apache.eventmesh.dashboard.console.service.message.GroupMemberService; import org.apache.eventmesh.dashboard.console.service.message.GroupService; -import java.time.LocalDateTime; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; @@ -40,9 +39,10 @@ public class GroupServiceImpl implements GroupService { @Autowired private GroupMemberService groupMemberService; + @Override - public List selectAll() { - return groupMapper.selectAll(); + public List queryGroupListByTopicId(TopicEntity topicEntity) { + return this.groupMapper.queryGroupListByTopicId(topicEntity); } @Override @@ -50,7 +50,6 @@ public void batchInsert(List groupEntities) { groupMapper.batchInsert(groupEntities); } - @EmLog(OprType = "search", OprTarget = "Group") @Override public List getGroupByClusterId(GroupEntity groupEntity) { return groupMapper.selectGroup(groupEntity); @@ -63,52 +62,9 @@ public void addGroup(GroupEntity groupEntity) { groupMapper.addGroup(groupEntity); } - @Override - public void updateGroup(GroupEntity groupEntity) { - groupMapper.updateGroup(groupEntity); - } - @Override public Integer deleteGroup(GroupEntity groupEntity) { return groupMapper.deleteGroup(groupEntity); } - @Override - public GroupEntity selectGroup(GroupEntity groupEntity) { - return groupMapper.selectGroupById(groupEntity); - } - - @Override - public Integer insertMemberToGroup(SubscriptionEntity subscriptionEntity) { - groupMemberService.addGroupMember(subscriptionEntity); - GroupEntity groupEntity = new GroupEntity(); - groupEntity.setName(subscriptionEntity.getGroupName()); - groupEntity.setClusterId(subscriptionEntity.getClusterId()); - GroupEntity groupEntity1 = groupMapper.selectGroupByUnique(groupEntity); - //^Obtain the group to which the member belongs - groupEntity1.setMembers(subscriptionEntity.getId() + "" + "," + groupEntity1.getMembers()); - //Concatenate the members of the group - groupEntity1.setMemberCount(groupEntity1.getMemberCount() + 1); - groupEntity1.setUpdateTime(LocalDateTime.now()); - groupMapper.updateGroup(groupEntity1); - return 1; - //Modify the group member information - } - - @Override - public Integer deleteMemberFromGroup(SubscriptionEntity subscriptionEntity) { - groupMemberService.deleteGroupMember(subscriptionEntity); - GroupEntity groupEntity = new GroupEntity(); - groupEntity.setName(subscriptionEntity.getGroupName()); - groupEntity.setClusterId(subscriptionEntity.getClusterId()); - GroupEntity groupEntity1 = groupMapper.selectGroupByUnique(groupEntity); - //^Obtain the group to which the member belongs - groupEntity1.setMembers(groupEntity1.getMembers().replaceAll(subscriptionEntity.getId() + "" + ",", "")); - groupEntity1.setMemberCount(groupEntity1.getMemberCount() - 1); - groupEntity1.setUpdateTime(LocalDateTime.now()); - groupMapper.updateGroup(groupEntity1); - return 1; - } - - } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/impl/OffsetServiceImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/impl/OffsetServiceImpl.java new file mode 100644 index 00000000..679e253d --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/impl/OffsetServiceImpl.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.eventmesh.dashboard.console.service.message.impl; + +import org.apache.eventmesh.dashboard.console.mapper.message.ConsumerOffsetMapper; +import org.apache.eventmesh.dashboard.console.mapper.message.OffsetMapper; +import org.apache.eventmesh.dashboard.console.mapper.message.TopicOffsetMapper; +import org.apache.eventmesh.dashboard.console.service.message.OffsetService; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@Transactional +public class OffsetServiceImpl implements OffsetService { + + @Autowired + private TopicOffsetMapper topicOffsetMapper; + + @Autowired + private ConsumerOffsetMapper consumerOffsetMapper; + + + @Autowired + private OffsetMapper offsetMapper; +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/impl/TopicServiceImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/impl/TopicServiceImpl.java index ec471645..771cf98a 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/impl/TopicServiceImpl.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/message/impl/TopicServiceImpl.java @@ -28,7 +28,7 @@ import org.apache.eventmesh.dashboard.console.mapper.function.ConfigMapper; import org.apache.eventmesh.dashboard.console.mapper.function.HealthCheckResultMapper; import org.apache.eventmesh.dashboard.console.mapper.message.GroupMapper; -import org.apache.eventmesh.dashboard.console.mapper.message.OprGroupMemberMapper; +import org.apache.eventmesh.dashboard.console.mapper.message.GroupMemberMapper; import org.apache.eventmesh.dashboard.console.mapper.message.TopicMapper; import org.apache.eventmesh.dashboard.console.modle.dto.topic.GetTopicListDTO; import org.apache.eventmesh.dashboard.console.modle.vo.topic.TopicDetailGroupVO; @@ -47,7 +47,7 @@ public class TopicServiceImpl implements TopicService { TopicMapper topicMapper; @Autowired - OprGroupMemberMapper oprGroupMemberMapper; + GroupMemberMapper groupMemberMapper; @Autowired HealthCheckResultMapper healthCheckResultMapper; @@ -70,20 +70,20 @@ public List getTopicDetailGroups(Long topicId) { SubscriptionEntity subscriptionEntity = new SubscriptionEntity(); subscriptionEntity.setClusterId(topicEntity.getClusterId()); subscriptionEntity.setTopicName(topicEntity.getTopicName()); - List groupNamelist = oprGroupMemberMapper.selectGroupNameByTopicName(subscriptionEntity); + List groupNamelist = groupMemberMapper.selectGroupNameByTopicName(subscriptionEntity); ArrayList topicDetailGroupVOList = new ArrayList<>(); TopicEntity finalTopicEntity = topicEntity; groupNamelist.forEach(n -> { TopicDetailGroupVO topicDetailGroupVO = new TopicDetailGroupVO(); topicDetailGroupVO.setGroupName(n); subscriptionEntity.setGroupName(n); - List list = oprGroupMemberMapper.selectTopicsByGroupNameAndClusterId(subscriptionEntity); + List list = groupMemberMapper.selectTopicsByGroupNameAndClusterId(subscriptionEntity); topicDetailGroupVO.setTopics(list); GroupEntity groupEntity = new GroupEntity(); groupEntity.setClusterId(finalTopicEntity.getClusterId()); groupEntity.setName(n); GroupEntity group = groupMapper.selectGroupByNameAndClusterId(groupEntity); - topicDetailGroupVO.setMemberNum(group.getMemberCount()); + //topicDetailGroupVO.setMemberNum(group.getMemberCount()); topicDetailGroupVOList.add(topicDetailGroupVO); }); @@ -119,7 +119,7 @@ public List selectAll() { public void addTopic(TopicEntity topicEntity) { SubscriptionEntity subscriptionEntity = new SubscriptionEntity(); subscriptionEntity.setTopicName(topicEntity.getTopicName()); - oprGroupMemberMapper.updateMemberByTopic(subscriptionEntity); + groupMemberMapper.updateMemberByTopic(subscriptionEntity); topicMapper.insertTopic(topicEntity); } @@ -157,8 +157,7 @@ public TopicEntity setSearchCriteria(GetTopicListDTO getTopicListDTO, TopicEntit @Override public List getTopicListToFront(TopicEntity topicEntity) { - List topicEntityList = topicMapper.queryTopicsToFrontByClusterId(topicEntity); - return topicEntityList; + return topicMapper.queryTopicsToFrontByClusterId(topicEntity); } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/RuntimeDeployService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/RuntimeDeployService.java index 92b028a9..4b3c4393 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/RuntimeDeployService.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/RuntimeDeployService.java @@ -289,7 +289,7 @@ public void influence() { if (this.clusterType.isMetaAndRuntime() && Objects.equals(this.runtimeEntity.getDeployStatusType(), DeployStatusType.CREATE_WAIT)) { - // 修改数据 + // 修改数据 nacos this.metaAndRuntimeList.forEach((value) -> { value.setDeployStatusType(DeployStatusType.CREATE_CAP_UPDATE_WAIT); this.updateRuntimeList.add(value); @@ -311,6 +311,13 @@ public void influence() { @Override public void run() { try { + this.updateRuntimeList.add(this.runtimeEntity); + try { + runtimeService.batchUpdate(this.updateRuntimeList); + } catch (Exception e) { + log.error(e.getMessage(), e); + } + this.queryHandlerData(); this.buildOperationMetaData(); if (Objects.equals(this.runtimeEntity.getDeployStatusType(), DeployStatusType.UNINSTALL)) { @@ -325,7 +332,6 @@ public void run() { log.error(e.getMessage(), e); this.runtimeEntity.setDeployStatusType(getFailedType(runtimeEntity.getDeployStatusType())); } - this.updateRuntimeList.add(this.runtimeEntity); try { runtimeService.batchUpdate(this.updateRuntimeList); diff --git a/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.jmx b/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.jmx index 24226780..fa2a1025 100644 --- a/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.jmx +++ b/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.jmx @@ -1,21 +1,3 @@ - - - @@ -70,15 +52,15 @@ application/json - queryClause + queryClause1 {"limitPageNum":1,limitSize:10} - + - + true @@ -113,7 +95,7 @@ false { - "id":1 + } = @@ -123,7 +105,7 @@ ${port} - ${path}/runtime/queryRuntimeListByClusterId + ${path}/runtime/queryRuntimeListById POST true false @@ -196,7 +178,7 @@ - + true diff --git a/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql b/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql index 9cb612fa..ad0b2db0 100644 --- a/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql +++ b/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql @@ -110,26 +110,28 @@ create table `cluster_relationship` drop table if exists `config`; create table config ( - id bigint unsigned auto_increment primary key, - organization_id bigint unsigned not null comment '组织id', - cluster_id bigint not null comment '集群id', - instance_type tinyint not null comment '实例类型 0:runtime,1:storage,2:connector,3:topic', - instance_id bigint not null default -1 comment '实例id,上面配置对应的(比如runtime)的id,如果是-1,是cluster的配置', - config_type varchar(31) not null default '' comment '配置类型', - config_name varchar(192) not null comment '配置名称', - config_value text not null comment '配置值', - start_version varchar(64) not null default '' comment '配置开始使用的版本', - end_version varchar(64) not null default '' comment '配置结束使用的版本', - status int not null default 1 comment '0 关闭 1 开启 ', - is_default int not null default 1, - diff_type int not null default -1 comment '差异类型', - description varchar(1000) not null default '' comment '备注', - edit int not null default 1 comment '是否可以编辑 1 不可编辑(程序获取) 2 可编辑', - create_time timestamp not null default current_timestamp comment '创建时间', - update_time timestamp not null default current_timestamp on update current_timestamp comment '修改时间', - is_modify int not null default 0 comment '是否修改元版本数据', - already_update int not null default 0 comment '0:no,1:yes', - is_delete int not null default 0 comment '0', + id bigint unsigned auto_increment primary key, + organization_id bigint unsigned not null comment '组织id', + cluster_id bigint not null comment '集群id', + instance_type varchar(31) not null comment '实例类型 0:runtime,1:storage,2:connector,3:topic', + instance_id bigint not null default -1 comment '实例id,上面配置对应的(比如runtime)的id,如果是-1,是cluster的配置', + config_type varchar(31) not null default '' comment '配置类型', + config_name varchar(192) not null comment '配置名称', + config_value text not null comment '配置值', + config_value_type varchar(16) not null comment '值类型,number,string,boolean,date,enum', + config_value_range varchar(16) not null comment '', + start_version varchar(64) not null default '' comment '配置开始使用的版本', + end_version varchar(64) not null default '' comment '配置结束使用的版本', + status int not null default 1 comment '0 关闭 1 开启 ', + is_default int not null default 1, + diff_type int not null default -1 comment '差异类型', + description varchar(1000) not null default '' comment '备注', + edit int not null default 1 comment '是否可以编辑 1 不可编辑(程序获取) 2 可编辑', + create_time timestamp not null default current_timestamp comment '创建时间', + update_time timestamp not null default current_timestamp on update current_timestamp comment '修改时间', + is_modify int not null default 0 comment '是否修改元版本数据', + already_update int not null default 0 comment '0:no,1:yes', + is_delete int not null default 0 comment '0', unique key uniq_cluster_id_instance_type_instance_id_config_name (instance_id, config_name, instance_type, cluster_id) ) comment '配置信息表'; @@ -190,6 +192,32 @@ create table group_member unique key uniq_cluster_topic_group (cluster_id, topic_name, group_name) ) comment 'groupmember信息表'; +drop table if exists `offset`; + +create table offset +( + id bigint unsigned primary key auto_increment comment 'id', + organization_id bigint unsigned not null comment '组织id', + cluster_id bigint unsigned not null default -1 comment '集群id', + runtime_id bigint unsigned not null default -1 comment '', + offset_record_type varchar(16) not null default '' comment 'topic or consume', + topic_id bigint unsigned not null default '', + topic_name varchar(128) not null default '', + queue_index bigint not null default '', + topic_offset bigint unsigned not null default '', + group_id bigint unsigned not null default '', + group_name varchar(128) not null default '', + consume_offset bigint unsigned not null default '', + consume_rote bigint unsigned not null default '消费速率,写到这个表?', + delay_num bigint unsigned not null default '延迟数量', + create_time timestamp not null default current_timestamp comment '创建时间', + update_time timestamp not null default current_timestamp on update current_timestamp comment '修改时间', + status int not null default 1, + is_delete int not null default 0 comment '0', + key cluster_topic_group (cluster_id, topic_name, group_name) + +); + drop table if exists runtime; create table runtime diff --git a/eventmesh-dashboard-console/src/main/resources/report/elasticsearch.yaml b/eventmesh-dashboard-console/src/main/resources/report/elasticsearch.yaml new file mode 100644 index 00000000..7e72c467 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/resources/report/elasticsearch.yaml @@ -0,0 +1,77 @@ +data: + bool: + type: model + content: + "query": { + "bool": { + "must": [ { + "term": { + "clusterPhyId": { + "value": %d + } + } + }, + { + "term": { + "brokerId": { + "value": %d + } + } + }, + { + "range": { + "timestamp": { + "gte": %d, + "lte": %d + } + } + } + ] + } + }, + xxxx: + type: + - + content: + { "size": 0, + "query": { + "bool": { + "must": [ { + "term": { + "clusterPhyId": { + "value": %d + } + } + }, + { + "term": { + "brokerId": { + "value": %d + } + } + }, + { + "range": { + "timestamp": { + "gte": %d, + "lte": %d + } + } + } + ] + } + }, + "aggs": { + "hist": { + "date_histogram": { + "field": "timestamp", + "fixed_interval": "%s", + "time_zone": "Asia/Shanghai", + "min_doc_count": 0 + }, + "aggs": { + %s + } + } + } + } \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/main/resources/report/report-RocketMQ.sql b/eventmesh-dashboard-console/src/main/resources/report/report-RocketMQ.sql new file mode 100644 index 00000000..865388fb --- /dev/null +++ b/eventmesh-dashboard-console/src/main/resources/report/report-RocketMQ.sql @@ -0,0 +1,327 @@ +/* + * 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. + */ + +create database if not exists eventmesh_dashboard with(TTL=2592000000); + +create table rocketmq_messages_in_total +( + time timestamp time, + organization_id string tag, + organization_name string attribute, + clusters_id string tag, + cluster_name string attribute, + runtime_type string attribute, + runtime_id string tag, + runtime_name string attribute, + topic_id string tag, + topic_name string attribute, + message_type string attribute, + value int64 field +)comment '消息in总数统计表' with(ttl=default); + +create table rocketmq_messages_out_total +( + time timestamp time, + organization_id string tag, + organization_name string attribute, + clusters_id string tag, + cluster_name string attribute, + runtime_type string attribute, + runtime_id string tag, + runtime_name string attribute, + topic_id string tag, + topic_name string attribute, + message_type string attribute, + value int64 field +)comment '消息out总数统计表' with(ttl=default); + +create table rocketmq_throughput_in_total +( + time timestamp time, + organization_id string tag, + organization_name string attribute, + clusters_id string tag, + cluster_name string attribute, + runtime_type string attribute, + runtime_id string tag, + runtime_name string attribute, + topic_id string tag, + topic_name string attribute, + message_type string attribute, + value int64 field +)comment '消息体 in 总数统计表' with(ttl=default); + +create table rocketmq_throughput_out_total +( + time timestamp time, + organization_id string tag, + organization_name string attribute, + clusters_id string tag, + cluster_name string attribute, + runtime_type string attribute, + runtime_id string tag, + runtime_name string attribute, + topic_id string tag, + topic_name string attribute, + message_type string attribute, + value int64 field +)comment '消息体 out 总数统计表' with(ttl=default); + + +create table rocketmq_consumer_ready_messages +( + time timestamp time, + organization_id string tag, + organization_name string attribute, + clusters_id string tag, + cluster_name string attribute, + runtime_type string attribute, + runtime_id string tag, + runtime_name string attribute, + topic_id string tag, + topic_name string attribute, + group_id string tag, + group_name string attribute, + value int64 field +)comment '已就绪消息量' with(ttl=default); + +create table rocketmq_consumer_inflight_messages +( + time timestamp time, + organization_id string tag, + organization_name string attribute, + clusters_id string tag, + cluster_name string attribute, + runtime_type string attribute, + runtime_id string tag, + runtime_name string attribute, + topic_id string tag, + topic_name string attribute, + group_id string tag, + group_name string attribute, + value int64 field +)comment '处理中消息量' with(ttl=default); + +create table rocketmq_consumer_queueing_latency +( + time timestamp time, + organization_id string tag, + organization_name string attribute, + clusters_id string tag, + cluster_name string attribute, + runtime_type string attribute, + runtime_id string tag, + runtime_name string attribute, + topic_id string tag, + topic_name string attribute, + group_id string tag, + group_name string attribute, + value int64 field +)comment '已就绪消息排队延迟时间' with(ttl=default); + +create table rocketmq_consumer_lag_latency +( + time timestamp time, + organization_id string tag, + organization_name string attribute, + clusters_id string tag, + cluster_name string attribute, + runtime_type string attribute, + runtime_id string tag, + runtime_name string attribute, + topic_id string tag, + topic_name string attribute, + group_id string tag, + group_name string attribute, + value int64 field +)comment '消费处理延迟时间' with(ttl=default); + +create table rocketmq_send_to_dlq_messages_total +( + time timestamp time, + organization_id string tag, + organization_name string attribute, + clusters_id string tag, + cluster_name string attribute, + runtime_type string attribute, + runtime_id string tag, + runtime_name string attribute, + topic_id string tag, + topic_name string attribute, + group_id string tag, + group_name string attribute, + value int64 field +)comment '转为死信状态的消息量' with(ttl=default); + +create table rocketmq_storage_message_reserve_time +( + time timestamp time, + organization_id string tag, + organization_name string attribute, + clusters_id string tag, + cluster_name string attribute, + runtime_type string attribute, + runtime_id string tag, + runtime_name string attribute, + value int64 field +)comment '储存层消息保存时间' with(ttl=default); + +create table rocketmq_storage_dispatch_behind_bytes +( + time timestamp time, + organization_id string tag, + organization_name string attribute, + clusters_id string tag, + cluster_name string attribute, + runtime_type string attribute, + runtime_id string tag, + runtime_name string attribute, + value int64 field +)comment 'dispatch 落后大小' with(ttl=default); + +create table rocketmq_storage_flush_behind_bytes +( + time timestamp time, + organization_id string tag, + organization_name string attribute, + clusters_id string tag, + cluster_name string attribute, + runtime_type string attribute, + runtime_id string tag, + runtime_name string attribute, + value int64 field +)comment '刷盘落后大小' with(ttl=default); + +create table rocketmq_thread_pool_wartermark +( + time timestamp time, + organization_id string tag, + organization_name string attribute, + clusters_id string tag, + cluster_name string attribute, + runtime_type string attribute, + runtime_id string tag, + runtime_name string attribute, + name string attribute, + value int64 field +)comment '线程池排队数' with(ttl=default); + +create table rocketmq_topic_number +( + time timestamp time, + organization_id string tag, + organization_name string attribute, + clusters_id string tag, + cluster_name string attribute, + runtime_type string attribute, + runtime_id string tag, + runtime_name string attribute, + value int64 field +)comment '主题数量' with(ttl=default); + + +create table rocketmq_consumer_group_number +( + time timestamp time, + organization_id string tag, + organization_name string attribute, + clusters_id string tag, + cluster_name string attribute, + runtime_type string attribute, + runtime_id string tag, + runtime_name string attribute, + value int64 field +)comment '消费者组数量' with(ttl=default); + +create table rocketmq_message_size +( + time timestamp time, + organization_id string tag, + organization_name string attribute, + clusters_id string tag, + cluster_name string attribute, + runtime_type string attribute, + runtime_id string tag, + runtime_name string attribute, + topic_id string tag, + topic_name string attribute, + message_type string attribute, + value_le_1_kb int64 field, + value_le_4_kb int64 field, + value_le_512_kb int64 field, + value_le_1_mb int64 field, + value_le_2_mb int64 field, + value_le_4_mb int64 field, + value_le_overflow int64 field +)comment '消息大小的分布情况,发送成功时统计' with(ttl=default); + +create table rocketmq_rpc_latency( + time timestamp time, + organization_id string tag, + organization_name string attribute, + clusters_id string tag, + cluster_name string attribute, + runtime_type string attribute, + runtime_id string tag, + runtime_name string attribute, + protocol_type string attribute, + request_code string attribute, + response_code string attribute, + value_le_1_ms int32 field, + value_le_3_ms int32 field, + value_le_5_ms int32 field, + value_le_10_ms int32 field, + value_le_100_ms int32 field, + value_le_1_s int32 field, + value_le_3_s int32 field, + value_le_overflow_s int32 field + +)comment '调用耗时' with(ttl=default); + +create table rocketmq_topic_create_execution_time( + time timestamp time, + organization_id string tag, + organization_name string attribute, + clusters_id string tag, + cluster_name string attribute, + runtime_type string attribute, + runtime_id string tag, + runtime_name string attribute, + value_le_10_ms int32 field, + value_le_100_ms int32 field, + value_le_1_s int32 field, + value_le_3_s int32 field, + value_le_5_s int32 field, + value_le_overflow_s int32 field +)comment '创建主题执行耗时' with(ttl=default); + +create table rocketmq_consumer_group_create_execution_time( + time timestamp time, + organization_id string tag, + organization_name string attribute, + clusters_id string tag, + cluster_name string attribute, + runtime_type string attribute, + runtime_id string tag, + runtime_name string attribute, + value_le_10_ms int32 field, + value_le_100_ms int32 field, + value_le_1_s int32 field, + value_le_3_s int32 field, + value_le_5_s int32 field, + value_le_overflow_s int32 field +)comment '创建消费者组执行耗时' with(ttl=default); diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/databuild/BuildFullDataMapper.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/databuild/BuildFullDataMapper.java new file mode 100644 index 00000000..27505456 --- /dev/null +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/databuild/BuildFullDataMapper.java @@ -0,0 +1,94 @@ +/* + * 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.databuild; + +import org.apache.eventmesh.dashboard.common.enums.MetadataType; +import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication; +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; +import org.apache.eventmesh.dashboard.console.mapper.cluster.ClusterMapper; +import org.apache.eventmesh.dashboard.console.mapper.function.ConfigMapper; +import org.apache.eventmesh.dashboard.console.mapper.message.GroupMapper; +import org.apache.eventmesh.dashboard.console.mapper.message.GroupMemberMapper; +import org.apache.eventmesh.dashboard.console.mapper.message.TopicMapper; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; +import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase.Replace; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = {EventMeshDashboardApplication.class}) +//@Sql(scripts = {"classpath:eventmesh-dashboard.sql"}) +@AutoConfigureTestDatabase(replace = Replace.NONE) +public class BuildFullDataMapper { + + @Autowired + private ClusterMapper clusterMapper; + + @Autowired + private TopicMapper topicMapper; + + @Autowired + private GroupMapper groupMapper; + + @Autowired + private GroupMemberMapper groupMemberMapper; + + @Autowired + private ConfigMapper configMapper; + + private final BuildMessageData buildMessageData = new BuildMessageData(); + + @Test + public void buildFullDataMapper() { + Map clusterEntityMap = new HashMap(); + List clusterList = this.clusterMapper.queryAllCluster(); + clusterList.forEach(cluster -> { + buildMessageData.buildCluster(cluster); + clusterEntityMap.put(cluster.getId(), cluster); + }); + this.configMapper.batchInsert(this.buildMessageData.getConfigEntityList()); + this.buildMessageData.getConfigEntityList().clear(); + + this.topicMapper.batchInsert(this.buildMessageData.getTopicEntityList()); + this.groupMapper.batchInsert(this.buildMessageData.getGroupEntityList()); + + this.buildMessageData.getTopicEntityList().forEach(topicEntity -> { + buildMessageData.buildConfig(MetadataType.TOPIC, clusterEntityMap.get(topicEntity.getClusterId()), topicEntity.getId()); + }); + this.configMapper.batchInsert(this.buildMessageData.getConfigEntityList()); + this.buildMessageData.getConfigEntityList().clear(); + + this.buildMessageData.getGroupEntityList().forEach(groupEntity -> { + buildMessageData.buildConfig(MetadataType.GROUP, clusterEntityMap.get(groupEntity.getClusterId()), groupEntity.getId()); + }); + this.configMapper.batchInsert(this.buildMessageData.getConfigEntityList()); + this.buildMessageData.getConfigEntityList().clear(); + + this.buildMessageData.buildSubscription(null, this.buildMessageData.getTopicEntityList(), this.buildMessageData.getGroupEntityList()); + + this.groupMemberMapper.batchInsert(this.buildMessageData.getSubscriptionEntityList()); + } +} diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/databuild/BuildFullSceneData.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/databuild/BuildFullSceneData.java index b6265c4d..755803e9 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/databuild/BuildFullSceneData.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/databuild/BuildFullSceneData.java @@ -390,6 +390,8 @@ private static class ShareMetadata { private Integer shareNum = 0; private final Map> shareMap = new HashMap<>(); + + } } diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/databuild/BuildMessageData.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/databuild/BuildMessageData.java new file mode 100644 index 00000000..92354ee2 --- /dev/null +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/databuild/BuildMessageData.java @@ -0,0 +1,165 @@ +/* + * 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.databuild; + + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.common.enums.MetadataType; +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; +import org.apache.eventmesh.dashboard.console.entity.function.ConfigEntity; +import org.apache.eventmesh.dashboard.console.entity.message.GroupEntity; +import org.apache.eventmesh.dashboard.console.entity.message.SubscriptionEntity; +import org.apache.eventmesh.dashboard.console.entity.message.TopicEntity; + +import org.apache.commons.lang3.tuple.Pair; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Random; + +import lombok.Getter; + +@Getter +public class BuildMessageData { + + private Map> clusterTypeListHashMap = new HashMap<>(); + + private Map>> entityMapHashMap = new HashMap<>(); + + private List configEntityList = new ArrayList<>(); + + private List topicEntityList = new ArrayList<>(); + + private List, List>> pairList = new ArrayList<>(); + + private List groupEntityList = new ArrayList<>(); + + private List subscriptionEntityList = new ArrayList<>(); + + + public void buildCluster(ClusterEntity clusterEntity) { + List topicEntityList = this.buildTopic(clusterEntity); + List groupEntityList = this.buildGroup(clusterEntity); + this.topicEntityList.addAll(topicEntityList); + this.groupEntityList.addAll(groupEntityList); + + this.buildConfig(MetadataType.CLUSTER, clusterEntity, clusterEntity.getId()); + + pairList.add(Pair.of(topicEntityList, groupEntityList)); + } + + public List buildTopic(ClusterEntity clusterEntity) { + List topicEntityList = new ArrayList<>(); + int num = new Random().nextInt(10) + 10; + for (int i = 0; i < num; i++) { + TopicEntity topicEntity = new TopicEntity(); + topicEntity.setOrganizationId(clusterEntity.getOrganizationId()); + topicEntity.setClusterId(clusterEntity.getId()); + topicEntity.setRuntimeId(0L); + topicEntity.setTopicType("test-data"); + topicEntity.setTopicName("cluster-" + clusterEntity.getId() + ".topic-" + i); + + if (Objects.equals(clusterEntity.getClusterType(), ClusterType.STORAGE_ROCKETMQ_BROKER_MAIN_SLAVE) || + Objects.equals(clusterEntity.getClusterType(), ClusterType.STORAGE_ROCKETMQ_BROKER_RAFT)) { + topicEntity.setReadQueueNum(8); + topicEntity.setWriteQueueNum(8); + topicEntity.setReplicationFactor(0); + topicEntity.setOrder(i % 3 == 0 ? 1 : 2); + topicEntity.setTopicFilterType(""); + + + } else { + topicEntity.setReadQueueNum(8); + topicEntity.setWriteQueueNum(0); + topicEntity.setReplicationFactor(2); + topicEntity.setOrder(0); + topicEntity.setTopicFilterType(""); + + } + topicEntity.setAttributes(""); + + topicEntity.setDescription(topicEntity.getTopicName()); + topicEntity.setCreateProgress(1); + topicEntity.setRetentionMs(-1L); + topicEntityList.add(topicEntity); + } + return topicEntityList; + } + + + public List buildGroup(ClusterEntity clusterEntity) { + List groupEntityArrayList = new ArrayList<>(); + Random random = new Random(); + int num = random.nextInt(10) + 10; + for (int i = 0; i < num; i++) { + GroupEntity groupEntity = new GroupEntity(); + groupEntity.setOrganizationId(clusterEntity.getOrganizationId()); + groupEntity.setClusterId(clusterEntity.getId()); + + groupEntity.setRuntimeId(0L); + groupEntity.setName("cluster-" + clusterEntity.getId() + ".group-" + i); + groupEntity.setType(random.nextInt(1)); + groupEntity.setOwnType("0"); + groupEntityList.add(groupEntity); + } + return groupEntityArrayList; + } + + public void buildSubscription(ClusterEntity clusterEntity, List topicEntityList, List groupEntityList) { + List subscriptionEntityList = new ArrayList<>(); + topicEntityList.forEach(topicEntity -> { + groupEntityList.forEach(groupEntity -> { + SubscriptionEntity subscriptionEntity = new SubscriptionEntity(); + subscriptionEntity.setOrganizationId(groupEntity.getOrganizationId()); + subscriptionEntity.setClusterId(groupEntity.getClusterId()); + subscriptionEntity.setGroupName(groupEntity.getName()); + subscriptionEntity.setTopicName(topicEntity.getTopicName()); + subscriptionEntity.setEventMeshUser("11111"); + subscriptionEntity.setStatus(1L); + subscriptionEntityList.add(subscriptionEntity); + }); + }); + this.subscriptionEntityList.addAll(subscriptionEntityList); + } + + public void buildConfig(MetadataType metadataType, ClusterEntity clusterEntity, Long id) { + for (int i = 0; i < 15; i++) { + ConfigEntity configEntity = new ConfigEntity(); + configEntity.setOrganizationId(clusterEntity.getOrganizationId()); + configEntity.setClusterId(clusterEntity.getId()); + configEntity.setInstanceType(metadataType); + configEntity.setInstanceId(id); + configEntity.setConfigType("test-data"); + configEntity.setConfigName("config~" + "id~" + id + "~index~" + i); + configEntity.setConfigValue(String.valueOf(i)); + configEntity.setConfigValueType("number"); + configEntity.setConfigValueRange("{num}"); + configEntity.setStartVersion("2"); + configEntity.setEndVersion("1"); + configEntity.setDescription("test-data"); + configEntity.setEdit(0); + configEntity.setIsDefault(1); + + this.configEntityList.add(configEntity); + } + } + +} diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/report/DataIdModel.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/report/DataIdModel.java new file mode 100644 index 00000000..641e5acb --- /dev/null +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/report/DataIdModel.java @@ -0,0 +1,141 @@ +/* + * 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.function.report; + +import org.apache.eventmesh.dashboard.console.function.report.elasticsearch.DataModel.DataModelBuilder; + +import java.util.ArrayList; +import java.util.List; + +import lombok.Data; + +@Data +public class DataIdModel { + + private Long organizationId; + + private Long clusterId; + + private Long runtimeId; + + private Long topicId; + + private Long groupId; + + private Long queueId; + + private Long subscriptionId; + + private Integer count = 3; + + private Integer deep = 3; + + private Integer totalTrequency; + + private boolean init = false; + + private DataModelBuilder dataModelBuilder; + + public void init() { + if (init) { + return; + } + this.totalTrequency = (int) Math.pow(count, deep); + this.init = true; + } + + public List getRuntimeDataModel() { + return this.get(3, () -> this.runtimeId(null, false)); + } + + public List get(Integer deep, Runnable runnable) { + this.deep = deep; + this.init(); + List list = new ArrayList<>(); + for (int i = 0; i < this.totalTrequency; i++) { + dataModelBuilder = org.apache.eventmesh.dashboard.console.function.report.elasticsearch.DataModel.builder(); + runnable.run(); + this.runtimeId(null, false); + list.add(dataModelBuilder.build()); + } + + return list; + } + + public void runtimeId(Long id, boolean newValue) { + boolean newValue1 = false; + if (this.runtimeId == null) { + this.runtimeId = 0L; + } + if (this.deep == 3) { + this.runtimeId++; + newValue1 = true; + } else if (id != null) { + Integer runtimeCount = (int) Math.pow(this.deep, 3); + if (id != 1 && id % this.deep == 1 && newValue) { + this.runtimeId++; + newValue1 = true; + } + } + this.clusterId(this.runtimeId, newValue1); + + dataModelBuilder.runtimeId(this.runtimeId); + dataModelBuilder.runtimeName("runtimeName-" + this.runtimeId); + } + + public void clusterId(Long id, boolean newValue) { + boolean newValue1 = false; + if (this.clusterId == null) { + this.clusterId = 0L; + } + if (this.deep == 2) { + this.clusterId++; + } else { + //Integer runtimeCount = (int) Math.pow(this.deep, this.deep - 2); + if (id != 1 && id % this.deep == 1 && newValue) { + this.clusterId++; + newValue1 = true; + } + } + if (this.clusterId == 0) { + this.clusterId++; + } + this.organizationId(this.clusterId, newValue1); + dataModelBuilder.clusterId(this.clusterId); + dataModelBuilder.clusterName("cluster-" + this.clusterId); + } + + public void organizationId(Long id, boolean newValue) { + if (this.organizationId == null) { + this.organizationId = 0L; + } + if (this.deep == 1) { + this.organizationId++; + } else { + if (id != 1 && id % this.deep == 1 && newValue) { + this.organizationId++; + } + } + if (this.organizationId == 0) { + this.organizationId++; + } + dataModelBuilder.organizationId(this.organizationId); + dataModelBuilder.organizationName("organization-" + this.organizationId); + } + +} diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/report/DataValueModel.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/report/DataValueModel.java new file mode 100644 index 00000000..db65de0b --- /dev/null +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/report/DataValueModel.java @@ -0,0 +1,69 @@ +/* + * 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.function.report; + +import org.apache.eventmesh.dashboard.console.function.report.elasticsearch.DataModel; +import org.apache.eventmesh.dashboard.console.function.report.elasticsearch.DataModel.DataModelBuilder; + +import java.time.LocalDateTime; +import java.time.ZoneOffset; +import java.time.temporal.ChronoUnit; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Random; + +/** + * 峰值点,峰值开始时间,结束时间,上升开始时间,上升结束时间,上升坡度,下降坡度,下降开始时间,下降结束时间 几次峰 value的类型,累加型,有规律随机性 先实现累加型 + */ +public class DataValueModel { + + + public Map value(List list) { + LocalDateTime localDateTime = LocalDateTime.now(); + LocalDateTime minusDays = localDateTime.minusDays(1); + long seconds = ChronoUnit.SECONDS.between(minusDays, localDateTime); + int cont = (int) (seconds / 5); + Map builders = new HashMap<>(list.size() * cont); + long key = minusDays.atZone(ZoneOffset.UTC).toInstant().toEpochMilli(); + list.forEach((value) -> { + Random random = new Random(); + int count = 0; + for (int i = 0; i < cont; i++) { + DataModelBuilder dataModelBuilder = DataModel.builder(); + dataModelBuilder.organizationId(value.getOrganizationId()) + .organizationName(value.getOrganizationName()) + .clusterId(value.getClusterId()) + .clusterName(value.getClusterName()) + .runtimeId(value.getRuntimeId()) + .runtimeName(value.getRuntimeName()) + .runtimeType(value.getRuntimeType()) + .topicId(value.getTopicId()) + .topicName(value.getTopicName()) + .topicType(value.getTopicType()) + .groupId(value.getGroupId()) + .groupName(value.getGroupName()) + .subscribeId(value.getSubscribeId()); + dataModelBuilder.recordTime(minusDays.plusSeconds(i)); + dataModelBuilder.value("" + count++); + builders.put((key + i) + "", dataModelBuilder.build()); + } + }); + return builders; + } +} diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/report/ReportHandlerManageTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/report/ReportHandlerManageTest.java new file mode 100644 index 00000000..710bc92f --- /dev/null +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/report/ReportHandlerManageTest.java @@ -0,0 +1,55 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.eventmesh.dashboard.console.function.report; + +import org.apache.ibatis.mapping.BoundSql; +import org.apache.ibatis.mapping.SqlSource; +import org.apache.ibatis.scripting.xmltags.XMLLanguageDriver; +import org.apache.ibatis.session.Configuration; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Test; + +public class ReportHandlerManageTest { + + Configuration configuration = new Configuration(); + + @Test + public void test() { + XMLLanguageDriver xmlLanguageDriver = new XMLLanguageDriver(); + + String sql = """ + + """; + SqlSource sqlSource = xmlLanguageDriver.createSqlSource(configuration, sql, ReportHandlerManageTest.class); + + Map data = new HashMap<>(); + data.put("id", 1); + data.put("status", 1); + BoundSql s = sqlSource.getBoundSql(data); + System.out.println(s.getSql()); + } +} diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/report/RocketMQ.txt b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/report/RocketMQ.txt new file mode 100644 index 00000000..c4e561f0 --- /dev/null +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/report/RocketMQ.txt @@ -0,0 +1,54 @@ +从某个点开始,现在重量 , 同统计时间开始的总量,同时计算百分比 +一个指标统计,全量数据,统计全量数据,对当前查询出来的数据进行,统计 +进行中的百分比,如果计算,这里结算不了。只能在前端计算 +cluster,node_type,node_id,topic,message_type + consumer_group + user,client,连接 +counter rocketmq_messages_in_total count 消息生产数量。 cluster,node_type,node_id,topic,message_type +counter rocketmq_messages_out_total count 消息消费数量。 cluster,node_type,node_id,topic, consumer_group + topic num , min_offset max_offset + 消费延迟数量 cluster,node_type,node_id,topic, consumer_group +counter rocketmq_throughput_in_total byte 消息生产流入服务端的吞吐量。 cluster,node_type,node_id,topic,message_type +counter rocketmq_throughput_out_total byte 消息消费从服务端流出的吞吐量。 cluster,node_type,node_id,topic, consumer_group +histogram rocketmq_message_size byte 消息大小的分布情况,发送成功时统计。分布区间如下: cluster,node_type,node_id,topic,message_type + le_1_kb: ≤ 1 KB + le_4_kb: ≤ 4 KB + le_512_kb: ≤ 512 KB + le_1_mb: ≤ 1 MB + le_2_mb: ≤ 2 MB + le_4_mb: ≤ 4 MB + le_overflow: > 4 MB +gauge rocketmq_consumer_ready_messages count 已就绪消息量。 cluster,node_type,node_id,topic, consumer_group +gauge rocketmq_consumer_inflight_messages count 处理中消息量。 cluster,node_type,node_id,topic, consumer_group +gauge rocketmq_consumer_queueing_latency millisecond 已就绪消息排队延迟时间。 cluster,node_type,node_id,topic, consumer_group +gauge rocketmq_consumer_lag_latency millisecond 消费处理延迟时间。 cluster,node_type,node_id,topic, consumer_group +counter rocketmq_send_to_dlq_messages_total count 转为死信状态的消息量。(变成死信状态指的是消息达到最大重投次数后不再投递) cluster,node_type,node_id,topic, consumer_group +histogram rocketmq_rpc_latency millisecond rpc 调用耗时: cluster,node_typ,node_id,protocol_type,request_code,response_code + le_1_ms + le_3_ms + le_5_ms + le_10_ms + le_100_ms + le_1_s + le_3_s + le_overflow +gauge rocketmq_storage_message_reserve_time millisecond 储存层消息保存时间(broker 硬盘上最早一条消息储存时间和当前时间作差) cluster,node_type,node_id +gauge rocketmq_storage_dispatch_behind_bytes byte dispatch 落后大小 cluster,node_type,node_id +gauge rocketmq_storage_flush_behind_bytes byte 刷盘落后大小。 cluster,node_type,node_id +gauge rocketmq_thread_pool_wartermark count 线程池排队数 cluster,node_type,node_id,name +histogram rocketmq_topic_create_execution_time millisecond 创建主题执行耗时: cluster,node_type,node_id,invocation_status,is_system + le_10_ms + le_100_ms + le_1_s + le_3_s + le_5_s + le_overflow +histogram rocketmq_consumer_group_create_execution_time millisecond 创建消费者组执行耗时: cluster,node_type,node_id,invocation_status + le_10_ms + le_100_ms + le_1_s + le_3_s + le_5_s + le_overflow +gauge rocketmq_topic_number count 主题数量 cluster,node_type,node_id +gauge rocketmq_consumer_group_number count 消费者组数量 cluster,node_type,node_id diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/report/elasticsearch/DataModel.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/report/elasticsearch/DataModel.java new file mode 100644 index 00000000..737bbe2c --- /dev/null +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/report/elasticsearch/DataModel.java @@ -0,0 +1,60 @@ +/* + * 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.function.report.elasticsearch; + +import java.time.LocalDateTime; + +import lombok.Builder; +import lombok.Data; + +@Builder +@Data +public class DataModel { + + private Long organizationId; + + private String organizationName; + + private Long clusterId; + + private String clusterName; + + private Long runtimeId; + + private String runtimeName; + + private String runtimeType; + + private Long groupId; + + private String groupName; + + private Long subscribeId; + + private Long topicId; + + private String topicName; + + private String topicType; + + private LocalDateTime recordTime; + + private String value; + + +} diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/report/elasticsearch/ElasticsearchReportEngineTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/report/elasticsearch/ElasticsearchReportEngineTest.java new file mode 100644 index 00000000..e81818b6 --- /dev/null +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/report/elasticsearch/ElasticsearchReportEngineTest.java @@ -0,0 +1,131 @@ +/* + * 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.function.report.elasticsearch; + +public class ElasticsearchReportEngineTest { + +// private Long clusterId = System.currentTimeMillis(); +// +// +// private ElasticsearchReportEngine elasticsearchReportEngine = new ElasticsearchReportEngine(); +// +// private ElasticsearchClient esClient; +// +// private OpenSearchClient client; +// +// private List builders; +// +// @Before +// public void init() { +// HttpHost httpHost = new HttpHost("localhost", 9200, "http"); +// RestClient restClient = RestClient.builder(httpHost).build(); +// this.esClient = new ElasticsearchClient( +// new RestClientTransport(restClient, new JacksonJsonpMapper()) +// ); +// ReportConfig reportConfig = new ReportConfig(); +// reportConfig.setEngineAddress("http://localhost:9200"); +// elasticsearchReportEngine.setReportConfig(reportConfig); +// elasticsearchReportEngine.init(); +// this.init2(); +// } +// +// +// public void init2() { +// // 使用 RestClient 传输层 +// org.opensearch.client.RestClient restClient = +// org.opensearch.client.RestClient.builder(new org.apache.hc.core5.http.HttpHost("localhost", 9200)) +// .setDefaultHeaders(new Header[] { +// new BasicHeader("Accept", "application/json"), +// new BasicHeader("Content-Type", "application/json") +// }).build(); +// client = new OpenSearchClient( +// new org.opensearch.client.transport.rest_client.RestClientTransport(restClient, +// new org.opensearch.client.json.jackson.JacksonJsonpMapper()) +// ); +// +// } +// +// /** +// * 数据模拟,每个维度三到五个数据。数据集类型四个,in out size byte 每秒一条数据,一个小时,3600条。 100 +// */ +// public void mockData() { +// for (long i = 0; i < 3; i++) { +// +// DataModelBuilder builder = DataModel.builder().organizationId(i); +// +// } +// } +// +// public void mockOrganization(String reportType) { +// this.builders = new ArrayList<>(); +// for (long i = 0; i < 3; i++) { +// +// } +// } +// +// public void mockCluster(DataModelBuilder builder) { +// for (long i = 0; i < 3; i++) { +// +// } +// } +// +// @Test +// public void test() { +// +// DataIdModel dataIdModel = new DataIdModel(); +// dataIdModel.setCount(3); +// List list = dataIdModel.getRuntimeDataModel(); +// DataValueModel dataValueModel = new DataValueModel(); +// Collection valueList = dataValueModel.value(list).values(); +// +// BulkRequest.Builder bulkRequestBuilder = new BulkRequest.Builder(); +// try { +// valueList.forEach(v -> { +// bulkRequestBuilder.operations((op) -> { +// return op +// .index(idx -> idx +// .index("test___1111") +// .id("p1") +// .document(v) +// ); +// }); +// }); +// this.client.bulk(bulkRequestBuilder.build()); +// } catch (IOException e) { +// throw new RuntimeException(e); +// } +// +///* try { +// valueList.forEach(v -> { +// bulkRequestBuilder.operations((op) -> { +// return op +// .index(idx -> idx +// .index("test___1111") +// .id("p1") +// .document(v) +// ); +// }); +// }); +// this.esClient.bulk(bulkRequestBuilder.build()); +// } catch (IOException e) { +// throw new RuntimeException(e); +// }*/ +// +// } + +} diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/report/iotdb/IotDBReportEngineTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/report/iotdb/IotDBReportEngineTest.java new file mode 100644 index 00000000..b9147c80 --- /dev/null +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/report/iotdb/IotDBReportEngineTest.java @@ -0,0 +1,124 @@ +/* + * 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.function.report.iotdb; + +import org.apache.eventmesh.dashboard.console.function.report.ReportConfig; +import org.apache.eventmesh.dashboard.console.function.report.ReportHandlerManage; +import org.apache.eventmesh.dashboard.console.function.report.ReportViewType; +import org.apache.eventmesh.dashboard.console.function.report.model.SingleGeneralReportDO; +import org.apache.eventmesh.dashboard.console.function.report.model.rocketmq.RocketmqConsumerGroupCreateExecutionTime; +import org.apache.eventmesh.dashboard.console.function.report.model.rocketmq.RocketmqConsumerQueueingLatency; + +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; + +import org.junit.Before; +import org.junit.Test; + +public class IotDBReportEngineTest { + + private IotDBReportEngine iotDBReportEngine = new IotDBReportEngine(); + + private ReportHandlerManage reportHandlerManage = new ReportHandlerManage(); + + private ReportConfig reportConfig = new ReportConfig(); + + @Before + public void init() { + reportHandlerManage.setReportEngine(iotDBReportEngine); + reportHandlerManage.init(); + + reportConfig.setEngineAddress("127.0.0.1:6667"); + iotDBReportEngine.setReportConfig(reportConfig); + iotDBReportEngine.doInit(); + } + + + @Test + public void test_batchInsert() { + + List list = new ArrayList<>(); + RocketmqConsumerQueueingLatency rocketmqConsumerQueueingLatency = new RocketmqConsumerQueueingLatency(); + rocketmqConsumerQueueingLatency.setOrganizationId(1L); + rocketmqConsumerQueueingLatency.setOrganizationName("test"); + rocketmqConsumerQueueingLatency.setClustersId(1L); + rocketmqConsumerQueueingLatency.setClustersName("test-cluster"); + rocketmqConsumerQueueingLatency.setRuntimeId(3L); + rocketmqConsumerQueueingLatency.setRuntimeName("test-runtime"); + rocketmqConsumerQueueingLatency.setRuntimeType("type-type"); + rocketmqConsumerQueueingLatency.setTopicId(4L); + rocketmqConsumerQueueingLatency.setTopicName("test-topic"); + rocketmqConsumerQueueingLatency.setGroupId(5L); + rocketmqConsumerQueueingLatency.setGroupName("test-group"); + rocketmqConsumerQueueingLatency.setValue(6666L); + rocketmqConsumerQueueingLatency.setTime(LocalDateTime.now()); + + list.add(rocketmqConsumerQueueingLatency); + //iotDBReportEngine.batchInsert("rocketmq_consumer_queueing_latency", (List) ((Object) list)); + + RocketmqConsumerGroupCreateExecutionTime rocketmqConsumerGroupCreateExecutionTime = new RocketmqConsumerGroupCreateExecutionTime(); + rocketmqConsumerGroupCreateExecutionTime.setOrganizationId(1L); + rocketmqConsumerGroupCreateExecutionTime.setOrganizationName("test"); + rocketmqConsumerGroupCreateExecutionTime.setClustersId(1L); + rocketmqConsumerGroupCreateExecutionTime.setClustersName("test-cluster"); + rocketmqConsumerGroupCreateExecutionTime.setRuntimeId(3L); + rocketmqConsumerGroupCreateExecutionTime.setRuntimeName("test-runtime"); + rocketmqConsumerGroupCreateExecutionTime.setRuntimeType("type-type"); + rocketmqConsumerGroupCreateExecutionTime.setValueLe1s(1L); + rocketmqConsumerGroupCreateExecutionTime.setValueLe3s(2L); + rocketmqConsumerGroupCreateExecutionTime.setValueLe5s(3L); + rocketmqConsumerGroupCreateExecutionTime.setValueLe10ms(4L); + rocketmqConsumerGroupCreateExecutionTime.setValueLe100ms(5L); + rocketmqConsumerGroupCreateExecutionTime.setValueLeOverflow(6L); + rocketmqConsumerGroupCreateExecutionTime.setInvocationStatus("123"); + rocketmqConsumerGroupCreateExecutionTime.setTime(LocalDateTime.now()); + List objects = new ArrayList<>(); + objects.add(rocketmqConsumerGroupCreateExecutionTime); + iotDBReportEngine.batchInsert("rocketmq_consumer_group_create_execution_time", objects); + + } + + @Test + public void test_createReport() { + + iotDBReportEngine.createReport("rocketmq_consumer_queueing_latency"); + + //iotDBReportEngine.createReport("rocketmq_consumer_group_create_execution_time"); + } + + @Test + public void test_query() throws ExecutionException, InterruptedException { + SingleGeneralReportDO singleGeneralReportDO = new SingleGeneralReportDO(); + singleGeneralReportDO.setReportName("rocketmq_consumer_group_create_execution_time"); + singleGeneralReportDO.setReportType(ReportViewType.COUNTER.getName()); + singleGeneralReportDO.setOrganizationId(1L); + singleGeneralReportDO.setClustersId(2L); + singleGeneralReportDO.setRuntimeId(3L); + LocalDateTime endTime = LocalDateTime.now(); + singleGeneralReportDO.setStartTime(endTime.minusDays(1L)); + singleGeneralReportDO.setEndTime(endTime); + singleGeneralReportDO.setInterval("15m"); + CompletableFuture>> query = iotDBReportEngine.query(singleGeneralReportDO); + query.get(); + } + +} diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/report/opensearch/OpensearchReportEngineTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/report/opensearch/OpensearchReportEngineTest.java new file mode 100644 index 00000000..b4563787 --- /dev/null +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/report/opensearch/OpensearchReportEngineTest.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.function.report.opensearch; + +import org.apache.eventmesh.dashboard.console.function.report.DataIdModel; +import org.apache.eventmesh.dashboard.console.function.report.DataValueModel; +import org.apache.eventmesh.dashboard.console.function.report.ReportConfig; +import org.apache.eventmesh.dashboard.console.function.report.elasticsearch.DataModel; + +import java.util.List; + +import org.junit.Before; +import org.junit.Test; + +public class OpensearchReportEngineTest { + + private OpensearchReportEngine engine = new OpensearchReportEngine(); + + @Before + public void init() { + ReportConfig reportConfig = new ReportConfig(); + reportConfig.setEngineAddress("http://localhost:9200"); + engine.setReportConfig(reportConfig); + engine.init(); + } + + @Test + public void addData(){ + DataIdModel dataIdModel = new DataIdModel(); + dataIdModel.setCount(3); + List list = dataIdModel.getRuntimeDataModel(); + DataValueModel dataValueModel = new DataValueModel(); + List objectList = list; + this.engine.batchInsert("tstttt", (List) objectList); + + + } + +} diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/message/TopicEntityMapperTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/message/TopicEntityMapperTest.java index a6bfff80..13ec86e6 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/message/TopicEntityMapperTest.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/message/TopicEntityMapperTest.java @@ -91,11 +91,12 @@ public static TopicEntity createTopicEntity(Long clusterId, Long topicId) { topicEntity.setRuntimeId(2L); topicEntity.setTopicName("test-" + nameIndex.getAndIncrement()); topicEntity.setTopicType("topicType"); - topicEntity.setNumQueue(8L); + topicEntity.setWriteQueueNum(8); + topicEntity.setReadQueueNum(8); topicEntity.setReplicationFactor(2); topicEntity.setTopicFilterType("topicFilterType"); topicEntity.setAttributes("1"); - topicEntity.setOrder("desc"); + topicEntity.setOrder(1); topicEntity.setRetentionMs(1L); topicEntity.setDescription("desc"); topicEntity.setCreateProgress(1); diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/spring/support/RuntimeDeployServiceTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/spring/support/RuntimeDeployServiceTest.java index 011a798f..30760eb1 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/spring/support/RuntimeDeployServiceTest.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/spring/support/RuntimeDeployServiceTest.java @@ -103,6 +103,7 @@ public void init() throws IllegalAccessException { FieldUtils.writeField(runtimeDeployService, "configService", configService, true); FieldUtils.writeField(runtimeDeployService, "portService", portService, true); + sdkManageMockedStatic = Mockito.mockStatic(SDKManage.class); sdkManageMockedStatic.when(SDKManage::getInstance).thenReturn(sdkManageMock); diff --git a/eventmesh-dashboard-console/src/test/resources/kubernetes/EventMesh-runtime.yaml b/eventmesh-dashboard-console/src/test/resources/kubernetes/EventMesh-runtime.yaml index 67f8bdd3..0c353ec2 100644 --- a/eventmesh-dashboard-console/src/test/resources/kubernetes/EventMesh-runtime.yaml +++ b/eventmesh-dashboard-console/src/test/resources/kubernetes/EventMesh-runtime.yaml @@ -47,6 +47,7 @@ spec: value: "rocketmq-namesrv:9876" # 中间件地址 - name: CONFIG value: "${runtimeConfig}" + command: ["java -jar "] --- apiVersion: v1 diff --git a/pom.xml b/pom.xml index bcf45f19..b9695351 100644 --- a/pom.xml +++ b/pom.xml @@ -87,6 +87,7 @@ eventmesh-dashboard-service eventmesh-dashboard-core eventmesh-dashboard-observe + eventmesh-dashboard-agent @@ -221,7 +222,7 @@ maven-surefire-plugin 3.5.3 - -Xmx1024m -XX:MaxPermSize=256m + -Xmx1024m true **/*Test*.java From e38ef26826ae9b066ad71432fe82f1b81b16ae34 Mon Sep 17 00:00:00 2001 From: "jie@apache.org" <2732554140@qq.com> Date: Mon, 18 Aug 2025 09:11:00 +0800 Subject: [PATCH 04/11] =?UTF-8?q?fix(*):1.=20=E4=BF=9D=E5=AD=98=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=EF=BC=8C=E5=9B=A0=E4=B8=BA=20rocketmq-exporter=20?= =?UTF-8?q?=E5=AE=98=E6=96=B9=E6=96=87=E6=A1=A3=20=E4=B8=8E=20rocketmq-exp?= =?UTF-8?q?orter=20=E6=BA=90=E7=A0=81=E6=96=87=E6=A1=A3=E4=B8=8D=E4=B8=80?= =?UTF-8?q?=E8=87=B4=EF=BC=8C=E9=9C=80=E8=A6=81=E5=AE=89=E8=A3=85=E6=BA=90?= =?UTF-8?q?=E7=A0=81=E6=96=87=E6=A1=A3=E5=AE=9A=E4=B9=89=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=AF=B9=E8=B1=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../report/annotation/Aggregation.java | 21 ++++++ .../report/collect/CollectManage.java | 21 ++++++ .../report/collect/MetadataDataManage.java | 72 +++++++++++++++++++ .../function/report/model/base/Query.java | 22 ++++++ .../rocketmq/RocketmqGroupGetLatency.java | 22 ++++++ .../collect/exporter/CollectExporterTest.java | 22 ++++++ ...st.java => RuntimeConvertMetaKeyTest.java} | 0 7 files changed, 180 insertions(+) create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/annotation/Aggregation.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/collect/CollectManage.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/collect/MetadataDataManage.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/base/Query.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqGroupGetLatency.java create mode 100644 eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/report/collect/exporter/CollectExporterTest.java rename eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/spring/support/metadata/convert/{RuntimeConvertMetaDataTest.java => RuntimeConvertMetaKeyTest.java} (100%) diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/annotation/Aggregation.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/annotation/Aggregation.java new file mode 100644 index 00000000..3ad72fda --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/annotation/Aggregation.java @@ -0,0 +1,21 @@ +/* + * 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.function.report.annotation; + +public @interface Aggregation { +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/collect/CollectManage.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/collect/CollectManage.java new file mode 100644 index 00000000..767ff35a --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/collect/CollectManage.java @@ -0,0 +1,21 @@ +/* + * 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.function.report.collect; + +public class CollectManage { +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/collect/MetadataDataManage.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/collect/MetadataDataManage.java new file mode 100644 index 00000000..b340ed02 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/collect/MetadataDataManage.java @@ -0,0 +1,72 @@ +/* + * 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.function.report.collect; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import lombok.Data; +import lombok.Setter; + +public class EntityManage { + + + @Setter + private MetaData metaData = new MetaData(); + + + public void supplement(String orId, List metaKeyList) { + MetaData metaData = this.metaData.getMetaMap().get(orId); + + } + + + + @Data + public static class MetaData{ + + + private Map metaMap = new HashMap<>(); + + private Long id; + } + + + public static class ClusterMeta{ + + private MetaData runtime = new MetaData(); + + private MetaData topic = new MetaData(); + + private MetaData group = new MetaData(); + + + } + + public static class MetaKey { + + + private String metaType; + + private String name; + + + } + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/base/Query.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/base/Query.java new file mode 100644 index 00000000..a128b6d4 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/base/Query.java @@ -0,0 +1,22 @@ +/* + * 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.function.report.model.base; + +public class Query { + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqGroupGetLatency.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqGroupGetLatency.java new file mode 100644 index 00000000..d522ade4 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/model/rocketmq/RocketmqGroupGetLatency.java @@ -0,0 +1,22 @@ +/* + * 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.function.report.model.rocketmq; + +public class RocketmqGroupGetLatency { + +} diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/report/collect/exporter/CollectExporterTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/report/collect/exporter/CollectExporterTest.java new file mode 100644 index 00000000..0418790c --- /dev/null +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/function/report/collect/exporter/CollectExporterTest.java @@ -0,0 +1,22 @@ +/* + * 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.function.report.collect.exporter; + +public class CollectExporterTest { + +} diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/spring/support/metadata/convert/RuntimeConvertMetaDataTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/spring/support/metadata/convert/RuntimeConvertMetaKeyTest.java similarity index 100% rename from eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/spring/support/metadata/convert/RuntimeConvertMetaDataTest.java rename to eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/spring/support/metadata/convert/RuntimeConvertMetaKeyTest.java From 50e43ef570b605f383de95fb0b9867c2c95137a3 Mon Sep 17 00:00:00 2001 From: "jie@apache.org" <2732554140@qq.com> Date: Sun, 28 Sep 2025 12:28:46 +0800 Subject: [PATCH 05/11] =?UTF-8?q?fix(console):=201.=20=E5=AE=8C=E6=88=90?= =?UTF-8?q?=20db=20cluster=20=E5=85=B3=E7=B3=BB=202.=20=E4=B8=A4=E4=B8=AA?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=20mock=20=E6=A8=A1=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/TODO.md | 91 +++++ .../common/annotation/ClusterTypeMark.java | 35 ++ .../annotation/RemotingServiceMapper.java | 2 +- .../common/enums/ClusterFramework.java | 4 + .../common/enums/ClusterOwnType.java | 12 + .../common/enums/ClusterSyncMetadataEnum.java | 16 +- .../common/enums/ClusterTrusteeshipType.java | 2 + .../dashboard/common/enums/ClusterType.java | 25 +- .../dashboard/common/enums/CollectType.java | 34 ++ .../common/enums/DeployStatusType.java | 6 + .../dashboard/common/enums/MetadataType.java | 9 +- .../common/enums/OperationRange.java | 21 +- .../dashboard/common/enums/SyncStatus.java | 28 ++ .../dashboard/common/enums/SyncType.java | 37 ++ .../enums/health/HealthCheckStatus.java | 2 + .../enums/health/HealthCheckTypeEnum.java | 4 +- .../common/model/ClusterSyncMetadata.java | 8 +- .../common/model/base/BaseClusterIdBase.java | 4 +- .../model/base/BaseOrganizationBase.java | 74 +++- .../model/metadata/ClusterMetadata.java | 2 +- .../model/metadata/CollectMetadata.java | 99 +++++ .../model/metadata/GroupMemberMetadata.java | 41 ++ .../model/metadata/NetConnectionMetadata.java | 50 +++ .../remoting/topic/DeleteTopicRequest.java | 11 +- .../remoting/topic/GetTopics2Request.java | 5 +- .../EventMeshDashboardApplication.java | 2 + .../console/controller/ReportController.java | 14 +- .../deploy/ActiveCreateController.java | 135 +++++++ .../deploy/ActiveCreateDTOHandler.java | 198 +++++++++ .../deploy/ClusterCycleController.java | 84 +--- .../controller/deploy/DeployBeforeCheck.java | 25 ++ .../deploy/base/AbstractUpdateHandler.java | 34 ++ .../create/CreateClusterByCopyHandler.java | 50 +++ .../CreateClusterByDeployScriptHandler.java | 4 + .../CreateClusterByFullMetadataHandler.java | 41 ++ .../CreateRuntimeByDeployScriptHandler.java | 13 +- .../deploy/handler/UpdateHandler.java | 9 +- .../controller/deploy/pause/PauseCluster.java | 2 - .../relationship/RelationshipHandler.java | 46 ++- .../uninstall/UninstallClusterHandler.java | 12 + .../uninstall/UninstallRuntimeHandler.java | 15 + .../controller/message/TopicController.java | 11 +- .../domain/ClusterAndRuntimeDomain.java | 2 + .../Impl/ClusterAndRuntimeDomainImpl.java | 372 ++++++++++++++++- .../metadata/ClusterMetadataDomain.java | 4 +- .../entity/base/BaseOrganizationEntity.java | 1 + .../console/entity/cluster/CollectEntity.java | 43 ++ .../console/entity/function/ConfigEntity.java | 4 +- .../function/HealthCheckResultEntity.java | 6 +- ...tionEntity.java => GroupMemberEntity.java} | 2 +- .../function/health/Health2Service.java | 95 ++++- .../health/check/impl/jvm/JVMCheck.java | 4 +- .../function/report/AbstractReportEngine.java | 12 +- .../console/function/report/ReportEngine.java | 13 +- .../function/report/ReportHandlerManage.java | 93 ++++- .../annotation/AbstractReportMetaHandler.java | 12 +- .../report/annotation/Aggregation.java | 12 + .../report/annotation/ReportMeta.java | 9 +- .../report/annotation/ReportMetaData.java | 32 +- .../function/report/collect/Collect.java | 59 +++ .../report/collect/CollectManage.java | 254 ++++++++++++ .../report/collect/MetadataDataManage.java | 215 +++++++++- .../collect/active/AbstractCollect.java | 68 ++++ .../active/AbstractMetadataCollect.java | 49 +++ .../collect/exporter/CollectExporter.java | 238 +++++++++++ .../ElasticsearchReportEngine.java | 4 +- .../report/iotdb/IotDBReportEngine.java | 106 +++-- .../report/iotdb/IotDBReportMetaHandler.java | 11 +- .../function/report/model/base/Query.java | 20 + .../rocketmq/RocketmqGroupGetLatency.java | 21 +- .../RocketmqTopicCreateExecutionTime.java | 2 + .../opensearch/OpensearchReportEngine.java | 4 +- .../dashboard/console/log/OprLog.java | 3 +- .../console/mapper/cluster/ClusterMapper.java | 50 ++- .../cluster/ClusterRelationshipMapper.java | 17 + .../console/mapper/cluster/RuntimeMapper.java | 35 +- .../console/mapper/function/ConfigMapper.java | 10 +- .../function/HealthCheckResultMapper.java | 36 +- .../console/mapper/message/GroupMapper.java | 18 + .../mapper/message/GroupMemberMapper.java | 41 +- .../console/mapper/message/TopicMapper.java | 17 +- .../cluster/ClusterControllerMapper.java | 3 + .../cluster/RuntimeControllerMapper.java | 3 +- .../deploy/ActiveCreateControllerMapper.java | 47 +++ .../deploy/ClusterCycleControllerMapper.java | 4 - .../dashboard/console/modle/ClusterIdDTO.java | 4 + .../modle/DO/CreateTheEventClusterDO.java | 78 ++++ .../QueryListByClusterIdAndTypeDO.java | 2 + .../ClusterAndRuntimeOfRelationshipDO.java | 47 +++ .../GetClusterInSyncReturnDO.java | 34 ++ .../console/modle/OrganizationIdDTO.java | 2 +- ...RelationClusterByClusterIdListAndType.java | 34 ++ .../deploy/active/BaseCreateClusterDTO.java | 33 ++ .../modle/deploy/active/CreateClusterDTO.java | 50 +++ .../CreateEventMeshSpaceDTO.java} | 10 +- .../active}/CreateRuntimeDTO.java | 15 +- .../active/CreateTheEntireClusterDTO.java | 36 ++ .../active/CreateTheEventClusterDTO.java | 94 +++++ .../create/CreateClusterByFormDataDTO.java | 43 ++ .../cluster/ClusterRelationshipService.java | 6 + .../service/cluster/ClusterService.java | 17 + .../service/cluster/RuntimeService.java | 10 + .../impl/ClusterRelationshipServiceImpl.java | 13 +- .../cluster/impl/ClusterServiceImpl.java | 59 ++- .../cluster/impl/RuntimeServiceImpl.java | 22 + .../Impl/HealthDataServiceDatabaseImpl.java | 17 +- .../service/message/GroupMemberService.java | 20 +- .../message/impl/GroupMemberServiceImp.java | 42 +- .../message/impl/TopicServiceImpl.java | 20 +- .../AbstractDBDataMetadataHandler.java | 8 +- .../metadata/ClientDataMetadataHandler.java | 3 +- .../metadata/ConfigDataMetadataHandler.java | 17 +- .../ConsumeOffsetDataMetadataHandler.java | 3 +- .../metadata/GroupDataMetadataHandler.java | 3 +- .../GroupMemberDataMetadataHandler.java | 41 ++ .../NetConnectionDataMetadataHandler.java | 3 +- .../metadata/RuntimeDataMetadataHandler.java | 3 +- .../metadata/TopicDataMetadataHandler.java | 6 +- .../TopicOffsetDataMetadataHandler.java | 5 +- .../spring/support/FunctionManage.java | 23 +- .../spring/support/RuntimeDeployService.java | 5 +- .../metadata/DatabaseAndMetadataType.java | 14 +- .../DefaultMetadataSyncResultHandler.java | 2 +- .../convert/GroupMemberConvertMetaData.java | 37 ++ .../convert/NetConnectionMetaData.java | 41 ++ .../src/main/resources/RENAME.md | 38 -- .../src/main/resources/application-dev.yml | 4 +- .../src/main/resources/application.yml | 4 +- .../main/resources/eventmesh-dashboard.jmx | 138 +++---- .../main/resources/eventmesh-dashboard.sql | 47 ++- .../src/main/resources/logback.xml | 94 ++++- .../ActiveCreateControllerTest.java | 308 ++++++++++++++ .../databuild/BuildDataController.java | 89 ++++ .../console/databuild/BuildDataService.java | 382 ++++++++++++++++++ .../databuild/BuildFullDataMapper.java | 272 ++++++++++++- .../console/databuild/BuildFullSceneData.java | 269 +++++++++--- .../console/databuild/BuildMessageData.java | 106 +++-- .../collect/exporter/CollectExporterTest.java | 51 +++ .../report/iotdb/IotDBReportEngineTest.java | 7 +- .../cluster/ClusterEntityMapperTest.java | 7 +- .../cluster/RuntimeEntityMapperTest.java | 55 ++- .../HealthDataServiceDatabaseImplTest.java | 67 +++ .../convert/RuntimeConvertMetaKeyTest.java | 2 +- .../kubernetes/RocketMQ-exporter.yaml | 0 .../dashboard/core/cluster/ColonyDO.java | 6 + .../core/function/SDK/AbstractClientInfo.java | 4 +- .../core/function/SDK/SDKManage.java | 6 +- .../SDK/config/AbstractCreateSDKConfig.java | 4 +- .../config/AbstractMultiCreateSDKConfig.java | 18 +- .../config/AbstractSimpleCreateSDKConfig.java | 1 + .../SDK/config/NullCreateSDKConfig.java | 2 +- .../function/SDK/operation/jvm/JvmAdmin.java | 5 +- .../core/metadata/FullMetadataHandler.java | 10 +- .../core/metadata/MetadataSyncManage.java | 133 +++--- .../core/metadata/MetadataSyncWrapper.java | 235 +++++++++-- .../metadata/SyncMetadataCreateFactory.java | 83 +++- .../difference/AbstractBothDifference.java | 72 +++- .../difference/AbstractBufferDifference.java | 16 +- .../difference/AbstractDifference.java | 15 +- .../difference/BodyDataDifference.java | 3 +- .../difference/BothCacheDifference.java | 41 ++ ...rence.java => BothNotCacheDifference.java} | 19 +- .../metadata/difference/BufferDifference.java | 5 +- .../metadata/result/MetadataSyncResult.java | 7 +- .../core/remoting/Remoting2Manage.java | 117 ++++-- .../jvm/AbstractJvmRemotingService.java | 3 +- ...ava => JvmGroupMemberRemotingService.java} | 4 +- .../remoting/jvm/JvmMetaRemotingService.java | 30 ++ .../AbstractRocketMQRemotingService.java | 3 + ...> RocketMQGroupMemberRemotingService.java} | 4 +- .../runtime/AbstractJvmRemotingService.java | 29 ++ .../runtime/JvmAclRemotingService.java | 48 +++ .../runtime/JvmClientRemotingService.java | 35 ++ .../runtime/JvmConfigRemotingService.java | 46 +++ .../JvmGroupMemberRemotingService.java | 33 ++ .../runtime/JvmGroupRemotingService.java | 40 ++ .../runtime/JvmOffsetRemotingService.java | 42 ++ .../runtime/JvmTopicRemotingService.java | 53 +++ .../runtime/JvmUserRemotingService.java | 44 ++ .../jvm/AbstractRuntimeRemotingService.java | 30 ++ .../jvm/RuntimeAclRemotingService.java | 48 +++ .../jvm/RuntimeClientRemotingService.java | 35 ++ .../jvm/RuntimeConfigRemotingService.java | 46 +++ .../RuntimeGroupMemberRemotingService.java | 33 ++ .../jvm/RuntimeGroupRemotingService.java | 40 ++ .../jvm/RuntimeOffsetRemotingService.java | 42 ++ .../jvm/RuntimeTopicRemotingService.java | 56 +++ .../jvm/RuntimeUserRemotingService.java | 44 ++ .../remoting/difference/DifferenceTest.java | 123 ++++++ ...e.java => GroupMemberRemotingService.java} | 2 +- .../remoting/RemotingIntegrationService.java | 2 +- 191 files changed, 7081 insertions(+), 866 deletions(-) create mode 100644 doc/TODO.md create mode 100644 eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/annotation/ClusterTypeMark.java create mode 100644 eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/CollectType.java create mode 100644 eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/SyncStatus.java create mode 100644 eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/SyncType.java create mode 100644 eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/CollectMetadata.java create mode 100644 eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/GroupMemberMetadata.java create mode 100644 eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/NetConnectionMetadata.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/ActiveCreateController.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/ActiveCreateDTOHandler.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/DeployBeforeCheck.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/base/AbstractUpdateHandler.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/create/CreateClusterByCopyHandler.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/create/CreateClusterByFullMetadataHandler.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/CollectEntity.java rename eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/message/{SubscriptionEntity.java => GroupMemberEntity.java} (94%) create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/collect/Collect.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/collect/active/AbstractCollect.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/collect/active/AbstractMetadataCollect.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/collect/exporter/CollectExporter.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapstruct/deploy/ActiveCreateControllerMapper.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/DO/CreateTheEventClusterDO.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/DO/domain/clusterAndRuntimeDomain/ClusterAndRuntimeOfRelationshipDO.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/DO/domain/clusterAndRuntimeDomain/GetClusterInSyncReturnDO.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/QO/cluster/QueryRelationClusterByClusterIdListAndType.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/active/BaseCreateClusterDTO.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/active/CreateClusterDTO.java rename eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/{create/CreateClusterByEventMesh.java => active/CreateEventMeshSpaceDTO.java} (85%) rename eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/{cluster/runtime => deploy/active}/CreateRuntimeDTO.java (79%) create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/active/CreateTheEntireClusterDTO.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/active/CreateTheEventClusterDTO.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/modle/deploy/create/CreateClusterByFormDataDTO.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/metadata/GroupMemberDataMetadataHandler.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/metadata/convert/GroupMemberConvertMetaData.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/spring/support/metadata/convert/NetConnectionMetaData.java delete mode 100644 eventmesh-dashboard-console/src/main/resources/RENAME.md create mode 100644 eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/controller/ActiveCreateControllerTest.java create mode 100644 eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/databuild/BuildDataController.java create mode 100644 eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/databuild/BuildDataService.java create mode 100644 eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/function/HealthDataServiceDatabaseImplTest.java create mode 100644 eventmesh-dashboard-console/src/test/resources/kubernetes/RocketMQ-exporter.yaml create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/difference/BothCacheDifference.java rename eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/metadata/difference/{BothDifference.java => BothNotCacheDifference.java} (77%) rename eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/jvm/{JvmSubscriptionRemotingService.java => JvmGroupMemberRemotingService.java} (85%) create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/jvm/JvmMetaRemotingService.java rename eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/rocketmq/{RocketMQSubscriptionRemotingService.java => RocketMQGroupMemberRemotingService.java} (84%) create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/runtime/AbstractJvmRemotingService.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/runtime/JvmAclRemotingService.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/runtime/JvmClientRemotingService.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/runtime/JvmConfigRemotingService.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/runtime/JvmGroupMemberRemotingService.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/runtime/JvmGroupRemotingService.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/runtime/JvmOffsetRemotingService.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/runtime/JvmTopicRemotingService.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/runtime/JvmUserRemotingService.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/runtime/jvm/AbstractRuntimeRemotingService.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/runtime/jvm/RuntimeAclRemotingService.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/runtime/jvm/RuntimeClientRemotingService.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/runtime/jvm/RuntimeConfigRemotingService.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/runtime/jvm/RuntimeGroupMemberRemotingService.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/runtime/jvm/RuntimeGroupRemotingService.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/runtime/jvm/RuntimeOffsetRemotingService.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/runtime/jvm/RuntimeTopicRemotingService.java create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/remoting/runtime/jvm/RuntimeUserRemotingService.java create mode 100644 eventmesh-dashboard-core/src/test/java/org/apache/eventmesh/dashboard/core/remoting/difference/DifferenceTest.java rename eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/remoting/{SubscriptionRemotingService.java => GroupMemberRemotingService.java} (96%) diff --git a/doc/TODO.md b/doc/TODO.md new file mode 100644 index 00000000..e9d59487 --- /dev/null +++ b/doc/TODO.md @@ -0,0 +1,91 @@ + +## 文档任务 +- 整体设计文档 +- metadata 数据 设计文档 +- 部署设计文档 +- Cluster 设计文档 +- 同步设计文档 +- 心跳设计文档 +- SDK 设计文档 +- 远程服务设计文档 +- 日志说明与使用设计文档 +- 采集设计文档 +- 采集数据库设计文档 +- 模拟数据 同步测试文档 +- RocketMQ 同步测试文档 +- 部署测试文档 +- 采集测试文档 +- 增加一个 存储 整个开发流程 +- 增加一个 meta 整个开发流程 + + +## 问题 +- 自动化部署之后,如何确定部署是否成功,部署测试如何做? +- group 与 group memer 是 cluster 级别还是 runtime 级别 + - 如果是 cluster 级别,rocketmq 需要支持 cluster 级别操作,如果不支持着需要全量删除 +- group 与 group memer 只读,不允许创建 + +## 任务 +- SyncStatus 状态补充 +- 采集支持 es +- 采集支持 OpenSearch +- RocketMQ 采集API +- kafka API 与 采集API +- Runtime API 与 采集API + + +## SyncStatus 状态补充 +- 同步表,需要添加 SyncStatus 字段 +- Entity 需要一个 SyncStatus 类 +- 状态转换确认 。 RemotingService(是否独立出来) 里面 成功与失败状态 +- 所有查询 需要过滤 成功状态 +- 操作数据时, 需要修改 SyncStatus +- 需要一个 SyncStatus 管理类 + + + + +无法进行确认,支持同类型修改 + +1. 用户进来,是进入默认组织 首页 +2. 通过左上角切换 +3. 组织视图与 cluster 共存,这样是否会出现三级路由 +4. 人员添加,可以从组织添加,也可以从 cluster 里面添加。如果从 cluster 里面添加,是否就属于合格组织一员? +5. 资源维度,是否是cluster 的 + +6. 删除 topic 之后,同时需要作废对应的 订阅吗? +7. 删除 group 之后,同时需要作废对应的 订阅吗? +8. 删除 cluster 或则 runtime 之后对应的信息是否全部作废。 +9. 暂停状态数据如何标记,激活 对应的 metadata 之前相关的数据是否启动 +10. 删除 cluster 之前之后校验 关联。如何关联存在是否允许删除 +11. kafka 的查询维度全是 cluster +12. RocketMQ 大集群查询,是否支持 metadata 数据查询,如何对数据进行展示? 是否现实差异化,是否提示差异字段 + 1. 那些 topic 有差异? + 2. 是否配置 不允许有差异? + 3. 如果不允许有差异, console 进行处理的 metadata 是否要进行具体标识 +14. RocketMQ 支持大集群,小集群,runtime 维度的展示 + + +项目发起人,项目架构师,项目设计师,项目经理, +交互设计师,半个ui设计 +前端,后台,运维,产品,测试, + + +## 用户域 +### 用户首页 +1. 查看 组织 + +### 组织首页 +1. 左边是一级菜单: + 1. 工作台 + 2. eventmesh集群 + 3. +1. 集群信息 + 2. 集群列表 + +### 日志分类 +1. 心跳加载日志 +2. 数据同步日志 +3. 运维操作日志 +4. 数据采集日志 +5. metadata 数据日志 \ No newline at end of file diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/annotation/ClusterTypeMark.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/annotation/ClusterTypeMark.java new file mode 100644 index 00000000..cb8ef1a4 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/annotation/ClusterTypeMark.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.eventmesh.dashboard.common.annotation; + +import org.apache.eventmesh.dashboard.common.enums.ClusterType; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface ClusterTypeMark { + + ClusterType clusterType(); + +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/annotation/RemotingServiceMapper.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/annotation/RemotingServiceMapper.java index 20a278b3..dc32be1a 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/annotation/RemotingServiceMapper.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/annotation/RemotingServiceMapper.java @@ -32,6 +32,6 @@ public @interface RemotingServiceMapper { - ClusterType clusterType(); + ClusterType[] clusterType(); } diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ClusterFramework.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ClusterFramework.java index 0de7ccb2..7a89b0f2 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ClusterFramework.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ClusterFramework.java @@ -44,6 +44,10 @@ public enum ClusterFramework { ZK, ; + public boolean isIndependence() { + return this == ClusterFramework.INDEPENDENCE; + } + public boolean isAP() { return Objects.equals(this, AP); } diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ClusterOwnType.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ClusterOwnType.java index b5deee5c..c4337fd7 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ClusterOwnType.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ClusterOwnType.java @@ -22,12 +22,24 @@ public enum ClusterOwnType { NOT, + /** + * 独立 + */ INDEPENDENCE, + /** + * 共享 + */ SHARE, + /** + * 全局共享 + */ OVERALL_SHARE, + /** + * 组织内部共享 + */ ORGANIZATION_SHARE, ; diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ClusterSyncMetadataEnum.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ClusterSyncMetadataEnum.java index 7560b195..ddc136f3 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ClusterSyncMetadataEnum.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ClusterSyncMetadataEnum.java @@ -41,6 +41,12 @@ public enum ClusterSyncMetadataEnum { EVENTMESH_META_NACOS(ClusterSyncMetadata.builder().clusterFramework(ClusterFramework.AP).metadataTypeList(ClusterSyncMetadata.META).build()), + EVENTMESH_JVM_RUNTIME(EVENTMESH_RUNTIME), + + EVENTMESH_JVM_META(EVENTMESH_META_NACOS), + + + STORAGE_ROCKETMQ_NAMESERVER( ClusterSyncMetadata.builder().clusterFramework(ClusterFramework.AP).metadataTypeList(ClusterSyncMetadata.META).build()), @@ -59,9 +65,15 @@ public enum ClusterSyncMetadataEnum { .metadataTypeList(ListWrapper.build().add(ClusterSyncMetadata.STORAGE).add(ClusterSyncMetadata.AUTH).list) .replicationDimension(ReplicationDimension.TOPIC).build()), + + STORAGE_JVM_META(EVENTMESH_META_NACOS), + STORAGE_JVM_BROKER( ClusterSyncMetadata.builder().clusterFramework(ClusterFramework.MAIN_SLAVE).metadataTypeList(ClusterSyncMetadata.TEST_ONE).build()), + + STORAGE_JVM_CAP_META(STORAGE_KAFKA_ZK), + STORAGE_JVM_CAP_BROKER( ClusterSyncMetadata.builder().clusterFramework(ClusterFramework.CAP).metadataTypeList(ClusterSyncMetadata.STORAGE) .replicationDimension(ReplicationDimension.TOPIC).build()), @@ -109,5 +121,7 @@ ListWrapper add(List list) { this.clusterSyncMetadata = clusterSyncMetadata; } - + ClusterSyncMetadataEnum(ClusterSyncMetadataEnum clusterSyncMetadataEnum) { + this.clusterSyncMetadata = clusterSyncMetadataEnum.clusterSyncMetadata; + } } diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ClusterTrusteeshipType.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ClusterTrusteeshipType.java index 49c949ee..581fa92e 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ClusterTrusteeshipType.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ClusterTrusteeshipType.java @@ -85,6 +85,8 @@ public enum FirstToWhom { */ UNDER_WAY, + NOT_EXECUTED, + FAIL, ; diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ClusterType.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ClusterType.java index f8b24519..db9fdd48 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ClusterType.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/ClusterType.java @@ -28,6 +28,9 @@ public enum ClusterType { + /** + * 只有逻辑集群才会使用 这个枚举。比如 EVENTMESH_CLUSTER,先定义 EVENTMESH_CLUSTER,然后 runtime 与 meta 集群关联上 + */ DEFINITION(0), DEFAULT(1), @@ -35,6 +38,8 @@ public enum ClusterType { EVENTMESH(20), + EVENTMESH_JVM(21), + CLUSTER(1), META(2), @@ -69,6 +74,8 @@ public enum ClusterType { CLUSTER_TYPE_STORAGE(1), + PROMETHEUS_EXPORTER(1), + NODE_BY_COPY_IN_TYPE(2), NODE_BY_COPY_IN_TYPE_NOT_HAVE(2), @@ -88,6 +95,8 @@ public enum ClusterType { META_TYPE_ZK(ClusterType.META.code + 3), + META_TYPE_JVM(ClusterType.META.code + 4), + META_TYPE_ROCKETMQ_NAMESERVER(ClusterType.META.code + 31), KUBERNETES_RUNTIME(DEFAULT, DEFAULT, CLUSTER, RUNTIME, RemotingType.KUBERNETES), @@ -100,6 +109,14 @@ public enum ClusterType { EVENTMESH_META_NACOS(EVENTMESH, EVENTMESH, META, META_TYPE_NACOS, RemotingType.EVENT_MESH_NACOS), + EVENTMESH_JVM_CLUSTER(EVENTMESH, EVENTMESH_JVM, CLUSTER, DEFINITION, RemotingType.EVENT_MESH_RUNTIME), + + EVENTMESH_JVM_RUNTIME(EVENTMESH, EVENTMESH_JVM, RUNTIME, DEFAULT, RemotingType.EVENT_MESH_RUNTIME), + + EVENTMESH_JVM_META(EVENTMESH, EVENTMESH_JVM, META, META_TYPE_JVM, RemotingType.JVM), + + + STORAGE_ROCKETMQ(ClusterType.STORAGE.code + 1), STORAGE_ROCKETMQ_CLUSTER(STORAGE, STORAGE_ROCKETMQ, CLUSTER, DEFINITION, RemotingType.ROCKETMQ), @@ -143,6 +160,8 @@ public enum ClusterType { STORAGE_JVM_CAP_CLUSTER(STORAGE, STORAGE_JVM_CAP, CLUSTER, DEFINITION, RemotingType.JVM), STORAGE_JVM_CAP_BROKER(STORAGE, STORAGE_JVM_CAP, META_AND_RUNTIME, DEFAULT, RemotingType.JVM), + + STORAGE_JVM_CAP_META(STORAGE,STORAGE_JVM_CAP, META, DEFAULT, RemotingType.JVM), ; @@ -249,8 +268,12 @@ public boolean isEventMethMeta() { } + public boolean isEventCluster(){ + return this.eventmeshNodeType.equals(EVENTMESH) && this.assemblyNodeType.equals(CLUSTER); + } + public boolean isEventMethRuntime() { - return this == EVENTMESH_RUNTIME; + return this == EVENTMESH_RUNTIME || this == EVENTMESH_JVM_RUNTIME; } public boolean isMeta() { diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/CollectType.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/CollectType.java new file mode 100644 index 00000000..1fcb5351 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/CollectType.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.common.enums; + + +public enum CollectType { + + NONE, + + /** + * + */ + PROMETHEUS, + + EVENTMESH + + ; + +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/DeployStatusType.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/DeployStatusType.java index 2e8556bb..87a5e570 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/DeployStatusType.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/DeployStatusType.java @@ -20,11 +20,17 @@ public enum DeployStatusType { + SETTLE, RESOURCE_APPLY, RESOURCE_APPLY_FAILED, + /** + * 是不是需要这个状态的检查 + */ + CREATE_DATA_ING, + CREATE_WAIT, CREATE_FULL_WAIT, diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/MetadataType.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/MetadataType.java index 42ca89d9..184104fc 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/MetadataType.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/MetadataType.java @@ -24,6 +24,7 @@ import org.apache.eventmesh.dashboard.common.model.metadata.ConfigMetadata; import org.apache.eventmesh.dashboard.common.model.metadata.ConnectionMetadata; import org.apache.eventmesh.dashboard.common.model.metadata.ConsumeOffsetMetadata; +import org.apache.eventmesh.dashboard.common.model.metadata.GroupMemberMetadata; import org.apache.eventmesh.dashboard.common.model.metadata.GroupMetadata; import org.apache.eventmesh.dashboard.common.model.metadata.RuntimeMetadata; import org.apache.eventmesh.dashboard.common.model.metadata.TopicMetadata; @@ -43,16 +44,20 @@ public enum MetadataType { TOPIC(TopicMetadata.class), - GROUP(GroupMetadata.class), + GROUP(GroupMetadata.class,true), + @Deprecated TOPIC_OFFSET(TopicOffsetMetadata.class, true), + @Deprecated CONSUME_OFFSET(ConsumeOffsetMetadata.class, true), - SUBSCRIBER(GroupMetadata.class), + GROUP_MEMBER(GroupMemberMetadata.class,true), + @Deprecated CLIENT(ClientMetadata.class, true), + @Deprecated NET_CONNECT(ConnectionMetadata.class, true), USER(ConnectionMetadata.class), diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/OperationRange.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/OperationRange.java index bfe248db..5521f264 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/OperationRange.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/OperationRange.java @@ -48,6 +48,17 @@ private void setOperationRange(ClusterType clusterType, OperationRangeType opera public List getOperationRangeTypeList(ClusterType clusterType) { return operationRangeListHashMap.get(clusterType); + } + + + public enum OperationType{ + + RUNTIME_CONFIG, + + + + + } /** @@ -56,13 +67,15 @@ public List getOperationRangeTypeList(ClusterType clusterTyp */ public enum OperationRangeType { - ALL(null), + ALL(), + + CLUSTER(), + + ALL_RUNTIME(), - CLUSTER(null), + ONCE_CLUSTER(), - ALL_RUNTIME(null), - ONCE_CLUSTER(null), RANGE_CLUSTER_CAP(CLUSTER), diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/SyncStatus.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/SyncStatus.java new file mode 100644 index 00000000..e479381b --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/SyncStatus.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.eventmesh.dashboard.common.enums; + +public enum SyncStatus { + + ING, + + SUCCESS, + + FAIL, + +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/SyncType.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/SyncType.java new file mode 100644 index 00000000..20d74ec0 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/SyncType.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.common.enums; + +public enum SyncType { + + NOT, + + READONLY, + + FIRSTTOWHOM, + + INIT, + + CHECK, + + TIMINGSYNC, + + ; + + +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/health/HealthCheckStatus.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/health/HealthCheckStatus.java index 34a5891d..4cb6f5c7 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/health/HealthCheckStatus.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/health/HealthCheckStatus.java @@ -25,6 +25,8 @@ @AllArgsConstructor public enum HealthCheckStatus { + ING(1L,"ing"), + SUCCESS(1L, "success"), FAILED(0L, "failed"), diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/health/HealthCheckTypeEnum.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/health/HealthCheckTypeEnum.java index 457e65b5..b28854ae 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/health/HealthCheckTypeEnum.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/health/HealthCheckTypeEnum.java @@ -25,6 +25,7 @@ @AllArgsConstructor public enum HealthCheckTypeEnum { + UNKNOWN(0, HealthCheckTypeConstant.HEALTH_CHECK_TYPE_UNKNOWN), PROCESS(0, "检查进场"), @@ -37,7 +38,7 @@ public enum HealthCheckTypeEnum { TOPIC(3, HealthCheckTypeConstant.HEALTH_CHECK_TYPE_TOPIC), - CLUSTER(1, HealthCheckTypeConstant.HEALTH_CHECK_TYPE_CLUSTER), + CLUSTER(5, HealthCheckTypeConstant.HEALTH_CHECK_TYPE_CLUSTER), RUNTIME(2, HealthCheckTypeConstant.HEALTH_CHECK_TYPE_RUNTIME), @@ -46,6 +47,7 @@ public enum HealthCheckTypeEnum { @Getter private final Integer number; + @Getter private final String name; diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/ClusterSyncMetadata.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/ClusterSyncMetadata.java index c58890d3..afdf9bd9 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/ClusterSyncMetadata.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/ClusterSyncMetadata.java @@ -50,11 +50,11 @@ public class ClusterSyncMetadata { META.add(MetadataType.RUNTIME); - STORAGE.add(MetadataType.CONFIG); + //STORAGE.add(MetadataType.CONFIG); STORAGE.add(MetadataType.TOPIC); - STORAGE.add(MetadataType.GROUP); - STORAGE.add(MetadataType.NET_CONNECT); - STORAGE.add(MetadataType.SUBSCRIBER); + //STORAGE.add(MetadataType.GROUP); + //STORAGE.add(MetadataType.NET_CONNECT); + //STORAGE.add(MetadataType.GROUP_MEMBER); AUTH.add(MetadataType.USER); AUTH.add(MetadataType.ACL); diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/base/BaseClusterIdBase.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/base/BaseClusterIdBase.java index b45c9e07..42c36fc0 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/base/BaseClusterIdBase.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/base/BaseClusterIdBase.java @@ -20,6 +20,8 @@ import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import java.util.Objects; + public abstract class BaseClusterIdBase extends BaseOrganizationBase { private Long clusterId; @@ -51,7 +53,7 @@ public boolean isUpdate() { } public boolean isInsert() { - return true; + return Objects.equals(this.getUpdateTime() , this.getCreateTime()); } } diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/base/BaseOrganizationBase.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/base/BaseOrganizationBase.java index a4c2356c..b36fc5d3 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/base/BaseOrganizationBase.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/base/BaseOrganizationBase.java @@ -19,14 +19,34 @@ package org.apache.eventmesh.dashboard.common.model.base; +import org.apache.eventmesh.dashboard.common.enums.SyncStatus; + +import java.time.LocalDateTime; +import java.util.Objects; + +@SuppressWarnings({"LombokGetterMayBeUsed", "LombokSetterMayBeUsed"}) public abstract class BaseOrganizationBase { + private String unique; + private Long id; private Long status; private Long organizationId; + private LocalDateTime createTime; + + private Long createUserId; + + private LocalDateTime updateTime; + + private Long updateUserId; + + private Integer isDelete; + + private SyncStatus syncStatus; + public Long getId() { return id; } @@ -51,8 +71,52 @@ public void setStatus(Long status) { this.status = status; } + + public LocalDateTime getCreateTime() { + return createTime; + } + + public void setCreateTime(LocalDateTime createTime) { + this.createTime = createTime; + } + + public Long getCreateUserId() { + return createUserId; + } + + public void setCreateUserId(Long createUserId) { + this.createUserId = createUserId; + } + + public LocalDateTime getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(LocalDateTime updateTime) { + this.updateTime = updateTime; + } + + public Long getUpdateUserId() { + return updateUserId; + } + + public void setUpdateUserId(Long updateUserId) { + this.updateUserId = updateUserId; + } + + public Integer getIsDelete() { + return isDelete; + } + + public void setIsDelete(Integer isDelete) { + this.isDelete = isDelete; + } + public String getUnique() { - return this.getClass().getSimpleName() + "-" + this.id.toString(); + if(Objects.isNull(this.unique)) { + this.unique = this.getClass().getSimpleName() + "-" + this.id.toString(); + } + return this.unique; } /** @@ -60,4 +124,12 @@ public String getUnique() { * @return */ public abstract String nodeUnique(); + + public SyncStatus getSyncStatus() { + return syncStatus; + } + + public void setSyncStatus(SyncStatus syncStatus) { + this.syncStatus = syncStatus; + } } diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/ClusterMetadata.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/ClusterMetadata.java index a45d68c1..9198d8d3 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/ClusterMetadata.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/ClusterMetadata.java @@ -47,7 +47,7 @@ public class ClusterMetadata extends BaseSyncBase { private String regProperties; - private Integer authType; + private String authType; private Integer runState; diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/CollectMetadata.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/CollectMetadata.java new file mode 100644 index 00000000..d6e92684 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/CollectMetadata.java @@ -0,0 +1,99 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.eventmesh.dashboard.common.model.metadata; + +import org.apache.eventmesh.dashboard.common.enums.CollectType; +import org.apache.eventmesh.dashboard.common.model.base.BaseClusterIdBase; + +public class CollectMetadata extends BaseClusterIdBase { + + private CollectType collectType; + + private Long saveTime; + + private Long collectInterval; + + private Long storageClusterId; + + private Long storageClusterName; + + private Boolean enable; + + private Boolean defaultStorage; + + @Override + public String nodeUnique() { + return ""; + } + + public CollectType getCollectType() { + return collectType; + } + + public void setCollectType(CollectType collectType) { + this.collectType = collectType; + } + + public Long getSaveTime() { + return saveTime; + } + + public void setSaveTime(Long saveTime) { + this.saveTime = saveTime; + } + + public Long getCollectInterval() { + return collectInterval; + } + + public void setCollectInterval(Long collectInterval) { + this.collectInterval = collectInterval; + } + + public Long getStorageClusterId() { + return storageClusterId; + } + + public void setStorageClusterId(Long storageClusterId) { + this.storageClusterId = storageClusterId; + } + + public Long getStorageClusterName() { + return storageClusterName; + } + + public void setStorageClusterName(Long storageClusterName) { + this.storageClusterName = storageClusterName; + } + + public Boolean getEnable() { + return enable; + } + + public void setEnable(Boolean enable) { + this.enable = enable; + } + + public Boolean getDefaultStorage() { + return defaultStorage; + } + + public void setDefaultStorage(Boolean defaultStorage) { + this.defaultStorage = defaultStorage; + } +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/GroupMemberMetadata.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/GroupMemberMetadata.java new file mode 100644 index 00000000..5dfc8395 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/GroupMemberMetadata.java @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.eventmesh.dashboard.common.model.metadata; + +import org.apache.eventmesh.dashboard.common.model.base.BaseRuntimeIdBase; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class GroupMemberMetadata extends BaseRuntimeIdBase { + + private Long groupId; + + private String groupName; + + private Long topicId; + + private String topicName; + + @Override + public String nodeUnique() { + return ""; + } +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/NetConnectionMetadata.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/NetConnectionMetadata.java new file mode 100644 index 00000000..23be8151 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/NetConnectionMetadata.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.eventmesh.dashboard.common.model.metadata; + +import org.apache.eventmesh.dashboard.common.enums.MetadataType; +import org.apache.eventmesh.dashboard.common.model.base.BaseRuntimeIdBase; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * Config metadata is a piece of config with key and value + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class NetConnectionMetadata extends BaseRuntimeIdBase { + + /** + * property key + */ + private String configName; + + private String configValue; + + private MetadataType instanceType; + + private Long instanceId; + + + @Override + public String nodeUnique() { + return this.configName; + } +} diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/DeleteTopicRequest.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/DeleteTopicRequest.java index deecfb44..53dfde77 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/DeleteTopicRequest.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/DeleteTopicRequest.java @@ -20,15 +20,8 @@ import org.apache.eventmesh.dashboard.common.model.metadata.TopicMetadata; +import org.apache.eventmesh.dashboard.common.model.remoting.AbstractGlobal2Request; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; +public class DeleteTopicRequest extends AbstractGlobal2Request { -@Data -@NoArgsConstructor -@AllArgsConstructor -public class DeleteTopicRequest { - - TopicMetadata topicMetadata; } diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/GetTopics2Request.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/GetTopics2Request.java index 2178d093..607082ef 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/GetTopics2Request.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/topic/GetTopics2Request.java @@ -18,14 +18,15 @@ package org.apache.eventmesh.dashboard.common.model.remoting.topic; -import org.apache.eventmesh.dashboard.common.model.remoting.Global2Request; +import org.apache.eventmesh.dashboard.common.model.metadata.TopicMetadata; +import org.apache.eventmesh.dashboard.common.model.remoting.AbstractGlobal2Request; import lombok.Data; import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = true) -public class GetTopics2Request extends Global2Request { +public class GetTopics2Request extends AbstractGlobal2Request { private String runtimeHost; 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 d0d6a4f8..7ed6bf1d 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 @@ -20,12 +20,14 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.transaction.annotation.EnableTransactionManagement; import lombok.extern.slf4j.Slf4j; @Slf4j @SpringBootApplication +@EnableScheduling @EnableTransactionManagement public class EventMeshDashboardApplication { diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/ReportController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/ReportController.java index 58eb4bef..1923c14f 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/ReportController.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/ReportController.java @@ -23,6 +23,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.Map; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -36,23 +37,22 @@ public class ReportController { private ReportHandlerManage reportHandlerManage; @RequestMapping("reportByHome") - public void reportByHome(@RequestBody MultiGeneralReportDO multiGeneralReportDO) { + public Map>> reportByHome(@RequestBody MultiGeneralReportDO multiGeneralReportDO) { // List singleGeneralReportDOList = new ArrayList<>(); multiGeneralReportDO.getReportNameList().forEach(reportName -> { SingleGeneralReportDO singleGeneralReportDO = new SingleGeneralReportDO(); singleGeneralReportDOList.add(singleGeneralReportDO); - - }); + return reportHandlerManage.queryResultIsMap(singleGeneralReportDOList); - singleGeneralReportDOList.forEach(singleGeneralReportDO -> { - - }); } - public void reportBySingle(@RequestBody SingleGeneralReportDO singleGeneralReportDO) { + @RequestMapping("reportBySingle") + public List> reportBySingle(@RequestBody SingleGeneralReportDO singleGeneralReportDO) { + Map>> data = reportHandlerManage.queryResultIsMap(List.of(singleGeneralReportDO)); + return data.get(singleGeneralReportDO.getReportName()); } public void reportByMulti() { diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/ActiveCreateController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/ActiveCreateController.java new file mode 100644 index 00000000..c80a8821 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/ActiveCreateController.java @@ -0,0 +1,135 @@ +/* + * 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.deploy; + +import org.apache.eventmesh.dashboard.common.enums.ClusterOwnType; +import org.apache.eventmesh.dashboard.common.enums.ClusterTrusteeshipType; +import org.apache.eventmesh.dashboard.common.enums.ClusterTrusteeshipType.FirstToWhom; +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.common.enums.DeployStatusType; +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterRelationshipEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; +import org.apache.eventmesh.dashboard.console.mapstruct.deploy.ActiveCreateControllerMapper; +import org.apache.eventmesh.dashboard.console.modle.deploy.active.CreateClusterDTO; +import org.apache.eventmesh.dashboard.console.modle.deploy.active.CreateEventMeshSpaceDTO; +import org.apache.eventmesh.dashboard.console.modle.deploy.active.CreateRuntimeDTO; +import org.apache.eventmesh.dashboard.console.modle.deploy.active.CreateTheEntireClusterDTO; +import org.apache.eventmesh.dashboard.console.modle.deploy.active.CreateTheEventClusterDTO; +import org.apache.eventmesh.dashboard.console.service.cluster.ClusterService; +import org.apache.eventmesh.dashboard.console.service.cluster.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.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + + +@RestController +@RequestMapping("organization/activeCreate") +public class ActiveCreateController { + + @Autowired + private RuntimeService runtimeService; + + @Autowired + private ClusterService clusterService; + + + /** + * 分 eventmesh 集群创建 + * + * @param + */ + @PostMapping("createEventMeshSpace") + public Long createEventMeshSpace(@RequestBody @Validated CreateEventMeshSpaceDTO dto) { + ClusterEntity clusterEntity = ActiveCreateControllerMapper.INSTANCE.createEventMeshSpace(dto); + clusterEntity.setClusterType(ClusterType.EVENTMESH_CLUSTER); + clusterEntity.setClusterOwnType(ClusterOwnType.NOT); + clusterEntity.setAuthType(""); + clusterEntity.setVersion(""); + clusterEntity.setRuntimeIndex(0); + clusterEntity.setTrusteeshipType(ClusterTrusteeshipType.NOT); + clusterEntity.setFirstToWhom(FirstToWhom.NOT); + clusterEntity.setDeployStatusType(DeployStatusType.CREATE_SUCCESS); + clusterEntity.setResourcesConfigId(0L); + clusterEntity.setDeployScriptId(0L); + clusterEntity.setDeployScriptName(""); + clusterEntity.setDeployScriptVersion(""); + clusterService.insertCluster(clusterEntity); + return clusterEntity.getId(); + } + + @PostMapping("createCluster") + public Long createCluster(@RequestBody @Validated CreateClusterDTO dto) { + ClusterEntity clusterEntity = ActiveCreateControllerMapper.INSTANCE.createCluster(dto); + clusterEntity.setClusterType(ClusterType.EVENTMESH_CLUSTER); + clusterEntity.setClusterOwnType(ClusterOwnType.INDEPENDENCE); + clusterEntity.setAuthType(""); + clusterEntity.setVersion(""); + clusterEntity.setRuntimeIndex(Integer.valueOf(0)); + clusterEntity.setDeployStatusType(DeployStatusType.CREATE_SUCCESS); + clusterEntity.setResourcesConfigId(0L); + clusterEntity.setDeployScriptId(0L); + clusterEntity.setDeployScriptName(""); + clusterEntity.setDeployScriptVersion(""); + ClusterRelationshipEntity relationshipEntity = new ClusterRelationshipEntity(); + clusterService.insertClusterAndRelationship(clusterEntity, relationshipEntity); + return clusterEntity.getId(); + } + + @PostMapping("createRuntime") + public void createRuntime(@RequestBody @Validated CreateRuntimeDTO dto) { + RuntimeEntity runtimeEntity = ActiveCreateControllerMapper.INSTANCE.createRuntime(dto); + runtimeService.insertRuntime(runtimeEntity); + } + + + @PostMapping("createTheEntireCluster") + public Long createTheEntireCluster(@RequestBody @Validated CreateTheEntireClusterDTO dto) { + ClusterEntity clusterEntity = ActiveCreateControllerMapper.INSTANCE.createCluster(dto.getCreateClusterDTO()); + + List runtimeEntityList = ActiveCreateControllerMapper.INSTANCE.createRuntimeList(dto.getCreateRuntimeDTOList()); + + ClusterRelationshipEntity relationshipEntity = new ClusterRelationshipEntity(); + relationshipEntity.setClusterId(clusterEntity.getId()); + this.clusterService.createTheEntireCluster(clusterEntity, relationshipEntity, runtimeEntityList); + return 1L; + } + + /** + * TODO 先完成 数据 直接录入的实现, + * 在完成 通过 API 调用获得 broker config 补充 broker 与 cluster 信息,以及 cluster 组织关系 + * 保留 两套机制,还是只留下 通过 API 获得信息的机制? + * @param createTheEventClusterDTO + * @return + */ + @PostMapping("createTheEventCluster") + public Long createTheEventCluster(@RequestBody CreateTheEventClusterDTO createTheEventClusterDTO) { + ActiveCreateDTOHandler activeCreateDTOHandler = new ActiveCreateDTOHandler(); + activeCreateDTOHandler.handler(createTheEventClusterDTO); + this.clusterService.createTheEventCluster(activeCreateDTOHandler.getClusterEntityList(), + activeCreateDTOHandler.getClusterListRelationshipList(),activeCreateDTOHandler.getClusterAndRuntimeList()); + + return activeCreateDTOHandler.getEventSapaceClusterEntity().getId(); + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/ActiveCreateDTOHandler.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/ActiveCreateDTOHandler.java new file mode 100644 index 00000000..93960d0c --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/ActiveCreateDTOHandler.java @@ -0,0 +1,198 @@ +/* + * 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.deploy; + +import org.apache.eventmesh.dashboard.common.enums.ClusterFramework; +import org.apache.eventmesh.dashboard.common.enums.ClusterOwnType; +import org.apache.eventmesh.dashboard.common.enums.ClusterSyncMetadataEnum; +import org.apache.eventmesh.dashboard.common.enums.ClusterTrusteeshipType; +import org.apache.eventmesh.dashboard.common.enums.ClusterTrusteeshipType.FirstToWhom; +import org.apache.eventmesh.dashboard.common.enums.DeployStatusType; +import org.apache.eventmesh.dashboard.common.enums.ReplicationType; +import org.apache.eventmesh.dashboard.console.entity.base.BaseSyncEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; +import org.apache.eventmesh.dashboard.console.mapstruct.cluster.ClusterControllerMapper; +import org.apache.eventmesh.dashboard.console.mapstruct.deploy.ActiveCreateControllerMapper; +import org.apache.eventmesh.dashboard.console.modle.deploy.active.CreateClusterDTO; +import org.apache.eventmesh.dashboard.console.modle.deploy.active.CreateRuntimeDTO; +import org.apache.eventmesh.dashboard.console.modle.deploy.active.CreateTheEntireClusterDTO; +import org.apache.eventmesh.dashboard.console.modle.deploy.active.CreateTheEventClusterDTO; +import org.apache.eventmesh.dashboard.console.modle.deploy.active.CreateTheEventClusterDTO.BaseCreateTheEntireClusterDTO; +import org.apache.eventmesh.dashboard.console.modle.deploy.active.CreateTheEventClusterDTO.CreateCapStorageClusterDTO; +import org.apache.eventmesh.dashboard.console.modle.deploy.active.CreateTheEventClusterDTO.MainStorageClusterDTO; +import org.apache.eventmesh.dashboard.console.modle.deploy.active.CreateTheEventClusterDTO.RuntimeClusterDTO; + +import org.apache.commons.lang3.tuple.Pair; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +import lombok.Getter; + +@Getter +public class ActiveCreateDTOHandler { + + private final List clusterEntityList = new ArrayList<>(); + + private final List> clusterListRelationshipList = new ArrayList<>(); + + private final List>> clusterAndRuntimeList = new ArrayList<>(); + + private ClusterEntity eventSapaceClusterEntity; + + private Long organizationId; + + private String organizationName; + + private ClusterEntity createClusterEntity(CreateClusterDTO createClusterDTO) { + ClusterEntity clusterEntity = ClusterControllerMapper.INSTANCE.createClusterDTO(createClusterDTO); + this.fillBaseSyncEntity(clusterEntity); + clusterEntity.setClusterOwnType(ClusterOwnType.NOT); + clusterEntity.setConfig(""); + clusterEntity.setAuthType("none"); + clusterEntity.setJmxProperties(""); + clusterEntity.setConfig(""); + ClusterFramework clusterFramework = ClusterSyncMetadataEnum.getClusterFramework(clusterEntity.getClusterType()); + if (clusterFramework.isCAP()) { + clusterEntity.setReplicationType(ReplicationType.NOT); + } + this.clusterEntityList.add(clusterEntity); + return clusterEntity; + } + + private void fillBaseSyncEntity(BaseSyncEntity baseSyncEntity){ + if(Objects.isNull(baseSyncEntity.getTrusteeshipType())){ + baseSyncEntity.setTrusteeshipType(ClusterTrusteeshipType.NO_TRUSTEESHIP); + } + if(Objects.isNull(baseSyncEntity.getFirstToWhom())){ + baseSyncEntity.setFirstToWhom(FirstToWhom.NOT); + } + baseSyncEntity.setOrganizationId(organizationId); + baseSyncEntity.setVersion(""); + baseSyncEntity.setReplicationType(ReplicationType.NOT); + baseSyncEntity.setDeployStatusType(DeployStatusType.SETTLE); + baseSyncEntity.setResourcesConfigId(0L); + baseSyncEntity.setDeployScriptId(0L); + baseSyncEntity.setDeployScriptName(""); + baseSyncEntity.setDeployScriptVersion(""); + } + + private RuntimeEntity createRuntimeEntity(ClusterEntity clusterEntity, CreateRuntimeDTO createRuntimeDTO) { + return ActiveCreateControllerMapper.INSTANCE.createRuntime(createRuntimeDTO); + } + + + private void createTheEntireClusterDTO(ClusterEntity superior, CreateTheEntireClusterDTO dto) { + ClusterEntity clusterEntity = this.createClusterEntity(dto.getCreateClusterDTO()); + this.clusterListRelationshipList.add(Pair.of(superior, clusterEntity)); + + List runtimeEntityList = new ArrayList<>(); + dto.getCreateRuntimeDTOList().forEach(runtimeDTO -> { + runtimeDTO.setFirstToWhom(clusterEntity.getFirstToWhom()); + runtimeDTO.setClusterTrusteeshipType(clusterEntity.getTrusteeshipType()); + + RuntimeEntity runtimeEntity = this.createRuntimeEntity(clusterEntity, runtimeDTO); + runtimeEntity.setOrganizationId(organizationId); + runtimeEntity.setClusterType(clusterEntity.getClusterType()); + runtimeEntity.setVersion(clusterEntity.getVersion()); + runtimeEntity.setTrusteeshipType(clusterEntity.getTrusteeshipType()); + runtimeEntity.setFirstToWhom(runtimeDTO.getFirstToWhom()); + runtimeEntity.setKubernetesClusterId(0L); + runtimeEntity.setDeployStatusType(DeployStatusType.SETTLE); + runtimeEntity.setResourcesConfigId(0L); + runtimeEntity.setDeployScriptId(0L); + runtimeEntity.setCreateScriptContent(""); + runtimeEntity.setAuthType(""); + runtimeEntity.setJmxPort(1); + + + + + runtimeEntityList.add(runtimeEntity); + }); + this.clusterAndRuntimeList.add(Pair.of(clusterEntity, runtimeEntityList)); + + } + + private ClusterEntity baseCreateTheEntireClusterDTO(ClusterEntity superior, BaseCreateTheEntireClusterDTO dto) { + ClusterEntity clusterEntity = this.createClusterEntity(dto.getCreateClusterDTO()); + if (Objects.nonNull(dto.getPrometheusRuntime())) { + RuntimeEntity runtimeEntity = this.createRuntimeEntity(clusterEntity, dto.getPrometheusRuntime()); + this.clusterAndRuntimeList.add(Pair.of(clusterEntity, List.of(runtimeEntity))); + } + + return clusterEntity; + } + + private void runtimeClusterDTO(ClusterEntity superior, RuntimeClusterDTO runtimeClusterDTO) { + if (Objects.isNull(runtimeClusterDTO)) { + return; + } + ClusterEntity clusterEntity = this.baseCreateTheEntireClusterDTO(superior, runtimeClusterDTO); + this.clusterListRelationshipList.add(Pair.of(superior, clusterEntity)); + this.createTheEntireClusterDTO(clusterEntity, runtimeClusterDTO.getMetaClusterList()); + this.createTheEntireClusterDTO(clusterEntity, runtimeClusterDTO.getBrokerClusterList()); + } + + + private void createCapStorageClusterDTO(ClusterEntity superior, CreateCapStorageClusterDTO createCapStorageClusterDTO) { + if (Objects.isNull(createCapStorageClusterDTO)) { + return; + } + ClusterEntity clusterEntity = this.baseCreateTheEntireClusterDTO(superior, createCapStorageClusterDTO); + this.clusterListRelationshipList.add(Pair.of(superior, clusterEntity)); + this.createTheEntireClusterDTO(clusterEntity, createCapStorageClusterDTO.getMetaClusterList()); + this.createTheEntireClusterDTO(clusterEntity, createCapStorageClusterDTO.getBrokerClusterList()); + } + + private void createMainStorageClusterDTO(ClusterEntity superior, MainStorageClusterDTO mainStorageClusterDTO) { + if (Objects.isNull(mainStorageClusterDTO)) { + return; + } + ClusterEntity clusterEntity = this.baseCreateTheEntireClusterDTO(superior, mainStorageClusterDTO); + mainStorageClusterDTO.getMetaClusterList().forEach(metaClusterDTO -> { + this.createTheEntireClusterDTO(clusterEntity, metaClusterDTO); + }); + mainStorageClusterDTO.getBrokerClusterList().forEach(mainClusterDTO -> { + ClusterEntity cluster = this.baseCreateTheEntireClusterDTO(clusterEntity, mainClusterDTO); + mainClusterDTO.getClusterList().forEach(clusterDTO -> { + this.createTheEntireClusterDTO(cluster, clusterDTO); + }); + }); + } + + /** + * 通過 runtime 信息 得到 meta 信息,然後通過 + * @param createTheEventClusterDTO + */ + public void handler(CreateTheEventClusterDTO createTheEventClusterDTO) { + this.organizationId = createTheEventClusterDTO.getOrganizationId(); + this.eventSapaceClusterEntity = this.createClusterEntity(createTheEventClusterDTO.getEventSpace()); + + this.runtimeClusterDTO(eventSapaceClusterEntity, createTheEventClusterDTO.getEventClusterList()); + + this.runtimeClusterDTO(eventSapaceClusterEntity, createTheEventClusterDTO.getMonomerStorageClusters()); + + this.createCapStorageClusterDTO(eventSapaceClusterEntity, createTheEventClusterDTO.getCapStorageClusters()); + + this.createMainStorageClusterDTO(eventSapaceClusterEntity, createTheEventClusterDTO.getMainStorageClusters()); + + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/ClusterCycleController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/ClusterCycleController.java index c805861e..7346b3bb 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/ClusterCycleController.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/ClusterCycleController.java @@ -18,22 +18,11 @@ package org.apache.eventmesh.dashboard.console.controller.deploy; -import org.apache.eventmesh.dashboard.common.enums.ClusterOwnType; -import org.apache.eventmesh.dashboard.common.enums.ClusterTrusteeshipType; -import org.apache.eventmesh.dashboard.common.enums.ClusterTrusteeshipType.FirstToWhom; -import org.apache.eventmesh.dashboard.common.enums.ClusterType; -import org.apache.eventmesh.dashboard.common.enums.DeployStatusType; import org.apache.eventmesh.dashboard.console.controller.deploy.create.CreateClusterByDeployScriptHandler; import org.apache.eventmesh.dashboard.console.controller.deploy.create.CreateRuntimeByDeployScriptHandler; -import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; -import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterRelationshipEntity; -import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; -import org.apache.eventmesh.dashboard.console.mapstruct.deploy.ClusterCycleControllerMapper; import org.apache.eventmesh.dashboard.console.modle.cluster.VerifyNameDTO; import org.apache.eventmesh.dashboard.console.modle.deploy.create.CreateClusterByDeployScriptDO; -import org.apache.eventmesh.dashboard.console.modle.deploy.create.CreateClusterByEventMesh; import org.apache.eventmesh.dashboard.console.modle.deploy.create.CreateRuntimeByDeployScriptDTO; -import org.apache.eventmesh.dashboard.console.modle.deploy.create.CreateRuntimeByOnlyDataDO; import org.apache.eventmesh.dashboard.console.service.cluster.ClusterService; import org.apache.eventmesh.dashboard.console.service.cluster.RuntimeService; @@ -105,11 +94,7 @@ public String verifyName(VerifyNameDTO verifyNameDTO) { return ""; } - @PostMapping("createRuntimeByOnlyDataHandler") - public void createRuntimeByOnlyDataHandler(@RequestBody @Validated CreateRuntimeByOnlyDataDO createRuntimeByOnlyDataDO) { - RuntimeEntity runtimeEntity = ClusterCycleControllerMapper.INSTANCE.createRuntimeByOnlyDataHandler(createRuntimeByOnlyDataDO); - runtimeService.insertRuntime(runtimeEntity); - } + @PostMapping("createRuntimeByDeployScript") public void createRuntimeByDeployScript(@RequestBody @Validated CreateRuntimeByDeployScriptDTO createRuntimeByDeployScriptDTO) { @@ -121,72 +106,5 @@ public void createClusterByDeployScript(@RequestBody @Validated CreateClusterByD this.createClusterByDeployScriptHandler.handler(createClusterByDeployScriptDO); } - /** - * 分 eventmesh 集群创建 - * - * @param createClusterByEventMesh - */ - @PostMapping("createEventMeshClusterByOnlyData") - public Long createEventMeshClusterByOnlyData(@RequestBody @Validated CreateClusterByEventMesh createClusterByEventMesh) { - ClusterEntity clusterEntity = ClusterCycleControllerMapper.INSTANCE.createClusterByEventMesh(createClusterByEventMesh); - clusterEntity.setClusterType(ClusterType.EVENTMESH_CLUSTER); - clusterEntity.setClusterOwnType(ClusterOwnType.NOT); - clusterEntity.setAuthType(""); - clusterEntity.setVersion(""); - clusterEntity.setRuntimeIndex(0); - clusterEntity.setTrusteeshipType(ClusterTrusteeshipType.NOT); - clusterEntity.setFirstToWhom(FirstToWhom.NOT); - clusterEntity.setDeployStatusType(DeployStatusType.CREATE_SUCCESS); - clusterEntity.setResourcesConfigId(0L); - clusterEntity.setDeployScriptId(0L); - clusterEntity.setDeployScriptName(""); - clusterEntity.setDeployScriptVersion(""); - clusterService.insertCluster(clusterEntity); - return clusterEntity.getId(); - } - - @PostMapping("createClusterByEventMesh") - public Long createClusterByEventMesh(@RequestBody @Validated CreateClusterByEventMesh createClusterByEventMesh) { - ClusterEntity clusterEntity = ClusterCycleControllerMapper.INSTANCE.createClusterByEventMesh(createClusterByEventMesh); - clusterEntity.setClusterType(ClusterType.EVENTMESH_CLUSTER); - clusterEntity.setClusterOwnType(ClusterOwnType.INDEPENDENCE); - clusterEntity.setAuthType(""); - clusterEntity.setVersion(""); - clusterEntity.setRuntimeIndex(0); - clusterEntity.setDeployStatusType(DeployStatusType.CREATE_SUCCESS); - clusterEntity.setResourcesConfigId(0L); - clusterEntity.setDeployScriptId(0L); - clusterEntity.setDeployScriptName(""); - clusterEntity.setDeployScriptVersion(""); - ClusterRelationshipEntity relationshipEntity = new ClusterRelationshipEntity(); - clusterService.insertClusterAndRelationship(clusterEntity, relationshipEntity); - return clusterEntity.getId(); - - } - - - @PostMapping("pauseCluster") - public void pauseCluster(@RequestBody @Validated CreateClusterByEventMesh createClusterByEventMesh) { - } - - @PostMapping("pauseRuntime") - public void pauseRuntime(@RequestBody @Validated CreateClusterByEventMesh createClusterByEventMesh) { - } - - @PostMapping("relationship") - public void relationship(@RequestBody @Validated CreateClusterByEventMesh createClusterByEventMesh) { - } - - @PostMapping("unrelationship") - public void unrelationship(@RequestBody @Validated CreateClusterByEventMesh createClusterByEventMesh) { - } - - @PostMapping("uninstallCluster") - public void uninstallCluster(@RequestBody @Validated CreateClusterByEventMesh createClusterByEventMesh) { - } - - @PostMapping("uninstallRuntime") - public void uninstallRuntime(@RequestBody @Validated CreateClusterByEventMesh createClusterByEventMesh) { - } } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/DeployBeforeCheck.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/DeployBeforeCheck.java new file mode 100644 index 00000000..052209e8 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/DeployBeforeCheck.java @@ -0,0 +1,25 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.eventmesh.dashboard.console.controller.deploy; + +public interface DeployBeforeCheck { + + + boolean check(T t); + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/base/AbstractUpdateHandler.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/base/AbstractUpdateHandler.java new file mode 100644 index 00000000..5d871497 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/base/AbstractUpdateHandler.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.controller.deploy.base; + +import org.apache.eventmesh.dashboard.console.service.cluster.ClusterRelationshipService; +import org.apache.eventmesh.dashboard.console.service.cluster.ClusterService; +import org.apache.eventmesh.dashboard.console.service.cluster.RuntimeService; +import org.apache.eventmesh.dashboard.console.service.function.ConfigService; + +public abstract class AbstractUpdateHandler { + + private ClusterService clusterService; + + private ConfigService configService; + + private RuntimeService runtimeService; + + private ClusterRelationshipService clusterRelationshipService; +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/create/CreateClusterByCopyHandler.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/create/CreateClusterByCopyHandler.java new file mode 100644 index 00000000..e845e1c6 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/create/CreateClusterByCopyHandler.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.eventmesh.dashboard.console.controller.deploy.create; + +import org.apache.eventmesh.dashboard.console.controller.deploy.handler.UpdateHandler; +import org.apache.eventmesh.dashboard.console.modle.deploy.create.CreateRuntimeByDeployScriptDTO; + +public class CreateClusterByCopyHandler implements UpdateHandler { + + @Override + public void init() { + + } + + @Override + public void handler(CreateRuntimeByDeployScriptDTO createRuntimeByDeployScriptDTO) { + // 这是所有 新增 cluster runtime 的名字的 后缀 + + // 查询所有的集群 + + // 查询 关系 + + // 查询所有 runtime + + // 查询所有 config + + // 查询所有 topic + + // 查询所有 acl + + // 组织关系 + + // 调用 cluster service + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/create/CreateClusterByDeployScriptHandler.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/create/CreateClusterByDeployScriptHandler.java index 95ef6d0b..5cd5f0cb 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/create/CreateClusterByDeployScriptHandler.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/create/CreateClusterByDeployScriptHandler.java @@ -79,6 +79,10 @@ private void handlerMetadata(ClusterEntity clusterEntity) { this.clusterFramework = ClusterSyncMetadataEnum.getClusterFramework(clusterEntity.getClusterType()); } + /** + * + * @param createClusterByDeployScriptDO + */ @Override public void handler(CreateClusterByDeployScriptDO createClusterByDeployScriptDO) { this.clusterEntity = ClusterCycleControllerMapper.INSTANCE.createClusterByDeployScript(createClusterByDeployScriptDO); diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/create/CreateClusterByFullMetadataHandler.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/create/CreateClusterByFullMetadataHandler.java new file mode 100644 index 00000000..dc82a9a9 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/create/CreateClusterByFullMetadataHandler.java @@ -0,0 +1,41 @@ +/* + * 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.deploy.create; + +import org.apache.eventmesh.dashboard.console.controller.deploy.handler.UpdateHandler; +import org.apache.eventmesh.dashboard.console.modle.deploy.create.CreateRuntimeByDeployScriptDTO; + +public class CreateClusterByFullMetadataHandler implements UpdateHandler { + + + @Override + public void init() { + + } + + @Override + public void handler(CreateRuntimeByDeployScriptDTO createRuntimeByDeployScriptDTO) { + // 这是所有 新增 cluster runtime 的名字的 后缀 + + // 通过 json 进行序列化,得到所有的配置 cluster runtime relationship config topic 等 + + // 然后进行关联 + + // 调用 cluster service 进行写入 + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/create/CreateRuntimeByDeployScriptHandler.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/create/CreateRuntimeByDeployScriptHandler.java index f0691520..ba254294 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/create/CreateRuntimeByDeployScriptHandler.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/create/CreateRuntimeByDeployScriptHandler.java @@ -39,8 +39,11 @@ import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; +import lombok.extern.slf4j.Slf4j; + @Component @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) +@Slf4j public class CreateRuntimeByDeployScriptHandler implements UpdateHandler { @@ -55,16 +58,21 @@ public void init() { } + /** + * 支持 多 复杂的主从架构 + */ @Override public void handler(CreateRuntimeByDeployScriptDTO createRuntimeByDeployScriptDTO) { ClusterEntity clusterEntity = ClusterControllerMapper.INSTANCE.toClusterEntity(createRuntimeByDeployScriptDTO); clusterEntity = this.clusterService.queryClusterById(clusterEntity); RuntimeEntity runtimeEntity = ClusterCycleControllerMapper.INSTANCE.createRuntimeByDeployScript(createRuntimeByDeployScriptDTO); if (Objects.isNull(runtimeEntity.getDeployScriptId()) && Objects.isNull(clusterEntity.getDeployScriptId())) { + log.error("create runtime by deploy script id is null"); return; } if (Objects.isNull(runtimeEntity.getResourcesConfigId()) && Objects.isNull(clusterEntity.getResourcesConfigId())) { + log.error("create runtime by deploy script resources config id is null"); return; } if (Objects.nonNull(runtimeEntity.getDeployScriptId())) { @@ -88,9 +96,10 @@ public void handler(CreateRuntimeByDeployScriptDTO createRuntimeByDeployScriptDT runtimeEntity.setClusterType(clusterEntity.getClusterType()); runtimeEntity.setTrusteeshipType(ClusterTrusteeshipType.SELF); runtimeEntity.setReplicationType(replicationType); - runtimeEntity.setDeployStatusType(DeployStatusType.CREATE_WAIT); + runtimeEntity.setDeployStatusType(DeployStatusType.CREATE_DATA_ING); runtimeEntity.setRuntimeIndex(linkedList.poll()); - this.runtimeService.insertRuntime(runtimeEntity); + + this.runtimeService.insertRuntimeByClusterData(runtimeEntity); } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/handler/UpdateHandler.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/handler/UpdateHandler.java index 8d137735..fef722d7 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/handler/UpdateHandler.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/handler/UpdateHandler.java @@ -18,13 +18,20 @@ package org.apache.eventmesh.dashboard.console.controller.deploy.handler; +import org.apache.eventmesh.dashboard.console.controller.deploy.DeployBeforeCheck; + /** * */ -public interface UpdateHandler { +public interface UpdateHandler extends DeployBeforeCheck { void init(); void handler(T t); + + @Override + default boolean check(T t){ + return true; + } } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/pause/PauseCluster.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/pause/PauseCluster.java index cbcd273e..ee50969e 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/pause/PauseCluster.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/pause/PauseCluster.java @@ -65,9 +65,7 @@ public void init() { */ @Override public void handler(ClusterEntity clusterEntity) { - clusterEntity = this.clusterService.queryClusterById(clusterEntity); - if (clusterEntity.getClusterType().isMeta()) { // 检查 meta 集群 是否被关联,如何被关联,就禁止删除 ClusterRelationshipEntity clusterRelationshipEntity = new ClusterRelationshipEntity(); diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/relationship/RelationshipHandler.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/relationship/RelationshipHandler.java index 82c66a83..1a2705f0 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/relationship/RelationshipHandler.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/relationship/RelationshipHandler.java @@ -19,6 +19,7 @@ package org.apache.eventmesh.dashboard.console.controller.deploy.relationship; import org.apache.eventmesh.dashboard.console.controller.deploy.handler.UpdateHandler; +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterRelationshipEntity; import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; import org.apache.eventmesh.dashboard.console.service.cluster.ClusterRelationshipService; @@ -39,16 +40,59 @@ public void init() { } + /** + * 是否 允许 + * + */ @Override public void handler(ClusterRelationshipEntity clusterRelationshipEntity) { + ClusterEntity queryMainClusterEntity = new ClusterEntity(); + queryMainClusterEntity.setId(clusterRelationshipEntity.getClusterId()); + ClusterEntity mainClusterEntity = this.clusterService.queryClusterById(queryMainClusterEntity); + + ClusterEntity queryRelationshipClusterEntity = new ClusterEntity(); + queryRelationshipClusterEntity.setId(clusterRelationshipEntity.getRelationshipId()); + ClusterEntity relationshipClusterEntity = this.clusterService.queryClusterById(queryRelationshipClusterEntity); + // 绑定 meta 集群, 那么下面所有的 runtime 集群,需要更新更新 - // 绑定 runtime 集群, main cluster 依赖的 + // 绑定 runtime 集群, 这个 runtime 集群 需要获得绑定集群的 meta ,然后重启 + // 绑定 存储集群 clusterRelationshipService.addClusterRelationshipEntry(clusterRelationshipEntity); + // 如果 relationship runtime 集群 不是 托管类型 不需要处理 + + // main cluster 与 relationship cluster 都不是 self 类型就不需要管 + if(mainClusterEntity.getTrusteeshipType().isReverse() && relationshipClusterEntity.getTrusteeshipType().isReverse()){ + return; + } + + if(mainClusterEntity.getClusterType().isEventCluster() && relationshipClusterEntity.getClusterType().isStorageCluster()){ + // 还要判断 main 集群 是否 支持 API 操作 meta cluster + if(mainClusterEntity.getTrusteeshipType().isReverse()){ + return; + } + // 查询 relationship 里面的 所有的 meta cluster 的 runtime list + // 查询 main cluster 里面 所有 runtime cluster 的 runtime list + // 查询 main cluster runtime list 的所有 meta 配置 ,追加配置 + // 如果 main cluster 支持远程操作配置,等待 sync 模块同步 + // 如果 main cluster 不支持...... 同时是self 模式,操作 k8s 更新 runtime list + } + + // 如果 storage runtime cluster 不支持 meta 配置操作,不需要处理 + + /* + 如果 main cluster 需要 relationship cluster 的 meta 集群 地址,则 runtime 集群需要重启 + + */ if (clusterRelationshipEntity.getRelationshipType().isMeta()) { RuntimeEntity runtimeEntity = new RuntimeEntity(); runtimeEntity.setClusterId(clusterRelationshipEntity.getClusterId()); //runtimeService.queryOnlyRuntimeByClusterId(runtimeEntity); + } else if(clusterRelationshipEntity.getRelationshipType().isRuntime()){ + // 查询 main cluster 里面 是否存在 meta cluster , 如果存在则需要更新 + + + // 如果 没有 meta cluster 不需要查询 runtime 列表 } } } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/uninstall/UninstallClusterHandler.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/uninstall/UninstallClusterHandler.java index c6e8f90e..c79c7352 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/uninstall/UninstallClusterHandler.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/uninstall/UninstallClusterHandler.java @@ -19,10 +19,19 @@ package org.apache.eventmesh.dashboard.console.controller.deploy.uninstall; import org.apache.eventmesh.dashboard.console.controller.deploy.handler.UpdateHandler; +import org.apache.eventmesh.dashboard.console.domain.ClusterAndRuntimeDomain; import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; +import org.apache.eventmesh.dashboard.console.modle.DO.domain.clusterAndRuntimeDomain.ClusterAndRuntimeOfRelationshipDO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component public class UninstallClusterHandler implements UpdateHandler { + @Autowired + private ClusterAndRuntimeDomain clusterAndRuntimeDomain; + @Override public void init() { @@ -31,5 +40,8 @@ public void init() { @Override public void handler(ClusterEntity clusterEntity) { + // 查询所有 cluster 标记 状态 + ClusterAndRuntimeOfRelationshipDO clusterAndRuntimeOfRelationshipDO = clusterAndRuntimeDomain.getAllClusterAndRuntimeByCluster(clusterEntity); + // 查询 所有 runtime 标记 ing } } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/uninstall/UninstallRuntimeHandler.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/uninstall/UninstallRuntimeHandler.java index 987de5ea..6c8bd223 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/uninstall/UninstallRuntimeHandler.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/uninstall/UninstallRuntimeHandler.java @@ -18,11 +18,22 @@ package org.apache.eventmesh.dashboard.console.controller.deploy.uninstall; +import org.apache.eventmesh.dashboard.common.enums.DeployStatusType; import org.apache.eventmesh.dashboard.console.controller.deploy.handler.UpdateHandler; import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; +import org.apache.eventmesh.dashboard.console.service.cluster.RuntimeService; +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component public class UninstallRuntimeHandler implements UpdateHandler { + @Autowired + private RuntimeService runtimeService; + @Override public void init() { @@ -30,6 +41,10 @@ public void init() { @Override public void handler(RuntimeEntity runtimeEntity) { + // 主从 架构 如果有从存在则不能操作主 + // 直接修改 runtime 状态就行了 + runtimeEntity.setDeployStatusType(DeployStatusType.UNINSTALL_ING); + this.runtimeService.batchUpdateDeployStatusType(List.of(runtimeEntity)); } } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/message/TopicController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/message/TopicController.java index 5b6b9bd1..23a4dedd 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/message/TopicController.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/message/TopicController.java @@ -61,10 +61,6 @@ public class TopicController { @Autowired private ClusterMetadataDomain clusterMetadataDomain; - /** - * @param getTopicListDTO - * @return - */ @PostMapping("/queryTopicListByClusterId") public List queryTopicListByClusterId(@Validated @RequestBody GetTopicListDTO getTopicListDTO) { // cap 的直接查询 @@ -177,12 +173,7 @@ public void handler(ClusterMetadata clusterDO) { this.topicService.batchInsert(createTopicList); } - /** - * TODO delete - * - * @param topicId - * @return - */ + @Deprecated @GetMapping("/cluster/topic/getTopicDetailGroups") public List getTopicDetailGroups(Long topicId) { return topicService.getTopicDetailGroups(topicId); diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/domain/ClusterAndRuntimeDomain.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/domain/ClusterAndRuntimeDomain.java index 0aa12223..33898ad5 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/domain/ClusterAndRuntimeDomain.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/domain/ClusterAndRuntimeDomain.java @@ -20,6 +20,7 @@ import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; +import org.apache.eventmesh.dashboard.console.modle.DO.domain.clusterAndRuntimeDomain.ClusterAndRuntimeOfRelationshipDO; import java.util.List; @@ -34,6 +35,7 @@ public interface ClusterAndRuntimeDomain { + ClusterAndRuntimeOfRelationshipDO getAllClusterAndRuntimeByCluster(ClusterEntity clusterEntity); } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/domain/Impl/ClusterAndRuntimeDomainImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/domain/Impl/ClusterAndRuntimeDomainImpl.java index 67fa472e..ae1a873d 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/domain/Impl/ClusterAndRuntimeDomainImpl.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/domain/Impl/ClusterAndRuntimeDomainImpl.java @@ -18,16 +18,386 @@ package org.apache.eventmesh.dashboard.console.domain.Impl; +import org.apache.eventmesh.dashboard.common.enums.ClusterFramework; +import org.apache.eventmesh.dashboard.common.enums.ClusterSyncMetadataEnum; +import org.apache.eventmesh.dashboard.common.enums.ClusterType; import org.apache.eventmesh.dashboard.console.domain.ClusterAndRuntimeDomain; import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterRelationshipEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; +import org.apache.eventmesh.dashboard.console.modle.DO.clusterRelationship.QueryListByClusterIdAndTypeDO; +import org.apache.eventmesh.dashboard.console.modle.DO.domain.clusterAndRuntimeDomain.ClusterAndRuntimeOfRelationshipDO; +import org.apache.eventmesh.dashboard.console.modle.DO.domain.clusterAndRuntimeDomain.GetClusterInSyncReturnDO; +import org.apache.eventmesh.dashboard.console.modle.QO.cluster.QueryRelationClusterByClusterIdListAndType; +import org.apache.eventmesh.dashboard.console.service.cluster.ClusterRelationshipService; +import org.apache.eventmesh.dashboard.console.service.cluster.ClusterService; +import org.apache.eventmesh.dashboard.console.service.cluster.RuntimeService; +import org.apache.commons.lang3.tuple.Pair; +import org.apache.commons.lang3.tuple.Triple; + +import java.util.ArrayList; import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedList; import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Queue; +import java.util.function.Function; +import java.util.stream.Collectors; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.cache.CacheProperties; +import org.springframework.stereotype.Component; + +import net.sf.jsqlparser.statement.ExplainStatement.OptionType; + +import lombok.Setter; +/** + * TODO 1. 这个类提供 cluster 和 runtime 的关系 以及 树结构

+ * 2. 其他 domain , 通过该 domain 获得 操作对象

+ * 3. 这个与 类 其实与 ColonyDO 域冲突了。 两个 domain 功能基本重叠了。

+ * 1. ColonyDO 的 QueueConditionHandler 没有 实现好,没有 SQL 的查询效果好。

+ * 2. 后期加强 QueueConditionHandler

+ * 4. 本域 是否 与 ColonyDO 统一,设计一个统一接口。

+ * TODO + * 这个类主要是在主要在一下域使用: + * 1. 部署 需要整体关系 + * 2. 运维 只需要 可操作节点 + * 3. 关系可视化 需要整体关系 + */ +@Component public class ClusterAndRuntimeDomainImpl implements ClusterAndRuntimeDomain { + @Autowired + private ClusterService clusterService; + + @Autowired + private RuntimeService runtimeService; + + + @Autowired + private ClusterRelationshipService clusterRelationshipService; + + @Autowired + private CacheProperties cacheProperties; + + @Override public List getClusterByCLusterId(ClusterEntity clusterEntity) { return Collections.emptyList(); } -} + + + public void getClusterTree(ClusterEntity clusterEntity) { + + } + + /** + * 运维操作使用列表啊:

+ *

+ * 部署操作使用列表:

+ * + * @see org.apache.eventmesh.dashboard.console.controller.deploy.uninstall.UninstallClusterHandler + * @see org.apache.eventmesh.dashboard.console.controller.deploy.create.CreateClusterByCopyHandler + * @see org.apache.eventmesh.dashboard.console.controller.deploy.relationship.RelationshipHandler + * @see org.apache.eventmesh.dashboard.console.controller.deploy.relationship.UnRelationshipHandler + * @see org.apache.eventmesh.dashboard.console.controller.deploy.pause.PauseCluster + */ + @Override + public ClusterAndRuntimeOfRelationshipDO getAllClusterAndRuntimeByCluster(ClusterEntity clusterEntity) { + GetSyncObjectHandler getSyncObjectHandler = new GetSyncObjectHandler(); + getSyncObjectHandler.setClusterEntity(clusterEntity); + return getSyncObjectHandler.deploy(); + } + + public GetClusterInSyncReturnDO getClusterInSync(ClusterEntity clusterEntity, OptionType optionType) { + + return null; + } + + /** + * 修改配置只能在一个维度的进行操作 topic 需要对 eventmesh 与 存储同时进行操作, acl 需要多维度操作,还是? offset 的操作 按照具体 offset,只能操作 队列 级别 按照 最大或则最小 和 时间,可以 是 大集群 或则 全域操作 定义操作域 + */ + public GetClusterInSyncReturnDO getClusterInSync(ClusterEntity clusterEntity, List syncClusterTypeList) { + GetSyncObjectHandler getSyncObjectHandler = new GetSyncObjectHandler(); + getSyncObjectHandler.setClusterEntity(clusterEntity); + getSyncObjectHandler.setSyncClusterTypeList(syncClusterTypeList); + + return getSyncObjectHandler.sync(); + } + + public void getClusterInSyncByEventmesh() { + + } + + + class GetSyncObjectHandler { + + @Setter + private ClusterEntity clusterEntity; + + private ClusterType clusterType; + + @Setter + private List syncClusterTypeList; + + private List independenceClusterList = new ArrayList<>(); + + private final List clusterRelationshipEntityList = new ArrayList<>(); + + private List clusterEntityList = new ArrayList<>(); + + private final List capClusterList = new ArrayList<>(); + + private List runtimeList; + + private void base(boolean isSync) { + this.clusterEntity = clusterService.queryClusterById(clusterEntity); + this.clusterType = clusterEntity.getClusterType(); + ClusterFramework clusterFramework = ClusterSyncMetadataEnum.getClusterFramework(clusterEntity.getClusterType()); + if(clusterFramework.isCAP() && isSync){ + return; + } + if (this.clusterType.isRuntime()) { + this.queryRuntimeByClusterId(); + return; + } + this.queryClusterRelationship(); + this.queryClusterByRelationship(); + } + + public ClusterAndRuntimeOfRelationshipDO deploy() { + this.base(false); + if(this.clusterType.isRuntime()) { + ClusterAndRuntimeOfRelationshipDO clusterAndRuntimeOfRelationshipDO = new ClusterAndRuntimeOfRelationshipDO(); + clusterAndRuntimeOfRelationshipDO.setClusterEntityList(List.of(this.clusterEntity)); + clusterAndRuntimeOfRelationshipDO.setRuntimeEntityList(this.runtimeList); + clusterAndRuntimeOfRelationshipDO.getRuntimeEntityPairList().add(Pair.of(this.clusterEntity, this.runtimeList)); + return clusterAndRuntimeOfRelationshipDO; + } + this.queryRuntimeByClusterList(); + // 组织关系 + return this.structureRelationship(); + } + + + public GetClusterInSyncReturnDO sync() { + this.base(true); + if(this.clusterType.isRuntime()){ + ClusterFramework clusterFramework = ClusterSyncMetadataEnum.getClusterFramework(clusterEntity.getClusterType()); + if(clusterFramework.isCAP()){ + this.independenceClusterList = List.of(this.clusterEntity); + } + }else{ + this.filerSyncObject(); + this.queryRuntimeByIndependenceClusterList(); + } + GetClusterInSyncReturnDO syncReturnDO = new GetClusterInSyncReturnDO(); + syncReturnDO.setClusterEntityList(this.independenceClusterList); + syncReturnDO.setRuntimeEntityList(this.runtimeList); + return syncReturnDO; + } + + private ClusterAndRuntimeOfRelationshipDO structureRelationship() { + Map clusterEntityMap = + this.clusterEntityList.stream().collect(Collectors.toMap(ClusterEntity::getId, Function.identity())); + ClusterAndRuntimeOfRelationshipDO clusterAndRuntimeOfRelationshipDO = new ClusterAndRuntimeOfRelationshipDO(); + + Map> runtimeListByClusterIdMap = new HashMap<>(); + Map> clusterListByClusterIdMap = new HashMap<>(); + this.clusterRelationshipEntityList.forEach(relation -> { + ClusterEntity mainClusterEntity = clusterEntityMap.get(relation.getClusterId()); + ClusterEntity relationshipClusterEntity = clusterEntityMap.get(relation.getRelationshipId()); + + Triple triple = + Triple.of(relation, mainClusterEntity, relationshipClusterEntity); + clusterAndRuntimeOfRelationshipDO.getClusterRelationshipTripleList().add(triple); + + if (relationshipClusterEntity.getClusterType().isRuntime()) { + runtimeListByClusterIdMap.computeIfAbsent(relationshipClusterEntity.getClusterId(), k -> { + List runtimeEntityList = new ArrayList<>(); + clusterAndRuntimeOfRelationshipDO.getRuntimeEntityPairList().add(Pair.of(relationshipClusterEntity, runtimeEntityList)); + return runtimeEntityList; + }); + } + clusterListByClusterIdMap.computeIfAbsent(mainClusterEntity.getClusterId(), k->{ + List clusterEntityList = new ArrayList<>(); + clusterAndRuntimeOfRelationshipDO.getClusterEntityPairleList().add(Pair.of(mainClusterEntity, clusterEntityList)); + return clusterEntityList; + }); + }); + + this.clusterEntityList.forEach(clusterEntity -> { + List list = clusterListByClusterIdMap.get(clusterEntity.getId()); + if(Objects.nonNull(list)){ + list.add(clusterEntity); + } + }); + + this.runtimeList.forEach(runtimeEntity -> { + List list = runtimeListByClusterIdMap.get(runtimeEntity.getId()); + if(Objects.nonNull(list)){ + list.add(runtimeEntity); + } + }); + return clusterAndRuntimeOfRelationshipDO; + } + + public void getEventSpace() { + /* + 查询 eventmesh 集群 里面 eventmesh 相关集群 + storage 有一份,那么 eventmesh 也要有一份。至于 eventmesh 的是否执行,另外说。 + TODO 这里需要有一个任务,对比 eventmesh 与 storage 的相关配置是否一样,不一样就补充 + 这个对比在数据数据的对比,不在 sync 行为进行 + 比如 新增集群,激活集群,集群上线等造成,会造成 eventmesh 与 storage 数据不一样。 + 这样需要把 eventmesh 的数据 与 storage 的数据 进行一次对比,保证一样 + */ + // 分类集群 + List oneClusterList = clusterService.queryRelationClusterByClusterIdAndType(clusterEntity); + List notDefinitionClusterList = new ArrayList<>(oneClusterList); + // 查询 eventmesh 里面 存储集群 + List clusterEntityList = clusterService.queryStorageClusterByEventMeshId(clusterEntity); + } + + public void getDefinition() { + // 查询是否存 + List reationClusterList = clusterService.queryRelationClusterByClusterIdAndType(clusterEntity); + List definitionClusterList = new ArrayList<>(); + reationClusterList.forEach(value -> { + ClusterType storageClusterType = value.getClusterType(); + if (!storageClusterType.isDefinition()) { + /* + 目前来说 definition 的 storage 集群 只有 rocketmq(还有关系型数据库), + 如果认为 definition 即 主从集群,那么认 definition + */ + definitionClusterList.add(value); + } else { + capClusterList.add(value); + } + }); + if (definitionClusterList.isEmpty()) { + QueryRelationClusterByClusterIdListAndType queryRelationClusterByClusterIdListAndType = + new QueryRelationClusterByClusterIdListAndType(); + queryRelationClusterByClusterIdListAndType.setClusterEntityList(definitionClusterList); + queryRelationClusterByClusterIdListAndType.setClusterTypeList(syncClusterTypeList); + List definitionQueryRelustClusternList = + clusterService.queryRelationClusterByClusterIdListAndType(queryRelationClusterByClusterIdListAndType); + capClusterList.addAll(definitionQueryRelustClusternList); + } + } + + public void getRuntimeByCluster() { + RuntimeEntity runtimeEntity = new RuntimeEntity(); + runtimeEntity.setClusterId(clusterEntity.getId()); + this.runtimeList = runtimeService.queryRuntimeToFrontByClusterId(runtimeEntity); + } + + private void filerSyncObject() { + this.clusterEntityList.forEach(value -> { + ClusterFramework clusterFramework = ClusterSyncMetadataEnum.getClusterFramework(value.getClusterType()); + if (clusterFramework.isCAP() || clusterFramework.isCP()) { + capClusterList.add(value); + } else if (clusterFramework.isIndependence()) { + independenceClusterList.add(value); + } + }); + } + + private void queryRuntimeByClusterId(){ + RuntimeEntity runtimeEntity = new RuntimeEntity(); + runtimeEntity.setClusterId(clusterEntity.getId()); + this.runtimeList = runtimeService.queryRuntimeToFrontByClusterId(runtimeEntity); + } + + private void queryRuntimeByIndependenceClusterList() { + if (!this.independenceClusterList.isEmpty()) { + this.runtimeList = runtimeService.queryRuntimeToFrontByClusterIdList(this.independenceClusterList); + } + } + + private void queryRuntimeByClusterList() { + if (!this.clusterEntityList.isEmpty()) { + this.runtimeList = runtimeService.queryRuntimeToFrontByClusterIdList(this.clusterEntityList); + } + } + + private void queryClusterByRelationship() { + List clsuterEnttiyList = this.clusterRelationshipEntityList.stream().map(value -> { + ClusterEntity entity = new ClusterEntity(); + entity.setId(value.getRelationshipId()); + return entity; + }).toList(); + this.clusterEntityList = clusterService.queryClusterListByClusterList(clsuterEnttiyList); + } + + private void queryClusterRelationship() { + List clusterId = new ArrayList<>(); + Queue clusterRelationshipEntityQueue = new LinkedList<>(); + QueryListByClusterIdAndTypeDO queryListByClusterIdAndTypeDO = new QueryListByClusterIdAndTypeDO(); + queryListByClusterIdAndTypeDO.setClusterId(this.clusterEntity.getId()); + queryListByClusterIdAndTypeDO.setClusterTypeList(this.syncClusterTypeList); + List relationshipEntityList = + clusterRelationshipService.queryListByClusterIdAndType(queryListByClusterIdAndTypeDO); + this.clusterRelationshipEntityList.addAll(relationshipEntityList); + for (; ; ) { + List idList = relationshipEntityList.stream().map(ClusterRelationshipEntity::getRelationshipId).toList(); + queryListByClusterIdAndTypeDO.setClusterIdList(idList); + relationshipEntityList = clusterRelationshipService.queryListByClusterIdListAndType(queryListByClusterIdAndTypeDO); + if (relationshipEntityList.isEmpty()) { + break; + } + this.clusterRelationshipEntityList.addAll(relationshipEntityList); + } + } + + /** + * TODO for 循环查询 所有 cluster ,不想 怕有 性能 问题,造成 bug。 + * queryClusterRelationship 可以代替这个 方法 + */ + private void queryCluster() { + // 构建第一次查询对象 + QueryRelationClusterByClusterIdListAndType queryRelationClusterByClusterIdListAndType = + new QueryRelationClusterByClusterIdListAndType(); + queryRelationClusterByClusterIdListAndType.setClusterTypeList(syncClusterTypeList); + List clusterEntityList = new ArrayList<>(); + queryRelationClusterByClusterIdListAndType.setClusterEntityList(clusterEntityList); + clusterEntityList.add(clusterEntity); + /* + 循环查询所有 cluster

+ 目前循环四次就行了,

+ 需要去重,应为 有共享集群的存在

+ TODO 如何 识别 目标对象 + */ + for (int i = 0; i < 5; i++) { + List reationClusterList = + clusterService.queryRelationClusterByClusterIdListAndType(queryRelationClusterByClusterIdListAndType); + + List definitionClusterList = new ArrayList<>(); + reationClusterList.forEach(value -> { + ClusterType storageClusterType = value.getClusterType(); + if (!storageClusterType.isDefinition()) { + /* + 目前来说 definition 的 storage 集群 只有 rocketmq(还有关系型数据库), + 如果认为 definition 即 主从集群,那么认 definition + */ + definitionClusterList.add(value); + } else { + ClusterFramework clusterFramework = ClusterSyncMetadataEnum.getClusterFramework(value.getClusterType()); + if (clusterFramework.isCAP() || clusterFramework.isCP()) { + capClusterList.add(value); + } else if (clusterFramework.isIndependence()) { + independenceClusterList.add(value); + } + } + }); + if (definitionClusterList.isEmpty()) { + return; + } + queryRelationClusterByClusterIdListAndType.setClusterEntityList(definitionClusterList); + } + } + } +} \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/domain/metadata/ClusterMetadataDomain.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/domain/metadata/ClusterMetadataDomain.java index 85475d0d..3824310a 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/domain/metadata/ClusterMetadataDomain.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/domain/metadata/ClusterMetadataDomain.java @@ -50,6 +50,7 @@ import java.util.Map; import java.util.Objects; +import lombok.Getter; import lombok.Setter; import lombok.extern.slf4j.Slf4j; @@ -60,12 +61,13 @@ @Slf4j public class ClusterMetadataDomain { + @Getter private ColonyDO colonyDO; private boolean coreModel = true; - private boolean buildConfig = false; + private boolean buildConfig = true; @Setter private DataHandler handler; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/base/BaseOrganizationEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/base/BaseOrganizationEntity.java index 622fe753..5b0f9064 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/base/BaseOrganizationEntity.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/base/BaseOrganizationEntity.java @@ -30,4 +30,5 @@ public class BaseOrganizationEntity extends BaseIdEntity { private Long organizationId; + } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/CollectEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/CollectEntity.java new file mode 100644 index 00000000..648ae6fe --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/CollectEntity.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.entity.cluster; + +import org.apache.eventmesh.dashboard.common.enums.CollectType; +import org.apache.eventmesh.dashboard.console.entity.base.BaseClusterIdEntity; + +/** + * + */ +public class CollectEntity extends BaseClusterIdEntity { + + + private CollectType collectType; + + private Long saveTime; + + private Long collectInterval; + + private Long storageClusterId; + + private Long storageClusterName; + + private Boolean enable; + + private Boolean defaultStorage; + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/function/ConfigEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/function/ConfigEntity.java index c29b1f80..77c7e42b 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/function/ConfigEntity.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/function/ConfigEntity.java @@ -19,14 +19,14 @@ package org.apache.eventmesh.dashboard.console.entity.function; import org.apache.eventmesh.dashboard.common.enums.MetadataType; -import org.apache.eventmesh.dashboard.console.entity.base.BaseClusterIdEntity; +import org.apache.eventmesh.dashboard.console.entity.base.BaseRuntimeIdEntity; import lombok.Data; import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = true) -public class ConfigEntity extends BaseClusterIdEntity { +public class ConfigEntity extends BaseRuntimeIdEntity { diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/function/HealthCheckResultEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/function/HealthCheckResultEntity.java index 4e22de66..5067e08c 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/function/HealthCheckResultEntity.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/function/HealthCheckResultEntity.java @@ -37,15 +37,13 @@ @Schema(name = "HealthCheckResultEntity", description = "Health check result entity") public class HealthCheckResultEntity extends BaseRuntimeIdEntity { - private static final long serialVersionUID = -7350585209577598040L; - private ClusterType clusterType; private String protocol; - private String interfaces; + private String address; - private HealthCheckTypeEnum healthCheckTypeEnum; + private HealthCheckTypeEnum healthCheckType; private HealthCheckStatus result; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/message/SubscriptionEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/message/GroupMemberEntity.java similarity index 94% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/message/SubscriptionEntity.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/message/GroupMemberEntity.java index cfd36cfe..813b43cb 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/message/SubscriptionEntity.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/message/GroupMemberEntity.java @@ -25,7 +25,7 @@ @Data @EqualsAndHashCode(callSuper = true) -public class SubscriptionEntity extends BaseRuntimeIdEntity { +public class GroupMemberEntity extends BaseRuntimeIdEntity { private String topicName; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/Health2Service.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/Health2Service.java index 5c938fcb..964b385f 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/Health2Service.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/Health2Service.java @@ -18,10 +18,12 @@ package org.apache.eventmesh.dashboard.console.function.health; +import org.apache.eventmesh.dashboard.common.enums.ClusterSyncMetadataEnum; import org.apache.eventmesh.dashboard.common.enums.ClusterType; import org.apache.eventmesh.dashboard.common.enums.health.HealthCheckStatus; import org.apache.eventmesh.dashboard.common.enums.health.HealthCheckTypeEnum; import org.apache.eventmesh.dashboard.common.model.base.BaseSyncBase; +import org.apache.eventmesh.dashboard.common.model.metadata.RuntimeMetadata; import org.apache.eventmesh.dashboard.common.util.ClasspathScanner; import org.apache.eventmesh.dashboard.console.entity.function.HealthCheckResultEntity; import org.apache.eventmesh.dashboard.console.function.health.annotation.HealthCheckType; @@ -31,6 +33,8 @@ import org.apache.eventmesh.dashboard.console.function.health.check.HealthCheckService; import org.apache.eventmesh.dashboard.console.service.function.HealthDataService; import org.apache.eventmesh.dashboard.core.function.SDK.SDKManage; +import org.apache.eventmesh.dashboard.core.function.SDK.config.AbstractCreateSDKConfig; +import org.apache.eventmesh.dashboard.core.function.SDK.config.AbstractMultiCreateSDKConfig; import java.time.LocalDateTime; import java.util.ArrayList; @@ -106,13 +110,20 @@ public Thread newThread(Runnable r) { @Setter private HealthDataService dataService; + private LocalDateTime beginTime = LocalDateTime.now(); + public void register(BaseSyncBase baseSyncBase) { try { - this.createHealthCheckWrapper(baseSyncBase, HealthCheckTypeEnum.PING); + HealthCheckWrapper healthCheckWrapper = this.createHealthCheckWrapper(baseSyncBase, HealthCheckTypeEnum.PING); if (baseSyncBase.getClusterType().isHealthTopic()) { this.createHealthCheckWrapper(baseSyncBase, HealthCheckTypeEnum.TOPIC); } + if(log.isDebugEnabled()){ + AbstractCreateSDKConfig abstractCreateSDKConfig = (AbstractCreateSDKConfig)healthCheckWrapper.getCheckService().getCreateSDKConfig(); + log.debug("register health check service for {} , {} ,{}", baseSyncBase.getClusterType(),baseSyncBase.getId(), + abstractCreateSDKConfig.getUniqueKey()); + } } catch (Exception e) { log.error(e.getMessage(), e); } @@ -126,6 +137,11 @@ public void unRegister(BaseSyncBase baseSyncBase) { } this.checkServiceMap.remove(getKey(baseSyncBase, HealthCheckTypeEnum.PING)); this.checkServiceMap.remove(getKey(baseSyncBase, HealthCheckTypeEnum.TOPIC)); + if(log.isDebugEnabled()){ + RuntimeMetadata runtimeMetadata = (RuntimeMetadata)baseSyncBase; + log.debug("unRegister health check service for {} , {} ,{},{}", baseSyncBase.getClusterType(),baseSyncBase.getId(), + runtimeMetadata.getHost(), runtimeMetadata.getPort()); + } } @Deprecated @@ -134,7 +150,7 @@ public void unRegisterCluster(Long clusterId) { } - void createHealthCheckWrapper(BaseSyncBase baseSyncBase, HealthCheckTypeEnum healthCheckTypeEnum) { + private HealthCheckWrapper createHealthCheckWrapper(BaseSyncBase baseSyncBase, HealthCheckTypeEnum healthCheckTypeEnum) { Map> map = Objects.equals(healthCheckTypeEnum, HealthCheckTypeEnum.PING) ? HEALTH_PING_CHECK_CLASS_CACHE : HEALTH_TOPIC_CHECK_CLASS_CACHE; Class clazz = map.get(baseSyncBase.getClusterType()); @@ -142,6 +158,7 @@ void createHealthCheckWrapper(BaseSyncBase baseSyncBase, HealthCheckTypeEnum hea HealthCheckWrapper healthCheckWrapper = this.createHealthCheckWrapper(baseSyncBase, abstractHealthCheckService, healthCheckTypeEnum); this.checkServiceMap.put(healthCheckWrapper.getKey(), healthCheckWrapper); + return healthCheckWrapper; } private HealthCheckWrapper createHealthCheckWrapper(BaseSyncBase baseSyncBase, @@ -158,15 +175,26 @@ private HealthCheckWrapper createHealthCheckWrapper(BaseSyncBase baseSyncBase, } public void executeAll() { + if(checkServiceMap.isEmpty()){ + log.info("check service is empty"); + return; + } long startTime = System.currentTimeMillis(); + this.beginTime = LocalDateTime.now(); List healthCheckResultEntityList = new ArrayList<>(); CountDownLatch countDownLatch = new CountDownLatch(this.checkServiceMap.size()); this.checkServiceMap.forEach((k, wrapper) -> { - healthCheckResultEntityList.add(wrapper.createHealthCheckResultEntity()); + DefaultHealthCheckCallback healthExecutor = new DefaultHealthCheckCallback(); healthExecutor.healthCheckWrapper = wrapper; healthExecutor.countDownLatch = countDownLatch; - healthExecutor.healthCheckResultEntity = wrapper.getHealthCheckResultEntity(); + if(wrapper.isCap()){ + healthCheckResultEntityList.add(wrapper.createHealthCheckResultEntity()); + healthExecutor.healthCheckResultEntity = wrapper.getHealthCheckResultEntity(); + }else{ + healthExecutor.healthCheckResultEntityMap = wrapper.createHealthCheckResultEntityMap(); + healthCheckResultEntityList.addAll(healthExecutor.healthCheckResultEntityMap.values()); + } threadPoolExecutor.execute(() -> { try { @@ -176,20 +204,26 @@ public void executeAll() { } }); }); - try { - dataService.batchInsertHealthCheckResult(healthCheckResultEntityList); - } catch (Exception e) { - log.error("batchInsertHealthCheckResult failed", e); - } +// try { +// dataService.batchInsertHealthCheckResult(healthCheckResultEntityList); +// } catch (Exception e) { +// log.error("batchInsertHealthCheckResult failed", e); +// } try { boolean await = countDownLatch.await(3, TimeUnit.SECONDS); - log.info("await ia {} downLatch count {}", await, countDownLatch.getCount()); - log.info(" startup cost {} ms", System.currentTimeMillis() - startTime); + log.info("await ia {} downLatch count {}, startup cost {} ms", await, countDownLatch.getCount(),System.currentTimeMillis() - startTime); } catch (Exception e) { log.error(e.getMessage(), e); } finally { try { - dataService.batchUpdateCheckResultByClusterIdAndTypeAndTypeId(healthCheckResultEntityList); + LocalDateTime endTime = LocalDateTime.now(); + healthCheckResultEntityList.forEach(healthCheckResultEntity -> { + if(healthCheckResultEntity.getResult() == HealthCheckStatus.ING){ + healthCheckResultEntity.setResult(HealthCheckStatus.TIMEOUT); + healthCheckResultEntity.setFinishTime(endTime); + } + }); + dataService.batchInsertHealthCheckResult(healthCheckResultEntityList); } catch (Exception e) { log.error("batchUpdateCheckResultByClusterIdAndTypeAndTypeId failed", e); } @@ -209,6 +243,8 @@ static class DefaultHealthCheckCallback implements HealthCheckCallback { private HealthCheckResultEntity healthCheckResultEntity; + private Map healthCheckResultEntityMap; + @Override public void onSuccess() { healthCheckResultEntity.setResult(HealthCheckStatus.SUCCESS); @@ -220,7 +256,6 @@ public void onSuccess() { public void onFail(Exception e) { healthCheckResultEntity.setResult(HealthCheckStatus.FAILED); healthCheckResultEntity.setResultDesc(e.getMessage()); - healthCheckResultEntity.setFinishTime(LocalDateTime.now()); countDownLatch.countDown(); log.error("healthCheckCallback onFail Id: ", e); } @@ -233,6 +268,7 @@ class HealthCheckWrapper { private AbstractHealthCheckService checkService; + private String address; private HealthCheckResultEntity healthCheckResultEntity = new HealthCheckResultEntity(); @@ -241,16 +277,37 @@ class HealthCheckWrapper { private HealthCheckResultEntity createHealthCheckResultEntity() { + if(Objects.isNull(this.address)){ + this.address = ((AbstractCreateSDKConfig)checkService.getCreateSDKConfig()).doUniqueKey(); + } + return this.createHealthCheckResultEntity(this.address); + } + + private HealthCheckResultEntity createHealthCheckResultEntity(String address) { HealthCheckResultEntity healthCheckResultEntity = new HealthCheckResultEntity(); - healthCheckResultEntity.setClusterId(this.baseSyncBase.getClusterId()); - healthCheckResultEntity.setInterfaces(this.baseSyncBase.getId().toString()); - healthCheckResultEntity.setHealthCheckTypeEnum(this.healthCheckTypeEnum); healthCheckResultEntity.setClusterType(this.baseSyncBase.getClusterType()); - healthCheckResultEntity.setBeginTime(LocalDateTime.now()); + healthCheckResultEntity.setClusterId(this.baseSyncBase.getClusterId()); + healthCheckResultEntity.setProtocol(""); + healthCheckResultEntity.setType(2); + healthCheckResultEntity.setTypeId(this.baseSyncBase.getId()); + healthCheckResultEntity.setAddress(this.address); + healthCheckResultEntity.setHealthCheckType(this.healthCheckTypeEnum); + healthCheckResultEntity.setResult(HealthCheckStatus.ING); + healthCheckResultEntity.setResultDesc(""); + healthCheckResultEntity.setBeginTime(beginTime); this.healthCheckResultEntity = healthCheckResultEntity; return healthCheckResultEntity; } + public Map createHealthCheckResultEntityMap() { + Map healthCheckResultEntityMap = new HashMap<>(); + AbstractMultiCreateSDKConfig abstractMultiCreateSDKConfig = (AbstractMultiCreateSDKConfig)this.checkService.getCreateSDKConfig(); + for(String address : abstractMultiCreateSDKConfig.getNetAddresses()){ + healthCheckResultEntityMap.put(address,createHealthCheckResultEntity(address)); + } + return healthCheckResultEntityMap; + } + @Override public boolean equals(Object object) { if (object instanceof HealthCheckWrapper) { @@ -266,6 +323,10 @@ public String getKey() { return Health2Service.this.getKey(this.baseSyncBase, this.healthCheckTypeEnum); } + public boolean isCap(){ + return ClusterSyncMetadataEnum.getClusterFramework(this.baseSyncBase.getClusterType()).isCAP(); + } + } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/jvm/JVMCheck.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/jvm/JVMCheck.java index acaf8475..f5de38df 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/jvm/JVMCheck.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/impl/jvm/JVMCheck.java @@ -25,7 +25,9 @@ import org.apache.eventmesh.dashboard.console.function.health.check.AbstractHealthCheckService; import org.apache.eventmesh.dashboard.core.function.SDK.wrapper.NacosSDKWrapper; -@HealthCheckType(clusterType = {ClusterType.STORAGE_JVM_BROKER}, healthType = HealthCheckTypeEnum.PING) +@HealthCheckType(clusterType = {ClusterType.STORAGE_JVM_BROKER,ClusterType.STORAGE_JVM_META, + ClusterType.EVENTMESH_JVM_META,ClusterType.EVENTMESH_JVM_RUNTIME}, + healthType = HealthCheckTypeEnum.PING) public class JVMCheck extends AbstractHealthCheckService { @Override diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/AbstractReportEngine.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/AbstractReportEngine.java index 12c76adc..ca60e465 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/AbstractReportEngine.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/AbstractReportEngine.java @@ -18,7 +18,7 @@ package org.apache.eventmesh.dashboard.console.function.report; import org.apache.eventmesh.dashboard.console.function.report.annotation.AbstractReportMetaHandler; -import org.apache.eventmesh.dashboard.console.function.report.annotation.ReportMeta; +import org.apache.eventmesh.dashboard.console.function.report.annotation.ReportMetaData; import org.apache.eventmesh.dashboard.console.function.report.model.SingleGeneralReportDO; import org.apache.ibatis.mapping.BoundSql; @@ -95,12 +95,14 @@ protected String querySentence(SingleGeneralReportDO singleGeneralReportDO) { } @Override - public void createReportHandler(ReportMeta reportMeta, List fieldList) { - AbstractReportMetaHandler abstractReportMetaHandler = this.doCreateReportHandler(reportMeta, fieldList); - this.reportMetaHandlerMap.put(reportMeta.reportName(), abstractReportMetaHandler); + public void createReportHandler(ReportMetaData reportMetaData, List fieldList) { + AbstractReportMetaHandler abstractReportMetaHandler = this.doCreateReportHandler(reportMetaData, fieldList); + abstractReportMetaHandler.setReportMeta(reportMetaData); + abstractReportMetaHandler.setFieldList(fieldList); + this.reportMetaHandlerMap.put(reportMetaData.getReportName(), abstractReportMetaHandler); } - protected abstract AbstractReportMetaHandler doCreateReportHandler(ReportMeta reportMeta, List fieldList); + protected abstract AbstractReportMetaHandler doCreateReportHandler(ReportMetaData reportMetaData, List fieldList); protected String buildSql(String reportName, String type, Object value) { SqlSource sqlSource = this.buildSqlSource(reportName, type); diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/ReportEngine.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/ReportEngine.java index 6f92ec90..91fb5be2 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/ReportEngine.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/ReportEngine.java @@ -17,7 +17,7 @@ package org.apache.eventmesh.dashboard.console.function.report; -import org.apache.eventmesh.dashboard.console.function.report.annotation.ReportMeta; +import org.apache.eventmesh.dashboard.console.function.report.annotation.ReportMetaData; import org.apache.eventmesh.dashboard.console.function.report.model.SingleGeneralReportDO; import java.lang.reflect.Field; @@ -28,14 +28,17 @@ public interface ReportEngine { - CompletableFuture>> query(SingleGeneralReportDO singleGeneralReportDO); - + CompletableFuture>> query(SingleGeneralReportDO singleGeneralReportDO); void createReport(String tableName); - void batchInsert(String tableName , List data); + void batchInsert(String tableName, List data); + + default void batchInsert(Map> data) { + data.forEach(this::batchInsert); + } - void createReportHandler(ReportMeta reportMeta, List fieldList); + void createReportHandler(ReportMetaData reportMetaData, List fieldList); } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/ReportHandlerManage.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/ReportHandlerManage.java index 44321d0a..5438b5d3 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/ReportHandlerManage.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/ReportHandlerManage.java @@ -18,9 +18,18 @@ package org.apache.eventmesh.dashboard.console.function.report; import org.apache.eventmesh.dashboard.common.util.ClasspathScanner; +import org.apache.eventmesh.dashboard.console.function.report.annotation.Aggregation; import org.apache.eventmesh.dashboard.console.function.report.annotation.ReportMeta; +import org.apache.eventmesh.dashboard.console.function.report.annotation.ReportMetaData; +import org.apache.eventmesh.dashboard.console.function.report.annotation.ReportMetaData.AggregationClass; +import org.apache.eventmesh.dashboard.console.function.report.collect.CollectManage; +import org.apache.eventmesh.dashboard.console.function.report.collect.MetadataDataManage; import org.apache.eventmesh.dashboard.console.function.report.model.SingleGeneralReportDO; +import org.apache.eventmesh.dashboard.console.function.report.model.base.OrganizationId; +import org.apache.eventmesh.dashboard.console.function.report.model.base.Time; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.reflect.FieldUtils; import java.lang.reflect.Field; @@ -30,9 +39,14 @@ import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.Set; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; +import lombok.Getter; import lombok.Setter; /** @@ -62,9 +76,20 @@ public class ReportHandlerManage { + private final ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(); + @Setter private ReportEngine reportEngine; + @Getter + private Map reportMetaDataMap = new HashMap<>(); + + private final Map, String> clazzToTableName = new HashMap<>(); + + private final CollectManage collectManage = new CollectManage(); + + private final MetadataDataManage metadataDataManage = new MetadataDataManage(); + public void init() { ClasspathScanner classpathScanner = ClasspathScanner.builder().base(ReportHandlerManage.class).subPath("/model/**").build(); @@ -74,6 +99,33 @@ public void init() { } catch (Exception e) { throw new RuntimeException(e); } + + scheduledExecutorService.schedule(this.collectManage::request, 5, TimeUnit.SECONDS); + + scheduledExecutorService.schedule(this::handlerData, 5, TimeUnit.SECONDS); + + scheduledExecutorService.schedule(this.metadataDataManage::syncData, 100, TimeUnit.MINUTES); + } + + /** + * 后期再支持多存储与多数据 + */ + private void handlerData(){ + List