diff --git a/.asf.yaml b/.asf.yaml index fdb990a7..faf433b8 100644 --- a/.asf.yaml +++ b/.asf.yaml @@ -34,9 +34,9 @@ github: - serverless-workflow - message-bus enabled_merge_buttons: - squash: true - merge: false - rebase: false + squash: true + merge: false + rebase: false protected_branches: main: required_status_checks: @@ -47,11 +47,11 @@ github: dismiss_stale_reviews: true required_approving_review_count: 0 # Temporary 0 to allow committers to merge themselves PR notifications: - commits: commits@eventmesh.apache.org - # Send all issue emails (new, closed, comments) to issues@ - issues: issues@eventmesh.apache.org - # Send new/closed PR notifications to dev@ - pullrequests_status: dev@eventmesh.apache.org - # Send individual PR comments/reviews to issues@ - pullrequests_comment: issues@eventmesh.apache.org - jira_options: link label worklog + commits: commits@eventmesh.apache.org + # Send all issue emails (new, closed, comments) to issues@ + issues: issues@eventmesh.apache.org + # Send new/closed PR notifications to dev@ + pullrequests_status: dev@eventmesh.apache.org + # Send individual PR comments/reviews to issues@ + pullrequests_comment: issues@eventmesh.apache.org + jira_options: link label worklog diff --git a/.github/workflows/config/eventmesh.properties b/.github/workflows/config/eventmesh.properties index 7f26487c..31ad594c 100644 --- a/.github/workflows/config/eventmesh.properties +++ b/.github/workflows/config/eventmesh.properties @@ -43,12 +43,10 @@ eventMesh.server.session.expiredInMills=60000 eventMesh.server.tcp.msgReqnumPerSecond=15000 eventMesh.server.http.msgReqnumPerSecond=15000 eventMesh.server.session.upstreamBufferSize=20 - # for single event publish, maximum size allowed per event eventMesh.server.maxEventSize=1000 # for batch event publish, maximum number of events allowed in one batch eventMesh.server.maxEventBatchSize=10 - # thread number about global scheduler eventMesh.server.global.scheduler=5 eventMesh.server.tcp.taskHandleExecutorPoolSize=8 @@ -59,32 +57,26 @@ eventMesh.server.retry.async.pushRetryDelayInMills=500 eventMesh.server.retry.sync.pushRetryDelayInMills=500 eventMesh.server.retry.pushRetryQueueSize=10000 eventMesh.server.retry.plugin.type=default - # sleep interval between closing client of different group in server graceful shutdown eventMesh.server.gracefulShutdown.sleepIntervalInMills=1000 eventMesh.server.rebalanceRedirect.sleepIntervalInMills=200 - # ip address blacklist eventMesh.server.blacklist.ipv4=0.0.0.0/8,127.0.0.0/8,169.254.0.0/16,255.255.255.255/32 eventMesh.server.blacklist.ipv6=::/128,::1/128,ff00::/8 - ########################## EventMesh Plugin Configuration ########################## # storage plugin eventMesh.storage.plugin.type=rocketmq - # security plugin eventMesh.server.security.enabled=false eventMesh.security.plugin.type=security eventMesh.security.validation.type.token=false eventMesh.security.publickey= - # metaStorage plugin eventMesh.metaStorage.plugin.enabled=true eventMesh.metaStorage.plugin.type=nacos eventMesh.metaStorage.plugin.server-addr=127.0.0.1:8848 eventMesh.metaStorage.plugin.username=nacos eventMesh.metaStorage.plugin.password=nacos - # metaStorage plugin: nacos #eventMesh.metaStorage.nacos.endpoint= #eventMesh.metaStorage.nacos.accessKey= @@ -93,16 +85,13 @@ eventMesh.metaStorage.plugin.password=nacos #eventMesh.metaStorage.nacos.namespace= # The default value is half of CPU's num #eventMesh.metaStorage.nacos.namingPollingThreadCount=5 - # metaStorage plugin: zookeeper #eventMesh.metaStorage.zookeeper.scheme= #eventMesh.metaStorage.zookeeper.auth= #eventMesh.metaStorage.zookeeper.connectionTimeoutMs= #eventMesh.metaStorage.zookeeper.sessionTimeoutMs= - # Fully qualified name of org.apache.curator.RetryPolicy implementation #eventMesh.metaStorage.zookeeper.retryPolicy.class= - # Constructor arguments for different org.apache.curator.RetryPolicy implementations #eventMesh.metaStorage.zookeeper.retryPolicy.baseSleepTimeMs= #eventMesh.metaStorage.zookeeper.retryPolicy.maxRetries= @@ -110,7 +99,6 @@ eventMesh.metaStorage.plugin.password=nacos #eventMesh.metaStorage.zookeeper.retryPolicy.retryIntervalMs= #eventMesh.metaStorage.zookeeper.retryPolicy.nTimes= #eventMesh.metaStorage.zookeeper.retryPolicy.sleepMsBetweenRetries= - # The TLS configuration of metaStorage plugin: consul # keyStoreInstanceType's value can refer to com.ecwid.consul.transport.TLSConfig.KeyStoreInstanceType #eventMesh.metaStorage.consul.tls.keyStoreInstanceType= @@ -118,21 +106,18 @@ eventMesh.metaStorage.plugin.password=nacos #eventMesh.metaStorage.consul.tls.certificatePassword= #eventMesh.metaStorage.consul.tls.keyStorePath= #eventMesh.metaStorage.consul.tls.keyStorePassword= - # metrics plugin, if you have multiple plugin, you can use ',' to split eventMesh.metrics.plugin=prometheus - # trace plugin eventMesh.server.trace.enabled=false eventMesh.trace.plugin=zipkin - # webhook # Start webhook admin service eventMesh.webHook.admin.start=true # Webhook event configuration storage mode. Currently, only file and nacos are supported eventMesh.webHook.operationMode=file # The file storage path of the file storage mode. If #{eventMeshHome} is written, it is in the EventMesh root directory -eventMesh.webHook.fileMode.filePath= #{eventMeshHome}/webhook +eventMesh.webHook.fileMode.filePath=#{eventMeshHome}/webhook # Nacos storage mode, and the configuration naming rule is EventMesh webHook. nacosMode. {nacos native configuration key} please see the specific configuration [nacos github api](https://github.com/alibaba/nacos/blob/develop/api/src/main/java/com/alibaba/nacos/api/SystemPropertyKeyConst.java) ## Address of Nacos eventMesh.webHook.nacosMode.serverAddr=127.0.0.1:8848 diff --git a/.github/workflows/license.yml b/.github/workflows/license.yml index d62e6331..ed1e79e1 100644 --- a/.github/workflows/license.yml +++ b/.github/workflows/license.yml @@ -16,7 +16,7 @@ # name: 'License Check' -on: [pull_request] +on: [ pull_request ] permissions: contents: read diff --git a/README.md b/README.md index 0f3b3708..52807545 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,11 @@ ## Introduction -The EventMesh Dashboard is under development and will support functionalities such as Connection management, cluster health checks, etc. Feel free to reach out to the [EventMesh Assistant](https://github.com/apache/eventmesh?tab=readme-ov-file#community) to contribute. +The EventMesh Dashboard is under development and will support functionalities such as Connection management, cluster health checks, etc. Feel free to +reach out to the [EventMesh Assistant](https://github.com/apache/eventmesh?tab=readme-ov-file#community) to contribute. -The Dashboard for EventMesh, maintained during v1.8.0 ~ v1.10.0, is a pure frontend project located at the [Next.js Dashboard branch](https://github.com/apache/eventmesh-dashboard/tree/nextjs-dashboard). +The Dashboard for EventMesh, maintained during v1.8.0 ~ v1.10.0, is a pure frontend project located at +the [Next.js Dashboard branch](https://github.com/apache/eventmesh-dashboard/tree/nextjs-dashboard). Weekly development meeting documents for EventMesh Dashboard: https://docs.qq.com/doc/DQmhVbklUdGNNWGZi @@ -67,7 +69,7 @@ cd eventmesh-dashboard ./mvnw clean package ``` ->TODO download mysql-connector-j manually +> TODO download mysql-connector-j manually ``` java -DDB_ADDRESS=$DB_ADDRESS -DDB_USERNAME=$DB_USERNAME -DDB_PASSWORD=$DB_PASSWORD -jar eventmesh-dashboard-console/target/eventmesh-dashboard-console-0.0.1-SNAPSHOT.jar @@ -75,7 +77,7 @@ java -DDB_ADDRESS=$DB_ADDRESS -DDB_USERNAME=$DB_USERNAME -DDB_PASSWORD=$DB_PASSW ### Build and Run with Docker ->To be updated +> To be updated ``` cd eventmesh-dashboard diff --git a/README.zh-CN.md b/README.zh-CN.md index ccb82a83..ea1ae6f0 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -4,9 +4,11 @@ ## 介绍 -EventMesh Dashboard 处于开发中,将支持 Connection 管理、集群健康检查等功能。欢迎联系 [EventMesh 小助手](https://github.com/apache/eventmesh?tab=readme-ov-file#community)参与贡献。 +EventMesh Dashboard 处于开发中,将支持 Connection +管理、集群健康检查等功能。欢迎联系 [EventMesh 小助手](https://github.com/apache/eventmesh?tab=readme-ov-file#community)参与贡献。 -EventMesh 于 v1.8.0 ~ v1.10.0 期间维护的 Dashboard 纯前端项目位于 [Next.js Dashboard 分支](https://github.com/apache/eventmesh-dashboard/tree/nextjs-dashboard)。 +EventMesh 于 v1.8.0 ~ v1.10.0 期间维护的 Dashboard +纯前端项目位于 [Next.js Dashboard 分支](https://github.com/apache/eventmesh-dashboard/tree/nextjs-dashboard)。 EventMesh Dashboard 每周开发例会文档:https://docs.qq.com/doc/DQmhVbklUdGNNWGZi @@ -16,18 +18,18 @@ EventMesh Dashboard 每周开发例会文档:https://docs.qq.com/doc/DQmhVbklU ### 环境 -- JDK 8/11 +- JDK 17 - Maven 3.9.x - Spring Boot 2.7.x ### 模块介绍 -1. eventmesh-dashboard-console 业务模块的代码,调用service接口 -2. eventmesh-dashboard-observe 监控模块的代码 -3. eventmesh-dashboard-core 对EventMesh Runtime, Meta以及相关组件的代码,提供service实现 -4. eventmesh-dashboard-service 公用API接口,对core的抽象 -5. eventmesh-dashboard-common 公共模块的代码 -6. eventmesh-dashboard-view 前端代码 +1. eventmesh-dashboard-console 业务模块的代码,调用service接口 +2. eventmesh-dashboard-observe 监控模块的代码 +3. eventmesh-dashboard-core 对EventMesh Runtime, Meta以及相关组件的代码,提供service实现 +4. eventmesh-dashboard-service 公用API接口,对core的抽象 +5. eventmesh-dashboard-common 公共模块的代码 +6. eventmesh-dashboard-view 前端代码 ## 自动部署最新版 EventMesh Dashboard @@ -67,7 +69,7 @@ cd eventmesh-dashboard ./mvnw clean package ``` ->TODO download mysql-connector-j manually +> TODO download mysql-connector-j manually ``` java -DDB_ADDRESS=$DB_ADDRESS -DDB_USERNAME=$DB_USERNAME -DDB_PASSWORD=$DB_PASSWORD -jar eventmesh-dashboard-console/target/eventmesh-dashboard-console-0.0.1-SNAPSHOT.jar @@ -75,7 +77,7 @@ java -DDB_ADDRESS=$DB_ADDRESS -DDB_USERNAME=$DB_USERNAME -DDB_PASSWORD=$DB_PASSW ### 构建并运行 Docker 镜像 ->To be updated +> To be updated ``` cd eventmesh-dashboard @@ -88,17 +90,19 @@ docker run -d --name eventmesh-dashboard -p 8080:8080 yourname/eventmesh-dashboa ``` ### 开发准备 -1. 配置格式化 - 1. 后端格式文档地址:https://eventmesh.apache.org/zh/community/contribute/contribute/ - 2. 前端使用 eslint -2. 配置协议头工具 license-eye。 - 1. 检查命令:license-eye header check - 2. 使用命令:license-eye header fix - 3. 下载地址: https://skywalking.apache.org/downloads/ +1. 配置格式化 + 1. 后端格式文档地址:https://eventmesh.apache.org/zh/community/contribute/contribute/ + 2. 前端使用 eslint +2. 配置协议头工具 license-eye。 + 1. 检查命令:license-eye header check + 2. 使用命令:license-eye header fix + 3. 下载地址: https://skywalking.apache.org/downloads/ ### 提交代码前 + 在项目根目录执行下面命令 + ``` license-eye -v info -c .licenserc.yaml header check ./mvnw -B package -DskipTests --file pom.xml diff --git a/doc/TODO.md b/doc/TODO.md new file mode 100644 index 00000000..2859363a --- /dev/null +++ b/doc/TODO.md @@ -0,0 +1,107 @@ +## 文档任务 + +- 整体设计文档 +- metadata 数据 设计文档 +- 部署设计文档 +- Cluster 设计文档 +- 同步设计文档 +- 心跳设计文档 +- SDK 设计文档 +- 远程服务设计文档 +- 日志说明与使用设计文档 +- 采集设计文档 +- 采集数据库设计文档 +- 模拟数据 同步测试文档 +- RocketMQ 同步测试文档 +- 部署测试文档 +- 采集测试文档 +- 增加一个 存储 整个开发流程 +- 增加一个 meta 整个开发流程 + +## 问题 + +- 自动化部署之后,如何确定部署是否成功,部署测试如何做? +- group 与 group memer 是 cluster 级别还是 runtime 级别 + - 如果是 cluster 级别,rocketmq 需要支持 cluster 级别操作,如果不支持着需要全量删除 +- group 与 group memer 只读,不允许创建 +- config 问题 + - 不同的 存储 与 runtime 对不同的 metadata 有的支持 config ,有的不支持 config + - 需要一个 config 管理模块 + - 对 runtime(包含 存储)的 metadata 进行标记 + - 支持 runtime(包含 存储) metadata 双维度 + - 不同的 存储 与 runtime 对 config 的修改不同 + - kakfa 支持一个一个 config 的修改 + - rocketmq 只能对 config 的 主体 进行修改。比如 修改 queue ,那么需要 对 Topic 全量修改 + - 通过 config 模块 对 config 的行为标记做出不同的处理 + - 修改 rocketmq 的 metadata 的 config , 需要对 metadata 主体进行标准,然后触发 metadata 对象的 同步操作 + +## 任务 or issue + +- SyncStatus 状态补充 +- LogManage 记录模块 +- 操作记录模块 + - 优点是:可以进行记录 +- 部署与操作流模块 +- 是否设计运维操作模块 +- rometing service 入参 与 返回 讨论 +- 手动添加 集群 与 节点 信息时的 url 设计 +- kubernetes 部署 RocketMQ 的 IP 问题。client 调用 broker 是 kubernetes node ip,broker 调用 broker 是 kubernetes pod ip +- TODO 内容整理之后去除 +- 文档与代码整理 +- 讨论:手动添加集群与节点 +- 分析:db 的负载。 维度:业务操作,统计操作,sync and 部署等操作 +- 用户进来,是进入默认组织 首页 + +1. 通过左上角切换 +2. 组织视图与 cluster 共存,这样是否会出现三级路由 +3. 人员添加,可以从组织添加,也可以从 cluster 里面添加。如果从 cluster 里面添加,是否就属于合格组织一员? + +6. 删除 cluster 或则 runtime 之后对应的信息是否全部作废。 +7. 暂停状态数据如何标记,激活 对应的 metadata 之前相关的数据是否启动 +8. 删除 cluster 之前之后校验 关联。如何关联存在是否允许删除 +9. kafka 的查询维度全是 cluster +10. RocketMQ 大集群查询,是否支持 metadata 数据查询,如何对数据进行展示? 是否现实差异化,是否提示差异字段 + 1. 那些 topic 有差异? + 2. 是否配置 不允许有差异? + 3. 如果不允许有差异, console 进行处理的 metadata 是否要进行具体标识 +11. RocketMQ 支持大集群,小集群,runtime 维度的展示 +12. 指标数据表结构,目前不支持表修改。是否需要支持变修改 +13. 是否需要支持 不同的 cluster 使用不同的 指标数据修改 + +## SyncStatus 状态补充 + +- 同步表,需要添加 SyncStatus 字段 +- Entity 需要一个 SyncStatus 类 +- 状态转换确认 。 RemotingService(是否独立出来) 里面 成功与失败状态 +- 所有查询 需要过滤 成功状态 +- 操作数据时, 需要修改 SyncStatus +- 需要一个 SyncStatus 管理类 + +无法进行确认,支持同类型修改 + +项目发起人,项目架构师,项目设计师,项目经理, +交互设计师,半个ui设计 +前端,后台,运维,产品,测试, + +## 用户域 + +### 用户首页 + +1. 查看 组织 + +### 组织首页 + +1. 左边是一级菜单: + 1. 工作台 + 2. eventmesh集群 + 3. +2. 集群信息 + 1. 集群列表 + +### 日志分类 + +1. 心跳加载日志 +2. 数据同步日志 +3. 运维操作日志 +4. 数据采集日志 +5. metadata 数据日志 \ No newline at end of file diff --git "a/doc/\350\256\276\350\256\241\346\226\207\346\241\243.md" "b/doc/\350\256\276\350\256\241\346\226\207\346\241\243.md" new file mode 100644 index 00000000..ed4976d9 --- /dev/null +++ "b/doc/\350\256\276\350\256\241\346\226\207\346\241\243.md" @@ -0,0 +1,217 @@ +# 前言 + +# 整体架构设计 + +## 主因子 + +![画板](https://cdn.nlark.com/yuque/0/2025/jpeg/1509048/1764878781688-b43b3acc-03c3-4907-ab72-ee856860ef69.jpeg) + +## 架构略图 + +![画板](https://cdn.nlark.com/yuque/0/2025/jpeg/1509048/1764730146232-e06895bd-69a5-4e71-9141-af38f6227cdb.jpeg) + +## 主流程图 + +> 主要流程流转图 +> + + + +![画板](https://cdn.nlark.com/yuque/0/2025/jpeg/1509048/1764675942640-32a72c77-b800-4527-a9d3-0ce3d6d0a31b.jpeg) + +# Console 子系统(独立部署) + +> console 子模块是管理系统,负责 构建整体运行态 +> + ++ 业务模块 ++ 自动部署模块 ++ 架构关系模块 ++ agent 模块 ++ function 模块 ++ 指标展示模块 ++ 生产与消费可视化模块 ++ input 模块(目前没有设计) + +## 业务模块 + +## 集群创建 + ++ 已有集群通过 地址 直接创建 ++ 通过 自动部署模块创建 + +## 架构关系模块 + +> 架构关系是 整个项目双核模块之一。从 主因子 的视图关系,可以看到,不同的组件不同的架构,相同的组件也有不同的架构,组件同时以来多种其他组件,相同依赖类型同时支持多种组件。以及混乱 +> 的 API 行为等等 +> +> 比如: +> +> + Kafka 支持 zookepper 与 Kraft 为注册中心,并且独享注册中心 +> + RocketMQ broker 支持 主从架构 和 ratf 架构 +> + Pulast 支持 zookepper , etcd 等注册中心,共享注册中心 + > +- Pulat 集群有 当前集群注册中心,还有一个 跨集群同步 注册中心 +> + 复杂操作如: + > +- 操作当前 集群空间下所有 broker +> - 操作当前 集群空间下所有 zookeeper 注册中心 +> - 为当前 集群下 kafka,RockeMQ,Palsar 添加一个新 Topic +> - 等等等等 +> +> 架构关系是解决 在 **多种架构** 和 **多种多依赖** 的之间 巨大差异,通过统一行为,屏蔽底层细节,对模块进行深度解 +> + + + +![画板](https://cdn.nlark.com/yuque/0/2025/jpeg/1509048/1764833378606-938515b7-1295-499b-8266-1fe5b2fe3925.jpeg) + +## 自动部署模块 + +### 部署模块图 + +### 部署架构与主流程图 + +![画板](https://cdn.nlark.com/yuque/0/2025/jpeg/1509048/1764819759990-25775a85-69ab-4030-8c65-34d7dc12fd3e.jpeg) + +## 采集查询模块 + +> 采集查询模块(ReportController)在 console 的 查询模块相对比较简单,所有的逻辑都在 core 的 report 模块里面 +> + + + +重点: + ++ 支持多个指标的查询 ++ 支持单个子表的查询 + +## agent模块 + +> agent功能 主要是为了 支持 Agent 子系统。与 Agent 子系统完成 服务启动前的操作。 +> 确保当前节点启动之前 依赖启动成功 +> + +## 消费与生产模块 + +> 本模块只是为了方便 项目参与人员 测试与 mock 数据。查询指定数据,慢消费批量数据,如果 消息中间件支持链路跟踪,也可以查看相关信息 +> + +# core 子系统 + +> core 子系统是核心模块。有常量与枚举,metadata 等基础模块,以及下列核心功能 +> + + + +![画板](https://cdn.nlark.com/yuque/0/2025/jpeg/1509048/1764877150447-fbc3dbba-9a0a-42af-8600-f27797f91d7d.jpeg) + +## SDK 模块 + +> SDK模块( SDKManage ) 把 SDK 集中到一起,形成高内聚。 +> + + + +重点: + ++ SDK 的类型有:admin,ping,生产者,消费者 四个类型 (SDKTypeEnum) ++ client 都对应个 Config 对象 + +## 远程服务模块 + +> 设计 console 目前需要调用 组件 对应的能力 +> + +## 心跳模块 + +重点: + ++ 支持组件节点接的 ping 心跳 ++ 支持 broker 级别的 topic 心跳,通知 check 延迟情况。 用于检查 单个broker 节点的生产与消费的健康 ++ 心跳任务异步执行 ++ 组件心跳异步回调,提高性能与吞吐率 + +## 同步数据模块 + +> 数据同步模块是 整个项目的双核之一。负责不同模式下 console metadata 同步到 组件 或则 组件 metadata 同步到 console。 +> + +### 架构关系图 + +同步模块主要四个主逻辑线 + ++ console sync db 创建流程 ( SyncMetadataCreateFactory ) ++ 同步行为创建 以及 db 和 组件 同步创建 流程 (MetadataSyncManage.register ) ++ sync 行为执行 流程 ( MetadataSyncWrapper.run ) ++ SyncManage 管理流程 ( MetadataSyncManage.run ) + +### console sync db 创建流程 + +重点: + + - 是 metadata 维度, 负责 同步对应 metadata 对象,有多个metadata 就有多少 SyncMetadataCreateFactory + - 负责从 db 读取 与 **批量**写入同步数据 同步数据, + - 本逻辑第一次 全量读取 有效 metadata 数据,之后读取增量数据 + - 在 同步行为创建时,创建 BaseSyncBase(Cluster or Runtime)对应的 db MetadataHandler,其维度是 BaseSyncBase type + BaseSyncBaseId + metadata。 + * 比如 负责 topic,注册一个 Id为 1的 kafka cluster 。维度是 Topic , Cluster , 1 + +### SyncManage 管理流程 + +重点: + + - 负责触发 console sync 读取 与写入 以及 同步行为 + - 有多个 metadata 以及 大量 组件,所以需要保证 操作的循序性 + - 提高吞吐量 + +![画板](https://cdn.nlark.com/yuque/0/2025/jpeg/1509048/1764876625558-96eb3f60-881d-4374-9f37-4f5d5e0c00fa.jpeg) + +### sync 行为执行 流程 + +![画板](https://cdn.nlark.com/yuque/0/2025/jpeg/1509048/1764872488646-c857c419-039c-4111-9cff-fababa0352b4.jpeg) + +### 模式如下 + ++ 创建时同步 + - 从 console 同步到 组件。 FirstToWhom.DASHBOARD + - 从 组件 同步 console。FirstToWhom.RUNTIME ++ 运行时同步 + - 以 console 为主,从 console 同步到 组件 ClusterTrusteeshipType.SELF or TRUSTEESHIP + - 以 组件的数据为主,即从 组件 同步 console。ClusterTrusteeshipType.TRUSTEESHIP_FIND_REVERSE + - 不同步。ClusterTrusteeshipType.NOT or NO_TRUSTEESHIP ++ check(对比双非数据差异性) + - 初始化时,check双方数据(MetadataSyncWrapper.initStatus) + - 运行时,定时 check 双方数据(MetadataSyncWrapper.checkTime) + +### 数据基本操作模块 + +> 数据基本操作模块负责 复杂场景下 数据的流通 +> + + + +![](https://cdn.nlark.com/yuque/0/2025/png/1509048/1764861703394-07351cf1-4e5d-40a2-aca7-ae2eaeb3545e.png) + +### Difference 模块 + +> Difference 模块负责两个数据集在不同场景下的比较 +> + +![](https://cdn.nlark.com/yuque/0/2025/png/1509048/1764862179515-d629b2ee-62d8-4c01-b2cd-a7a4097b19bc.png) + +# 指标子系统 + +> 目前还在 集成在 console 子系统里面。后期会独立出来,独立部署,有大量采集情况下,可能会影响 console 子系统的运行。在小规模采集任务情况,也可以集成到 +> console里面,可以有一套简单架构 +> + +## 架构关系图 + +![画板](https://cdn.nlark.com/yuque/0/2025/jpeg/1509048/1764878542970-b17ea835-c3a3-4c93-ac3f-c8f44653a655.jpeg) + +# agent子系统 + +# 新增组件流程 + +![画板](https://cdn.nlark.com/yuque/0/2025/jpeg/1509048/1764760018082-731af3df-565e-40f1-9c5d-7fd38d82ea4e.jpeg) + diff --git a/eventmesh-dashboard-agent/pom.xml b/eventmesh-dashboard-agent/pom.xml new file mode 100644 index 00000000..9a82aac6 --- /dev/null +++ b/eventmesh-dashboard-agent/pom.xml @@ -0,0 +1,115 @@ + + + + 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.apache.httpcomponents + httpclient + 4.5.14 + + + com.alibaba.fastjson2 + fastjson2 + 2.0.43 + + + org.slf4j + jcl-over-slf4j + ${slf4j.version} + + + ch.qos.logback + logback-access + + + + ch.qos.logback + logback-classic + 1.5.13 + + + ch.qos.logback + logback-core + 1.5.19 + + + org.projectlombok + lombok + + + junit + junit + 4.13.1 + test + + + org.mockito + mockito-inline + 5.2.0 + test + + + com.github.stefanbirkner + system-rules + 1.19.0 + 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/AgentController.java b/eventmesh-dashboard-agent/src/main/java/org/apache/eventmesh/dashboard/agent/AgentController.java new file mode 100644 index 00000000..596ba121 --- /dev/null +++ b/eventmesh-dashboard-agent/src/main/java/org/apache/eventmesh/dashboard/agent/AgentController.java @@ -0,0 +1,250 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.action.AbstractAgentActionClient; +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 org.apache.http.HttpEntity; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.ContentType; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.util.EntityUtils; + +import java.io.File; +import java.net.Inet6Address; +import java.net.InetAddress; +import java.net.NetworkInterface; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.concurrent.atomic.AtomicBoolean; + +import com.alibaba.fastjson2.JSON; + +import lombok.extern.slf4j.Slf4j; + +@Slf4j +public class AgentController { + + + public static String getLocalAddress() { + try { + // Traversal Network interface to get the first non-loopback and non-private address + Enumeration enumeration = NetworkInterface.getNetworkInterfaces(); + ArrayList ipv4Result = new ArrayList(); + ArrayList ipv6Result = new ArrayList(); + while (enumeration.hasMoreElements()) { + final NetworkInterface networkInterface = enumeration.nextElement(); + final Enumeration en = networkInterface.getInetAddresses(); + while (en.hasMoreElements()) { + final InetAddress address = en.nextElement(); + if (!address.isLoopbackAddress()) { + if (address instanceof Inet6Address) { + ipv6Result.add(normalizeHostAddress(address)); + } else { + ipv4Result.add(normalizeHostAddress(address)); + } + } + } + } + + // prefer ipv4 + if (!ipv4Result.isEmpty()) { + for (String ip : ipv4Result) { + if (ip.startsWith("127.0") || ip.startsWith("192.168")) { + continue; + } + + return ip; + } + + return ipv4Result.get(ipv4Result.size() - 1); + } else if (!ipv6Result.isEmpty()) { + return ipv6Result.get(0); + } + //If failed to find,fall back to localhost + final InetAddress localHost = InetAddress.getLocalHost(); + return normalizeHostAddress(localHost); + } catch (Exception e) { + //log.error("Failed to obtain local address", e); + } + + return null; + } + + public static String normalizeHostAddress(final InetAddress localHost) { + if (localHost instanceof Inet6Address) { + return "[" + localHost.getHostAddress() + "]"; + } else { + return localHost.getHostAddress(); + } + } + + + private final ConfigHandlerManage configHandlerManage = new ConfigHandlerManage(); + + private final List waitTime = new ArrayList<>(); + + private final AbstractAgentActionClient agentActionClient = new DefaultAgentActionClient(); + + private final Map env = System.getenv(); + + private final String localAddress = getLocalAddress(); + + { + 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 static void main(String[] args) { + AgentController agentController = new AgentController(); + agentController.start(); + } + + public void start() { + + String consoleAddress = this.getEnv(Constant.ENV_CONSOLE); + if (Objects.isNull(consoleAddress)) { + log.error("{} is null", Constant.ENV_CONSOLE); + return; + } + String clusterId = this.getEnv(Constant.ENV_CLUSTER_ID); + if (Objects.isNull(clusterId)) { + log.error("{} is null", Constant.ENV_CLUSTER_ID); + return; + } + + String runtimeId = this.getEnv(Constant.ENV_RUNTIME_ID); + if (Objects.isNull(runtimeId)) { + log.error("{} is null", Constant.ENV_RUNTIME_ID); + return; + } + String runtimeHome = this.getEnv(Constant.ENV_RUNTIME_HOME); + if (Objects.isNull(runtimeHome)) { + log.error("{} is null", Constant.ENV_RUNTIME_HOME); + return; + } + File file = new File(runtimeHome); + if (file.exists() && !file.isDirectory()) { + log.error("eventmesh.agent.runtimeHome is not a directory"); + return; + } + this.agentActionClient.setBaseUrl(consoleAddress); + this.agentActionClient.init(); + + Map data = new HashMap<>(); + data.put("clusterId", clusterId); + data.put("runtimeId", runtimeId); + data.put("localAddress", this.localAddress); + data.put("nodeAddress", this.getEnv("NODE_ID")); + AgentStartActionVO agentStartActionVO = agentActionClient.agentStartAction(data); + + // 得到 clusterType 对应的执行对象 + ConfigHandler configHandler = null; + try { + configHandler = this.configHandlerManage.getConfigHandler(agentStartActionVO.getClusterType()); + } catch (Exception e) { + log.error(e.getMessage(), e); + return; + } + 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"); + } + + } + + public String getEnv(String key) { + return env.get(key); + } + + private static class DefaultAgentActionClient extends AbstractAgentActionClient { + + private CloseableHttpClient httpClient = HttpClients.createDefault(); + + + @Override + public AgentStartActionVO agentStartAction(Map data) { + return this.execute(this.agentStartActionFullPath, data, AgentStartActionVO.class); + } + + @Override + public AgentCheckRuntimeVO agentCheckRuntime(Map data) { + return this.execute(this.agentCheckRuntimePath, data, AgentCheckRuntimeVO.class); + } + + + private T execute(String url, Object data, Class clazz) { + HttpPost request = new HttpPost(url); + HttpEntity httpEntity = new StringEntity(JSON.toJSONString(data), ContentType.APPLICATION_JSON); + request.setEntity(httpEntity); + try (CloseableHttpResponse response = httpClient.execute(request)) { + JSON.parseObject(EntityUtils.toString(response.getEntity()), clazz); + return JSON.parseObject(EntityUtils.toString(response.getEntity()), clazz); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + } +} diff --git a/eventmesh-dashboard-agent/src/main/java/org/apache/eventmesh/dashboard/agent/Constant.java b/eventmesh-dashboard-agent/src/main/java/org/apache/eventmesh/dashboard/agent/Constant.java new file mode 100644 index 00000000..5218b613 --- /dev/null +++ b/eventmesh-dashboard-agent/src/main/java/org/apache/eventmesh/dashboard/agent/Constant.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.agent; + +public class Constant { + + public static final String ENV_CONSOLE = "eventmesh.agent.console"; + + public static final String ENV_CLUSTER_ID = "eventmesh.agent.clusterId"; + + public static final String ENV_RUNTIME_ID = "eventmesh.agent.runtimeId"; + + public static final String ENV_RUNTIME_HOME = "eventmesh.agent.runtimeHome"; + +} diff --git a/eventmesh-dashboard-agent/src/main/java/org/apache/eventmesh/dashboard/agent/action/AbstractAgentActionClient.java b/eventmesh-dashboard-agent/src/main/java/org/apache/eventmesh/dashboard/agent/action/AbstractAgentActionClient.java new file mode 100644 index 00000000..f171126a --- /dev/null +++ b/eventmesh-dashboard-agent/src/main/java/org/apache/eventmesh/dashboard/agent/action/AbstractAgentActionClient.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.agent.action; + +import lombok.Setter; + +@Setter +public abstract class AbstractAgentActionClient implements AgentActionClient { + + protected String baseUrl; + + protected String basePath = "/eventmesh/dashboard"; + + protected String agentStartActionPath = "/agent/agentStartAction"; + + protected String agentCheckRuntimePath = "/agent/agentCheckRuntime"; + + protected String agentStartActionFullPath = "/agent/agentCheckAgent"; + + protected String agentCheckRuntimeFullPath = "/agent/agentCheckAgent"; + + public void init() { + this.agentStartActionFullPath = "http://" + this.baseUrl + basePath + agentStartActionPath; + this.agentCheckRuntimeFullPath = "http://" + this.baseUrl + basePath + agentCheckRuntimePath; + } + +} diff --git a/eventmesh-dashboard-agent/src/main/java/org/apache/eventmesh/dashboard/agent/action/AgentActionClient.java b/eventmesh-dashboard-agent/src/main/java/org/apache/eventmesh/dashboard/agent/action/AgentActionClient.java new file mode 100644 index 00000000..9f4f7e0d --- /dev/null +++ b/eventmesh-dashboard-agent/src/main/java/org/apache/eventmesh/dashboard/agent/action/AgentActionClient.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.agent.action; + +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/config/AbstractConfigHandler.java b/eventmesh-dashboard-agent/src/main/java/org/apache/eventmesh/dashboard/agent/config/AbstractConfigHandler.java new file mode 100644 index 00000000..fe7045db --- /dev/null +++ b/eventmesh-dashboard-agent/src/main/java/org/apache/eventmesh/dashboard/agent/config/AbstractConfigHandler.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.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; + +import lombok.Setter; + +@Setter +public abstract class AbstractConfigHandler implements ConfigHandler { + + protected String 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..b33cef20 --- /dev/null +++ b/eventmesh-dashboard-agent/src/main/java/org/apache/eventmesh/dashboard/agent/config/ConfigHandler.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; + +/** + * + */ +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..22a6ec19 --- /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.RocketMQNameServiceConfigHandler; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +public class ConfigHandlerManage { + + private Map> configHandlerMap = new ConcurrentHashMap<>(); + + { + this.configHandlerMap.put("", RocketMQNameServiceConfigHandler.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/RocketMQNameServiceConfigHandler.java b/eventmesh-dashboard-agent/src/main/java/org/apache/eventmesh/dashboard/agent/config/handler/RocketMQNameServiceConfigHandler.java new file mode 100644 index 00000000..91070f6b --- /dev/null +++ b/eventmesh-dashboard-agent/src/main/java/org/apache/eventmesh/dashboard/agent/config/handler/RocketMQNameServiceConfigHandler.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.agent.config.handler; + +import org.apache.eventmesh.dashboard.agent.config.AbstractConfigHandler; + +public class RocketMQNameServiceConfigHandler 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..9a39e76e --- /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..cc2cbe7b --- /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..880c6948 --- /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/AgentControllerTest.java b/eventmesh-dashboard-agent/src/test/java/org/apache/eventmesh/dashboard/agent/AgentControllerTest.java new file mode 100644 index 00000000..32d03010 --- /dev/null +++ b/eventmesh-dashboard-agent/src/test/java/org/apache/eventmesh/dashboard/agent/AgentControllerTest.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.agent; + +import java.lang.reflect.Field; +import java.util.HashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +public class AgentControllerTest { + + private AgentController agentController = new AgentController(); + + @Before + public void init() throws Throwable { + Map environmentVariables = new HashMap<>(); + environmentVariables.put(Constant.ENV_CONSOLE, "127.0.0.1:9898"); + environmentVariables.put(Constant.ENV_CLUSTER_ID, "1"); + environmentVariables.put(Constant.ENV_RUNTIME_ID, "1"); + environmentVariables.put(Constant.ENV_RUNTIME_HOME, "./test/"); + + + Field envField = agentController.getClass().getDeclaredField("env"); + envField.setAccessible(true); + envField.set(agentController, environmentVariables); + + } + + @Test + public void test_request(){ + agentController.start(); + } + +} 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..6384bc9c --- /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/pom.xml b/eventmesh-dashboard-common/pom.xml index 806a2892..00578711 100644 --- a/eventmesh-dashboard-common/pom.xml +++ b/eventmesh-dashboard-common/pom.xml @@ -16,8 +16,8 @@ ~ limitations under the License. --> - 4.0.0 @@ -31,6 +31,8 @@ 17 + 17 + 17 UTF-8 UTF-8 @@ -49,7 +51,7 @@ org.apache.commons commons-lang3 - 3.14.0 + 3.18.0 org.apache.commons @@ -61,6 +63,11 @@ fastjson2 2.0.51 + + com.github.javaparser + javaparser-core + 3.23.1 + \ 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..74e04697 --- /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/annotation/RemotingServiceMethodMapper.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/annotation/RemotingServiceMethodMapper.java index fb619f6d..e62e29b4 100644 --- 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 @@ -27,7 +27,7 @@ import java.lang.annotation.Target; /** - * + * */ @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) 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 b00ea3d1..9394c921 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 @@ -47,11 +47,11 @@ public class HealthConstant { public static final String ROCKETMQ_CHECK_CONSUMER_GROUP = "eventmesh-dashboard-healthcheck-rocketmq-consumer-group"; public static final String ROCKETMQ_CHECK_TOPIC = "DO-NOT-USE-THIS-TOPIC-" - + "eventmesh-dashboard-healthcheck-rocketmq-topic-90a78a5d-b803-447e-8c48-1c87ab0c74d9"; + + "eventmesh-dashboard-healthcheck-rocketmq-topic-90a78a5d-b803-447e-8c48-1c87ab0c74d9"; public static final String ROCKETMQ_CHECK_TOPIC_MSG = "eventmesh-dashboard-healthcheck-rocketmq-message"; public static final String NACOS_CHECK_DATA_ID = "DO-NOT-USE-THIS-" - + "eventmesh-dashboard-healthcheck-nacos-data-id-28e2933f-a47b-439d-b14b-7d9970c37042"; + + "eventmesh-dashboard-healthcheck-nacos-data-id-28e2933f-a47b-439d-b14b-7d9970c37042"; public static final String NACOS_CHECK_GROUP = "EVENTMESH_DASHBOARD_HEALTH_CHECK_GROUP"; 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 2b6bfafb..175af49a 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 @@ -19,8 +19,7 @@ package org.apache.eventmesh.dashboard.common.enums; /** - * 业务类型, - * storage:可选值(rocketmq,pravega,mongodb,pulsar,redis,kafka,knative,rabbitmq), + * 业务类型, storage:可选值(rocketmq,pravega,mongodb,pulsar,redis,kafka,knative,rabbitmq), * sinkConnector:可选值(rocketmq,spring,pravega,wechat,openfunction,file,knative,pulsar,lark,slack,rabbitmq,redis,mongodb,dingtalk) * sourceConnector:可选值(rocketmq,spring,pravega,openfunction,jdbc,file,http,wecom,knative,pulsar,prometheus,rabbitmq,redis,mongodb)', */ 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..41e09290 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 @@ -27,7 +27,7 @@ public enum ClusterFramework { INDEPENDENCE, /** - * AP 架构,的 meta 有控制行为,需要逐一通知 + * AP 架构,的 meta 有控制行为,需要逐一通知 */ AP, @@ -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..dac75f9e 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 @@ -37,10 +37,17 @@ public enum ClusterSyncMetadataEnum { EVENTMESH_RUNTIME( ClusterSyncMetadata.builder().clusterFramework(ClusterFramework.INDEPENDENCE).metadataTypeList(ClusterSyncMetadata.STORAGE).build()), + EVENTMESH_JVM_CLUSTER(EVENTMESH_RUNTIME), + EVENTMESH_META_ETCD(ClusterSyncMetadata.builder().clusterFramework(ClusterFramework.RAFT).metadataTypeList(ClusterSyncMetadata.META).build()), 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,28 +66,45 @@ 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()), ; private static final Map SYNC_METADATA_CONCURRENT_HASH_MAP = new ConcurrentHashMap<>(); + @Getter + private ClusterSyncMetadata clusterSyncMetadata; + + ClusterSyncMetadataEnum(ClusterSyncMetadata clusterSyncMetadata) { + this.clusterSyncMetadata = clusterSyncMetadata; + } + + ClusterSyncMetadataEnum(ClusterSyncMetadataEnum clusterSyncMetadataEnum) { + this.clusterSyncMetadata = clusterSyncMetadataEnum.clusterSyncMetadata; + } public static ClusterSyncMetadata getClusterSyncMetadata(ClusterType clusterType) { ClusterSyncMetadata clusterSyncMetadata = SYNC_METADATA_CONCURRENT_HASH_MAP.get(clusterType); + if (Objects.nonNull(clusterSyncMetadata)) { + return clusterSyncMetadata; + } try { - if (Objects.isNull(clusterSyncMetadata)) { - ClusterSyncMetadataEnum clusterSyncMetadataEnum = ClusterSyncMetadataEnum.valueOf(clusterType.toString()); - SYNC_METADATA_CONCURRENT_HASH_MAP.put(clusterType, clusterSyncMetadataEnum.getClusterSyncMetadata()); - clusterSyncMetadata = clusterSyncMetadataEnum.getClusterSyncMetadata(); - } + ClusterSyncMetadataEnum clusterSyncMetadataEnum = ClusterSyncMetadataEnum.valueOf(clusterType.toString()); + clusterSyncMetadata = clusterSyncMetadataEnum.getClusterSyncMetadata(); } catch (Exception e) { + clusterSyncMetadata = ClusterSyncMetadata.EMPTY_OBJECT; - SYNC_METADATA_CONCURRENT_HASH_MAP.put(clusterType, clusterSyncMetadata); } + SYNC_METADATA_CONCURRENT_HASH_MAP.put(clusterType, clusterSyncMetadata); return clusterSyncMetadata; } @@ -90,24 +114,15 @@ public static ClusterFramework getClusterFramework(ClusterType clusterType) { static class ListWrapper { + private final List list = new ArrayList<>(); + static ListWrapper build() { return new ListWrapper(); } - private List list = new ArrayList<>(); - ListWrapper add(List list) { - list.addAll(list); + this.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 66daa531..e0c7c2d6 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 @@ -54,14 +54,26 @@ public enum ClusterTrusteeshipType { // 不托管 NO_TRUSTEESHIP("不托管", List.of(ClusterType.CLUSTER, ClusterType.META, ClusterType.RUNTIME, ClusterType.META_AND_RUNTIME)); - private List clusterTypeList; - private final String type; - + private List clusterTypeList; private String name; private FirstToWhom firstToWhom; + ClusterTrusteeshipType(String type, List clusterTypeList) { + this.type = type; + this.clusterTypeList = clusterTypeList; + } + + public boolean isSelf() { + return this == ClusterTrusteeshipType.SELF || this == ClusterTrusteeshipType.TRUSTEESHIP; + } + + public boolean isReverse() { + return this == ClusterTrusteeshipType.TRUSTEESHIP_FIND || this == ClusterTrusteeshipType.TRUSTEESHIP_FIND_REVERSE; + } + + public enum FirstToWhom { NOT, @@ -85,6 +97,10 @@ public enum FirstToWhom { */ UNDER_WAY, + NOT_EXECUTED, + + ERROR_ING, + FAIL, ; @@ -121,17 +137,4 @@ public enum TrusteeshipArrangeType { } - - ClusterTrusteeshipType(String type, List clusterTypeList) { - this.type = type; - } - - - 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 f8b24519..af16214a 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,13 @@ 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 +159,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), ; @@ -171,22 +189,6 @@ public enum 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集群 */ @@ -197,40 +199,33 @@ public static List getStorageMetaRuntimeCluster() { */ @Getter private ClusterType assemblyName; - /** * 这个节点在 具体集群内是什么节点 */ @Getter private ClusterType assemblyNodeType; - /** * 厂商是什么类型。比如注册中心。注册中心有 etc,nacos */ @Getter private ClusterType assemblyBusiness; - /** * 远程协议类型 */ @Getter private RemotingType remotingType; - @Getter private int code; - - + private ClusterType higherType; private List mainClusterType; - private List metaClusterType; - private List runtimeClusterType; + ClusterType(int code) { this.code = code; } - ClusterType(ClusterType eventmeshNodeType, ClusterType assemblyName, ClusterType assemblyNodeType, ClusterType assemblyBusiness, RemotingType remotingType) { this.eventmeshNodeType = eventmeshNodeType; @@ -240,6 +235,21 @@ public static List getStorageMetaRuntimeCluster() { this.remotingType = remotingType; } + 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; + } /** * 半托管状态需要 如要从 @@ -249,8 +259,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() { @@ -337,6 +351,33 @@ public List getRuntimeClusterType() { return this.getThisClusterType(RUNTIME, this.runtimeClusterType, "runtimeClusterType"); } + /** + * + */ + public ClusterType getHigher() { + if (Objects.isNull(this.higherType)) { + for (ClusterType allClusterType : ClusterType.values()) { + if (!Objects.equals(allClusterType.eventmeshNodeType, this.eventmeshNodeType) + || !Objects.equals(allClusterType.assemblyName, this.assemblyName)) { + continue; + } + if (!Objects.equals(allClusterType.assemblyNodeType, CLUSTER)) { + continue; + } + if (!Objects.equals(allClusterType.assemblyBusiness, DEFINITION)) { + continue; + } + this.higherType = allClusterType; + break; + } + if (Objects.isNull(this.higherType)) { + throw new RuntimeException("higher type is null, current type:" + this); + } + } + + return this.higherType; + } + private List getThisClusterType(ClusterType assemblyNodeType, List clusterTypeList, String fieldName) { if (Objects.equals(assemblyNodeType, this.assemblyNodeType) && !this.isDefinition()) { 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..8c66f750 --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/CollectType.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.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..79c047ee 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 @@ -18,13 +18,54 @@ package org.apache.eventmesh.dashboard.common.enums; +import lombok.Getter; + +/** + * TODO 流程: + * runtime: 先 创建数据 -> 绑定关系 -> 在启动 + * meta : 先 创建数据直接启动 + * eventmesh 空间是 + * 创建 eventmesh cluster -> + * 创建 eventmesh meta -> + * eventmesh cluster 与 meta 绑定关系 -> + * + * 创建 storage cluster -> + * create storage meta 且直接启动 -> + * storage cluster 与 meta 绑定关系 -> + * create storage runtime -> + * storage cluster 与 runtime 绑定关系(绑定关系的时候,是否主动启动 runtime) -> + * 启动 runtime -> + * eventmesh cluster 与 storage cluster 绑定关系 -> + * 启动 eventmesh runtime + * 启动操作在: + * meta BUILD_SUCCESS(数据构建) 时 创建 服务 , 是否可选 + * runtime 在 绑定时 , 是否可选 + * 点击 启动 + * 有 agent 的存在,就不需要启动循序了 + */ public enum DeployStatusType { + SETTLE, + + + BUILD_SUCCESS("数据构建", """ + 在 deploy 的 create handler 里面处理,如果使用 agent 模式,就没有意义, + build_success 状态 下一个是 CREATE_WAIT + """), RESOURCE_APPLY, RESOURCE_APPLY_FAILED, + CREATE, + + CREATE_COPY, + + /** + * 是不是需要这个状态的检查 + */ + CREATE_DATA_ING, + CREATE_WAIT, CREATE_FULL_WAIT, @@ -53,6 +94,8 @@ public enum DeployStatusType { CREATE_CAP_UPDATE_SUCCESS, + UPDATE, + UPDATE_WAIT, UPDATE_ING, @@ -69,6 +112,7 @@ public enum DeployStatusType { UPDATE_FULL_FAIL, + PAUSE, PAUSE_WAIT, @@ -86,6 +130,8 @@ public enum DeployStatusType { PAUSE_FULL_FAIL, + RESET, + RESET_WAIT, RESET_ING, @@ -94,6 +140,7 @@ public enum DeployStatusType { RESET_SUCCESS, + UNINSTALL, UNINSTALL_FAIL, @@ -104,4 +151,18 @@ public enum DeployStatusType { UNINSTALL_SUCCESS, ; + + @Getter + private String name; + + @Getter + private String explanation; + + DeployStatusType() { + } + + DeployStatusType(String name, String explanation) { + this.name = name; + this.explanation = explanation; + } } 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..31b1e260 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; @@ -39,20 +40,24 @@ public enum MetadataType { CONFIG(ConfigMetadata.class), - RUNTIME(RuntimeMetadata.class), + RUNTIME(RuntimeMetadata.class, true), 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..f53dd3ca 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 @@ -33,14 +33,13 @@ public class OperationRange { private static Map> operationRangeListHashMap = new HashMap<>(); - public static OperationRange getInstance() { - return operationRange; - } - private OperationRange() { } + public static OperationRange getInstance() { + return operationRange; + } private void setOperationRange(ClusterType clusterType, OperationRangeType operationRangeType) { operationRangeListHashMap.computeIfAbsent(clusterType, k -> new ArrayList<>()).add(operationRangeType); @@ -50,19 +49,27 @@ public List getOperationRangeTypeList(ClusterType clusterTyp return operationRangeListHashMap.get(clusterType); } + + public enum OperationType { + + RUNTIME_CONFIG, + + + } + /** - * 依据范围查询数据 - * 集群, runtime , topic ,SUBSCRIBER , SUBSCRIBER_QUEUE + * 依据范围查询数据 集群, runtime , topic ,SUBSCRIBER , SUBSCRIBER_QUEUE */ public enum OperationRangeType { - ALL(null), + ALL(), + + CLUSTER(), - CLUSTER(null), + ALL_RUNTIME(), - ALL_RUNTIME(null), + ONCE_CLUSTER(), - ONCE_CLUSTER(null), RANGE_CLUSTER_CAP(CLUSTER), 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 index 67d11afd..61084089 100644 --- 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 @@ -22,7 +22,6 @@ public enum ReplicationDimension { NOT, - /** * 节点复制 复制, */ @@ -31,7 +30,7 @@ public enum ReplicationDimension { 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 index 8b29f9e8..b0e3082e 100644 --- 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 @@ -29,7 +29,6 @@ public enum ReplicationType { MAIN_SLAVE, ; - public boolean isNot() { return this == NOT; } 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 822e260b..c37e6e5e 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 @@ -23,17 +23,14 @@ public enum ResetOffsetMode { /** * 支持维度如下: *

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

* storage cluster *

* storage definition cluster *

* storage runtime cluster - * - * */ CONSUME_FROM_LAST_OFFSET, 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..85b7aefa --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/SyncStatus.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.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..9d7d99bd --- /dev/null +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/enums/SyncType.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.common.enums; + +import lombok.Getter; +import lombok.ToString; + +@Getter +@ToString +public enum SyncType { + + NOT("NOT", "没命中"), + + READONLY("READONLY", "只读"), + + FIRSTTOWHOM("FIRSTTOWHOM", "第一次同步"), + + INIT("INIT", "初始化"), + + CHECK("CHECK", "检查"), + + TIMINGSYNC("TIMINGSYNC", "定时同步"), + + ; + + private final String name; + + private final String description; + + + SyncType(String name, String description) { + this.name = name; + this.description = description; + } + + +} 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..32544c08 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..f0402198 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..9cb193c3 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,13 +71,66 @@ 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; } /** - * 主要用于 database 数据 与 节点数据 对比用。这个数据在node的唯一 + * 主要用于 database 数据 与 节点数据 对比用。这个数据在node的唯一 + * * @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/base/BaseSyncBase.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/base/BaseSyncBase.java index a027241c..8933fd31 100644 --- 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 @@ -29,7 +29,7 @@ import lombok.EqualsAndHashCode; @Data -@EqualsAndHashCode(callSuper = true) +@EqualsAndHashCode(callSuper = false) public abstract class BaseSyncBase extends BaseClusterIdBase { 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..457514ad --- /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..cf329d08 --- /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/GroupMetadata.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/GroupMetadata.java index e08bf8a9..e4fb4ccd 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 @@ -36,7 +36,6 @@ public class GroupMetadata extends BaseRuntimeIdBase { private Integer type; - @Override public String nodeUnique() { return this.name; 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/metadata/RuntimeMetadata.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/metadata/RuntimeMetadata.java index 9d51ad81..df0b1c23 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 @@ -24,7 +24,7 @@ import lombok.EqualsAndHashCode; @Data -@EqualsAndHashCode(callSuper = true) +@EqualsAndHashCode(callSuper = false) public class RuntimeMetadata extends BaseSyncBase { private String host; 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 d5173cee..e33529b4 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 @@ -27,13 +27,18 @@ @EqualsAndHashCode(callSuper = true) public class TopicMetadata extends BaseRuntimeIdBase { + private String topicName; + private Integer readQueueNum; - private String topicName; + private Integer writeQueueNum; - private Long runtimeId; + /** + * topic 拦截器类型 + */ + private String topicFilterType; - private Long storageId; + private Integer order; private Long retentionMs; 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 2870a57c..0505858c 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 @@ -23,6 +23,17 @@ import lombok.Data; import lombok.NoArgsConstructor; +/** + * TODO + * 如果定义返回类, + * 定义异步返回,的成本太大,需要把所有链路实现异步返回操作 + * 需要统一异步返回行为。比如单个返回,多个返回。 + * 异步行为是否需要设计这样 + * 同步行为是否需要设计这样,是否可以通过异常去做。 直接返回结果,如果有问题 throw 异常,这样代码量很少。 + * 因为 所有的 远程调用,都在 RemotingService 里面。 在 RemotingService 做好同时支持 GlobalResult 与 直接返回 + * 对于同步行为 + * 本来设计成 请求,响应,返回 三件套的,因为完成整体链路的 异步调用,实在太麻烦了。最终 + */ @Data @Builder @NoArgsConstructor diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/DefaultConfigKey.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/RemotingServiceException.java similarity index 80% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/DefaultConfigKey.java rename to eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/RemotingServiceException.java index 49d740e5..73b9d179 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/DefaultConfigKey.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/RemotingServiceException.java @@ -15,21 +15,19 @@ * limitations under the License. */ - -package org.apache.eventmesh.dashboard.console.entity; - +package org.apache.eventmesh.dashboard.common.model.remoting; import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; +import lombok.Getter; -@NoArgsConstructor +@Getter @AllArgsConstructor -@Data -@Deprecated -public class DefaultConfigKey { +public class RemotingServiceException extends RuntimeException { + + private int code; + + + private String message; - private String businessType; - private String configName; } diff --git a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/runtime/GetRuntime2Request.java b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/runtime/GetRuntime2Request.java index f5a6f34b..10449ba1 100644 --- a/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/runtime/GetRuntime2Request.java +++ b/eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/remoting/runtime/GetRuntime2Request.java @@ -18,14 +18,15 @@ package org.apache.eventmesh.dashboard.common.model.remoting.runtime; -import org.apache.eventmesh.dashboard.common.model.remoting.Global2Request; +import org.apache.eventmesh.dashboard.common.model.metadata.RuntimeMetadata; +import org.apache.eventmesh.dashboard.common.model.remoting.AbstractGlobal2Request; import lombok.Data; import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = true) -public class GetRuntime2Request extends Global2Request { +public class GetRuntime2Request extends AbstractGlobal2Request { private String registryAddress; } 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-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..d57291b7 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..0ac59e57 100644 --- a/eventmesh-dashboard-console/pom.xml +++ b/eventmesh-dashboard-console/pom.xml @@ -17,8 +17,8 @@ --> - 4.0.0 @@ -32,6 +32,8 @@ 17 + 17 + 17 UTF-8 UTF-8 @@ -125,6 +127,64 @@ 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 + spring-boot-devtools + 2.7.6 + runtime + true + + org.springframework.boot @@ -159,16 +219,6 @@ - - org.apache.maven.plugins - maven-compiler-plugin - 3.13.0 - - 15 - 15 - UTF-8 - - org.springframework.boot spring-boot-maven-plugin @@ -199,12 +249,4 @@ - - - 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 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/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/ClusterAbilityService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/ClusterAbilityService.java new file mode 100644 index 00000000..b0d59261 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/ClusterAbilityService.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.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.model.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 ClusterAbilityService { + + + @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 = new ClusterEntity(); + clusterEntity.setId(clusterIdDTO.getClusterId()); + clusterEntity = this.clusterService.queryClusterById(clusterEntity); + return this.isCapByEntity(clusterEntity); + } + + 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/ClusterAbitityService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/ClusterAbitityService.java index 112a8898..4e81e1e0 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/ClusterAbitityService.java @@ -23,7 +23,7 @@ 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.model.ClusterIdDTO; import org.apache.eventmesh.dashboard.console.service.cluster.ClusterService; import org.springframework.beans.factory.annotation.Autowired; 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 7fe42b4f..e8a63de8 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 @@ -20,10 +20,10 @@ 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.AddConnectionDTO; -import org.apache.eventmesh.dashboard.console.modle.dto.connection.CreateConnectionDTO; -import org.apache.eventmesh.dashboard.console.modle.dto.connection.GetConnectionListDTO; -import org.apache.eventmesh.dashboard.console.modle.vo.connection.ConnectionListVO; +import org.apache.eventmesh.dashboard.console.model.dto.connection.AddConnectionDTO; +import org.apache.eventmesh.dashboard.console.model.dto.connection.CreateConnectionDTO; +import org.apache.eventmesh.dashboard.console.model.dto.connection.GetConnectionListDTO; +import org.apache.eventmesh.dashboard.console.model.vo.connection.ConnectionListVO; import org.apache.eventmesh.dashboard.console.service.cluster.ConnectionDataService; import java.util.List; 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..a54dd58b --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/ReportController.java @@ -0,0 +1,63 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 java.util.Map; + +import org.springframework.beans.factory.annotation.Autowired; +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 { + + + @Autowired + private ReportHandlerManage reportHandlerManage; + + @RequestMapping("reportByHome") + 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); + + } + + @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/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..eaae3466 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/agent/AgentActionController.java @@ -0,0 +1,156 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.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.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.model.DO.runtime.QueryRuntimeByBigExpandClusterDO; +import org.apache.eventmesh.dashboard.console.model.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.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import com.lamp.decoration.core.result.DecorationResultException; + + +@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); + if (Objects.isNull(clusterEntity)) { + DecorationResultException.throwDecorationResultException(41001, "cluster not exist"); + } + RuntimeEntity runtimeEntity = new RuntimeEntity(); + runtimeEntity.setId(data.getRuntimeId()); + runtimeEntity = this.runtimeService.queryRuntimeEntityById(runtimeEntity); + if (Objects.isNull(runtimeEntity)) { + DecorationResultException.throwDecorationResultException(41002, "runtime not exist"); + } + + RuntimeEntity updateRuntimeEntity = new RuntimeEntity(); + updateRuntimeEntity.setId(runtimeEntity.getId()); + updateRuntimeEntity.setHost(data.getNodeAddress()); + updateRuntimeEntity.setPodHost(data.getLocalAddress()); + this.runtimeService.updateAddressByRuntimeId(updateRuntimeEntity); + // 识别架构,修改 需要 修改 config 相关配置 , 端口 + + // TODO 识别 架构方式,修改 cap 架构配置 , + + // 依赖组件,在 agentCheckRuntime , + + // 识别架构, 获得 + + 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); + + ClusterType clusterType = clusterEntity.getClusterType(); + if (clusterType.isEventMethRuntime()) { + queryRuntimeByBigExpandClusterDO = QueryRuntimeByBigExpandClusterDO.builder().followClusterId(clusterEntity.getId()) + .storageMetaClusterTypeList(ClusterType.getStorageMetaRuntimeCluster()).build(); + //如果是 eventmesh 集群,name需要查询 存储集群的 runtime 是否启动 + // 如果识别 meta 的可用度 + runtimeEntityList = this.runtimeService.queryRuntimeByBigExpandCluster(queryRuntimeByBigExpandClusterDO); + } else { + ClusterFramework clusterFramework = ClusterSyncMetadataEnum.getClusterFramework(clusterType); + if (clusterFramework.isCAP() && clusterType.isMeta()) { + // + } else if (clusterType.isMetaAndRuntime()) { + // + } else if (clusterType.isRuntime()) { + // + } + + } + + 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..09fdf5df --- /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/controller/agent/AgentStartActionVO.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/agent/AgentStartActionVO.java new file mode 100644 index 00000000..f0e9dda1 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/agent/AgentStartActionVO.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.agent; + +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-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 dbfe803c..0ccdd2de 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 @@ -20,7 +20,7 @@ import org.apache.eventmesh.dashboard.console.entity.cluster.ClientEntity; -import org.apache.eventmesh.dashboard.console.modle.cluster.client.QueryClientByUserFormDTO; +import org.apache.eventmesh.dashboard.console.model.dto.cluster.client.QueryClientByUserFormDTO; import org.apache.eventmesh.dashboard.console.service.cluster.ClientDataService; import java.util.List; 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 416d6130..0c5c0c72 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 @@ -19,21 +19,35 @@ package org.apache.eventmesh.dashboard.console.controller.cluster; +import org.apache.eventmesh.dashboard.common.enums.ClusterTrusteeshipType; +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.console.domain.ClusterAndRuntimeDomain; 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.ClusterRelationshipEntity; 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.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.model.ClusterIdDTO; +import org.apache.eventmesh.dashboard.console.model.deploy.ClusterAllMetadataDO; +import org.apache.eventmesh.dashboard.console.model.dto.cluster.client.QueryClientByUserFormDTO; +import org.apache.eventmesh.dashboard.console.model.dto.cluster.cluster.BatchCreateClusterDataDTO; +import org.apache.eventmesh.dashboard.console.model.dto.cluster.cluster.ClusterDetailsVO; +import org.apache.eventmesh.dashboard.console.model.dto.cluster.cluster.CreateClusterByFullAddressDTO; +import org.apache.eventmesh.dashboard.console.model.dto.cluster.cluster.QueryClusterByOrganizationIdAndTypeDTO; +import org.apache.eventmesh.dashboard.console.model.dto.cluster.cluster.QueryRelationClusterByClusterIdAndTypeDTO; +import org.apache.eventmesh.dashboard.console.model.dto.cluster.cluster.QueryTreeByClusterIdDTO; +import org.apache.eventmesh.dashboard.console.model.dto.cluster.cluster.SimpleCreateClusterDataDTO; +import org.apache.eventmesh.dashboard.console.model.vo.cluster.ClusterTreeVO; +import org.apache.eventmesh.dashboard.console.model.vo.cluster.GetClusterBaseMessageVO; import org.apache.eventmesh.dashboard.console.service.cluster.ClusterService; import org.apache.eventmesh.dashboard.console.service.cluster.RuntimeService; +import org.apache.eventmesh.dashboard.console.utils.data.controller.cluster.ClusterControllerUtils; +import org.apache.commons.lang3.tuple.Pair; + +import java.util.ArrayList; import java.util.List; +import java.util.Objects; import java.util.concurrent.CompletableFuture; import org.springframework.beans.factory.annotation.Autowired; @@ -49,11 +63,12 @@ @RequestMapping("user/cluster") public class ClusterController { + @Autowired + public RuntimeService runtimeService; @Autowired private ClusterService clusterService; - @Autowired - public RuntimeService runtimeService; + private ClusterAndRuntimeDomain clusterAndRuntimeDomain; @GetMapping("queryHomeClusterData") @@ -86,11 +101,27 @@ public List queryClusterByUserForm(QueryClientByUserFormDTO queryC return null; } + + /** + * TODO 1. 返回全量数据 + * 2. 构建树 + * 3. 类型 + * 1. clusterType + * 2. cluster 与 runtime 状态 + * 1. 默认显示正常, + * 2. 是否按照状态排序 + * 3. eventmesh cluster 与 存储 cluster 是否分开 展示 + * 4. 提供获得 url 功能,在 后端进行整理,前端处理太麻烦了 + * 4. cluster 与 关系表内容是否进行关联 + * 5. cluster runtime 与 关联表 需要整理成 一个 DO,适配前端 前端 tree table + */ + @PostMapping("queryTreeByClusterId") + public List queryTreeByClusterId(@RequestBody QueryTreeByClusterIdDTO data) { + return this.clusterAndRuntimeDomain.queryClusterTree(ClusterControllerMapper.INSTANCE.queryTreeByClusterId(data)); + } + /** * 这个接口用户 cluster 对应业务的 首页,方便查询 - * - * @param dto - * @return */ @PostMapping("queryVisualizationClusterByOrganizationIdAndType") public List queryVisualizationClusterByOrganizationIdAndType(@RequestBody @Validated QueryClusterByOrganizationIdAndTypeDTO dto) { @@ -104,9 +135,6 @@ public List queryClusterByOrganizationIdAndType(@RequestBody @Val /** * 查询 cluster 的关联集群列表 - * - * @param dto - * @return */ @PostMapping("queryRelationClusterByClusterIdAndType") public List queryRelationClusterByClusterIdAndType(@RequestBody @Validated QueryRelationClusterByClusterIdAndTypeDTO dto) { @@ -115,4 +143,93 @@ public List queryRelationClusterByClusterIdAndType(@RequestBody @ } + public void updateClusterNode() { + + } + + /** + * TODO + * 多端口,怎么处理。 + * - 设计多端口 url + * - 127.0.0.1/tcp=9898&grpc=9899&http=9900;127.0.0.2/tcp=9898&grpc=9899&http=9900 + * - 127.0.0.1,2,3,4/tcp=9898&grpc=9899&http=9900; + * - 127.0.0.1,127.0.0.2,127.0.0.3,127.0.0.4/tcp=9898&grpc=9899&http=9900; + * - 需要设计 url 表达式? + * - 主动从 runtime 读取 端口信息,是否能读取 meta 信息 + * - + * eventmesh 是否可以从 meta 读取 runtime 信息 or 从 runtime 读取 meta + * 其他基础数据,怎么处理。 + *

+ * 适合 meta 与 runtime 弱关联的 架构。比如 eventmesh + */ + @PostMapping("createClusterByFullAddress") + public void createClusterByFullAddress(@RequestBody @Validated CreateClusterByFullAddressDTO data) { + + } + + + /** + * 此方法适合 AP 架构,通过 meta address 获得大量 runtime cluster。比如 RocketMQ 架构 + *

+ * 先创建 eventmesh 集群,在创建 rocketmq 集群 + */ + @PostMapping("createClusterByBachAddress") + public void createClusterByBachAddress(@RequestBody BatchCreateClusterDataDTO data) { + ClusterEntity mainClusterEntity = ClusterControllerMapper.INSTANCE.toClusterEntity(data); + ClusterControllerUtils.clusterEntityDataSupplement(mainClusterEntity); + + List>> list = new ArrayList<>(); + data.getSimpleCreateClusterDataList().forEach((value) -> { + ClusterEntity clusterEntity = ClusterControllerMapper.INSTANCE.toClusterEntity(value); + ClusterControllerUtils.clusterEntityDataSupplement(clusterEntity); + clusterEntity.setOrganizationId(mainClusterEntity.getOrganizationId()); + Pair> pair = + ClusterControllerUtils.handlerSimpleCreateClusterDataDTO(clusterEntity, value); + list.add(pair); + + }); + this.clusterService.createClusterInfo(mainClusterEntity, list, this.creatingRelation(data.getMainClusterId(), mainClusterEntity)); + } + + /** + * 此方法适合 runtime cap 架构 或则 以 runtime 为主 ,比如 kafka + * TODO + * kafka 集群 是否支持0.9 版本 到 2.8版本,因为这个版本 metadata 需要从 zookeeper 集群进行操作 + * 需要进行深度的讨论 + * 如果需要支持,那么作为 T1级以及 极难标准的任务,发布下去. 接口等模块需要支持 runtime meta 双同步操作 + */ + @PostMapping("createClusterByRuntimeAddress") + public void createClusterByRuntimeAddress(@RequestBody @Validated SimpleCreateClusterDataDTO data) { + ClusterEntity clusterEntity = ClusterControllerMapper.INSTANCE.toClusterEntity(data); + ClusterType mainClusterType = clusterEntity.getClusterType().getHigher(); + ClusterEntity mainClusterEntity = new ClusterEntity(); + mainClusterEntity.setOrganizationId(clusterEntity.getOrganizationId()); + mainClusterEntity.setClusterType(mainClusterType); + mainClusterEntity.setName(clusterEntity.getName()); + mainClusterEntity.setTrusteeshipType(ClusterTrusteeshipType.NOT); + ClusterControllerUtils.clusterEntityDataSupplement(mainClusterEntity); + + clusterEntity.setName(clusterEntity.getName() + "-broker"); + Pair> pair = + ClusterControllerUtils.handlerSimpleCreateClusterDataDTO(clusterEntity, data); + // runtime cap 架构需要 检查节点数量, + this.clusterService.createClusterInfo(mainClusterEntity, List.of(pair), this.creatingRelation(data.getMainClusterId(), mainClusterEntity)); + + } + + private ClusterRelationshipEntity creatingRelation(Long mainClusterId, ClusterEntity mainClusterEntity) { + if (Objects.isNull(mainClusterId)) { + return null; + } + ClusterEntity newClusterEntity = new ClusterEntity(); + newClusterEntity.setId(mainClusterId); + newClusterEntity = this.clusterService.queryClusterById(newClusterEntity); + ClusterRelationshipEntity clusterRelationshipEntity = clusterRelationshipEntity = new ClusterRelationshipEntity(); + clusterRelationshipEntity.setOrganizationId(newClusterEntity.getOrganizationId()); + clusterRelationshipEntity.setClusterId(newClusterEntity.getId()); + clusterRelationshipEntity.setClusterType(newClusterEntity.getClusterType()); + clusterRelationshipEntity.setRelationshipType(mainClusterEntity.getClusterType()); + return 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 index ca84a3df..8e9f0ce8 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 @@ -17,7 +17,7 @@ package org.apache.eventmesh.dashboard.console.controller.cluster; -import org.apache.eventmesh.dashboard.console.modle.ClusterIdDTO; +import org.apache.eventmesh.dashboard.console.model.ClusterIdDTO; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; @@ -54,4 +54,5 @@ 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..f9570258 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/cluster/RuntimeController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/cluster/RuntimeController.java index 6f7ba10e..5da4555e 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 @@ -21,8 +21,8 @@ import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; import org.apache.eventmesh.dashboard.console.function.health.CheckResultCache; import org.apache.eventmesh.dashboard.console.mapstruct.cluster.RuntimeControllerMapper; -import org.apache.eventmesh.dashboard.console.modle.ClusterIdDTO; -import org.apache.eventmesh.dashboard.console.modle.IdDTO; +import org.apache.eventmesh.dashboard.console.model.ClusterIdDTO; +import org.apache.eventmesh.dashboard.console.model.IdDTO; import org.apache.eventmesh.dashboard.console.service.cluster.RuntimeService; import java.util.List; 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..2d9d6cb8 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/ActiveCreateController.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.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.active.ActiveCreateDTOHandler; +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.model.deploy.active.CreateClusterDTO; +import org.apache.eventmesh.dashboard.console.model.deploy.active.CreateEventMeshSpaceDTO; +import org.apache.eventmesh.dashboard.console.model.deploy.active.CreateRuntimeDTO; +import org.apache.eventmesh.dashboard.console.model.deploy.active.CreateTheEntireClusterDTO; +import org.apache.eventmesh.dashboard.console.model.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 集群创建 + * + */ + @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/CaseController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/CaseController.java index 14b28185..2e1c4c99 100644 --- 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 @@ -21,8 +21,8 @@ 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 org.apache.eventmesh.dashboard.console.model.IdDTO; +import org.apache.eventmesh.dashboard.console.model.deploy.cases.QueryCaseByObjectTypeDTO; import java.util.List; @@ -49,7 +49,7 @@ public List queryCaseByOrganization() { } - public void backups(){ + public void backups() { } 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..619fa106 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,25 +18,22 @@ 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.CreateClusterByCopyHandler; import org.apache.eventmesh.dashboard.console.controller.deploy.create.CreateClusterByDeployScriptHandler; +import org.apache.eventmesh.dashboard.console.controller.deploy.create.CreateClusterByFullMetadataHandler; 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.model.deploy.create.CreateClusterByCopyDTO; +import org.apache.eventmesh.dashboard.console.model.deploy.create.CreateClusterByDeployScriptDO; +import org.apache.eventmesh.dashboard.console.model.deploy.create.CreateClusterByFullMetadataDTO; +import org.apache.eventmesh.dashboard.console.model.deploy.create.CreateClusterByServiceAddressDTO; +import org.apache.eventmesh.dashboard.console.model.deploy.create.CreateRuntimeByDeployScriptDTO; +import org.apache.eventmesh.dashboard.console.model.dto.cluster.VerifyNameDTO; import org.apache.eventmesh.dashboard.console.service.cluster.ClusterService; import org.apache.eventmesh.dashboard.console.service.cluster.RuntimeService; +import java.util.Objects; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PostMapping; @@ -95,6 +92,12 @@ public class ClusterCycleController { @Autowired private CreateClusterByDeployScriptHandler createClusterByDeployScriptHandler; + @Autowired + private CreateClusterByCopyHandler createClusterByCopyHandler; + + @Autowired + private CreateClusterByFullMetadataHandler createClusterByFullMetadataHandler; + /** * @param verifyNameDTO @@ -105,88 +108,52 @@ 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("createClusterByServiceAddress") + public void createClusterByServiceAddress(CreateClusterByServiceAddressDTO dto) { - @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(); + if (Objects.equals(dto.getClusterType(), ClusterType.STORAGE_ROCKETMQ_CLUSTER)) { + dto.setClusterType(null); + } } - @PostMapping("pauseCluster") - public void pauseCluster(@RequestBody @Validated CreateClusterByEventMesh createClusterByEventMesh) { - } + public void createClusterByFullAddress() { - @PostMapping("pauseRuntime") - public void pauseRuntime(@RequestBody @Validated CreateClusterByEventMesh createClusterByEventMesh) { } - @PostMapping("relationship") - public void relationship(@RequestBody @Validated CreateClusterByEventMesh createClusterByEventMesh) { + public void createClusterByMetaAddress() { + } - @PostMapping("unrelationship") - public void unrelationship(@RequestBody @Validated CreateClusterByEventMesh createClusterByEventMesh) { + public void createClusterByRuntimeAddress() { + } - @PostMapping("uninstallCluster") - public void uninstallCluster(@RequestBody @Validated CreateClusterByEventMesh createClusterByEventMesh) { + @PostMapping("createClusterByDeployScript") + public void createClusterByDeployScript(@RequestBody @Validated CreateClusterByDeployScriptDO createClusterByDeployScriptDO) { + this.createClusterByDeployScriptHandler.handler(createClusterByDeployScriptDO); } - @PostMapping("uninstallRuntime") - public void uninstallRuntime(@RequestBody @Validated CreateClusterByEventMesh createClusterByEventMesh) { + @PostMapping("createClusterByCopy") + public void createClusterByCopy(@RequestBody @Validated CreateClusterByCopyDTO dto) { + this.createClusterByCopyHandler.handler(dto); } + /** + * 这里应该上传一个文件 + */ + @PostMapping("createClusterByFullMetadata") + public void createClusterByFullMetadata(@RequestBody @Validated CreateClusterByFullMetadataDTO dto) { + this.createClusterByFullMetadataHandler.handler(dto); + } } 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 index 6345dc8f..1dd887d1 100644 --- 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 @@ -29,8 +29,8 @@ 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.model.dto.cluster.CreateClusterByCompleteDataDTO; +import org.apache.eventmesh.dashboard.console.model.dto.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; @@ -54,6 +54,7 @@ @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) @Component @Slf4j +@Deprecated public class CreateCycleService { @Autowired @@ -252,7 +253,6 @@ public void createRuntime() { // } - // TODO 添加修改绑定解绑 meta 集群,都需要 所有的 runtime集群。是通过事件方式处理还是立即处理? // IP 管理 // 配置写入, 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 index 5fd79969..d030c509 100644 --- 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 @@ -20,9 +20,9 @@ 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 org.apache.eventmesh.dashboard.console.model.IdDTO; +import org.apache.eventmesh.dashboard.console.model.OrganizationIdDTO; +import org.apache.eventmesh.dashboard.console.model.deploy.resouce.QueryResourceByObjectTypeDTO; import java.util.List; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/active/ActiveCreateDTOHandler.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/active/ActiveCreateDTOHandler.java new file mode 100644 index 00000000..1d477410 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/active/ActiveCreateDTOHandler.java @@ -0,0 +1,196 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.active; + +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.model.deploy.active.CreateClusterDTO; +import org.apache.eventmesh.dashboard.console.model.deploy.active.CreateRuntimeDTO; +import org.apache.eventmesh.dashboard.console.model.deploy.active.CreateTheEntireClusterDTO; +import org.apache.eventmesh.dashboard.console.model.deploy.active.CreateTheEventClusterDTO; +import org.apache.eventmesh.dashboard.console.model.deploy.active.CreateTheEventClusterDTO.BaseCreateTheEntireClusterDTO; +import org.apache.eventmesh.dashboard.console.model.deploy.active.CreateTheEventClusterDTO.CreateCapStorageClusterDTO; +import org.apache.eventmesh.dashboard.console.model.deploy.active.CreateTheEventClusterDTO.MainStorageClusterDTO; +import org.apache.eventmesh.dashboard.console.model.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/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..ee4be9e0 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/base/AbstractUpdateHandler.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.controller.deploy.base; + +import org.apache.eventmesh.dashboard.common.enums.DeployStatusType; +import org.apache.eventmesh.dashboard.console.domain.ClusterAndRuntimeDomain; +import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; +import org.apache.eventmesh.dashboard.console.model.DO.domain.clusterAndRuntimeDomain.ClusterAndRuntimeOfRelationshipDO; +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.deploy.DeployService; +import org.apache.eventmesh.dashboard.console.service.function.ConfigService; +import org.apache.eventmesh.dashboard.console.service.message.TopicService; +import org.apache.eventmesh.dashboard.console.spring.support.KubernetesManage; + +import org.springframework.beans.factory.annotation.Autowired; + +public abstract class AbstractUpdateHandler { + + @Autowired + protected DeployService deployService; + + @Autowired + protected ClusterService clusterService; + + @Autowired + protected RuntimeService runtimeService; + + @Autowired + protected TopicService topicService; + + @Autowired + protected ConfigService configService; + + @Autowired + protected ClusterRelationshipService clusterRelationshipService; + + @Autowired + protected ClusterAndRuntimeDomain clusterAndRuntimeDomain; + + @Autowired + protected KubernetesManage kubernetesManage; + + + protected void updateDeployStatus(ClusterEntity clusterEntity, DeployStatusType deployStatus) { + ClusterAndRuntimeOfRelationshipDO data = + this.clusterAndRuntimeDomain.getAllClusterAndRuntimeByCluster(clusterEntity, deployStatus); + + data.getRuntimeEntityList().forEach(runtime -> { + runtime.setDeployStatusType(deployStatus); + }); + this.runtimeService.batchUpdateDeployStatusType(data.getRuntimeEntityList(), deployStatus); + } + + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/base/DeployBeforeCheck.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/base/DeployBeforeCheck.java new file mode 100644 index 00000000..dfb5b824 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/base/DeployBeforeCheck.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.console.controller.deploy.base; + +/** + * + */ +public interface DeployBeforeCheck { + + + boolean check(T t); + +} 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..3ea52fa0 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/create/CreateClusterByCopyHandler.java @@ -0,0 +1,90 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.DeployStatusType; +import org.apache.eventmesh.dashboard.common.enums.MetadataType; +import org.apache.eventmesh.dashboard.console.controller.deploy.base.AbstractUpdateHandler; +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.function.ConfigEntity; +import org.apache.eventmesh.dashboard.console.entity.message.TopicEntity; +import org.apache.eventmesh.dashboard.console.model.DO.domain.clusterAndRuntimeDomain.ClusterAndRuntimeOfRelationshipDO; +import org.apache.eventmesh.dashboard.console.model.deploy.create.CreateClusterByCopyDTO; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.springframework.stereotype.Component; + +@Component +public class CreateClusterByCopyHandler extends AbstractUpdateHandler implements UpdateHandler { + + @Override + public void init() { + + } + + @Override + public void handler(CreateClusterByCopyDTO dto) { + + ClusterEntity clusterEntity = new ClusterEntity(); + ClusterAndRuntimeOfRelationshipDO data = + this.clusterAndRuntimeDomain.getAllClusterAndRuntimeByCluster(clusterEntity, DeployStatusType.CREATE_COPY); + + // 如果是 runtime 类型,那么只需要一个创建一个集群 + // 一个集群只会在一个 kubernetes 集群里面创建 + if (data.getClusterEntity().getClusterType().isRuntime()) { + this.kubernetesManage.checkResource(data.getClusterResourcesList().get(0).getRight(), dto.getKubernetesClusterId()); + } else { + data.getClusterResourcesList().forEach(pair -> { + this.kubernetesManage.checkResource(pair.getRight(), dto.getKubernetesClusterId()); + }); + } + // Topic + data.setTopicMap(new HashMap<>()); + data.getTopicMap().put(MetadataType.CLUSTER, new HashMap<>()); + data.getTopicMap().put(MetadataType.RUNTIME, new HashMap<>()); + Map>> topicMap = data.getTopicMap(); + + List topciEntityList = this.topicService.queryByClusterIdList(data.getClusterEntityList()); + topciEntityList.forEach(topicEntity -> { + boolean isRuntime = topicEntity.getRuntimeId() == 0; + data.getTopicMap().get(isRuntime ? MetadataType.RUNTIME : MetadataType.CLUSTER) + .computeIfAbsent(isRuntime ? topicEntity.getRuntimeId() : topicEntity.getClusterId(), k -> new ArrayList<>()).add(topicEntity); + }); + // config + data.setConfigMap(new HashMap<>()); + Arrays.stream(MetadataType.values()).toList().forEach(metadataType -> { + data.getTopicMap().put(metadataType, new HashMap<>()); + }); + + List configEntityList = this.configService.queryByClusterIdList(data.getClusterEntityList()); + + configEntityList.forEach(configEntity -> { + data.getConfigMap().get(configEntity.getInstanceType()).computeIfAbsent(configEntity.getInstanceId(), k -> new ArrayList<>()) + .add(configEntity); + }); + + this.deployService.createDeploy(data); + + } +} 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..237e67d9 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 @@ -29,7 +29,7 @@ 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.model.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; @@ -49,25 +49,16 @@ @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class CreateClusterByDeployScriptHandler implements UpdateHandler { + private final List runtimeEntityList = new ArrayList<>(); 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() { @@ -79,6 +70,9 @@ private void handlerMetadata(ClusterEntity clusterEntity) { this.clusterFramework = ClusterSyncMetadataEnum.getClusterFramework(clusterEntity.getClusterType()); } + /** + * 只支持 runtime 与 meta 集群的创建,不支持 集群空间的创建

如何支持 eventmesh space create, script 模式不适合。 + */ @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..c84b755f --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/create/CreateClusterByFullMetadataHandler.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.model.deploy.create.CreateClusterByFullMetadataDTO; + +import org.springframework.stereotype.Component; + +/** + * TODO + * 实现这个 handler 需要 对 ClusterAndRuntimeDomainImpl GetSyncObjectHandler 的 数据读取 与 数据整理 进行 解耦。

+ * 一个是 db read , 一个 get read + * issue Full metadata 创建 create cluster 以及 GetSyncObjectHandler 数据读取与数据操作解耦,支持 db read 与 get read + */ +@Component +public class CreateClusterByFullMetadataHandler implements UpdateHandler { + + + @Override + public void init() { + + } + + @Override + public void handler(CreateClusterByFullMetadataDTO dto) { + // 这是所有 新增 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..5efbb395 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 @@ -26,7 +26,7 @@ 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.model.deploy.create.CreateRuntimeByDeployScriptDTO; import org.apache.eventmesh.dashboard.console.service.cluster.ClusterService; import org.apache.eventmesh.dashboard.console.service.cluster.RuntimeService; @@ -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/design.md b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/design.md index 33a7903b..dd6039e9 100644 --- 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 @@ -1,92 +1,95 @@ +## -## 1. 存储 remote 服务 - 1. topic 创建在 cluster main runtime + 1. topic 创建在 cluster main runtime 2. message - 1. 发送 - 2. 查看消息 - 3. 发布订阅 - 4. console -> 抽象层 -> broker - 5. rocketmq 4.0 push(pull) 5.0 pull + 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 实现 +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. 修改 + 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 集群决定一致性架构 +超级难点一: +因消息中间件架构不一样,所以处理不一样。 +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 行为 - + PS: RocketMQ 的 queue 与 kafka 的 partition 是一个意思。 + 超级难点一: + 因消息中间件架构不一样,所以处理不一样 + kafka 的 offset 操作时 cluster行为 + RocketMQ 操作时 broker 行为 + kafka 只需要 队列id 就行了 - 1. 按照某个维度重置 topic 下面所有 队列 - 2. 按照某个维度重置 topic 下某个队列 -RocketMQ 的重置场景 + +1. 按照某个维度重置 topic 下面所有 队列 +2. 按照某个维度重置 topic 下某个队列 + RocketMQ 的重置场景 1. 按照某个维度重置 topic 在集群里面所有的 队列 2. 按照某个维度重置 topic 在集群里面某个主从节点的 队列 3. 按照某个维度重置 topic 在集群里面所有的 下某个队列 @@ -95,63 +98,64 @@ RocketMQ 的重置场景 5. 按照某个维度重置 topic 在某个节点上的所有 队列 6. 按照某个维度重置 topic 在某个节点上的所有 某个队列 - ## 数据关联 + 1. 所有对 eventmesh 的操作,需要再对应的存储集群进行操作 2. 什么状态的集群进行操作【】。读取数据的时候,需要过滤掉,不正常得节点 -## +## ## 数据创建 + 1. 把导出的数据,导入 - 1. 点击 eventmesh 集群导出 or 备份 - 1. 如果 eventmesh 独立集群直接操作 - 2. 不是,检查 依赖集群是否同时进行了备份 - 1. 没有,提示某某集群 - 2. 点击 runtime 集群 - 3. 点击 meta 集群 - 4. 点击 存储 集群 - 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. 定时 保存 cluster 信息 + 2. 绑定 集群架构 + 1. eventmesh cluster 1. meta cluster 列表 - 1. runtime列表 - 2. 一份 runtime config + 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 信息 + 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 + 1. 只能 添加 resource 5. 在 deploy 模块,添加 -6. deploy - 1. 部署方案 - 2. 资源配置 - 3. 部署关系 +6. deploy + 1. 部署方案 + 2. 资源配置 + 3. 部署关系 7. 部署信息 - 1. 每个runtime 的部署 对应一个 资源信息 - 2. cluster 第一次部署对应一个部署信息 - 1. 这次 + 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 index 8d137735..84cd684a 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.base.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..6d49f929 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 @@ -19,92 +19,23 @@ 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.base.AbstractUpdateHandler; 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<>(); - +public class PauseCluster extends AbstractUpdateHandler implements UpdateHandler { @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 - - // - } - + this.updateDeployStatus(clusterEntity, DeployStatusType.PAUSE); } } 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..8aa6fb52 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,14 +19,18 @@ 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; import org.apache.eventmesh.dashboard.console.service.cluster.ClusterService; import org.apache.eventmesh.dashboard.console.service.cluster.RuntimeService; +import org.apache.eventmesh.dashboard.console.spring.support.register.BuildMetadataManage; public class RelationshipHandler implements UpdateHandler { + private final BuildMetadataManage buildMetadataManage = new BuildMetadataManage(); + private ClusterService clusterService; private ClusterRelationshipService clusterRelationshipService; @@ -39,16 +43,88 @@ public void init() { } + /** + * TODO 如果是 替换关联,应该怎么做?

+ * kafka 的集群,接触,在关联上,时两个步骤,那么是两次,可以做到成一次 + */ @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 ,然后重启 + // 绑定 存储集群 + clusterRelationshipEntity.setClusterType(mainClusterEntity.getClusterType()); + clusterRelationshipEntity.setRelationshipType(relationshipClusterEntity.getClusterType()); clusterRelationshipService.addClusterRelationshipEntry(clusterRelationshipEntity); + // 如果 relationship runtime 集群 不是 托管类型 不需要处理 + + // main cluster 与 relationship cluster 都不是 self 类型就不需要管 + if (mainClusterEntity.getTrusteeshipType().isReverse() && relationshipClusterEntity.getTrusteeshipType().isReverse()) { + return; + } + + if (mainClusterEntity.getClusterType().isEventCluster()) { + if (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 + return; + } + if (relationshipClusterEntity.getClusterType().isEventMethMeta()) { + // 得到 所有 eventmesh runtime cluster + // 得到 所有 eventmesh meta cluster + // 组件新的 注册中心地址 + // 修改 eventmesh runtime 配置 + // 修改 runtime entity 部署状态,为更新 + return; + } + if (relationshipClusterEntity.getClusterType().isEventMethRuntime()) { + // 得到 所有 eventmesh meta + // 得到 该 runtime list + // 修改 runtime list config 的meta 配置 + // 修改 runtime entity 部署状态,为更新 + return; + } + return; + } + + /* + 如果 main cluster 需要 relationship cluster 的 meta 集群 地址,则 runtime 集群需要重启 + + */ if (clusterRelationshipEntity.getRelationshipType().isMeta()) { + // 得到 所有 runtime cluster + // 得到 所有 meta cluster + // 组件新的 注册中心地址 + // 修改 eventmesh runtime 配置 + // 修改 runtime entity 部署状态,为更新 RuntimeEntity runtimeEntity = new RuntimeEntity(); runtimeEntity.setClusterId(clusterRelationshipEntity.getClusterId()); //runtimeService.queryOnlyRuntimeByClusterId(runtimeEntity); + + // TODO 如果是 rocketmq 的 meta , 那么被关联的 eventmesh runtime cluster 需要更新 meta 地址 + } + if (clusterRelationshipEntity.getRelationshipType().isRuntime()) { + // 查询 main cluster 里面 是否存在 meta cluster , 如果存在则需要更新 + + // 如果 没有 meta cluster 不需要查询 runtime 列表 + + // TODO 如果是 kafka 的 runtime , 那么被关联的 eventmesh runtime cluster 需要更新 kafka runtime 地址 } } } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/start/StartClusterHandler.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/start/StartClusterHandler.java new file mode 100644 index 00000000..f4e91592 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/deploy/start/StartClusterHandler.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.controller.deploy.start; + +import org.apache.eventmesh.dashboard.common.enums.DeployStatusType; +import org.apache.eventmesh.dashboard.console.controller.deploy.base.AbstractUpdateHandler; +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.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class StartClusterHandler extends AbstractUpdateHandler implements UpdateHandler { + + @Autowired + private ClusterAndRuntimeDomain clusterAndRuntimeDomain; + + @Override + public void init() { + + } + + @Override + public void handler(ClusterEntity clusterEntity) { + this.updateDeployStatus(clusterEntity, DeployStatusType.CREATE); + } +} 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..1b795a8d 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 @@ -18,18 +18,28 @@ 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.base.AbstractUpdateHandler; import org.apache.eventmesh.dashboard.console.controller.deploy.handler.UpdateHandler; import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; -public class UninstallClusterHandler implements UpdateHandler { +import org.springframework.stereotype.Component; + +@Component +public class UninstallClusterHandler extends AbstractUpdateHandler implements UpdateHandler { + @Override public void init() { } + /** + * 只需要 修改状态,通知删除 容器就行了 + */ @Override public void handler(ClusterEntity clusterEntity) { + this.updateDeployStatus(clusterEntity, DeployStatusType.UNINSTALL); } } 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/function/ConfigController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/function/ConfigController.java index ef38b02e..debbec02 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.modle.dto.config.UpdateConfigDTO; +import org.apache.eventmesh.dashboard.console.mapstruct.message.ConfigControllerMapper; +import org.apache.eventmesh.dashboard.console.model.dto.config.UpdateConfigDTO; +import org.apache.eventmesh.dashboard.console.model.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/function/HealthController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/function/HealthController.java index f3d0b5aa..9abec7e9 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 @@ -19,7 +19,7 @@ package org.apache.eventmesh.dashboard.console.controller.function; import org.apache.eventmesh.dashboard.console.entity.function.HealthCheckResultEntity; -import org.apache.eventmesh.dashboard.console.modle.vo.health.InstanceLiveProportionVo; +import org.apache.eventmesh.dashboard.console.model.vo.health.InstanceLiveProportionVo; import org.apache.eventmesh.dashboard.console.service.function.HealthDataService; import java.time.LocalDateTime; 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 525de4fd..e05ee3b8 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 @@ -19,7 +19,7 @@ package org.apache.eventmesh.dashboard.console.controller.function; import org.apache.eventmesh.dashboard.console.entity.function.LogEntity; -import org.apache.eventmesh.dashboard.console.modle.dto.log.GetLogListDTO; +import org.apache.eventmesh.dashboard.console.model.dto.log.GetLogListDTO; import org.apache.eventmesh.dashboard.console.service.function.LogService; import java.util.List; @@ -41,4 +41,5 @@ public List getLogLIstToFront(@Validated @RequestBody GetLogListDTO g 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 46e49209..f439723e 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 @@ -20,7 +20,7 @@ package org.apache.eventmesh.dashboard.console.controller.function; -import org.apache.eventmesh.dashboard.console.modle.function.OverviewDTO; +import org.apache.eventmesh.dashboard.console.model.function.OverviewDTO; import org.apache.eventmesh.dashboard.console.service.OverviewService; import java.util.Map; 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..24045fb2 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,14 +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.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; +import org.apache.eventmesh.dashboard.console.model.IdDTO; +import org.apache.eventmesh.dashboard.console.model.vo.RuntimeIdDTO; import org.apache.eventmesh.dashboard.console.service.message.GroupService; import java.util.List; @@ -39,7 +39,7 @@ * */ @RestController -@RequestMapping("group") +@RequestMapping("/user/group") public class GroupController { @@ -51,6 +51,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/GroupRelationshipController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/message/GroupRelationshipController.java index a726dbcf..322bfca6 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 @@ -21,7 +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.modle.IdDTO; +import org.apache.eventmesh.dashboard.console.model.IdDTO; import java.util.List; @@ -35,7 +35,6 @@ public class GroupRelationshipController { - public List queryTopicByGroupId(@RequestBody @Validated IdDTO idDTO) { return null; 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 bfdddc44..b7305969 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 @@ -20,8 +20,8 @@ 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.console.model.message.offset.QueryOffsetByMessageMetadataDTO; +import org.apache.eventmesh.dashboard.console.model.message.offset.ResetOffsetDTO; import org.apache.eventmesh.dashboard.service.remoting.OffsetRemotingService; import org.springframework.beans.factory.annotation.Autowired; 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..ad50249b 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,16 +21,18 @@ 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.ClusterAndRuntimeDomain; 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.model.DO.domain.clusterAndRuntimeDomain.QueryClusterInSyncDO; +import org.apache.eventmesh.dashboard.console.model.IdDTO; +import org.apache.eventmesh.dashboard.console.model.dto.topic.CreateTopicDTO; +import org.apache.eventmesh.dashboard.console.model.dto.topic.GetTopicListDTO; +import org.apache.eventmesh.dashboard.console.model.vo.RuntimeIdDTO; +import org.apache.eventmesh.dashboard.console.model.vo.topic.TopicDetailGroupVO; import org.apache.eventmesh.dashboard.console.service.message.TopicService; import java.util.ArrayList; @@ -44,8 +46,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,93 +58,57 @@ public class TopicController { @Autowired - private ClusterAbitityService clusterAbitityService; + private ClusterAbilityService clusterAbilityService; @Autowired private ClusterMetadataDomain clusterMetadataDomain; - /** - * @param getTopicListDTO - * @return - */ + @Autowired + private ClusterAndRuntimeDomain clusterAndRuntimeDomain; + @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(); + 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; } - // - 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); + topicService.queryRuntimeByBaseSyncEntity( + this.clusterAndRuntimeDomain.queryClusterInSync(QueryClusterInSyncDO.create(topicEntity.getClusterId(), () -> { + TopicEntity entity = new TopicEntity(); + entity.setTopicName(topicEntity.getTopicName()); + return entity; + }))); return null; } @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 删除 - - 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); + return topicService.deleteTopicByRuntimeIdAndTopicName( + this.clusterAndRuntimeDomain.queryClusterInSync(QueryClusterInSyncDO.create(topicEntity.getClusterId(), () -> { + TopicEntity entity = new TopicEntity(); + entity.setTopicName(topicEntity.getTopicName()); + return entity; + }))); } @PostMapping("createTopic") @@ -169,12 +138,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..9138fa6a 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 @@ -19,9 +19,24 @@ package org.apache.eventmesh.dashboard.console.domain; +import org.apache.eventmesh.dashboard.common.enums.ClusterType; +import org.apache.eventmesh.dashboard.common.enums.DeployStatusType; +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.BaseRuntimeIdEntity; import org.apache.eventmesh.dashboard.console.entity.cluster.ClusterEntity; +import org.apache.eventmesh.dashboard.console.model.DO.domain.clusterAndRuntimeDomain.ClusterAndRuntimeOfRelationshipDO; +import org.apache.eventmesh.dashboard.console.model.DO.domain.clusterAndRuntimeDomain.GetClusterInSyncReturnDO; +import org.apache.eventmesh.dashboard.console.model.DO.domain.clusterAndRuntimeDomain.QueryClusterInSyncDO; +import org.apache.eventmesh.dashboard.console.model.DO.domain.clusterAndRuntimeDomain.QueryClusterTreeDO; +import org.apache.eventmesh.dashboard.console.model.vo.cluster.ClusterTreeVO; +import java.util.ArrayList; import java.util.List; +import java.util.Objects; +import java.util.function.Supplier; + +import com.alibaba.fastjson.JSON; /** * @@ -29,11 +44,66 @@ public interface ClusterAndRuntimeDomain { + List getClusterByClusterId(ClusterEntity clusterEntity); + + List queryClusterTree(QueryClusterTreeDO data); + + ClusterAndRuntimeOfRelationshipDO getAllClusterAndRuntimeByCluster(ClusterEntity clusterEntity, DeployStatusType deployStatusType); + + GetClusterInSyncReturnDO queryClusterInSync(ClusterEntity clusterEntity, List syncClusterTypeList); + + default T queryClusterInSync(QueryClusterInSyncDO data) { + GetClusterInSyncReturnDO getClusterInSyncReturnDO = this.queryClusterInSync(data.getClusterEntity(), data.getSyncClusterTypeList()); + if (Objects.isNull(getClusterInSyncReturnDO.getClusterEntityList()) + && Objects.isNull(getClusterInSyncReturnDO.getRuntimeEntityList())) { + throw new RuntimeException(""); + } + /* + * 如果 entity 的就直接调用。 是 core 的需要转换一次。 + * 目前只有 core 的, 没有 entity 的 + * + * 转两次,虽然有性能损失,对于一个运维系统意义不大。 + */ + if (Objects.nonNull(data.getClusterOperationHandler())) { + getClusterInSyncReturnDO.getRuntimeEntityList().forEach(runtimeEntity -> { + RuntimeMetadata runtimeMetadata = new RuntimeMetadata(); + data.getClusterOperationHandler().handler(runtimeMetadata); + }); + getClusterInSyncReturnDO.getClusterEntityList().forEach(entity -> { + ClusterMetadata clusterMetadata = new ClusterMetadata(); + data.getClusterOperationHandler().handler(clusterMetadata); + }); + return null; + } + Supplier function = + Objects.nonNull(data.getFunction()) ? data.getFunction() : this.createBaseRuntimeIdEntity(data.getObject()); + List runtimeIdEntityList = + new ArrayList<>(getClusterInSyncReturnDO.getClusterEntityList().size() + getClusterInSyncReturnDO.getRuntimeEntityList().size()); - List getClusterByCLusterId(ClusterEntity clusterEntity); + getClusterInSyncReturnDO.getClusterEntityList().forEach(clusterEntity -> { + BaseRuntimeIdEntity baseRuntimeIdEntity = function.get(); + runtimeIdEntityList.add(baseRuntimeIdEntity); + baseRuntimeIdEntity.setClusterId(clusterEntity.getId()); + baseRuntimeIdEntity.setClusterType(clusterEntity.getClusterType()); + baseRuntimeIdEntity.setRuntimeId(clusterEntity.getId()); + }); + getClusterInSyncReturnDO.getRuntimeEntityList().forEach(runtimeEntity -> { + BaseRuntimeIdEntity baseRuntimeIdEntity = function.get(); + runtimeIdEntityList.add(baseRuntimeIdEntity); + baseRuntimeIdEntity.setClusterId(runtimeEntity.getClusterId()); + baseRuntimeIdEntity.setClusterType(runtimeEntity.getClusterType()); + baseRuntimeIdEntity.setRuntimeId(runtimeEntity.getId()); + }); + return (T) runtimeIdEntityList; + } + default Supplier createBaseRuntimeIdEntity(Object object) { + String json = JSON.toJSONString(object); + Class clazz = object.getClass(); + return () -> (BaseRuntimeIdEntity) JSON.parseObject(json, clazz); + } } 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..8ff44639 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,471 @@ 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.common.enums.DeployStatusType; import org.apache.eventmesh.dashboard.console.domain.ClusterAndRuntimeDomain; +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.ClusterRelationshipEntity; +import org.apache.eventmesh.dashboard.console.entity.cluster.RuntimeEntity; +import org.apache.eventmesh.dashboard.console.mapstruct.model.entity.ClusterEntityMapstruct; +import org.apache.eventmesh.dashboard.console.mapstruct.model.entity.RuntimeEntityMapstruct; +import org.apache.eventmesh.dashboard.console.model.DO.clusterRelationship.QueryListByClusterIdAndTypeDO; +import org.apache.eventmesh.dashboard.console.model.DO.domain.clusterAndRuntimeDomain.ClusterAndRuntimeOfRelationshipDO; +import org.apache.eventmesh.dashboard.console.model.DO.domain.clusterAndRuntimeDomain.GetClusterInSyncReturnDO; +import org.apache.eventmesh.dashboard.console.model.DO.domain.clusterAndRuntimeDomain.QueryClusterTreeDO; +import org.apache.eventmesh.dashboard.console.model.QO.cluster.QueryRelationClusterByClusterIdListAndType; +import org.apache.eventmesh.dashboard.console.model.vo.cluster.ClusterTreeVO; +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 java.util.Collections; +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.List; +import java.util.Map; +import java.util.Objects; +import java.util.function.Function; +import java.util.stream.Collectors; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +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 ResourcesConfigService resourcesConfigService; + + + @Override + public List getClusterByClusterId(ClusterEntity clusterEntity) { + return List.of(); + } + + @Override + public List queryClusterTree(QueryClusterTreeDO data) { + GetSyncObjectHandler getSyncObjectHandler = new GetSyncObjectHandler(); + ClusterEntity clusterEntity = new ClusterEntity(); + clusterEntity.setId(data.getClusterId()); + getSyncObjectHandler.setClusterEntity(clusterEntity); + if (Objects.nonNull(data.getDeployStatusType())) { + getSyncObjectHandler.setDeployStatusType(data.getDeployStatusType().get(0)); + } + return this.queryClusterTree(getSyncObjectHandler.queryClusterAndRuntime()); + } + + /** + * 这个方法是否放到 controller 层 + */ + public List queryClusterTree(ClusterAndRuntimeOfRelationshipDO data) { + Map clusterIdMap = data.getClusterEntityList().stream().collect(Collectors.toMap(ClusterEntity::getId, + ClusterEntityMapstruct.INSTANCE::toClusterTreeVO)); + + Map> runtimeListByClusterIdGroupMap = + data.getRuntimeEntityList().stream() + .collect(Collectors.groupingBy(RuntimeEntity::getClusterId, + Collectors.mapping(RuntimeEntityMapstruct.INSTANCE::toClusterTreeVO, + Collectors.toList()))); + + Map> clusterRelationshipListByClusterIdGroupMap = + data.getClusterRelationshipEntityList().stream().collect(Collectors.groupingBy(ClusterRelationshipEntity::getClusterId, + Collectors.mapping(value -> clusterIdMap.get(value.getRelationshipId()), Collectors.toList()) + )); + + clusterIdMap.forEach((key, value) -> { + value.setChildren(runtimeListByClusterIdGroupMap.get(key)); + List clusterTreeVOList = clusterRelationshipListByClusterIdGroupMap.get(key); + if (Objects.nonNull(clusterTreeVOList)) { + value.setChildren(clusterTreeVOList); + } + }); + + return clusterRelationshipListByClusterIdGroupMap.get(data.getClusterEntity().getId()); + } + + /** + * 运维操作使用列表:

+ *

+ * 部署操作使用列表:

+ * + * @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, DeployStatusType deployStatusType) { + GetSyncObjectHandler getSyncObjectHandler = new GetSyncObjectHandler(); + getSyncObjectHandler.setClusterEntity(clusterEntity); + getSyncObjectHandler.setDeployStatusType(deployStatusType); + return getSyncObjectHandler.deploy(); + } + + + /** + * 修改配置只能在一个维度的进行操作 topic 需要对 eventmesh 与 存储同时进行操作, acl 需要多维度操作,还是? offset 的操作 按照具体 offset,只能操作 队列 级别 按照 最大或则最小 和 时间,可以 是 大集群 或则 全域操作 定义操作域 + */ @Override - public List getClusterByCLusterId(ClusterEntity clusterEntity) { - return Collections.emptyList(); + public GetClusterInSyncReturnDO queryClusterInSync(ClusterEntity clusterEntity, List syncClusterTypeList) { + GetSyncObjectHandler getSyncObjectHandler = new GetSyncObjectHandler(); + getSyncObjectHandler.setClusterEntity(clusterEntity); + getSyncObjectHandler.setSyncClusterTypeList(syncClusterTypeList); + + return getSyncObjectHandler.sync(); + } + + class GetSyncObjectHandler { + + private final List clusterRelationshipEntityList = new ArrayList<>(); + @Setter + private ClusterEntity clusterEntity; + @Setter + private DeployStatusType deployStatusType; + private ClusterType clusterType; + /** + * 修改 eventmesh 空间下 所有 存储集群 + */ + @Setter + private List syncClusterTypeList; + private List independenceClusterList = new ArrayList<>(); + private List clusterEntityList = new ArrayList<>(); + + private 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(); + } + + + private ClusterAndRuntimeOfRelationshipDO createClusterAndRuntimeOfRelationshipDO() { + ClusterAndRuntimeOfRelationshipDO clusterAndRuntimeOfRelationshipDO = new ClusterAndRuntimeOfRelationshipDO(); + clusterAndRuntimeOfRelationshipDO.setClusterEntity(this.clusterEntity); + clusterAndRuntimeOfRelationshipDO.setClusterEntityList(this.clusterEntityList); + clusterAndRuntimeOfRelationshipDO.setRuntimeEntityList(this.runtimeList); + clusterAndRuntimeOfRelationshipDO.setClusterRelationshipEntityList(this.clusterRelationshipEntityList); + return clusterAndRuntimeOfRelationshipDO; + } + + + public ClusterAndRuntimeOfRelationshipDO queryClusterAndRuntime() { + this.base(false); + this.queryRuntimeByClusterList(); + return this.createClusterAndRuntimeOfRelationshipDO(); + } + + + public ClusterAndRuntimeOfRelationshipDO deploy() { + this.base(false); + if (this.clusterType.isRuntime()) { + ClusterAndRuntimeOfRelationshipDO clusterAndRuntimeOfRelationshipDO = this.createClusterAndRuntimeOfRelationshipDO(); + 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.capClusterList = List.of(this.clusterEntity); + } + } else { + this.filerSyncObject(); + this.queryRuntimeByIndependenceClusterList(); + } + GetClusterInSyncReturnDO syncReturnDO = new GetClusterInSyncReturnDO(); + syncReturnDO.setClusterEntityList(this.capClusterList); + syncReturnDO.setRuntimeEntityList(this.runtimeList); + return syncReturnDO; + } + + private ClusterAndRuntimeOfRelationshipDO structureRelationship() { + ClusterAndRuntimeOfRelationshipDO clusterAndRuntimeOfRelationshipDO = this.createClusterAndRuntimeOfRelationshipDO(); + if (this.deployStatusType != DeployStatusType.CREATE) { + return clusterAndRuntimeOfRelationshipDO; + } + Map clusterEntityMap = + this.clusterEntityList.stream().collect(Collectors.toMap(ClusterEntity::getId, Function.identity())); + + 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); + } + }); + + if (Objects.equals(deployStatusType, DeployStatusType.CREATE_COPY)) { + this.copy(clusterAndRuntimeOfRelationshipDO); + } + + return clusterAndRuntimeOfRelationshipDO; + } + + private void copy(ClusterAndRuntimeOfRelationshipDO clusterAndRuntimeOfRelationshipDO) { + if (!Objects.equals(deployStatusType, DeployStatusType.CREATE_COPY)) { + return; + } + List resourcesConfigEntityList = + resourcesConfigService.queryByRuntimeList(this.runtimeList); + + Map resourcesConfigEntityMap = new HashMap<>(); + resourcesConfigEntityList.forEach(resourcesConfigEntity -> { + resourcesConfigEntityMap.put(resourcesConfigEntity.getId(), resourcesConfigEntity); + }); + + clusterAndRuntimeOfRelationshipDO.setResourceData(new ArrayList<>()); + clusterAndRuntimeOfRelationshipDO.setClusterResourcesList(new ArrayList<>()); + Map>> longPairMap = new HashMap<>(); + Map> clusterIdAndResourcesMap = new HashMap<>(); + this.runtimeList.forEach(runtimeEntity -> { + Pair pair = + Pair.of(runtimeEntity, resourcesConfigEntityMap.get(runtimeEntity.getResourcesConfigId())); + longPairMap.computeIfAbsent(runtimeEntity.getClusterId(), k -> new ArrayList<>()).add(pair); + + clusterIdAndResourcesMap.computeIfAbsent(runtimeEntity.getClusterId(), k -> new ArrayList<>()) + .add(resourcesConfigEntityMap.get(runtimeEntity.getResourcesConfigId())); + }); + + } + + 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() { + QueryListByClusterIdAndTypeDO queryListByClusterIdAndTypeDO = new QueryListByClusterIdAndTypeDO(); + queryListByClusterIdAndTypeDO.setClusterId(this.clusterEntity.getId()); + queryListByClusterIdAndTypeDO.setClusterTypeList(this.syncClusterTypeList); + + /* + * TODO 只能通过 代码 过滤需要的 clusterType, 除非 能从 syncClusterTypeList 得到 DEFINITION 与 目标类型 + * 前端如何操作, + */ + 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/OperationRangeDomain.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/domain/OperationRangeDomain.java index e08c9fae..eb32aabd 100644 --- 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 @@ -25,8 +25,8 @@ 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.model.deploy.ClusterAllMetadataDO; +import org.apache.eventmesh.dashboard.console.model.dto.operation.OperationBaseDTO; import org.apache.eventmesh.dashboard.console.service.cluster.ClusterService; import org.apache.eventmesh.dashboard.console.service.cluster.RuntimeService; @@ -43,24 +43,21 @@ /** * 可以得到返回的数据为两种: 1. 写入数据的 2. 直接请求其他组件 + * TODO 可能需要会被作废 与 ClusterAndRuntimeDomainImpl 冲突 + * 等于 又又重构一次..... 浪费两个星期 */ @Component +@Deprecated @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class OperationRangeDomain { + private final Set clusterTypeSet = new HashSet<>(); @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; 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..19b9c686 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 @@ -26,8 +26,8 @@ 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.model.domain.ClusterEntityDO; +import org.apache.eventmesh.dashboard.console.model.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; @@ -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; @@ -230,7 +232,7 @@ private ClusterBaseDO createClusterBaseDO(ClusterEntity clusterEntity) { ClusterFramework clusterFramework = ClusterSyncMetadataEnum.getClusterFramework(clusterType); if (this.buildConfig && !clusterType.isDefinition() && clusterFramework.isCAP()) { AbstractMultiCreateSDKConfig config = - ConfigManage.getInstance().getMultiCreateSDKConfig(clusterEntity.getClusterType(), SDKTypeEnum.ADMIN); + ConfigManage.getInstance().getMultiCreateSdkConfig(clusterEntity.getClusterType(), SDKTypeEnum.ADMIN); config.setKey(clusterEntity.getId().toString()); clusterBaseDO.setMultiCreateSDKConfig(config); } @@ -246,7 +248,7 @@ private RuntimeBaseDO createRuntimeDO(RuntimeEntity runtimeEntity) { ClusterFramework clusterFramework = ClusterSyncMetadataEnum.getClusterFramework(runtimeEntity.getClusterType()); if (!clusterFramework.isCAP()) { AbstractSimpleCreateSDKConfig config = - ConfigManage.getInstance().getSimpleCreateSDKConfig(runtimeEntity.getClusterType(), SDKTypeEnum.ADMIN); + ConfigManage.getInstance().getSimpleCreateSdkConfig(runtimeEntity.getClusterType(), SDKTypeEnum.ADMIN); config.setKey(runtimeEntity.getId().toString()); config.setNetAddress(this.createNetAddress(runtimeEntity)); runtimeBaseDO.setCreateSDKConfig(config); @@ -276,6 +278,7 @@ public void setConfigEntity() { /** * TODO @see OperationRangeDomain. + * * @param clusterId * @param clusterOperationHandler */ @@ -351,14 +354,11 @@ public interface DataHandler { @SuppressWarnings("rawtypes") private static class QueueConditionHandler { + private final List resultData = new ArrayList<>(); private QueueCondition queueCondition; - private ColonyDO colonyDO; - private Map> currentColonyDOMap; - private final List resultData = new ArrayList<>(); - public T handler() { this.getColonyDOMap(); if (MapUtils.isEmpty(currentColonyDOMap)) { @@ -399,18 +399,18 @@ public void handlerData(ColonyDO colonyDO) { public static class QueueCondition { + private final ClusterType resultType = ClusterType.CLUSTER; private Long clusterId; - /** * */ private ClusterType clusterType; - - private final ClusterType resultType = ClusterType.CLUSTER; - private boolean resultId = false; + public QueueCondition() { + } + public QueueCondition clusterId(Long clusterId) { this.clusterId = clusterId; return this; @@ -436,9 +436,6 @@ public QueueCondition 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/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/base/BaseRuntimeIdEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/base/BaseRuntimeIdEntity.java index 0c89a9d5..dcc2468e 100644 --- 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 @@ -25,6 +25,9 @@ @EqualsAndHashCode(callSuper = true) public class BaseRuntimeIdEntity extends BaseClusterIdEntity { + /** + * 如果是 runtime 级别的 runtime_id 为零, 比如 topic + */ 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 index cf12538a..ad72bb33 100644 --- 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 @@ -52,6 +52,8 @@ public abstract class BaseSyncEntity extends BaseClusterIdEntity { private DeployStatusType deployStatusType; + private DeployStatusType createMethod; + private Long resourcesConfigId; private Long deployScriptId; 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 index 6b6a233e..1df80f80 100644 --- 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 @@ -31,7 +31,7 @@ public class CaseEntity extends BaseOrganizationEntity { private String caseType; /** - * cluster , runtime + * cluster , runtime */ private String objectType; 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 index b5d6b3d7..0b4a050a 100644 --- 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 @@ -28,5 +28,4 @@ public class ResouceEntity extends BaseOrganizationEntity { - } 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..517e4b18 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,16 @@ 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 +49,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/cluster/ClusterAndRelationshipEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/ClusterAndRelationshipEntity.java index c2008142..078f397d 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 @@ -36,5 +36,4 @@ public class ClusterAndRelationshipEntity extends ClusterEntity { private ClusterType relationshipType; - } 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 2b1baaeb..ea95fa30 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 @@ -43,4 +43,6 @@ public class ClusterRelationshipEntity extends BaseClusterIdEntity { private LocalDateTime unRelationshipTime; + private String bindType; + } 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..a51c8492 --- /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/cluster/RuntimeEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/cluster/RuntimeEntity.java index 3850d0df..e49cf694 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 @@ -32,6 +32,8 @@ public class RuntimeEntity extends BaseSyncEntity { private String host; + private String podHost; + /** * 添加的时候只需要 host 与 post eventmesh runtime 是 admin port。通过 runtime admin 获得所有的配置。 meta 需要 host 与 post store host 与 post jmxPort */ @@ -52,5 +54,4 @@ public class RuntimeEntity extends BaseSyncEntity { private String authType; - } 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..43bfb031 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 { private String businessType; @@ -46,6 +46,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/function/HealthCheckResultEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/function/HealthCheckResultEntity.java index 4e22de66..f6b2e447 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; @@ -56,7 +54,6 @@ public class HealthCheckResultEntity extends BaseRuntimeIdEntity { 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"}) private Integer type; 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 index 3baa5660..39f21dd9 100644 --- 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 @@ -30,7 +30,6 @@ @EqualsAndHashCode(callSuper = true) public class MetadataSyncResultEntity extends BaseRuntimeIdEntity { - private Long syncId; private MetadataType metadataType; 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 index e7f3dda4..4c2b8418 100644 --- 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 @@ -17,6 +17,11 @@ package org.apache.eventmesh.dashboard.console.entity.message; + +import org.apache.eventmesh.dashboard.common.enums.OperationRange.OperationRangeType; + +import java.time.LocalDateTime; + import lombok.Data; import lombok.EqualsAndHashCode; @@ -26,14 +31,20 @@ public class ConsumeOffsetEntity extends TopicOffsetEntity { private Long subscribeId; - private Long groupId; + private OperationRangeType operationRangeType; - private String groupName; + private Long rangeId; private Long consumeOffset; + private Integer queueIndex; + private Integer consumeRate; private Long delayNum; + /** + * + */ + private LocalDateTime resetTime; } 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/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/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/health/Health2Service.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/Health2Service.java index 5c938fcb..d1e55215 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; @@ -48,6 +52,8 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; +import javax.annotation.Nullable; + import lombok.Data; import lombok.Setter; import lombok.extern.slf4j.Slf4j; @@ -72,47 +78,49 @@ public class Health2Service { } } - - 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) { + public Thread newThread(@Nullable Runnable r) { return new Thread(r, "health-manager-" + counter.incrementAndGet()); } }); - @Setter private HealthDataService dataService; + private LocalDateTime beginTime = LocalDateTime.now(); + + 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()) { + log.info("cluster type:{} health class name is {}", clusterType, clazz.getSimpleName()); + map.put(clusterType, clazz); + } + } + @SuppressWarnings("AlibabaLowerCamelCaseVariableNaming") 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 {} , metadata type {} , {} ,{}", baseSyncBase.getClusterType(), + baseSyncBase.getClass().getSimpleName(), baseSyncBase.getId(), + abstractCreateSDKConfig.getUniqueKey()); + } } catch (Exception e) { log.error(e.getMessage(), e); } @@ -126,6 +134,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 +147,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 +155,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 +172,36 @@ private HealthCheckWrapper createHealthCheckWrapper(BaseSyncBase baseSyncBase, } public void executeAll() { + try { + this.doExecuteAll(); + } catch (Exception e) { + log.error(e.getMessage(), e); + } + } + + + public void doExecuteAll() { + 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()) { + healthExecutor.healthCheckResultEntityMap = wrapper.createHealthCheckResultEntityMap(); + healthCheckResultEntityList.addAll(healthExecutor.healthCheckResultEntityMap.values()); + } else { + healthCheckResultEntityList.add(wrapper.createHealthCheckResultEntity()); + healthExecutor.healthCheckResultEntity = wrapper.getHealthCheckResultEntity(); + } threadPoolExecutor.execute(() -> { try { @@ -183,13 +218,19 @@ public void executeAll() { } 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 +250,8 @@ static class DefaultHealthCheckCallback implements HealthCheckCallback { private HealthCheckResultEntity healthCheckResultEntity; + private Map healthCheckResultEntityMap; + @Override public void onSuccess() { healthCheckResultEntity.setResult(HealthCheckStatus.SUCCESS); @@ -220,7 +263,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 +275,7 @@ class HealthCheckWrapper { private AbstractHealthCheckService checkService; + private String address; private HealthCheckResultEntity healthCheckResultEntity = new HealthCheckResultEntity(); @@ -241,20 +284,41 @@ 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; } + @SuppressWarnings("AlibabaLowerCamelCaseVariableNaming") + 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) { - HealthCheckWrapper wrapper = (HealthCheckWrapper) object; + if (object instanceof HealthCheckWrapper wrapper) { return this.baseSyncBase.getId().equals(wrapper.getBaseSyncBase().getId()) && this.baseSyncBase.getClusterType() .equals(wrapper.getBaseSyncBase().getClusterType()); } @@ -266,6 +330,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/AbstractHealthCheckService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/health/check/AbstractHealthCheckService.java index 6123866b..16ec58ac 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 @@ -34,7 +34,7 @@ public abstract class AbstractHealthCheckService extends AbstractClientInfo { @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 index 29d331a0..fd69571d 100644 --- 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 @@ -1,19 +1,19 @@ - ## health -> 心跳分为 服务(runtime)心跳,topic心跳 - +> 心跳分为 服务(runtime)心跳,topic心跳 ## topic 心跳 + > 通过 topic 的读写,确认 存储节点的主功能正常。同时需要验证复制是否正常。验证复制是否监控的同时,可以验证 节点是否可以读写 #### 问题是:每个 存储的topic 方式不一样 ,同时 同步方式也不一样 + 1. RocketMQ 使用主从集群。同时使用 raft 集群 -2. Kafka 集群使用同样节点 +2. Kafka 集群使用同样节点 3. pulusr 使用 book 作为存储,只能检查book 4. redis 会用主从集群。 raft 集群 5. MySQL 主从 -6. eventmesh 是代理。需要每个 runtime 都发送,获得一次吗? - 1. 只需要从一个节点得到所有数据就行了。如果节点有问题。怎么办? - 2. 请求所有节点确认所有数据是正确的 +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/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..353f948b --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/AbstractReportEngine.java @@ -0,0 +1,132 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.ReportConfig.ReportEngineConfig; +import org.apache.eventmesh.dashboard.console.function.report.annotation.AbstractReportMetaHandler; +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; +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 ReportEngineConfig reportEngineConfig; + protected XMLLanguageDriver xmlLanguageDriver = new XMLLanguageDriver(); + private VelocityEngine velocityEngine; + private Configuration configuration = new Configuration(); + private Map> stringSqlSourceMap = new HashMap<>(); + 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(); + + @Deprecated + 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(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(ReportMetaData reportMetaData, 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); + String stringBuilder = ""; + return this.xmlLanguageDriver.createSqlSource(configuration, stringBuilder, 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..0a8007c0 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/ReportConfig.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.function.report; + +import java.util.List; + +import lombok.Data; + +@Data +public class ReportConfig { + + private boolean initAllTables = false; + + private ReportEngineConfig defaultConfig; + + private List reportEngineConfigList; + + private String url; + + private String username; + + private String password; + + @Data + public static class ReportEngineConfig { + + private String name; + + 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..21c6cc09 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/ReportEngine.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; + +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; +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); + + + default void batchInsert(Map> data) { + data.forEach(this::batchInsert); + } + + void deleteData(); + + void createReportHandler(ReportMetaData reportMetaData, 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..3053e6be --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/ReportHandler.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.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..6f172c9a --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/function/report/ReportHandlerManage.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.report; + +import org.apache.eventmesh.dashboard.common.util.ClasspathScanner; +import org.apache.eventmesh.dashboard.console.function.report.ReportConfig.ReportEngineConfig; +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.collect.CollectManage; +import org.apache.eventmesh.dashboard.console.function.report.collect.MetadataDataManage; +import org.apache.eventmesh.dashboard.console.function.report.iotdb.IotDBReportEngine; +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.ArrayUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.reflect.FieldUtils; + +import java.lang.reflect.Field; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.ZoneId; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +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.ScheduledExecutorService; +import java.util.concurrent.ScheduledThreadPoolExecutor; +import java.util.concurrent.TimeUnit; + +import com.google.common.base.CaseFormat; + +import lombok.Getter; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; + +/** + * 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. 如果同时支持批量与单个,那么 前端需要提供连个 + */ +@Slf4j +public class ReportHandlerManage { + + private static final Map> engineClasses = new HashMap<>(); + + static { + engineClasses.put("iotdb", IotDBReportEngine.class); + } + + private final ScheduledExecutorService scheduledExecutorService = new ScheduledThreadPoolExecutor(10); + private final Map, String> clazzToTableName = new HashMap<>(); + private final CollectManage collectManage = new CollectManage(); + private final MetadataDataManage metadataDataManage = new MetadataDataManage(); + private Map reportEngineMap = new HashMap<>(); + @Setter + private ReportEngine reportEngine; + @Getter + private Map reportMetaDataMap = new HashMap<>(); + @Getter + private Map aggregationMetaDataMap = new HashMap<>(); + @Setter + private ReportConfig reportConfig; + + @Setter + private boolean enable = true; + + public void init() { + this.handlerConfig(); + 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); + } + if (!this.enable) { + return; + } + + this.metadataDataManage.init(this.reportConfig.getUrl(), this.reportConfig.getUsername(), this.reportConfig.getPassword()); + scheduledExecutorService.scheduleAtFixedRate(this.collectManage::request, 5, 5, TimeUnit.SECONDS); + + scheduledExecutorService.scheduleAtFixedRate(this::handlerData, 5, 5, TimeUnit.SECONDS); + + scheduledExecutorService.scheduleAtFixedRate(this.metadataDataManage::syncData, 5, 100, TimeUnit.MINUTES); + + this.buildDeleteDataTask(); + this.ddlHandler(); + } + + private void buildDeleteDataTask() { + LocalDate current = LocalDate.now().plusDays(1); + LocalDateTime nextTime = LocalDateTime.of(current, LocalTime.of(3, 0)); + long executeTime = nextTime.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(); + scheduledExecutorService.scheduleAtFixedRate(this::deleteDataTask, executeTime, 1000 * 60 * 60 * 24, TimeUnit.MINUTES); + } + + private void deleteDataTask() { + this.reportEngineMap.forEach((k, v) -> { + try { + long start = System.currentTimeMillis(); + v.deleteData(); + long end = System.currentTimeMillis(); + log.info("{} delete data cost {} ms", k, end - start); + } catch (Exception e) { + log.error(e.getMessage(), e); + } + }); + } + + private void handlerConfig() { + this.reportEngine = this.createEngine(this.reportConfig.getDefaultConfig()); + if (Objects.isNull(this.reportConfig.getReportEngineConfigList())) { + return; + } + this.reportConfig.getReportEngineConfigList().forEach(this::createEngine); + } + + private AbstractReportEngine createEngine(ReportEngineConfig reportEngineConfig) { + if (Objects.isNull(reportEngineConfig)) { + return null; + } + Class clazz = engineClasses.get(reportEngineConfig.getEngineType()); + try { + AbstractReportEngine reportEngine = (AbstractReportEngine) clazz.newInstance(); + reportEngine.setReportEngineConfig(reportEngineConfig); + reportEngineMap.put(reportEngineConfig.getName(), reportEngine); + return reportEngine; + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + private void ddlHandler() { + if (!this.reportConfig.isInitAllTables()) { + return; + } + this.reportEngineMap.forEach((k, v) -> { + v.createReport("*"); + }); + } + + /** + * 后期再支持多存储与多数据 + */ + private void handlerData() { + List