Compare commits

...

143 Commits

Author SHA1 Message Date
EricZeng
65499443c2 Merge pull request #590 from didi/master
默认用户名密码调整说明
2022-09-15 16:21:36 +08:00
zengqiao
993afa4c19 默认用户名密码调整说明 2022-09-15 16:20:13 +08:00
EricZeng
6515dd28aa Merge pull request #589 from didi/master
合并主分支
2022-09-15 15:54:09 +08:00
EricZeng
028d891c32 Merge pull request #588 from didi/dev_v3.0.0-beta.2
合并v3.0.0 beta.2
2022-09-15 15:46:58 +08:00
zengqiao
0df55ec22d 更新3.0.0-beta.2升级手册 2022-09-15 15:23:29 +08:00
zengqiao
579f64774d 更新3.0.0-beta.2变更说明 2022-09-15 15:20:50 +08:00
EricZeng
e4fb02fcda Merge pull request #587 from didi/dev
合并开发分支
2022-09-15 14:35:00 +08:00
EricZeng
dba671fd1e Merge pull request #586 from GraceWalk/dev
Dev
2022-09-15 13:49:04 +08:00
GraceWalk
80d1693722 fix: 修复单集群详情引导步骤定位错误的问题 2022-09-15 13:39:09 +08:00
GraceWalk
26014a11b2 feat: 补充前端打包构建部分文档说明 2022-09-15 13:36:09 +08:00
GraceWalk
848fddd55a fix: 切换依赖安装源为 taobao 镜像 2022-09-15 13:34:15 +08:00
EricZeng
97f5f05f1a Merge pull request #585 from didi/dev
更新单机部署文档
2022-09-15 13:05:14 +08:00
zengqiao
25b82810f2 更新单机部署文档 2022-09-15 13:01:33 +08:00
EricZeng
9b1e506fa7 Merge pull request #584 from didi/dev
修复日志表字段过短问题
2022-09-15 12:56:49 +08:00
zengqiao
7a42996e97 修复日志表字段过短问题 2022-09-15 12:55:06 +08:00
EricZeng
dbfcebcf67 Merge pull request #583 from didi/dev
合并开发分支
2022-09-15 12:38:11 +08:00
zengqiao
37c3f69a28 修复类型转化失败问题 2022-09-15 11:32:44 +08:00
zengqiao
5d412890b4 调整超时时间配置 2022-09-15 11:31:25 +08:00
zengqiao
1e318a4c40 修改默认的用户名密码 2022-09-15 11:31:03 +08:00
EricZeng
d4549176ec Merge pull request #566 from lomodays207/master
解决 java.lang.NumberFormatException: For input string: "{"value":0,"relation":"eq"}" 问题
2022-09-15 10:05:26 +08:00
lucasun
67ea4d44c8 Merge pull request #575 from GraceWalk/dev
同步前端代码
2022-09-13 15:13:02 +08:00
GraceWalk
fdae05a4aa fix: 登录页文案修改 2022-09-13 14:46:42 +08:00
GraceWalk
5efb837ee8 fix: 单集群详情样式优化 2022-09-13 14:46:29 +08:00
GraceWalk
584b626d93 fix: 修复 Broker Card 返回数据后依旧展示加载态的问题 2022-09-13 14:45:56 +08:00
GraceWalk
de25a4ed8e fix: 修复 Broker Card 返回数据后依旧展示加载态的问题 2022-09-13 14:45:27 +08:00
GraceWalk
2e852e5ca6 fix: 修复用户登出后回退还可以访问系统的问题 2022-09-13 14:44:18 +08:00
GraceWalk
b11000715a 修复 Topic Config 编辑表单不能正确回显当前值的问题 2022-09-13 14:43:35 +08:00
GraceWalk
b3f8b46f0f fix: 修复扩缩/迁移副本无法选中默认 Topic 的问题 & 迁移副本 Topic 迁移时间单位支持分钟粒度 2022-09-13 14:42:21 +08:00
GraceWalk
8d22a0664a fix: Broker 列表标识当前 Controller 2022-09-13 14:37:20 +08:00
GraceWalk
20756a3453 fix: 重置 Offset 部分 partationId 修改为 Select & Offset 数值限制 2022-09-13 14:35:23 +08:00
GraceWalk
c9b4d45a64 fix: 修复 Job 扩缩副本任务明细错误的问题 2022-09-13 14:31:45 +08:00
GraceWalk
83f7f5468b fix: 均衡历史列表样式重构 & 周期均衡场景化 & 立即均衡默认带入周期均衡参数 2022-09-13 14:30:03 +08:00
GraceWalk
59c042ad67 fix: Topic 列表趋势图优化 & 相关文案调整 2022-09-13 14:26:12 +08:00
GraceWalk
d550fc5068 fix: 修复 Consume 点击 Stop 后未停止请求发送的问题 2022-09-13 14:24:30 +08:00
GraceWalk
6effba69a0 feat: 补充 ReBalance 和 Topic 部分权限项 2022-09-13 14:22:50 +08:00
GraceWalk
9b46956259 fix: Topic 详情 Partition Tab 卡片模式展示优化 2022-09-13 14:18:17 +08:00
GraceWalk
b5a4a732da fix: 健康分设置问题修复 2022-09-13 14:15:15 +08:00
GraceWalk
487862367e feat: 多集群列表支持编辑 & 代码结构优化 2022-09-13 14:14:15 +08:00
GraceWalk
5b63b9ce67 feat: 左侧栏内容调整 2022-09-13 14:12:34 +08:00
GraceWalk
afbcd3e1df fix: Broker/Topic 图表详情 bugfix & 体验优化 2022-09-13 14:09:57 +08:00
GraceWalk
12b82c1395 fix: 图表展示 bugifx & 优化 2022-09-13 14:09:03 +08:00
GraceWalk
863b765e0d feat: 新增 RenderEmpty 组件 2022-09-13 14:04:55 +08:00
GraceWalk
731429c51c fix: 系统管理子应用补充返回 code 码拦截逻辑 2022-09-13 11:44:47 +08:00
GraceWalk
66f3bc61fe fix: 创建/编辑角色优化 2022-09-13 11:44:08 +08:00
GraceWalk
4efe35dd51 fix: 项目打包构建流程优化 & 补充说明 2022-09-13 11:43:30 +08:00
EricZeng
c92461ef93 Merge pull request #565 from didi/dev
合并开发分支
2022-09-12 05:53:34 +08:00
wangdongfang-aden
2e016800e0 Merge pull request #568 from wangdongfang-aden/dev
使用3.0.0-beta.1镜像
2022-09-09 15:18:36 +08:00
wangdongfang-aden
09f317b991 使用3.0.0-beta.1镜像 2022-09-09 15:17:02 +08:00
wangdongfang-aden
5a48cb1547 使用3.0.0-beta.1镜像 2022-09-09 15:16:33 +08:00
wangdongfang-aden
f632febf33 Update Chart.yaml 2022-09-09 15:15:56 +08:00
wangdongfang-aden
3c53467943 使用3.0.0-beta.1镜像 2022-09-09 15:15:24 +08:00
qiubo
d358c0f4f7 修复ES total 查询转换异常问题 2022-09-09 10:22:26 +08:00
zengqiao
de977a5b32 加快添加集群后的信息获取的速度 2022-09-08 14:21:26 +08:00
zengqiao
703d685d59 Task任务分为metrics,common,metaddata三类,每一类任务的执行对应一个线程池,减少对Job模块线程池的依赖 2022-09-08 14:17:15 +08:00
zengqiao
31a5f17408 修复旧副本数为NULL的问题 2022-09-08 13:53:41 +08:00
zengqiao
c40ae3c455 增加副本变更任务结束后,进行优先副本选举的操作 2022-09-08 13:52:51 +08:00
zengqiao
b71a34279e 调整默认的权限 2022-09-08 13:50:08 +08:00
zengqiao
8f8c0c4eda 删除无效文件 2022-09-08 13:49:07 +08:00
zengqiao
3a384f0e34 优化重置Offset时的错误信息 2022-09-08 13:47:21 +08:00
zengqiao
cf7bc11cbd 增加登录系统对接文档 2022-09-08 13:46:45 +08:00
EricZeng
be60ae8399 Merge pull request #560 from didi/dev
合并开发分支
2022-09-07 14:20:04 +08:00
zengqiao
7a3d15525c 支持Ldap登录认证 2022-09-06 15:25:27 +08:00
zengqiao
64f32d8b24 bump logi-security version to 2.10.13 and logi-elasticsearch-client version to 1.0.24 2022-09-06 15:24:05 +08:00
zengqiao
949d6ba605 集群Broker列表,增加Controller角色信息 2022-09-06 15:22:57 +08:00
zengqiao
ceb8db09f4 优化查询Topic信息,Topic不存在时的错误提示 2022-09-06 15:21:53 +08:00
zengqiao
ed05a0ebb8 修复集群Group列表搜索反馈结果错误问题 2022-09-06 15:20:50 +08:00
zengqiao
a7cbb76655 修复Offset单位错误问题 2022-09-06 15:19:29 +08:00
zengqiao
93cbfa0b1f 后端增加页面权限点 2022-09-06 15:18:54 +08:00
zengqiao
6120613a98 Merge branch 'dev' of github.com:didi/KnowStreaming into dev 2022-09-06 15:15:14 +08:00
EricZeng
dbd00db159 Merge pull request #559 from didi/master
合并主分支
2022-09-06 15:14:18 +08:00
zengqiao
befde952f5 补充KS连接特定JMX IP的说明 2022-09-06 15:13:03 +08:00
zengqiao
1aa759e5be bump version to 3.0.0-beta.2 2022-09-06 10:25:14 +08:00
EricZeng
13354145fc Merge pull request #558 from didi/master
合并主分支
2022-09-05 17:08:51 +08:00
EricZeng
2de27719c1 Merge pull request #557 from didi/dev
合并开发分支
2022-09-05 17:07:51 +08:00
EricZeng
21db57b537 Merge pull request #556 from GraceWalk/dev
fix: 锁定 tree-changes 版本
2022-09-05 16:55:22 +08:00
GraceWalk
dfe8d09477 fix: 锁定 tree-changes 版本 2022-09-05 16:53:49 +08:00
EricZeng
90dfa22c64 Merge pull request #554 from WYAOBO/master
修复jmx,ip错误
2022-09-05 16:08:03 +08:00
wangyaobo
7909f60ff8 修复jmx ip选择错误 2022-09-05 15:40:01 +08:00
WYAOBO
9a1a8a4c30 Merge pull request #1 from didi/dev
Dev
2022-09-05 15:31:34 +08:00
EricZeng
0b376bd69c Merge pull request #552 from didi/master
合并主分支
2022-09-05 11:37:26 +08:00
EricZeng
8a0c23339d Merge pull request #551 from didi/dev
合并开发分支
2022-09-05 11:31:40 +08:00
zengqiao
e7ab3aff16 增加升级至v3.0.0-beta.1的内容 2022-09-05 11:29:38 +08:00
zengqiao
d0948797b9 增加v3.0.0-beta.1信息 2022-09-05 11:28:51 +08:00
EricZeng
04a5e17451 Merge pull request #550 from didi/dev
合并开发分支
2022-09-03 08:50:34 +08:00
zengqiao
47065c8042 文档名修改 2022-09-03 08:49:47 +08:00
EricZeng
488c778736 Merge pull request #548 from WYAOBO/master
新增task使用文档
2022-09-03 08:46:43 +08:00
EricZeng
d10a7bcc75 Merge pull request #549 from didi/dev
合并开发分支
2022-09-03 08:42:57 +08:00
zengqiao
afe44a2537 自动创建ES索引 & 主动填补指标历史曲线缺少的点 2022-09-03 08:34:32 +08:00
zengqiao
9eadafe850 健康巡检交由KS线程进行执行 2022-09-03 08:32:33 +08:00
zengqiao
dab3eefcc0 调整超时时间 2022-09-03 08:31:46 +08:00
zengqiao
2b9a6b28d8 消费组信息获取时不包含认证信息 2022-09-03 08:31:06 +08:00
zengqiao
465f98ca2b 日志错误信息中补充Topic名称信息 2022-09-03 08:28:38 +08:00
zengqiao
a0312be4fd Jmx连接的主机IP支持可选择 2022-09-03 08:26:50 +08:00
WYAOBO
4a5161372b Update KnowStreaming Task模块简介.md 2022-09-02 18:06:06 +08:00
WYAOBO
4c9921f752 Update KnowStreaming Task模块简介.md 2022-09-02 18:05:10 +08:00
WYAOBO
6dd72d40ee Update KnowStreaming Task模块简介.md 2022-09-02 18:04:14 +08:00
WYAOBO
db49c234bb Update KnowStreaming Task模块简介.md 2022-09-02 18:03:09 +08:00
WYAOBO
4a9df0c4d9 Update KnowStreaming Task模块简介.md 2022-09-02 18:02:21 +08:00
wangyaobo
461573c2ba task文档 2022-09-02 17:57:56 +08:00
wangyaobo
291992753f 文档更新 2022-09-02 17:28:18 +08:00
wangyaobo
fcefe7ac38 文档 2022-09-02 17:19:44 +08:00
zengqiao
7da712fcff 文案错误订正 2022-09-02 14:56:11 +08:00
zengqiao
2fd8687624 补充数据库错误说明 2022-09-02 14:55:02 +08:00
EricZeng
639b1f8336 Merge pull request #542 from didi/dev
前端优化
2022-09-02 12:46:04 +08:00
EricZeng
ab3b83e42a Merge pull request #539 from ruanliang-hualun/dev
备注与实现不一致,优先使用EXTERNAL_KEY
2022-09-02 12:42:30 +08:00
lucasun
4818629c40 Merge pull request #541 from GraceWalk/dev
前端代码打包优化 & bug 修复
2022-09-02 11:08:05 +08:00
ruanliang01
61784c860a 备注与实现不一致,优先使用EXTERNAL_KEY 2022-09-01 21:07:15 +08:00
GraceWalk
d5667254f2 fix: 样式 & 文案细节优化 2022-09-01 19:51:27 +08:00
GraceWalk
af2b93983f fix: 修正均衡卡片展示状态 2022-09-01 19:50:36 +08:00
GraceWalk
8281301cbd fix: 修复 Consumer 点击 Stop 不发停止检索问题修复 2022-09-01 19:50:04 +08:00
GraceWalk
0043ab8371 feat: 优化前端打包体积 2022-09-01 19:46:50 +08:00
GraceWalk
500eaace82 feat: 前端打包增加分包策略 2022-09-01 19:44:37 +08:00
GraceWalk
28e8540c78 fix: 修复创建/编辑角色报错的问题 2022-09-01 19:43:33 +08:00
EricZeng
69adf682e2 Merge pull request #537 from didi/dev
开发合入主分支
2022-09-01 17:06:32 +08:00
EricZeng
69cd1ff6e1 Merge pull request #536 from didi/master
合并主分支
2022-09-01 17:02:32 +08:00
EricZeng
415d67cc32 Merge pull request #535 from chaixiaoxue/dev
Fix page does not take effect
2022-09-01 16:51:32 +08:00
TinoC
46a2fec79b Fix page does not take effect 2022-09-01 16:35:30 +08:00
EricZeng
560b322fca Merge pull request #532 from Strangevy/dev_v3.0.0
Modify the default value of logi_security_oplog.operation_methods
2022-09-01 13:34:09 +08:00
Strangevy
effe17ac85 logi_security_oplog.operation_methods default '' 2022-09-01 10:28:00 +08:00
EricZeng
7699acfc1b Merge pull request #531 from didi/dev_v3.0.0
1、后端补充leader选举能力;2、图片链接调整;3、健康检查文案调整;4、版本列表增加排序;5、指标采集缓存时间调整;
2022-08-31 19:29:46 +08:00
zengqiao
6e058240b3 指标采集缓存时间调整 2022-08-31 17:15:49 +08:00
zengqiao
f005c6bc44 版本列表增加排序 2022-08-31 17:14:56 +08:00
zengqiao
7be462599f 健康检查文案调整 2022-08-31 17:13:18 +08:00
zengqiao
271ab432d9 图片链接调整 2022-08-31 17:12:34 +08:00
zengqiao
4114777a4e 补充leader选举能力 2022-08-31 17:11:12 +08:00
Peng
9189a54442 Update README.md 2022-08-30 21:56:43 +08:00
EricZeng
b95ee762e3 Merge pull request #529 from didi/dev_v3.0.0
解决raft集群controller信息不断记录问题
2022-08-30 19:42:06 +08:00
zengqiao
9e3c4dc06b 解决raft集群controller信息不断记录问题 2022-08-30 19:39:15 +08:00
EricZeng
1891a3ac86 Merge pull request #526 from yzydtc/dev_v3.0.0
[KnowStreaming-524] fix one markdown link 404 not found
2022-08-30 14:53:22 +08:00
zhiyuan.yang
9ecdcac06d [KnowStreaming-524] fix one markdown link 404 not found 2022-08-30 14:47:54 +08:00
EricZeng
790cb6a2e1 Merge pull request #521 from didi/dev_v3.0.0
1、bump version;2、ES客户端数可配置化;3、采样优化;4、文档修改;
2022-08-30 13:36:36 +08:00
EricZeng
4a98e5f025 Merge pull request #520 from didi/dev_v3.0.0
1、删除无效字段;2、日志优化;
2022-08-29 20:33:55 +08:00
zengqiao
507abc1d84 bump version 2022-08-29 20:32:41 +08:00
zengqiao
9b732fbbad ES客户端数可配置化 2022-08-29 20:32:01 +08:00
zengqiao
220f1c6fc3 采样优化 2022-08-29 20:31:34 +08:00
zengqiao
7a950c67b6 文档修改 2022-08-29 20:30:47 +08:00
zengqiao
78f625dc8c 日志优化 2022-08-29 16:45:48 +08:00
zengqiao
211d26a3ed 删除无效字段 2022-08-29 16:44:53 +08:00
EricZeng
dce2bc6326 Merge pull request #519 from didi/master
合并主分支
2022-08-29 16:24:02 +08:00
EricZeng
90e5d7f6f0 Merge pull request #516 from didi/v3.0.0-beta
V3.0.0 beta
2022-08-28 14:07:14 +08:00
Peng
fc835e09c6 Update README.md 2022-08-28 06:10:24 +08:00
Peng
c6e782a637 Update README.md 2022-08-28 06:09:59 +08:00
Peng
1ddfbfc833 Update README.md 2022-08-28 06:09:17 +08:00
209 changed files with 41892 additions and 2022 deletions

View File

@@ -133,3 +133,7 @@ PS: 提问请尽量把问题一次性描述清楚,并告知环境信息情况
**`2、微信群`** **`2、微信群`**
微信加群:添加`mike_zhangliang``PenceXie`的微信号备注KnowStreaming加群。 微信加群:添加`mike_zhangliang``PenceXie`的微信号备注KnowStreaming加群。
## Star History
[![Star History Chart](https://api.star-history.com/svg?repos=didi/KnowStreaming&type=Date)](https://star-history.com/#didi/KnowStreaming&Date)

View File

@@ -1,6 +1,98 @@
## v3.0.0-beta ## v3.0.0-beta.2
**文档**
- 新增登录系统对接文档
- 优化前端工程打包构建部分文档说明
- FAQ补充KnowStreaming连接特定JMX IP的说明
**Bug修复**
- 修复logi_security_oplog表字段过短导致删除Topic等操作无法记录的问题
- 修复ES查询时抛java.lang.NumberFormatException: For input string: "{"value":0,"relation":"eq"}" 问题
- 修复LogStartOffset和LogEndOffset指标单位错误问题
- 修复进行副本变更时旧副本数为NULL的问题
- 修复集群Group列表在第二页搜索时搜索时返回的分页信息错误问题
- 修复重置Offset时返回的错误信息提示不一致的问题
- 修复集群查看系统查看LoadRebalance等页面权限点缺失问题
- 修复查询不存在的Topic时错误信息提示不明显的问题
- 修复Windows用户打包前端工程报错的问题
- package-lock.json锁定前端依赖版本号修复因依赖自动升级导致打包失败等问题
- 系统管理子应用补充后端返回的Code码拦截解决后端接口返回报错不展示的问题
- 修复用户登出后,依旧可以访问系统的问题
- 修复巡检任务配置时,数值显示错误的问题
- 修复Broker/Topic Overview 图表和图表详情问题
- 修复Job扩缩副本任务明细数据错误的问题
- 修复重置Offset时分区IDOffset数值无限制问题
- 修复扩缩/迁移副本时无法选中Kafka系统Topic的问题
- 修复Topic的Config页面编辑表单时不能正确回显当前值的问题
- 修复Broker Card返回数据后依旧展示加载态的问题
**体验优化**
- 优化默认用户密码为 admin/admin
- 缩短新增集群后,集群信息加载的耗时
- 集群Broker列表增加Controller角色信息
- 副本变更任务结束后,增加进行优先副本选举的操作
- Task模块任务分为Metrics、Common、Metadata三类任务每类任务配备独立线程池减少对Job模块的线程池以及不同类任务之间的相互影响
- 删除代码中存在的多余无用文件
- 自动新增ES索引模版及近7天索引减少用户搭建时需要做的事项
- 优化前端工程打包流程
- 优化登录页文案页面左侧栏内容单集群详情样式Topic列表趋势图等
- 首次进入Broker/Topic图表详情时进行预缓存数据从而优化体验
- 优化Topic详情Partition Tab的展示
- 多集群列表页增加编辑功能
- 优化副本变更时,迁移时间支持分钟级别粒度
- logi-security版本升级至2.10.13
- logi-elasticsearch-client版本升级至1.0.24
**能力提升**
- 支持Ldap登录认证
---
## v3.0.0-beta.1
**文档**
- 新增Task模块说明文档
- FAQ补充 `Specified key was too long; max key length is 767 bytes ` 错误说明
- FAQ补充 `出现ESIndexNotFoundException报错` 错误说明
**Bug修复**
- 修复 Consumer 点击 Stop 未停止检索的问题
- 修复创建/编辑角色权限报错问题
- 修复多集群管理/单集群详情均衡卡片状态错误问题
- 修复版本列表未排序问题
- 修复Raft集群Controller信息不断记录问题
- 修复部分版本消费组描述信息获取失败问题
- 修复分区Offset获取失败的日志中缺少Topic名称信息问题
- 修复GitHub图地址错误及图裂问题
- 修复Broker默认使用的地址和注释不一致问题
- 修复 Consumer 列表分页不生效问题
- 修复操作记录表operation_methods字段缺少默认值问题
- 修复集群均衡表中move_broker_list字段无效的问题
- 修复KafkaUser、KafkaACL信息获取时日志一直重复提示不支持问题
- 修复指标缺失时,曲线出现掉底的问题
**体验优化**
- 优化前端构建时间和打包体积,增加依赖打包的分包策略
- 优化产品样式和文案展示
- 优化ES客户端数为可配置
- 优化日志中大量出现的MySQL Key冲突日志
**能力提升**
- 增加周期任务用于主动创建缺少的ES模版及索引的能力减少额外的脚本操作
- 增加JMX连接的Broker地址可选择的能力
---
## v3.0.0-beta.0
**1、多集群管理** **1、多集群管理**

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 183 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 59 KiB

View File

@@ -0,0 +1,264 @@
# Task模块简介
## 1、Task简介
在 KnowStreaming 中(下面简称KS)Task模块主要是用于执行一些周期任务包括Cluster、Broker、Topic等指标的定时采集集群元数据定时更新至DB集群状态的健康巡检等。在KS中与Task模块相关的代码我们都统一存放在km-task模块中。
Task模块是基于 LogiCommon 中的Logi-Job组件实现的任务周期执行Logi-Job 的功能类似 XXX-Job它是 XXX-Job 在 KnowStreaming 的内嵌实现,主要用于简化 KnowStreaming 的部署。
Logi-Job 的任务总共有两种执行模式,分别是:
+ 广播模式同一KS集群下同一任务周期中所有KS主机都会执行该定时任务。
+ 抢占模式同一KS集群下同一任务周期中仅有某一台KS主机会执行该任务。
KS集群范围定义连接同一个DB且application.yml中的spring.logi-job.app-name的名称一样的KS主机为同一KS集群。
## 2、使用指南
Task模块基于Logi-Job的广播模式与抢占模式分别实现了任务的抢占执行、重复执行以及均衡执行他们之间的差别是
+ 抢占执行同一个KS集群同一个任务执行周期中仅有一台KS主机执行该任务
+ 重复执行同一个KS集群同一个任务执行周期中所有KS主机都执行该任务。比如3台KS主机3个Kafka集群此时每台KS主机都会去采集这3个Kafka集群的指标
+ 均衡执行同一个KS集群同一个任务执行周期中每台KS主机仅执行该任务的一部分所有的KS主机共同协作完成了任务。比如3台KS主机3个Kafka集群稳定运行情况下每台KS主机将仅采集1个Kafka集群的指标3台KS主机共同完成3个Kafka集群指标的采集。
下面我们看一下具体例子。
### 2.1、抢占模式——抢占执行
功能说明:
+ 同一个KS集群同一个任务执行周期中仅有一台KS主机执行该任务。
代码例子:
```java
// 1、实现Job接口重写excute方法
// 2、在类上添加@Task注解并且配置好信息指定为随机抢占模式
// 效果KS集群中每5秒会有一台KS主机输出 "测试定时任务运行中"
@Task(name = "TestJob",
description = "测试定时任务",
cron = "*/5 * * * * ?",
autoRegister = true,
consensual = ConsensualEnum.RANDOM, // 这里一定要设置为RANDOM
timeout = 6 * 60)
public class TestJob implements Job {
@Override
public TaskResult execute(JobContext jobContext) throws Exception {
System.out.println("测试定时任务运行中");
return new TaskResult();
}
}
```
### 2.2、广播模式——重复执行
功能说明:
+ 同一个KS集群同一个任务执行周期中所有KS主机都执行该任务。比如3台KS主机3个Kafka集群此时每台KS主机都会去重复采集这3个Kafka集群的指标。
代码例子:
```java
// 1、实现Job接口重写excute方法
// 2、在类上添加@Task注解并且配置好信息指定为广播抢占模式
// 效果KS集群中每5秒每台KS主机都会输出 "测试定时任务运行中"
@Task(name = "TestJob",
description = "测试定时任务",
cron = "*/5 * * * * ?",
autoRegister = true,
consensual = ConsensualEnum.BROADCAST, // 这里一定要设置为BROADCAST
timeout = 6 * 60)
public class TestJob implements Job {
@Override
public TaskResult execute(JobContext jobContext) throws Exception {
System.out.println("测试定时任务运行中");
return new TaskResult();
}
}
```
### 2.3、广播模式——均衡执行
功能说明:
+ 同一个KS集群同一个任务执行周期中每台KS主机仅执行该任务的一部分所有的KS主机共同协作完成了任务。比如3台KS主机3个Kafka集群稳定运行情况下每台KS主机将仅采集1个Kafka集群的指标3台KS主机共同完成3个Kafka集群指标的采集。
代码例子:
+ 该模式有点特殊是KS基于Logi-Job的广播模式做的一个扩展以下为一个使用例子
```java
// 1、继承AbstractClusterPhyDispatchTask实现processSubTask方法
// 2、在类上添加@Task注解并且配置好信息指定为广播模式
// 效果在本样例中每隔1分钟ks会将所有的kafka集群列表在ks集群主机内均衡拆分每台主机会将分发到自身的Kafka集群依次执行processSubTask方法,实现KS集群的任务协同处理。
@Task(name = "kmJobTask",
description = "km job 模块调度执行任务",
cron = "0 0/1 * * * ? *",
autoRegister = true,
consensual = ConsensualEnum.BROADCAST,
timeout = 6 * 60)
public class KMJobTask extends AbstractClusterPhyDispatchTask {
@Autowired
private JobService jobService;
@Override
protected TaskResult processSubTask(ClusterPhy clusterPhy, long triggerTimeUnitMs) throws Exception {
jobService.scheduleJobByClusterId(clusterPhy.getId());
return TaskResult.SUCCESS;
}
}
```
## 3、原理简介
### 3.1、Task注解说明
```java
public @interface Task {
String name() default ""; //任务名称
String description() default ""; //任务描述
String owner() default "system"; //拥有者
String cron() default ""; //定时执行的时间策略
int retryTimes() default 0; //失败以后所能重试的最大次数
long timeout() default 0; //在超时时间里重试
//是否自动注册任务到数据库中
//如果设置为false需要手动去数据库km_task表注册定时任务信息。数据库记录和@Task注解缺一不可
boolean autoRegister() default false;
//执行模式:广播、随机抢占
//广播模式:同一集群下的所有服务器都会执行该定时任务
//随机抢占模式:同一集群下随机一台服务器执行该任务
ConsensualEnum consensual() default ConsensualEnum.RANDOM;
}
```
### 3.2、数据库表介绍
+ logi_task记录项目中的定时任务信息一个定时任务对应一条记录。
+ logi_job具体任务执行信息。
+ logi_job_log定时任务的执行日志。
+ logi_worker记录机器信息实现集群控制。
### 3.3、均衡执行简介
#### 3.3.1、类关系图
这里以KMJobTask为例简单介绍KM中的定时任务实现逻辑。
![img](http://img-ys011.didistatic.com/static/dc2img/do1_knC85EtQ8Vbn1BcBzcjz)
+ Job使用logi组件实现定时任务必须实现该接口。
+ Comparable & EntufyIdInterface比较接口实现任务的排序逻辑。
+ AbstractDispatchTask实现广播模式下任务的均衡分发。
+ AbstractClusterPhyDispatchTask对分发到当前服务器的集群列表进行枚举。
+ KMJobTask:实现对单个集群的定时任务处理。
#### 3.3.2、关键类代码
+ **AbstractDispatchTask类**
```java
// 实现Job接口的抽象类进行任务的负载均衡执行
public abstract class AbstractDispatchTask<E extends Comparable & EntifyIdInterface> implements Job {
// 罗列所有的任务
protected abstract List<E> listAllTasks();
// 执行被分配给该KS主机的任务
protected abstract TaskResult processTask(List<E> subTaskList, long triggerTimeUnitMs);
// 被Logi-Job触发执行该方法
// 该方法进行任务的分配
@Override
public TaskResult execute(JobContext jobContext) {
try {
long triggerTimeUnitMs = System.currentTimeMillis();
// 获取所有的任务
List<E> allTaskList = this.listAllTasks();
// 计算当前KS机器需要执行的任务
List<E> subTaskList = this.selectTask(allTaskList, jobContext.getAllWorkerCodes(), jobContext.getCurrentWorkerCode());
// 进行任务处理
return this.processTask(subTaskList, triggerTimeUnitMs);
} catch (Exception e) {
// ...
}
}
}
```
+ **AbstractClusterPhyDispatchTask类**
```java
// 继承AbstractDispatchTask的抽象类对Kafka集群进行负载均衡执行
public abstract class AbstractClusterPhyDispatchTask extends AbstractDispatchTask<ClusterPhy> {
// 执行被分配的任务,具体由子类实现
protected abstract TaskResult processSubTask(ClusterPhy clusterPhy, long triggerTimeUnitMs) throws Exception;
// 返回所有的Kafka集群
@Override
public List<ClusterPhy> listAllTasks() {
return clusterPhyService.listAllClusters();
}
// 执行被分配给该KS主机的Kafka集群任务
@Override
public TaskResult processTask(List<ClusterPhy> subTaskList, long triggerTimeUnitMs) { // ... }
}
```
+ **KMJobTask类**
```java
// 加上@Task注解并配置任务执行信息
@Task(name = "kmJobTask",
description = "km job 模块调度执行任务",
cron = "0 0/1 * * * ? *",
autoRegister = true,
consensual = ConsensualEnum.BROADCAST,
timeout = 6 * 60)
// 继承AbstractClusterPhyDispatchTask类
public class KMJobTask extends AbstractClusterPhyDispatchTask {
@Autowired
private JobService jobService;
// 执行该Kafka集群的Job模块的任务
@Override
protected TaskResult processSubTask(ClusterPhy clusterPhy, long triggerTimeUnitMs) throws Exception {
jobService.scheduleJobByClusterId(clusterPhy.getId());
return TaskResult.SUCCESS;
}
}
```
#### 3.3.3、均衡执行总结
均衡执行的实现原理总结起来就是以下几点:
+ Logi-Job设置为广播模式触发所有的KS主机执行任务
+ 每台KS主机被触发执行后按照统一的规则对任务列表KS集群主机列表进行排序。然后按照顺序将任务列表均衡的分配给排序后的KS集群主机。KS集群稳定运行情况下这一步保证了每台KS主机之间分配到的任务列表不重复不丢失。
+ 最后每台KS主机执行被分配到的任务。
## 4、注意事项
+ 不能100%保证任务在一个周期内且仅且执行一次可能出现重复执行或丢失的情况所以必须严格是且仅且执行一次的任务不建议基于Logi-Job进行任务控制。
+ 尽量让Logi-Job仅负责任务的触发后续的执行建议放到自己创建的线程池中进行。

Binary file not shown.

Before

Width:  |  Height:  |  Size: 600 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 228 KiB

View File

@@ -36,7 +36,7 @@ KS-KM 根据其需要纳管的 kafka 版本,按照上述三个维度构建了
&emsp;&emsp;KS-KM 的每个版本针对需要纳管的 kafka 版本列表,事先分析各个版本的差异性和产品需求,同时 KS-KM 构建了一套专门处理兼容性的服务,来进行兼容性的注册、字典构建、处理器分发等操作,其中版本兼容性处理器是来具体处理不同 kafka 版本差异性的地方。 &emsp;&emsp;KS-KM 的每个版本针对需要纳管的 kafka 版本列表,事先分析各个版本的差异性和产品需求,同时 KS-KM 构建了一套专门处理兼容性的服务,来进行兼容性的注册、字典构建、处理器分发等操作,其中版本兼容性处理器是来具体处理不同 kafka 版本差异性的地方。
![registerHandler](./assets/multi_version_compatible/registerHandler.png) ![registerHandler](http://img-ys011.didistatic.com/static/dc2img/do1_WxVTzndYE59ah5DFrMfn)
&emsp;&emsp;如上图所示KS-KM 的 topic 服务在面对不同 kafka 版本时,其 topic 的创建、删除、扩容由于 kafka 版本自身的差异,导致 KnowStreaming 的处理也不一样,所以需要根据不同的 kafka 版本来实现不同的兼容性处理器,同时向 KnowStreaming 的兼容服务进行兼容性的注册,构建兼容性字典,后续在 KnowStreaming 的运行过程中,针对不同的 kafka 版本即可分发到不同的处理器中执行。 &emsp;&emsp;如上图所示KS-KM 的 topic 服务在面对不同 kafka 版本时,其 topic 的创建、删除、扩容由于 kafka 版本自身的差异,导致 KnowStreaming 的处理也不一样,所以需要根据不同的 kafka 版本来实现不同的兼容性处理器,同时向 KnowStreaming 的兼容服务进行兼容性的注册,构建兼容性字典,后续在 KnowStreaming 的运行过程中,针对不同的 kafka 版本即可分发到不同的处理器中执行。

View File

@@ -29,7 +29,7 @@
- 初始化 MySQL 表及数据 - 初始化 MySQL 表及数据
- 初始化 Elasticsearch 索引 - 初始化 Elasticsearch 索引
具体见:[快速开始](./1-quick-start.md) 中的最后一步,部署 KnowStreaming 服务中的初始化相关工作。 具体见:[单机部署手册](../install_guide/单机部署手册.md) 中的最后一步,部署 KnowStreaming 服务中的初始化相关工作。
### 6.1.4、本地启动 ### 6.1.4、本地启动
@@ -73,7 +73,7 @@ km-rest/src/main/java/com/xiaojukeji/know/streaming/km/rest/KnowStreaming.java
IDEA 更多具体的配置如下图所示: IDEA 更多具体的配置如下图所示:
<p align="center"> <p align="center">
<img src="./assets/startup_using_source_code/IDEA配置.jpg" width = "512" height = "318" div align=center /> <img src="http://img-ys011.didistatic.com/static/dc2img/do1_BW1RzgEMh4n6L4dL4ncl" width = "512" height = "318" div align=center />
</p> </p>
**第四步:启动项目** **第四步:启动项目**
@@ -84,7 +84,7 @@ IDEA 更多具体的配置如下图所示:
`Know Streaming` 启动之后,可以访问一些信息,包括: `Know Streaming` 启动之后,可以访问一些信息,包括:
- 产品页面http://localhost:8080 ,默认账号密码:`admin` / `admin2022_` 进行登录。 - 产品页面http://localhost:8080 ,默认账号密码:`admin` / `admin2022_` 进行登录。`v3.0.0-beta.2`版本开始,默认账号密码为`admin` / `admin`
- 接口地址http://localhost:8080/swagger-ui.html 查看后端提供的相关接口。 - 接口地址http://localhost:8080/swagger-ui.html 查看后端提供的相关接口。
更多信息,详见:[KnowStreaming 官网](https://knowstreaming.com/) 更多信息,详见:[KnowStreaming 官网](https://knowstreaming.com/)

View File

@@ -0,0 +1,199 @@
![Logo](https://user-images.githubusercontent.com/71620349/185368586-aed82d30-1534-453d-86ff-ecfa9d0f35bd.png)
## 登录系统对接
[KnowStreaming](https://github.com/didi/KnowStreaming)以下简称KS 除了实现基于本地MySQL的用户登录认证方式外还已经实现了基于Ldap的登录认证。
但是登录认证系统并非仅此两种。因此为了具有更好的拓展性KS具有自定义登陆认证逻辑快速对接已有系统的特性。
在KS中我们将登陆认证相关的一些文件放在[km-extends](https://github.com/didi/KnowStreaming/tree/master/km-extends)模块下的[km-account](https://github.com/didi/KnowStreaming/tree/master/km-extends/km-account)模块里。
本文将介绍KS如何快速对接自有的用户登录认证系统。
### 对接步骤
- 创建一个登陆认证类,实现[LogiCommon](https://github.com/didi/LogiCommon)的LoginExtend接口
- 将[application.yml](https://github.com/didi/KnowStreaming/blob/master/km-rest/src/main/resources/application.yml)中的spring.logi-security.login-extend-bean-name字段改为登陆认证类的bean名称
```Java
//LoginExtend 接口
public interface LoginExtend {
/**
* 验证登录信息,同时记住登录状态
*/
UserBriefVO verifyLogin(AccountLoginDTO var1, HttpServletRequest var2, HttpServletResponse var3) throws LogiSecurityException;
/**
* 登出接口,清楚登录状态
*/
Result<Boolean> logout(HttpServletRequest var1, HttpServletResponse var2);
/**
* 检查是否已经登录
*/
boolean interceptorCheck(HttpServletRequest var1, HttpServletResponse var2, String var3, List<String> var4) throws IOException;
}
```
### 对接例子
我们以Ldap对接为例说明KS如何对接登录认证系统。
+ 编写[LdapLoginServiceImpl](https://github.com/didi/KnowStreaming/blob/master/km-extends/km-account/src/main/java/com/xiaojukeji/know/streaming/km/account/login/ldap/LdapLoginServiceImpl.java)类实现LoginExtend接口。
+ 设置[application.yml](https://github.com/didi/KnowStreaming/blob/master/km-rest/src/main/resources/application.yml)中的spring.logi-security.login-extend-bean-name=ksLdapLoginService。
完成上述两步即可实现KS对接Ldap认证登陆。
```Java
@Service("ksLdapLoginService")
public class LdapLoginServiceImpl implements LoginExtend {
@Override
public UserBriefVO verifyLogin(AccountLoginDTO loginDTO,
HttpServletRequest request,
HttpServletResponse response) throws LogiSecurityException {
String decodePasswd = AESUtils.decrypt(loginDTO.getPw());
// 去LDAP验证账密
LdapPrincipal ldapAttrsInfo = ldapAuthentication.authenticate(loginDTO.getUserName(), decodePasswd);
if (ldapAttrsInfo == null) {
// 用户不存在,正常来说上如果有问题,上一步会直接抛出异常
throw new LogiSecurityException(ResultCode.USER_NOT_EXISTS);
}
// 进行业务相关操作
// 记录登录状态Ldap因为无法记录登录状态因此有KnowStreaming进行记录
initLoginContext(request, response, loginDTO.getUserName(), user.getId());
return CopyBeanUtil.copy(user, UserBriefVO.class);
}
@Override
public Result<Boolean> logout(HttpServletRequest request, HttpServletResponse response) {
//清理cookie和session
return Result.buildSucc(Boolean.TRUE);
}
@Override
public boolean interceptorCheck(HttpServletRequest request, HttpServletResponse response, String requestMappingValue, List<String> whiteMappingValues) throws IOException {
// 检查是否已经登录
String userName = HttpRequestUtil.getOperator(request);
if (StringUtils.isEmpty(userName)) {
// 未登录,则进行登出
logout(request, response);
return Boolean.FALSE;
}
return Boolean.TRUE;
}
}
```
### 实现原理
因为登陆和登出整体实现逻辑是一致的,所以我们以登陆逻辑为例进行介绍。
+ 登陆原理
登陆走的是[LogiCommon](https://github.com/didi/LogiCommon)自带的LoginController。
```java
@RestController
public class LoginController {
//登陆接口
@PostMapping({"/login"})
public Result<UserBriefVO> login(HttpServletRequest request, HttpServletResponse response, @RequestBody AccountLoginDTO loginDTO) {
try {
//登陆认证
UserBriefVO userBriefVO = this.loginService.verifyLogin(loginDTO, request, response);
return Result.success(userBriefVO);
} catch (LogiSecurityException var5) {
return Result.fail(var5);
}
}
}
```
而登陆操作是调用LoginServiceImpl类来实现但是具体由哪个登陆认证类来执行登陆操作却由loginExtendBeanTool来指定。
```java
//LoginServiceImpl类
@Service
public class LoginServiceImpl implements LoginService {
//实现登陆操作但是具体哪个登陆类由loginExtendBeanTool来管理
public UserBriefVO verifyLogin(AccountLoginDTO loginDTO, HttpServletRequest request, HttpServletResponse response) throws LogiSecurityException {
return this.loginExtendBeanTool.getLoginExtendImpl().verifyLogin(loginDTO, request, response);
}
}
```
而loginExtendBeanTool类会优先去查找用户指定的登陆认证类如果失败则调用默认的登陆认证函数。
```java
//LoginExtendBeanTool类
@Component("logiSecurityLoginExtendBeanTool")
public class LoginExtendBeanTool {
public LoginExtend getLoginExtendImpl() {
LoginExtend loginExtend;
//先调用用户指定登陆类,如果失败则调用系统默认登陆认证
try {
//调用的类由spring.logi-security.login-extend-bean-name指定
loginExtend = this.getCustomLoginExtendImplBean();
} catch (UnsupportedOperationException var3) {
loginExtend = this.getDefaultLoginExtendImplBean();
}
return loginExtend;
}
}
```
+ 认证原理
认证的实现则比较简单向Spring中注册我们的拦截器PermissionInterceptor。
拦截器会调用LoginServiceImpl类的拦截方法LoginServiceImpl后续处理逻辑就和前面登陆是一致的。
```java
public class PermissionInterceptor implements HandlerInterceptor {
/**
* 拦截预处理
* @return boolean false:拦截, 不向下执行, true:放行
*/
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
//免登录相关校验,如果验证通过,提前返回
//走拦截函数,进行普通用户验证
return loginService.interceptorCheck(request, response, classRequestMappingValue, whiteMappingValues);
}
}
```

View File

@@ -1,25 +1,20 @@
![Logo](../assets/KnowStreamingLogo.png)
![Logo](https://user-images.githubusercontent.com/71620349/185368586-aed82d30-1534-453d-86ff-ecfa9d0f35bd.png)
## JMX-连接失败问题解决 ## JMX-连接失败问题解决
- [JMX-连接失败问题解决](#jmx-连接失败问题解决) 集群正常接入`KnowStreaming`之后即可以看到集群的Broker列表此时如果查看不了Topic的实时流量或者是Broker的实时流量信息时那么大概率就是`JMX`连接的问题了。
- [1、问题&说明](#1问题说明)
- [2、解决方法](#2解决方法)
- [3、解决方法 —— 认证的JMX](#3解决方法--认证的jmx)
集群正常接入Logi-KafkaManager之后即可以看到集群的Broker列表此时如果查看不了Topic的实时流量或者是Broker的实时流量信息时那么大概率就是JMX连接的问题了。
下面我们按照步骤来一步一步的检查。 下面我们按照步骤来一步一步的检查。
### 1、问题&说明 ### 1、问题说明
**类型一JMX配置未开启** **类型一JMX配置未开启**
未开启时,直接到`2、解决方法`查看如何开启即可。 未开启时,直接到`2、解决方法`查看如何开启即可。
![check_jmx_opened](./assets/connect_jmx_failed/check_jmx_opened.jpg) ![check_jmx_opened](http://img-ys011.didistatic.com/static/dc2img/do1_dRX6UHE2IUSHqsN95DGb)
**类型二:配置错误** **类型二:配置错误**
@@ -43,6 +38,26 @@ java.rmi.ConnectException: Connection refused to host: 192.168.0.1; nested excep
java.rmi.ConnectException: Connection refused to host: 127.0.0.1;; nested exception is: java.rmi.ConnectException: Connection refused to host: 127.0.0.1;; nested exception is:
``` ```
**类型三连接特定IP**
Broker 配置了内外网而JMX在配置时可能配置了内网IP或者外网IP此时 `KnowStreaming` 需要连接到特定网络的IP才可以进行访问。
比如:
Broker在ZK的存储结构如下所示我们期望连接到 `endpoints` 中标记为 `INTERNAL` 的地址,但是 `KnowStreaming` 却连接了 `EXTERNAL` 的地址,此时可以看 `4、解决方法 —— JMX连接特定网络` 进行解决。
```json
{
"listener_security_protocol_map": {"EXTERNAL":"SASL_PLAINTEXT","INTERNAL":"SASL_PLAINTEXT"},
"endpoints": ["EXTERNAL://192.168.0.1:7092","INTERNAL://192.168.0.2:7093"],
"jmx_port": 8099,
"host": "192.168.0.1",
"timestamp": "1627289710439",
"port": -1,
"version": 4
}
```
### 2、解决方法 ### 2、解决方法
这里仅介绍一下比较通用的解决方式,如若有更好的方式,欢迎大家指导告知一下。 这里仅介绍一下比较通用的解决方式,如若有更好的方式,欢迎大家指导告知一下。
@@ -76,26 +91,36 @@ fi
如果您是直接看的这个部分,建议先看一下上一节:`2、解决方法`以确保`JMX`的配置没有问题了。 如果您是直接看的这个部分,建议先看一下上一节:`2、解决方法`以确保`JMX`的配置没有问题了。
在JMX的配置等都没有问题的情况下如果是因为认证的原因导致连接不了的此时可以使用下面介绍的方法进行解决 `JMX`的配置等都没有问题的情况下,如果是因为认证的原因导致连接不了的,可以在集群接入界面配置你的`JMX`认证信息
**当前这块后端刚刚开发完成,可能还不够完善,有问题随时沟通。** <img src='http://img-ys011.didistatic.com/static/dc2img/do1_EUU352qMEX1Jdp7pxizp' width=350>
`Logi-KafkaManager 2.2.0+`之后的版本后端已经支持`JMX`认证方式的连接,但是还没有界面,此时我们可以往`cluster`表的`jmx_properties`字段写入`JMX`的认证信息。
这个数据是`json`格式的字符串,例子如下所示:
### 4、解决方法 —— JMX连接特定网络
可以手动往`ks_km_physical_cluster`表的`jmx_properties`字段增加一个`useWhichEndpoint`字段,从而控制 `KnowStreaming` 连接到特定的JMX IP及PORT。
`jmx_properties`格式:
```json ```json
{ {
"maxConn": 10, # KM对单台Broker的最大JMX连接数 "maxConn": 100, # KM对单台Broker的最大JMX连接数
"username": "xxxxx", # 用户名 "username": "xxxxx", # 用户名,可以不填写
"password": "xxxx", # 密码 "password": "xxxx", # 密码,可以不填写
"openSSL": true, # 开启SSL, true表示开启ssl, false表示关闭 "openSSL": true, # 开启SSL, true表示开启ssl, false表示关闭
"useWhichEndpoint": "EXTERNAL" #指定要连接的网络名称填写EXTERNAL就是连接endpoints里面的EXTERNAL地址
} }
``` ```
&nbsp; &nbsp;
SQL例子: SQL例子
```sql ```sql
UPDATE cluster SET jmx_properties='{ "maxConn": 10, "username": "xxxxx", "password": "xxxx", "openSSL": false }' where id={xxx}; UPDATE ks_km_physical_cluster SET jmx_properties='{ "maxConn": 10, "username": "xxxxx", "password": "xxxx", "openSSL": false , "useWhichEndpoint": "xxx"}' where id={xxx};
``` ```
注意:
+ 目前此功能只支持采用 `ZK` 做分布式协调的kafka集群。

View File

@@ -6,9 +6,10 @@
### 2.1.1、安装说明 ### 2.1.1、安装说明
-`v3.0.0-bete` 版本为例进行部署; -`v3.0.0-beta.1` 版本为例进行部署;
- 以 CentOS-7 为例,系统基础配置要求 4C-8G - 以 CentOS-7 为例,系统基础配置要求 4C-8G
- 部署完成后,可通过浏览器:`IP:PORT` 进行访问,默认端口是 `8080`,系统默认账号密码: `admin` / `admin2022_` - 部署完成后,可通过浏览器:`IP:PORT` 进行访问,默认端口是 `8080`,系统默认账号密码: `admin` / `admin2022_`
- `v3.0.0-beta.2`版本开始,默认账号密码为`admin` / `admin`
- 本文为单机部署,如需分布式部署,[请联系我们](https://knowstreaming.com/support-center) - 本文为单机部署,如需分布式部署,[请联系我们](https://knowstreaming.com/support-center)
**软件依赖** **软件依赖**
@@ -19,7 +20,7 @@
| ElasticSearch | v7.6+ | 8060 | | ElasticSearch | v7.6+ | 8060 |
| JDK | v8+ | - | | JDK | v8+ | - |
| CentOS | v6+ | - | | CentOS | v6+ | - |
| Ubantu | v16+ | - | | Ubuntu | v16+ | - |
&nbsp; &nbsp;
@@ -29,7 +30,7 @@
```bash ```bash
# 在服务器中下载安装脚本, 该脚本中会在当前目录下重新安装MySQL。重装后的mysql密码存放在当前目录的mysql.password文件中。 # 在服务器中下载安装脚本, 该脚本中会在当前目录下重新安装MySQL。重装后的mysql密码存放在当前目录的mysql.password文件中。
wget https://s3-gzpu.didistatic.com/pub/knowstreaming/deploy_KnowStreaming.sh wget https://s3-gzpu.didistatic.com/pub/knowstreaming/deploy_KnowStreaming-3.0.0-beta.1.sh
# 执行脚本 # 执行脚本
sh deploy_KnowStreaming.sh sh deploy_KnowStreaming.sh
@@ -42,10 +43,10 @@ sh deploy_KnowStreaming.sh
```bash ```bash
# 将安装包下载到本地且传输到目标服务器 # 将安装包下载到本地且传输到目标服务器
wget https://s3-gzpu.didistatic.com/pub/knowstreaming/KnowStreaming-3.0.0-betaoffline.tar.gz wget https://s3-gzpu.didistatic.com/pub/knowstreaming/KnowStreaming-3.0.0-beta.1-offline.tar.gz
# 解压安装包 # 解压安装包
tar -zxf KnowStreaming-3.0.0-betaoffline.tar.gz tar -zxf KnowStreaming-3.0.0-beta.1-offline.tar.gz
# 执行安装脚本 # 执行安装脚本
sh deploy_KnowStreaming-offline.sh sh deploy_KnowStreaming-offline.sh
@@ -62,24 +63,26 @@ sh deploy_KnowStreaming-offline.sh
- Kubernetes >= 1.14 Helm >= 2.17.0 - Kubernetes >= 1.14 Helm >= 2.17.0
- 默认配置为全部安装 ElasticSearch + MySQL + KnowStreaming - 默认依赖全部安装ElasticSearch3 节点集群模式) + MySQL(单机) + KnowStreaming-manager + KnowStreaming-ui
- 如果使用已有的 ElasticSearch(7.6.x) 和 MySQL(5.7) 只需调整 values.yaml 部分参数即可 - 使用已有的 ElasticSearch(7.6.x) 和 MySQL(5.7) 只需调整 values.yaml 部分参数即可
**安装命令** **安装命令**
```bash ```bash
# 下载安装包 # 相关镜像在Docker Hub都可以下载
wget https://s3-gzpu.didistatic.com/pub/knowstreaming/knowstreaming-3.0.0-hlem.tgz # 快速安装(NAMESPACE需要更改为已存在的安装启动需要几分钟初始化请稍等~)
helm install -n [NAMESPACE] [NAME] http://download.knowstreaming.com/charts/knowstreaming-manager-0.1.3.tgz
# 解压安装包
tar -zxf knowstreaming-3.0.0-hlem.tgz
# 执行命令(NAMESPACE需要更改为已存在的)
helm install -n [NAMESPACE] knowstreaming knowstreaming-manager/
# 获取KnowStreaming前端ui的service. 默认nodeport方式. # 获取KnowStreaming前端ui的service. 默认nodeport方式.
# (http://nodeIP:nodeport默认用户名密码admin/admin2022_) # (http://nodeIP:nodeport默认用户名密码admin/admin2022_)
# `v3.0.0-beta.2`版本开始,默认账号密码为`admin` / `admin`
# 添加仓库
helm repo add knowstreaming http://download.knowstreaming.com/charts
# 拉取最新版本
helm pull knowstreaming/knowstreaming-manager
``` ```
&nbsp; &nbsp;
@@ -219,10 +222,10 @@ sh /data/elasticsearch/control.sh status
```bash ```bash
# 下载安装包 # 下载安装包
wget https://s3-gzpu.didistatic.com/pub/knowstreaming/KnowStreaming-3.0.0-beta.tar.gz wget https://s3-gzpu.didistatic.com/pub/knowstreaming/KnowStreaming-3.0.0-beta.1.tar.gz
# 解压安装包到指定目录 # 解压安装包到指定目录
tar -zxf KnowStreaming-3.0.0-beta.tar.gz -C /data/ tar -zxf KnowStreaming-3.0.0-beta.1.tar.gz -C /data/
# 修改启动脚本并加入systemd管理 # 修改启动脚本并加入systemd管理
cd /data/KnowStreaming/ cd /data/KnowStreaming/
@@ -236,7 +239,7 @@ mysql -uroot -pDidi_km_678 know_streaming < ./init/sql/dml-ks-km.sql
mysql -uroot -pDidi_km_678 know_streaming < ./init/sql/dml-logi.sql mysql -uroot -pDidi_km_678 know_streaming < ./init/sql/dml-logi.sql
# 创建elasticsearch初始化数据 # 创建elasticsearch初始化数据
sh ./init/template/template.sh sh ./bin/init_es_template.sh
# 修改配置文件 # 修改配置文件
vim ./conf/application.yml vim ./conf/application.yml

View File

@@ -1,6 +1,4 @@
![Logo](https://user-images.githubusercontent.com/71620349/185368586-aed82d30-1534-453d-86ff-ecfa9d0f35bd.png)
![Logo](../assets/KnowStreamingLogo.png)
# `Know Streaming` 源码编译打包手册 # `Know Streaming` 源码编译打包手册
@@ -11,7 +9,7 @@
`windows7+``Linux``Mac` `windows7+``Linux``Mac`
**环境依赖** **环境依赖**
- Maven 3.6.3 (后端) - Maven 3.6.3 (后端)
- Node v12.20.0/v14.17.3 (前端) - Node v12.20.0/v14.17.3 (前端)
- Java 8+ (后端) - Java 8+ (后端)
@@ -25,27 +23,23 @@
具体见下面描述。 具体见下面描述。
### 2.1、前后端合并打包 ### 2.1、前后端合并打包
1. 下载源码; 1. 下载源码;
2. 进入 `KS-KM` 工程目录,执行 `mvn -Prelease-package -Dmaven.test.skip=true clean install -U` 命令; 2. 进入 `KS-KM` 工程目录,执行 `mvn -Prelease-package -Dmaven.test.skip=true clean install -U` 命令;
3. 打包命令执行完成后,会在 `km-dist/target` 目录下面生成一个 `KnowStreaming-*.tar.gz` 的安装包。 3. 打包命令执行完成后,会在 `km-dist/target` 目录下面生成一个 `KnowStreaming-*.tar.gz` 的安装包。
### 2.2、前端单独打包
### 2.2、前端单独打包
1. 下载源码; 1. 下载源码;
2. 进入 `KS-KM/km-console` 工程目录; 2. 跳转到 [前端打包构建文档](https://github.com/didi/KnowStreaming/blob/master/km-console/README.md) 按步骤进行。打包成功后,会在 `km-rest/src/main/resources` 目录下生成名为 `templates` 的前端静态资源包;
3. 执行 `npm run build`命令,会在 `KS-KM/km-console` 目录下生成一个名为 `pub` 的前端静态资源包; 3. 如果上一步过程中报错,请查看 [FAQ](https://github.com/didi/KnowStreaming/blob/master/docs/user_guide/faq.md) 第 8.10 条;
### 2.3、后端单独打包
### 2.3、后端单独打包
1. 下载源码; 1. 下载源码;
2. 修改顶层 `pom.xml` ,去掉其中的 `km-console` 模块,如下所示; 2. 修改顶层 `pom.xml` ,去掉其中的 `km-console` 模块,如下所示;
```xml ```xml
<modules> <modules>
<!-- <module>km-console</module>--> <!-- <module>km-console</module>-->
@@ -62,10 +56,7 @@
<module>km-rest</module> <module>km-rest</module>
<module>km-dist</module> <module>km-dist</module>
</modules> </modules>
``` ```
3. 执行 `mvn -U clean package -Dmaven.test.skip=true`命令; 3. 执行 `mvn -U clean package -Dmaven.test.skip=true`命令;
4. 执行完成之后会在 `KS-KM/km-rest/target` 目录下面生成一个 `ks-km.jar` 即为KS的后端部署的Jar包也可以执行 `mvn -Prelease-package -Dmaven.test.skip=true clean install -U` 生成的tar包也仅有后端服务的功能 4. 执行完成之后会在 `KS-KM/km-rest/target` 目录下面生成一个 `ks-km.jar` 即为 KS 的后端部署的 Jar 包,也可以执行 `mvn -Prelease-package -Dmaven.test.skip=true clean install -U` 生成的 tar 包也仅有后端服务的功能;

View File

@@ -1,6 +1,105 @@
## 6.2、版本升级手册 ## 6.2、版本升级手册
**`2.x`版本 升级至 `3.0.0`版本** 注意:如果想升级至具体版本,需要将你当前版本至你期望使用版本的变更统统执行一遍,然后才能正常使用。
### 6.2.0、升级至 `master` 版本
暂无
### 6.2.1、升级至 `v3.0.0-beta.2`版本
**配置变更**
```yaml
# 新增配置
spring:
logi-security: # know-streaming 依赖的 logi-security 模块的数据库的配置,默认与 know-streaming 的数据库配置保持一致即可
login-extend-bean-name: logiSecurityDefaultLoginExtendImpl # 使用的登录系统Service的Bean名称无需修改
# 线程池大小相关配置在task模块中新增了三类线程池
# 从而减少不同类型任务之间的相互影响以及减少对logi-job内的线程池的影响
thread-pool:
task: # 任务模块的配置
metrics: # metrics采集任务配置
thread-num: 18 # metrics采集任务线程池核心线程数
queue-size: 180 # metrics采集任务线程池队列大小
metadata: # metadata同步任务配置
thread-num: 27 # metadata同步任务线程池核心线程数
queue-size: 270 # metadata同步任务线程池队列大小
common: # 剩余其他任务配置
thread-num: 15 # 剩余其他任务线程池核心线程数
queue-size: 150 # 剩余其他任务线程池队列大小
# 删除配置,下列配置将不再使用
thread-pool:
task: # 任务模块的配置
heaven: # 采集任务配置
thread-num: 20 # 采集任务线程池核心线程数
queue-size: 1000 # 采集任务线程池队列大小
```
**SQL变更**
```sql
-- 多集群管理权限2022-09-06新增
INSERT INTO `logi_security_permission` (`id`, `permission_name`, `parent_id`, `leaf`, `level`, `description`, `is_delete`, `app_name`) VALUES ('2000', '多集群管理查看', '1593', '1', '2', '多集群管理查看', '0', 'know-streaming');
INSERT INTO `logi_security_permission` (`id`, `permission_name`, `parent_id`, `leaf`, `level`, `description`, `is_delete`, `app_name`) VALUES ('2002', 'Topic-迁移副本', '1593', '1', '2', 'Topic-迁移副本', '0', 'know-streaming');
INSERT INTO `logi_security_permission` (`id`, `permission_name`, `parent_id`, `leaf`, `level`, `description`, `is_delete`, `app_name`) VALUES ('2004', 'Topic-扩缩副本', '1593', '1', '2', 'Topic-扩缩副本', '0', 'know-streaming');
INSERT INTO `logi_security_permission` (`id`, `permission_name`, `parent_id`, `leaf`, `level`, `description`, `is_delete`, `app_name`) VALUES ('2006', 'Cluster-LoadReBalance-周期均衡', '1593', '1', '2', 'Cluster-LoadReBalance-周期均衡', '0', 'know-streaming');
INSERT INTO `logi_security_permission` (`id`, `permission_name`, `parent_id`, `leaf`, `level`, `description`, `is_delete`, `app_name`) VALUES ('2008', 'Cluster-LoadReBalance-立即均衡', '1593', '1', '2', 'Cluster-LoadReBalance-立即均衡', '0', 'know-streaming');
INSERT INTO `logi_security_permission` (`id`, `permission_name`, `parent_id`, `leaf`, `level`, `description`, `is_delete`, `app_name`) VALUES ('2010', 'Cluster-LoadReBalance-设置集群规格', '1593', '1', '2', 'Cluster-LoadReBalance-设置集群规格', '0', 'know-streaming');
-- 系统管理权限2022-09-06新增
INSERT INTO `logi_security_permission` (`id`, `permission_name`, `parent_id`, `leaf`, `level`, `description`, `is_delete`, `app_name`) VALUES ('3000', '系统管理查看', '1595', '1', '2', '系统管理查看', '0', 'know-streaming');
INSERT INTO `logi_security_role_permission` (`role_id`, `permission_id`, `is_delete`, `app_name`) VALUES ('1677', '2000', '0', 'know-streaming');
INSERT INTO `logi_security_role_permission` (`role_id`, `permission_id`, `is_delete`, `app_name`) VALUES ('1677', '2002', '0', 'know-streaming');
INSERT INTO `logi_security_role_permission` (`role_id`, `permission_id`, `is_delete`, `app_name`) VALUES ('1677', '2004', '0', 'know-streaming');
INSERT INTO `logi_security_role_permission` (`role_id`, `permission_id`, `is_delete`, `app_name`) VALUES ('1677', '2006', '0', 'know-streaming');
INSERT INTO `logi_security_role_permission` (`role_id`, `permission_id`, `is_delete`, `app_name`) VALUES ('1677', '2008', '0', 'know-streaming');
INSERT INTO `logi_security_role_permission` (`role_id`, `permission_id`, `is_delete`, `app_name`) VALUES ('1677', '2010', '0', 'know-streaming');
INSERT INTO `logi_security_role_permission` (`role_id`, `permission_id`, `is_delete`, `app_name`) VALUES ('1677', '3000', '0', 'know-streaming');
-- 修改字段长度
ALTER TABLE `logi_security_oplog`
CHANGE COLUMN `operator_ip` `operator_ip` VARCHAR(64) NOT NULL COMMENT '操作者ip' ,
CHANGE COLUMN `operator` `operator` VARCHAR(64) NULL DEFAULT NULL COMMENT '操作者账号' ,
CHANGE COLUMN `operate_page` `operate_page` VARCHAR(64) NOT NULL DEFAULT '' COMMENT '操作页面' ,
CHANGE COLUMN `operate_type` `operate_type` VARCHAR(64) NOT NULL COMMENT '操作类型' ,
CHANGE COLUMN `target_type` `target_type` VARCHAR(64) NOT NULL COMMENT '对象分类' ,
CHANGE COLUMN `target` `target` VARCHAR(1024) NOT NULL COMMENT '操作对象' ,
CHANGE COLUMN `operation_methods` `operation_methods` VARCHAR(64) NOT NULL DEFAULT '' COMMENT '操作方式' ;
```
---
### 6.2.2、升级至 `v3.0.0-beta.1`版本
**SQL变更**
1、在`ks_km_broker`表增加了一个监听信息字段。
2、为`logi_security_oplog`表operation_methods字段设置默认值''。
因此需要执行下面的sql对数据库表进行更新。
```sql
ALTER TABLE `ks_km_broker`
ADD COLUMN `endpoint_map` VARCHAR(1024) NOT NULL DEFAULT '' COMMENT '监听信息' AFTER `update_time`;
ALTER TABLE `logi_security_oplog`
ALTER COLUMN `operation_methods` set default '';
```
---
### 6.2.3、`2.x`版本 升级至 `v3.0.0-beta.0`版本
**升级步骤:** **升级步骤:**

View File

@@ -1,5 +1,4 @@
# FAQ
# FAQ
## 8.1、支持哪些 Kafka 版本? ## 8.1、支持哪些 Kafka 版本?
@@ -109,3 +108,61 @@ SECURITY.TRICK_USERS
设置完成上面两步之后,就可以直接调用需要登录的接口了。 设置完成上面两步之后,就可以直接调用需要登录的接口了。
但是还有一点需要注意,绕过的用户仅能调用他有权限的接口,比如一个普通用户,那么他就只能调用普通的接口,不能去调用运维人员的接口。 但是还有一点需要注意,绕过的用户仅能调用他有权限的接口,比如一个普通用户,那么他就只能调用普通的接口,不能去调用运维人员的接口。
## 8.8、Specified key was too long; max key length is 767 bytes
**原因:** 不同版本的 InoDB 引擎参数innodb_large_prefix默认值不同即在 5.6 默认值为 OFF5.7 默认值为 ON。
对于引擎为 InnoDBinnodb_large_prefix=OFF且行格式为 Antelope 即支持 REDUNDANT 或 COMPACT 时,索引键前缀长度最大为 767 字节。innodb_large_prefix=ON且行格式为 Barracuda 即支持 DYNAMIC 或 COMPRESSED 时,索引键前缀长度最大为 3072 字节。
**解决方案:**
- 减少 varchar 字符大小低于 767/4=191。
- 将字符集改为 latin1一个字符=一个字节)。
- 开启innodb_large_prefix修改默认行格式innodb_file_format为 Barracuda并设置 row_format=dynamic。
## 8.9、出现 ESIndexNotFoundEXception 报错
**原因 **没有创建 ES 索引模版
**解决方案:**执行 init_es_template.sh 脚本,创建 ES 索引模版即可。
## 8.10、km-console 打包构建失败
首先,**请确保您正在使用最新版本**,版本列表见 [Tags](https://github.com/didi/KnowStreaming/tags)。如果不是最新版本,请升级后再尝试有无问题。
常见的原因是由于工程依赖没有正常安装,导致在打包过程中缺少依赖,造成打包失败。您可以检查是否有以下文件夹,且文件夹内是否有内容
```
KnowStreaming/km-console/node_modules
KnowStreaming/km-console/packages/layout-clusters-fe/node_modules
KnowStreaming/km-console/packages/config-manager-fe/node_modules
```
如果发现没有对应的 `node_modules` 目录或着目录内容为空,说明依赖没有安装成功。请按以下步骤操作,
1. 手动删除上述三个文件夹(如果有)
2. 如果之前是通过 `mvn install` 打包 `km-console`请到项目根目录KnowStreaming下重新输入该指令进行打包。观察打包过程有无报错。如有报错请见步骤 4。
3. 如果是通过本地独立构建前端工程的方式(指直接执行 `npm run build`),请进入 `KnowStreaming/km-console` 目录,执行下述步骤(注意:执行时请确保您在使用 `node v12` 版本)
a. 执行 `npm run i`。如有报错,请见步骤 4。
b. 执行 `npm run build`。如有报错,请见步骤 4。
4. 麻烦联系我们协助解决。推荐提供以下信息,方面我们快速定位问题,示例如下。
```
操作系统: Mac
命令行终端bash
Node 版本: v12.22.12
复现步骤: 1. -> 2.
错误截图:
```
## 8.11、在 `km-console` 目录下执行 `npm run start` 时看不到应用构建和热加载过程?如何启动单个应用?
需要到具体的应用中执行 `npm run start`,例如 `cd packages/layout-clusters-fe` 后,执行 `npm run start`
应用启动后需要到基座应用中查看(需要启动基座应用,即 layout-clusters-fe

View File

@@ -14,6 +14,7 @@ import com.xiaojukeji.know.streaming.km.common.bean.entity.topic.Topic;
import com.xiaojukeji.know.streaming.km.common.bean.vo.cluster.res.ClusterBrokersOverviewVO; import com.xiaojukeji.know.streaming.km.common.bean.vo.cluster.res.ClusterBrokersOverviewVO;
import com.xiaojukeji.know.streaming.km.common.bean.vo.cluster.res.ClusterBrokersStateVO; import com.xiaojukeji.know.streaming.km.common.bean.vo.cluster.res.ClusterBrokersStateVO;
import com.xiaojukeji.know.streaming.km.common.bean.vo.kafkacontroller.KafkaControllerVO; import com.xiaojukeji.know.streaming.km.common.bean.vo.kafkacontroller.KafkaControllerVO;
import com.xiaojukeji.know.streaming.km.common.constant.KafkaConstant;
import com.xiaojukeji.know.streaming.km.common.enums.SortTypeEnum; import com.xiaojukeji.know.streaming.km.common.enums.SortTypeEnum;
import com.xiaojukeji.know.streaming.km.common.utils.PaginationMetricsUtil; import com.xiaojukeji.know.streaming.km.common.utils.PaginationMetricsUtil;
import com.xiaojukeji.know.streaming.km.common.utils.PaginationUtil; import com.xiaojukeji.know.streaming.km.common.utils.PaginationUtil;
@@ -71,6 +72,9 @@ public class ClusterBrokersManagerImpl implements ClusterBrokersManager {
Topic groupTopic = topicService.getTopic(clusterPhyId, org.apache.kafka.common.internals.Topic.GROUP_METADATA_TOPIC_NAME); Topic groupTopic = topicService.getTopic(clusterPhyId, org.apache.kafka.common.internals.Topic.GROUP_METADATA_TOPIC_NAME);
Topic transactionTopic = topicService.getTopic(clusterPhyId, org.apache.kafka.common.internals.Topic.TRANSACTION_STATE_TOPIC_NAME); Topic transactionTopic = topicService.getTopic(clusterPhyId, org.apache.kafka.common.internals.Topic.TRANSACTION_STATE_TOPIC_NAME);
//获取controller信息
KafkaController kafkaController = kafkaControllerService.getKafkaControllerFromDB(clusterPhyId);
// 格式转换 // 格式转换
return PaginationResult.buildSuc( return PaginationResult.buildSuc(
this.convert2ClusterBrokersOverviewVOList( this.convert2ClusterBrokersOverviewVOList(
@@ -78,7 +82,8 @@ public class ClusterBrokersManagerImpl implements ClusterBrokersManager {
brokerList, brokerList,
metricsResult.getData(), metricsResult.getData(),
groupTopic, groupTopic,
transactionTopic transactionTopic,
kafkaController
), ),
paginationResult paginationResult
); );
@@ -159,7 +164,8 @@ public class ClusterBrokersManagerImpl implements ClusterBrokersManager {
List<Broker> brokerList, List<Broker> brokerList,
List<BrokerMetrics> metricsList, List<BrokerMetrics> metricsList,
Topic groupTopic, Topic groupTopic,
Topic transactionTopic) { Topic transactionTopic,
KafkaController kafkaController) {
Map<Integer, BrokerMetrics> metricsMap = metricsList == null? new HashMap<>(): metricsList.stream().collect(Collectors.toMap(BrokerMetrics::getBrokerId, Function.identity())); Map<Integer, BrokerMetrics> metricsMap = metricsList == null? new HashMap<>(): metricsList.stream().collect(Collectors.toMap(BrokerMetrics::getBrokerId, Function.identity()));
Map<Integer, Broker> brokerMap = brokerList == null? new HashMap<>(): brokerList.stream().collect(Collectors.toMap(Broker::getBrokerId, Function.identity())); Map<Integer, Broker> brokerMap = brokerList == null? new HashMap<>(): brokerList.stream().collect(Collectors.toMap(Broker::getBrokerId, Function.identity()));
@@ -169,12 +175,12 @@ public class ClusterBrokersManagerImpl implements ClusterBrokersManager {
Broker broker = brokerMap.get(brokerId); Broker broker = brokerMap.get(brokerId);
BrokerMetrics brokerMetrics = metricsMap.get(brokerId); BrokerMetrics brokerMetrics = metricsMap.get(brokerId);
voList.add(this.convert2ClusterBrokersOverviewVO(brokerId, broker, brokerMetrics, groupTopic, transactionTopic)); voList.add(this.convert2ClusterBrokersOverviewVO(brokerId, broker, brokerMetrics, groupTopic, transactionTopic, kafkaController));
} }
return voList; return voList;
} }
private ClusterBrokersOverviewVO convert2ClusterBrokersOverviewVO(Integer brokerId, Broker broker, BrokerMetrics brokerMetrics, Topic groupTopic, Topic transactionTopic) { private ClusterBrokersOverviewVO convert2ClusterBrokersOverviewVO(Integer brokerId, Broker broker, BrokerMetrics brokerMetrics, Topic groupTopic, Topic transactionTopic, KafkaController kafkaController) {
ClusterBrokersOverviewVO clusterBrokersOverviewVO = new ClusterBrokersOverviewVO(); ClusterBrokersOverviewVO clusterBrokersOverviewVO = new ClusterBrokersOverviewVO();
clusterBrokersOverviewVO.setBrokerId(brokerId); clusterBrokersOverviewVO.setBrokerId(brokerId);
if (broker != null) { if (broker != null) {
@@ -192,6 +198,9 @@ public class ClusterBrokersManagerImpl implements ClusterBrokersManager {
if (transactionTopic != null && transactionTopic.getBrokerIdSet().contains(brokerId)) { if (transactionTopic != null && transactionTopic.getBrokerIdSet().contains(brokerId)) {
clusterBrokersOverviewVO.getKafkaRoleList().add(transactionTopic.getTopicName()); clusterBrokersOverviewVO.getKafkaRoleList().add(transactionTopic.getTopicName());
} }
if (kafkaController != null && kafkaController.getBrokerId().equals(brokerId)) {
clusterBrokersOverviewVO.getKafkaRoleList().add(KafkaConstant.CONTROLLER_ROLE);
}
clusterBrokersOverviewVO.setLatestMetrics(brokerMetrics); clusterBrokersOverviewVO.setLatestMetrics(brokerMetrics);
return clusterBrokersOverviewVO; return clusterBrokersOverviewVO;

View File

@@ -20,6 +20,7 @@ import com.xiaojukeji.know.streaming.km.common.bean.vo.group.GroupTopicOverviewV
import com.xiaojukeji.know.streaming.km.common.constant.MsgConstant; import com.xiaojukeji.know.streaming.km.common.constant.MsgConstant;
import com.xiaojukeji.know.streaming.km.common.enums.AggTypeEnum; import com.xiaojukeji.know.streaming.km.common.enums.AggTypeEnum;
import com.xiaojukeji.know.streaming.km.common.enums.GroupOffsetResetEnum; import com.xiaojukeji.know.streaming.km.common.enums.GroupOffsetResetEnum;
import com.xiaojukeji.know.streaming.km.common.enums.group.GroupStateEnum;
import com.xiaojukeji.know.streaming.km.common.exception.AdminOperateException; import com.xiaojukeji.know.streaming.km.common.exception.AdminOperateException;
import com.xiaojukeji.know.streaming.km.common.exception.NotExistException; import com.xiaojukeji.know.streaming.km.common.exception.NotExistException;
import com.xiaojukeji.know.streaming.km.common.utils.ConvertUtil; import com.xiaojukeji.know.streaming.km.common.utils.ConvertUtil;
@@ -75,7 +76,7 @@ public class GroupManagerImpl implements GroupManager {
} }
if (!paginationResult.hasData()) { if (!paginationResult.hasData()) {
return PaginationResult.buildSuc(dto); return PaginationResult.buildSuc(new ArrayList<>(), paginationResult);
} }
// 获取指标 // 获取指标
@@ -171,7 +172,7 @@ public class GroupManagerImpl implements GroupManager {
} }
if (!ConsumerGroupState.EMPTY.equals(description.state()) && !ConsumerGroupState.DEAD.equals(description.state())) { if (!ConsumerGroupState.EMPTY.equals(description.state()) && !ConsumerGroupState.DEAD.equals(description.state())) {
return Result.buildFromRSAndMsg(ResultStatus.KAFKA_OPERATE_FAILED, String.format("group处于%s, 重置失败(仅Empty情况可重置)", description.state().name())); return Result.buildFromRSAndMsg(ResultStatus.KAFKA_OPERATE_FAILED, String.format("group处于%s, 重置失败(仅Empty情况可重置)", GroupStateEnum.getByRawState(description.state()).getState()));
} }
// 获取offset // 获取offset

View File

@@ -129,7 +129,12 @@ public class TopicStateManagerImpl implements TopicStateManager {
return Result.buildFromRSAndMsg(ResultStatus.NOT_EXIST, MsgConstant.getClusterPhyNotExist(clusterPhyId)); return Result.buildFromRSAndMsg(ResultStatus.NOT_EXIST, MsgConstant.getClusterPhyNotExist(clusterPhyId));
} }
// 获取分区offset // 获取分区beginOffset
Result<Map<TopicPartition, Long>> beginOffsetsMapResult = partitionService.getPartitionOffsetFromKafka(clusterPhyId, topicName, dto.getFilterPartitionId(), OffsetSpec.earliest(), null);
if (beginOffsetsMapResult.failed()) {
return Result.buildFromIgnoreData(beginOffsetsMapResult);
}
// 获取分区endOffset
Result<Map<TopicPartition, Long>> endOffsetsMapResult = partitionService.getPartitionOffsetFromKafka(clusterPhyId, topicName, dto.getFilterPartitionId(), OffsetSpec.latest(), null); Result<Map<TopicPartition, Long>> endOffsetsMapResult = partitionService.getPartitionOffsetFromKafka(clusterPhyId, topicName, dto.getFilterPartitionId(), OffsetSpec.latest(), null);
if (endOffsetsMapResult.failed()) { if (endOffsetsMapResult.failed()) {
return Result.buildFromIgnoreData(endOffsetsMapResult); return Result.buildFromIgnoreData(endOffsetsMapResult);
@@ -142,13 +147,25 @@ public class TopicStateManagerImpl implements TopicStateManager {
// 创建kafka-consumer // 创建kafka-consumer
kafkaConsumer = new KafkaConsumer<>(this.generateClientProperties(clusterPhy, dto.getMaxRecords())); kafkaConsumer = new KafkaConsumer<>(this.generateClientProperties(clusterPhy, dto.getMaxRecords()));
kafkaConsumer.assign(endOffsetsMapResult.getData().keySet()); List<TopicPartition> partitionList = new ArrayList<>();
for (Map.Entry<TopicPartition, Long> entry: endOffsetsMapResult.getData().entrySet()) { long maxMessage = 0;
kafkaConsumer.seek(entry.getKey(), Math.max(0, entry.getValue() - dto.getMaxRecords())); for (Map.Entry<TopicPartition, Long> entry : endOffsetsMapResult.getData().entrySet()) {
long begin = beginOffsetsMapResult.getData().get(entry.getKey());
long end = entry.getValue();
if (begin == end){
continue;
}
maxMessage += end - begin;
partitionList.add(entry.getKey());
}
maxMessage = Math.min(maxMessage, dto.getMaxRecords());
kafkaConsumer.assign(partitionList);
for (TopicPartition partition : partitionList) {
kafkaConsumer.seek(partition, Math.max(beginOffsetsMapResult.getData().get(partition), endOffsetsMapResult.getData().get(partition) - dto.getMaxRecords()));
} }
// 这里需要减去 KafkaConstant.POLL_ONCE_TIMEOUT_UNIT_MS 是因为poll一次需要耗时如果这里不减去则可能会导致poll之后超过要求的时间 // 这里需要减去 KafkaConstant.POLL_ONCE_TIMEOUT_UNIT_MS 是因为poll一次需要耗时如果这里不减去则可能会导致poll之后超过要求的时间
while (System.currentTimeMillis() - startTime + KafkaConstant.POLL_ONCE_TIMEOUT_UNIT_MS <= dto.getPullTimeoutUnitMs() && voList.size() < dto.getMaxRecords()) { while (System.currentTimeMillis() - startTime <= dto.getPullTimeoutUnitMs() && voList.size() < maxMessage) {
ConsumerRecords<String, String> consumerRecords = kafkaConsumer.poll(Duration.ofMillis(KafkaConstant.POLL_ONCE_TIMEOUT_UNIT_MS)); ConsumerRecords<String, String> consumerRecords = kafkaConsumer.poll(Duration.ofMillis(KafkaConstant.POLL_ONCE_TIMEOUT_UNIT_MS));
for (ConsumerRecord<String, String> consumerRecord : consumerRecords) { for (ConsumerRecord<String, String> consumerRecord : consumerRecords) {
if (this.checkIfIgnore(consumerRecord, dto.getFilterKey(), dto.getFilterValue())) { if (this.checkIfIgnore(consumerRecord, dto.getFilterKey(), dto.getFilterValue())) {

View File

@@ -5,7 +5,6 @@ import com.didiglobal.logi.log.LogFactory;
import com.xiaojukeji.know.streaming.km.common.bean.event.metric.*; import com.xiaojukeji.know.streaming.km.common.bean.event.metric.*;
import com.xiaojukeji.know.streaming.km.common.bean.po.BaseESPO; import com.xiaojukeji.know.streaming.km.common.bean.po.BaseESPO;
import com.xiaojukeji.know.streaming.km.common.bean.po.metrice.*; import com.xiaojukeji.know.streaming.km.common.bean.po.metrice.*;
import com.xiaojukeji.know.streaming.km.common.enums.metric.KafkaMetricIndexEnum;
import com.xiaojukeji.know.streaming.km.common.utils.ConvertUtil; import com.xiaojukeji.know.streaming.km.common.utils.ConvertUtil;
import com.xiaojukeji.know.streaming.km.common.utils.EnvUtil; import com.xiaojukeji.know.streaming.km.common.utils.EnvUtil;
import com.xiaojukeji.know.streaming.km.common.utils.NamedThreadFactory; import com.xiaojukeji.know.streaming.km.common.utils.NamedThreadFactory;
@@ -21,6 +20,8 @@ import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import static com.xiaojukeji.know.streaming.km.common.constant.ESIndexConstant.*;
@Component @Component
public class MetricESSender implements ApplicationListener<BaseMetricEvent> { public class MetricESSender implements ApplicationListener<BaseMetricEvent> {
protected static final ILog LOGGER = LogFactory.getLog("METRIC_LOGGER"); protected static final ILog LOGGER = LogFactory.getLog("METRIC_LOGGER");
@@ -41,37 +42,37 @@ public class MetricESSender implements ApplicationListener<BaseMetricEvent> {
public void onApplicationEvent(BaseMetricEvent event) { public void onApplicationEvent(BaseMetricEvent event) {
if(event instanceof BrokerMetricEvent) { if(event instanceof BrokerMetricEvent) {
BrokerMetricEvent brokerMetricEvent = (BrokerMetricEvent)event; BrokerMetricEvent brokerMetricEvent = (BrokerMetricEvent)event;
send2es(KafkaMetricIndexEnum.BROKER_INFO, send2es(BROKER_INDEX,
ConvertUtil.list2List(brokerMetricEvent.getBrokerMetrics(), BrokerMetricPO.class) ConvertUtil.list2List(brokerMetricEvent.getBrokerMetrics(), BrokerMetricPO.class)
); );
} else if(event instanceof ClusterMetricEvent) { } else if(event instanceof ClusterMetricEvent) {
ClusterMetricEvent clusterMetricEvent = (ClusterMetricEvent)event; ClusterMetricEvent clusterMetricEvent = (ClusterMetricEvent)event;
send2es(KafkaMetricIndexEnum.CLUSTER_INFO, send2es(CLUSTER_INDEX,
ConvertUtil.list2List(clusterMetricEvent.getClusterMetrics(), ClusterMetricPO.class) ConvertUtil.list2List(clusterMetricEvent.getClusterMetrics(), ClusterMetricPO.class)
); );
} else if(event instanceof TopicMetricEvent) { } else if(event instanceof TopicMetricEvent) {
TopicMetricEvent topicMetricEvent = (TopicMetricEvent)event; TopicMetricEvent topicMetricEvent = (TopicMetricEvent)event;
send2es(KafkaMetricIndexEnum.TOPIC_INFO, send2es(TOPIC_INDEX,
ConvertUtil.list2List(topicMetricEvent.getTopicMetrics(), TopicMetricPO.class) ConvertUtil.list2List(topicMetricEvent.getTopicMetrics(), TopicMetricPO.class)
); );
} else if(event instanceof PartitionMetricEvent) { } else if(event instanceof PartitionMetricEvent) {
PartitionMetricEvent partitionMetricEvent = (PartitionMetricEvent)event; PartitionMetricEvent partitionMetricEvent = (PartitionMetricEvent)event;
send2es(KafkaMetricIndexEnum.PARTITION_INFO, send2es(PARTITION_INDEX,
ConvertUtil.list2List(partitionMetricEvent.getPartitionMetrics(), PartitionMetricPO.class) ConvertUtil.list2List(partitionMetricEvent.getPartitionMetrics(), PartitionMetricPO.class)
); );
} else if(event instanceof GroupMetricEvent) { } else if(event instanceof GroupMetricEvent) {
GroupMetricEvent groupMetricEvent = (GroupMetricEvent)event; GroupMetricEvent groupMetricEvent = (GroupMetricEvent)event;
send2es(KafkaMetricIndexEnum.GROUP_INFO, send2es(GROUP_INDEX,
ConvertUtil.list2List(groupMetricEvent.getGroupMetrics(), GroupMetricPO.class) ConvertUtil.list2List(groupMetricEvent.getGroupMetrics(), GroupMetricPO.class)
); );
} else if(event instanceof ReplicaMetricEvent) { } else if(event instanceof ReplicaMetricEvent) {
ReplicaMetricEvent replicaMetricEvent = (ReplicaMetricEvent)event; ReplicaMetricEvent replicaMetricEvent = (ReplicaMetricEvent)event;
send2es(KafkaMetricIndexEnum.REPLICATION_INFO, send2es(REPLICATION_INDEX,
ConvertUtil.list2List(replicaMetricEvent.getReplicationMetrics(), ReplicationMetricPO.class) ConvertUtil.list2List(replicaMetricEvent.getReplicationMetrics(), ReplicationMetricPO.class)
); );
} }
@@ -80,19 +81,19 @@ public class MetricESSender implements ApplicationListener<BaseMetricEvent> {
/** /**
* 根据不同监控维度来发送 * 根据不同监控维度来发送
*/ */
private boolean send2es(KafkaMetricIndexEnum stats, List<? extends BaseESPO> statsList){ private boolean send2es(String index, List<? extends BaseESPO> statsList){
if (CollectionUtils.isEmpty(statsList)) { if (CollectionUtils.isEmpty(statsList)) {
return true; return true;
} }
if (!EnvUtil.isOnline()) { if (!EnvUtil.isOnline()) {
LOGGER.info("class=MetricESSender||method=send2es||ariusStats={}||size={}", LOGGER.info("class=MetricESSender||method=send2es||ariusStats={}||size={}",
stats.getIndex(), statsList.size()); index, statsList.size());
} }
BaseMetricESDAO baseMetricESDao = BaseMetricESDAO.getByStatsType(stats); BaseMetricESDAO baseMetricESDao = BaseMetricESDAO.getByStatsType(index);
if (Objects.isNull( baseMetricESDao )) { if (Objects.isNull( baseMetricESDao )) {
LOGGER.error("class=MetricESSender||method=send2es||errMsg=fail to find {}", stats.getIndex()); LOGGER.error("class=MetricESSender||method=send2es||errMsg=fail to find {}", index);
return false; return false;
} }

View File

@@ -1,5 +1,10 @@
package com.xiaojukeji.know.streaming.km.common.bean.entity.broker; package com.xiaojukeji.know.streaming.km.common.bean.entity.broker;
import com.alibaba.fastjson.TypeReference;
import com.xiaojukeji.know.streaming.km.common.bean.entity.common.IpPortData;
import com.xiaojukeji.know.streaming.km.common.bean.po.broker.BrokerPO;
import com.xiaojukeji.know.streaming.km.common.utils.ConvertUtil;
import com.xiaojukeji.know.streaming.km.common.zookeeper.znode.brokers.BrokerMetadata; import com.xiaojukeji.know.streaming.km.common.zookeeper.znode.brokers.BrokerMetadata;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
@@ -7,6 +12,7 @@ import lombok.NoArgsConstructor;
import org.apache.kafka.common.Node; import org.apache.kafka.common.Node;
import java.io.Serializable; import java.io.Serializable;
import java.util.Map;
/** /**
* @author didi * @author didi
@@ -55,6 +61,11 @@ public class Broker implements Serializable {
*/ */
private Integer status; private Integer status;
/**
* 监听信息
*/
private Map<String, IpPortData> endpointMap;
public static Broker buildFrom(Long clusterPhyId, Node node, Long startTimestamp) { public static Broker buildFrom(Long clusterPhyId, Node node, Long startTimestamp) {
Broker metadata = new Broker(); Broker metadata = new Broker();
metadata.setClusterPhyId(clusterPhyId); metadata.setClusterPhyId(clusterPhyId);
@@ -78,9 +89,31 @@ public class Broker implements Serializable {
metadata.setStartTimestamp(brokerMetadata.getTimestamp()); metadata.setStartTimestamp(brokerMetadata.getTimestamp());
metadata.setRack(brokerMetadata.getRack()); metadata.setRack(brokerMetadata.getRack());
metadata.setStatus(1); metadata.setStatus(1);
metadata.setEndpointMap(brokerMetadata.getEndpointMap());
return metadata; return metadata;
} }
public static Broker buildFrom(BrokerPO brokerPO) {
Broker broker = ConvertUtil.obj2Obj(brokerPO, Broker.class);
String endpointMapStr = brokerPO.getEndpointMap();
if (broker == null || endpointMapStr == null || endpointMapStr.equals("")) {
return broker;
}
// 填充endpoint信息
Map<String, IpPortData> endpointMap = ConvertUtil.str2ObjByJson(endpointMapStr, new TypeReference<Map<String, IpPortData>>(){});
broker.setEndpointMap(endpointMap);
return broker;
}
public String getJmxHost(String endPoint) {
if (endPoint == null || endpointMap == null) {
return host;
}
IpPortData ip = endpointMap.get(endPoint);
return ip != null ? ip.getIp() : host;
}
public boolean alive() { public boolean alive() {
return status != null && status > 0; return status != null && status > 0;
} }

View File

@@ -27,6 +27,9 @@ public class JmxConfig implements Serializable {
@ApiModelProperty(value="SSL情况下的token", example = "KsKmCCY19") @ApiModelProperty(value="SSL情况下的token", example = "KsKmCCY19")
private String token; private String token;
@ApiModelProperty(value="使用哪个endpoint网络", example = "EXTERNAL")
private String useWhichEndpoint;
} }

View File

@@ -0,0 +1,19 @@
package com.xiaojukeji.know.streaming.km.common.bean.entity.param.partition;
import com.xiaojukeji.know.streaming.km.common.bean.entity.param.cluster.ClusterPhyParam;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.kafka.common.TopicPartition;
import java.util.List;
@Data
@NoArgsConstructor
public class BatchPartitionParam extends ClusterPhyParam {
private List<TopicPartition> tpList;
public BatchPartitionParam(Long clusterPhyId, List<TopicPartition> tpList) {
super(clusterPhyId);
this.tpList = tpList;
}
}

View File

@@ -1,6 +1,6 @@
package com.xiaojukeji.know.streaming.km.common.bean.entity.param.partition; package com.xiaojukeji.know.streaming.km.common.bean.entity.param.partition;
import com.xiaojukeji.know.streaming.km.common.bean.entity.param.cluster.ClusterPhyParam; import com.xiaojukeji.know.streaming.km.common.bean.entity.param.topic.TopicParam;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import org.apache.kafka.clients.admin.OffsetSpec; import org.apache.kafka.clients.admin.OffsetSpec;
@@ -10,13 +10,13 @@ import java.util.Map;
@Data @Data
@NoArgsConstructor @NoArgsConstructor
public class PartitionOffsetParam extends ClusterPhyParam { public class PartitionOffsetParam extends TopicParam {
private Map<TopicPartition, OffsetSpec> topicPartitionOffsets; private Map<TopicPartition, OffsetSpec> topicPartitionOffsets;
private Long timestamp; private Long timestamp;
public PartitionOffsetParam(Long clusterPhyId, Map<TopicPartition, OffsetSpec> topicPartitionOffsets, Long timestamp) { public PartitionOffsetParam(Long clusterPhyId, String topicName, Map<TopicPartition, OffsetSpec> topicPartitionOffsets, Long timestamp) {
super(clusterPhyId); super(clusterPhyId, topicName);
this.topicPartitionOffsets = topicPartitionOffsets; this.topicPartitionOffsets = topicPartitionOffsets;
this.timestamp = timestamp; this.timestamp = timestamp;
} }

View File

@@ -15,4 +15,12 @@ public class TopicParam extends ClusterPhyParam {
super(clusterPhyId); super(clusterPhyId);
this.topicName = topicName; this.topicName = topicName;
} }
@Override
public String toString() {
return "TopicParam{" +
"clusterPhyId=" + clusterPhyId +
", topicName='" + topicName + '\'' +
'}';
}
} }

View File

@@ -0,0 +1,15 @@
package com.xiaojukeji.know.streaming.km.common.bean.event.cluster;
import lombok.Getter;
/**
* 集群新增事件
* @author zengqiao
* @date 22/02/25
*/
@Getter
public class ClusterPhyAddedEvent extends ClusterPhyBaseEvent {
public ClusterPhyAddedEvent(Object source, Long clusterPhyId) {
super(source, clusterPhyId);
}
}

View File

@@ -1,26 +0,0 @@
package com.xiaojukeji.know.streaming.km.common.bean.event.kafka.zk;
import lombok.Getter;
@Getter
public abstract class BaseKafkaZKEvent {
/**
* 触发时间
*/
protected Long eventTime;
/**
* 初始化数据的事件
*/
protected Boolean initEvent;
/**
* 集群ID
*/
protected Long clusterPhyId;
protected BaseKafkaZKEvent(Long eventTime, Long clusterPhyId) {
this.eventTime = eventTime;
this.clusterPhyId = clusterPhyId;
}
}

View File

@@ -1,10 +0,0 @@
package com.xiaojukeji.know.streaming.km.common.bean.event.kafka.zk;
import lombok.Getter;
@Getter
public class ControllerChangeEvent extends BaseKafkaZKEvent {
public ControllerChangeEvent(Long eventTime, Long clusterPhyId) {
super(eventTime, clusterPhyId);
}
}

View File

@@ -42,4 +42,9 @@ public class BrokerPO extends BasePO {
* Broker状态 * Broker状态
*/ */
private Integer status; private Integer status;
/**
* 监听信息
*/
private String endpointMap;
} }

View File

@@ -29,6 +29,10 @@ public class MetricPointVO implements Comparable<MetricPointVO> {
@Override @Override
public int compareTo(MetricPointVO o) { public int compareTo(MetricPointVO o) {
if(null == o){return 0;} if(null == o){return 0;}
if(null == this.getTimeStamp()
|| null == o.getTimeStamp()){
return 0;
}
return this.getTimeStamp().intValue() - o.getTimeStamp().intValue(); return this.getTimeStamp().intValue() - o.getTimeStamp().intValue();
} }

View File

@@ -63,4 +63,5 @@ public class Constant {
public static final String COLLECT_METRICS_COST_TIME_METRICS_NAME = "CollectMetricsCostTimeUnitSec"; public static final String COLLECT_METRICS_COST_TIME_METRICS_NAME = "CollectMetricsCostTimeUnitSec";
public static final Float COLLECT_METRICS_ERROR_COST_TIME = -1.0F; public static final Float COLLECT_METRICS_ERROR_COST_TIME = -1.0F;
public static final Integer DEFAULT_RETRY_TIME = 3;
} }

View File

@@ -0,0 +1,647 @@
package com.xiaojukeji.know.streaming.km.common.constant;
public class ESIndexConstant {
public final static String TOPIC_INDEX = "ks_kafka_topic_metric";
public final static String TOPIC_TEMPLATE = "{\n" +
" \"order\" : 10,\n" +
" \"index_patterns\" : [\n" +
" \"ks_kafka_topic_metric*\"\n" +
" ],\n" +
" \"settings\" : {\n" +
" \"index\" : {\n" +
" \"number_of_shards\" : \"10\"\n" +
" }\n" +
" },\n" +
" \"mappings\" : {\n" +
" \"properties\" : {\n" +
" \"brokerId\" : {\n" +
" \"type\" : \"long\"\n" +
" },\n" +
" \"routingValue\" : {\n" +
" \"type\" : \"text\",\n" +
" \"fields\" : {\n" +
" \"keyword\" : {\n" +
" \"ignore_above\" : 256,\n" +
" \"type\" : \"keyword\"\n" +
" }\n" +
" }\n" +
" },\n" +
" \"topic\" : {\n" +
" \"type\" : \"keyword\"\n" +
" },\n" +
" \"clusterPhyId\" : {\n" +
" \"type\" : \"long\"\n" +
" },\n" +
" \"metrics\" : {\n" +
" \"properties\" : {\n" +
" \"BytesIn_min_15\" : {\n" +
" \"type\" : \"float\"\n" +
" },\n" +
" \"Messages\" : {\n" +
" \"type\" : \"float\"\n" +
" },\n" +
" \"BytesRejected\" : {\n" +
" \"type\" : \"float\"\n" +
" },\n" +
" \"PartitionURP\" : {\n" +
" \"type\" : \"float\"\n" +
" },\n" +
" \"HealthCheckTotal\" : {\n" +
" \"type\" : \"float\"\n" +
" },\n" +
" \"ReplicationCount\" : {\n" +
" \"type\" : \"float\"\n" +
" },\n" +
" \"ReplicationBytesOut\" : {\n" +
" \"type\" : \"float\"\n" +
" },\n" +
" \"ReplicationBytesIn\" : {\n" +
" \"type\" : \"float\"\n" +
" },\n" +
" \"FailedFetchRequests\" : {\n" +
" \"type\" : \"float\"\n" +
" },\n" +
" \"BytesIn_min_5\" : {\n" +
" \"type\" : \"float\"\n" +
" },\n" +
" \"HealthScore\" : {\n" +
" \"type\" : \"float\"\n" +
" },\n" +
" \"LogSize\" : {\n" +
" \"type\" : \"float\"\n" +
" },\n" +
" \"BytesOut\" : {\n" +
" \"type\" : \"float\"\n" +
" },\n" +
" \"BytesOut_min_15\" : {\n" +
" \"type\" : \"float\"\n" +
" },\n" +
" \"FailedProduceRequests\" : {\n" +
" \"type\" : \"float\"\n" +
" },\n" +
" \"BytesIn\" : {\n" +
" \"type\" : \"float\"\n" +
" },\n" +
" \"BytesOut_min_5\" : {\n" +
" \"type\" : \"float\"\n" +
" },\n" +
" \"MessagesIn\" : {\n" +
" \"type\" : \"float\"\n" +
" },\n" +
" \"TotalProduceRequests\" : {\n" +
" \"type\" : \"float\"\n" +
" },\n" +
" \"HealthCheckPassed\" : {\n" +
" \"type\" : \"float\"\n" +
" }\n" +
" }\n" +
" },\n" +
" \"brokerAgg\" : {\n" +
" \"type\" : \"keyword\"\n" +
" },\n" +
" \"key\" : {\n" +
" \"type\" : \"text\",\n" +
" \"fields\" : {\n" +
" \"keyword\" : {\n" +
" \"ignore_above\" : 256,\n" +
" \"type\" : \"keyword\"\n" +
" }\n" +
" }\n" +
" },\n" +
" \"timestamp\" : {\n" +
" \"format\" : \"yyyy-MM-dd HH:mm:ss Z||yyyy-MM-dd HH:mm:ss||yyyy-MM-dd HH:mm:ss.SSS Z||yyyy-MM-dd HH:mm:ss.SSS||yyyy-MM-dd HH:mm:ss,SSS||yyyy/MM/dd HH:mm:ss||yyyy-MM-dd HH:mm:ss,SSS Z||yyyy/MM/dd HH:mm:ss,SSS Z||epoch_millis\",\n" +
" \"index\" : true,\n" +
" \"type\" : \"date\",\n" +
" \"doc_values\" : true\n" +
" }\n" +
" }\n" +
" },\n" +
" \"aliases\" : { }\n" +
" }";
public final static String CLUSTER_INDEX = "ks_kafka_cluster_metric";
public final static String CLUSTER_TEMPLATE = "{\n" +
" \"order\" : 10,\n" +
" \"index_patterns\" : [\n" +
" \"ks_kafka_cluster_metric*\"\n" +
" ],\n" +
" \"settings\" : {\n" +
" \"index\" : {\n" +
" \"number_of_shards\" : \"10\"\n" +
" }\n" +
" },\n" +
" \"mappings\" : {\n" +
" \"properties\" : {\n" +
" \"routingValue\" : {\n" +
" \"type\" : \"text\",\n" +
" \"fields\" : {\n" +
" \"keyword\" : {\n" +
" \"ignore_above\" : 256,\n" +
" \"type\" : \"keyword\"\n" +
" }\n" +
" }\n" +
" },\n" +
" \"clusterPhyId\" : {\n" +
" \"type\" : \"long\"\n" +
" },\n" +
" \"metrics\" : {\n" +
" \"properties\" : {\n" +
" \"Connections\" : {\n" +
" \"type\" : \"double\"\n" +
" },\n" +
" \"BytesIn_min_15\" : {\n" +
" \"type\" : \"double\"\n" +
" },\n" +
" \"PartitionURP\" : {\n" +
" \"type\" : \"double\"\n" +
" },\n" +
" \"HealthScore_Topics\" : {\n" +
" \"type\" : \"double\"\n" +
" },\n" +
" \"EventQueueSize\" : {\n" +
" \"type\" : \"double\"\n" +
" },\n" +
" \"ActiveControllerCount\" : {\n" +
" \"type\" : \"double\"\n" +
" },\n" +
" \"GroupDeads\" : {\n" +
" \"type\" : \"double\"\n" +
" },\n" +
" \"BytesIn_min_5\" : {\n" +
" \"type\" : \"double\"\n" +
" },\n" +
" \"HealthCheckTotal_Topics\" : {\n" +
" \"type\" : \"double\"\n" +
" },\n" +
" \"Partitions\" : {\n" +
" \"type\" : \"double\"\n" +
" },\n" +
" \"BytesOut\" : {\n" +
" \"type\" : \"double\"\n" +
" },\n" +
" \"Groups\" : {\n" +
" \"type\" : \"double\"\n" +
" },\n" +
" \"BytesOut_min_15\" : {\n" +
" \"type\" : \"double\"\n" +
" },\n" +
" \"TotalRequestQueueSize\" : {\n" +
" \"type\" : \"double\"\n" +
" },\n" +
" \"HealthCheckPassed_Groups\" : {\n" +
" \"type\" : \"double\"\n" +
" },\n" +
" \"TotalProduceRequests\" : {\n" +
" \"type\" : \"double\"\n" +
" },\n" +
" \"HealthCheckPassed\" : {\n" +
" \"type\" : \"double\"\n" +
" },\n" +
" \"TotalLogSize\" : {\n" +
" \"type\" : \"double\"\n" +
" },\n" +
" \"GroupEmptys\" : {\n" +
" \"type\" : \"double\"\n" +
" },\n" +
" \"PartitionNoLeader\" : {\n" +
" \"type\" : \"double\"\n" +
" },\n" +
" \"HealthScore_Brokers\" : {\n" +
" \"type\" : \"double\"\n" +
" },\n" +
" \"Messages\" : {\n" +
" \"type\" : \"double\"\n" +
" },\n" +
" \"Topics\" : {\n" +
" \"type\" : \"double\"\n" +
" },\n" +
" \"PartitionMinISR_E\" : {\n" +
" \"type\" : \"double\"\n" +
" },\n" +
" \"HealthCheckTotal\" : {\n" +
" \"type\" : \"double\"\n" +
" },\n" +
" \"Brokers\" : {\n" +
" \"type\" : \"double\"\n" +
" },\n" +
" \"Replicas\" : {\n" +
" \"type\" : \"double\"\n" +
" },\n" +
" \"HealthCheckTotal_Groups\" : {\n" +
" \"type\" : \"double\"\n" +
" },\n" +
" \"GroupRebalances\" : {\n" +
" \"type\" : \"double\"\n" +
" },\n" +
" \"MessageIn\" : {\n" +
" \"type\" : \"double\"\n" +
" },\n" +
" \"HealthScore\" : {\n" +
" \"type\" : \"double\"\n" +
" },\n" +
" \"HealthCheckPassed_Topics\" : {\n" +
" \"type\" : \"double\"\n" +
" },\n" +
" \"HealthCheckTotal_Brokers\" : {\n" +
" \"type\" : \"double\"\n" +
" },\n" +
" \"PartitionMinISR_S\" : {\n" +
" \"type\" : \"double\"\n" +
" },\n" +
" \"BytesIn\" : {\n" +
" \"type\" : \"double\"\n" +
" },\n" +
" \"BytesOut_min_5\" : {\n" +
" \"type\" : \"double\"\n" +
" },\n" +
" \"GroupActives\" : {\n" +
" \"type\" : \"double\"\n" +
" },\n" +
" \"MessagesIn\" : {\n" +
" \"type\" : \"double\"\n" +
" },\n" +
" \"GroupReBalances\" : {\n" +
" \"type\" : \"double\"\n" +
" },\n" +
" \"HealthCheckPassed_Brokers\" : {\n" +
" \"type\" : \"double\"\n" +
" },\n" +
" \"HealthScore_Groups\" : {\n" +
" \"type\" : \"double\"\n" +
" },\n" +
" \"TotalResponseQueueSize\" : {\n" +
" \"type\" : \"double\"\n" +
" },\n" +
" \"Zookeepers\" : {\n" +
" \"type\" : \"double\"\n" +
" },\n" +
" \"LeaderMessages\" : {\n" +
" \"type\" : \"double\"\n" +
" },\n" +
" \"HealthScore_Cluster\" : {\n" +
" \"type\" : \"double\"\n" +
" },\n" +
" \"HealthCheckPassed_Cluster\" : {\n" +
" \"type\" : \"double\"\n" +
" },\n" +
" \"HealthCheckTotal_Cluster\" : {\n" +
" \"type\" : \"double\"\n" +
" }\n" +
" }\n" +
" },\n" +
" \"key\" : {\n" +
" \"type\" : \"text\",\n" +
" \"fields\" : {\n" +
" \"keyword\" : {\n" +
" \"ignore_above\" : 256,\n" +
" \"type\" : \"keyword\"\n" +
" }\n" +
" }\n" +
" },\n" +
" \"timestamp\" : {\n" +
" \"format\" : \"yyyy-MM-dd HH:mm:ss Z||yyyy-MM-dd HH:mm:ss||yyyy-MM-dd HH:mm:ss.SSS Z||yyyy-MM-dd HH:mm:ss.SSS||yyyy-MM-dd HH:mm:ss,SSS||yyyy/MM/dd HH:mm:ss||yyyy-MM-dd HH:mm:ss,SSS Z||yyyy/MM/dd HH:mm:ss,SSS Z||epoch_millis\",\n" +
" \"type\" : \"date\"\n" +
" }\n" +
" }\n" +
" },\n" +
" \"aliases\" : { }\n" +
" }";
public final static String BROKER_INDEX = "ks_kafka_broker_metric";
public final static String BROKER_TEMPLATE = "{\n" +
" \"order\" : 10,\n" +
" \"index_patterns\" : [\n" +
" \"ks_kafka_broker_metric*\"\n" +
" ],\n" +
" \"settings\" : {\n" +
" \"index\" : {\n" +
" \"number_of_shards\" : \"10\"\n" +
" }\n" +
" },\n" +
" \"mappings\" : {\n" +
" \"properties\" : {\n" +
" \"brokerId\" : {\n" +
" \"type\" : \"long\"\n" +
" },\n" +
" \"routingValue\" : {\n" +
" \"type\" : \"text\",\n" +
" \"fields\" : {\n" +
" \"keyword\" : {\n" +
" \"ignore_above\" : 256,\n" +
" \"type\" : \"keyword\"\n" +
" }\n" +
" }\n" +
" },\n" +
" \"clusterPhyId\" : {\n" +
" \"type\" : \"long\"\n" +
" },\n" +
" \"metrics\" : {\n" +
" \"properties\" : {\n" +
" \"NetworkProcessorAvgIdle\" : {\n" +
" \"type\" : \"float\"\n" +
" },\n" +
" \"UnderReplicatedPartitions\" : {\n" +
" \"type\" : \"float\"\n" +
" },\n" +
" \"BytesIn_min_15\" : {\n" +
" \"type\" : \"float\"\n" +
" },\n" +
" \"HealthCheckTotal\" : {\n" +
" \"type\" : \"float\"\n" +
" },\n" +
" \"RequestHandlerAvgIdle\" : {\n" +
" \"type\" : \"float\"\n" +
" },\n" +
" \"connectionsCount\" : {\n" +
" \"type\" : \"float\"\n" +
" },\n" +
" \"BytesIn_min_5\" : {\n" +
" \"type\" : \"float\"\n" +
" },\n" +
" \"HealthScore\" : {\n" +
" \"type\" : \"float\"\n" +
" },\n" +
" \"BytesOut\" : {\n" +
" \"type\" : \"float\"\n" +
" },\n" +
" \"BytesOut_min_15\" : {\n" +
" \"type\" : \"float\"\n" +
" },\n" +
" \"BytesIn\" : {\n" +
" \"type\" : \"float\"\n" +
" },\n" +
" \"BytesOut_min_5\" : {\n" +
" \"type\" : \"float\"\n" +
" },\n" +
" \"TotalRequestQueueSize\" : {\n" +
" \"type\" : \"float\"\n" +
" },\n" +
" \"MessagesIn\" : {\n" +
" \"type\" : \"float\"\n" +
" },\n" +
" \"TotalProduceRequests\" : {\n" +
" \"type\" : \"float\"\n" +
" },\n" +
" \"HealthCheckPassed\" : {\n" +
" \"type\" : \"float\"\n" +
" },\n" +
" \"TotalResponseQueueSize\" : {\n" +
" \"type\" : \"float\"\n" +
" }\n" +
" }\n" +
" },\n" +
" \"key\" : {\n" +
" \"type\" : \"text\",\n" +
" \"fields\" : {\n" +
" \"keyword\" : {\n" +
" \"ignore_above\" : 256,\n" +
" \"type\" : \"keyword\"\n" +
" }\n" +
" }\n" +
" },\n" +
" \"timestamp\" : {\n" +
" \"format\" : \"yyyy-MM-dd HH:mm:ss Z||yyyy-MM-dd HH:mm:ss||yyyy-MM-dd HH:mm:ss.SSS Z||yyyy-MM-dd HH:mm:ss.SSS||yyyy-MM-dd HH:mm:ss,SSS||yyyy/MM/dd HH:mm:ss||yyyy-MM-dd HH:mm:ss,SSS Z||yyyy/MM/dd HH:mm:ss,SSS Z||epoch_millis\",\n" +
" \"index\" : true,\n" +
" \"type\" : \"date\",\n" +
" \"doc_values\" : true\n" +
" }\n" +
" }\n" +
" },\n" +
" \"aliases\" : { }\n" +
" }";
public final static String PARTITION_INDEX = "ks_kafka_partition_metric";
public final static String PARTITION_TEMPLATE = "{\n" +
" \"order\" : 10,\n" +
" \"index_patterns\" : [\n" +
" \"ks_kafka_partition_metric*\"\n" +
" ],\n" +
" \"settings\" : {\n" +
" \"index\" : {\n" +
" \"number_of_shards\" : \"10\"\n" +
" }\n" +
" },\n" +
" \"mappings\" : {\n" +
" \"properties\" : {\n" +
" \"brokerId\" : {\n" +
" \"type\" : \"long\"\n" +
" },\n" +
" \"partitionId\" : {\n" +
" \"type\" : \"long\"\n" +
" },\n" +
" \"routingValue\" : {\n" +
" \"type\" : \"text\",\n" +
" \"fields\" : {\n" +
" \"keyword\" : {\n" +
" \"ignore_above\" : 256,\n" +
" \"type\" : \"keyword\"\n" +
" }\n" +
" }\n" +
" },\n" +
" \"clusterPhyId\" : {\n" +
" \"type\" : \"long\"\n" +
" },\n" +
" \"topic\" : {\n" +
" \"type\" : \"keyword\"\n" +
" },\n" +
" \"metrics\" : {\n" +
" \"properties\" : {\n" +
" \"LogStartOffset\" : {\n" +
" \"type\" : \"float\"\n" +
" },\n" +
" \"Messages\" : {\n" +
" \"type\" : \"float\"\n" +
" },\n" +
" \"LogEndOffset\" : {\n" +
" \"type\" : \"float\"\n" +
" }\n" +
" }\n" +
" },\n" +
" \"key\" : {\n" +
" \"type\" : \"text\",\n" +
" \"fields\" : {\n" +
" \"keyword\" : {\n" +
" \"ignore_above\" : 256,\n" +
" \"type\" : \"keyword\"\n" +
" }\n" +
" }\n" +
" },\n" +
" \"timestamp\" : {\n" +
" \"format\" : \"yyyy-MM-dd HH:mm:ss Z||yyyy-MM-dd HH:mm:ss||yyyy-MM-dd HH:mm:ss.SSS Z||yyyy-MM-dd HH:mm:ss.SSS||yyyy-MM-dd HH:mm:ss,SSS||yyyy/MM/dd HH:mm:ss||yyyy-MM-dd HH:mm:ss,SSS Z||yyyy/MM/dd HH:mm:ss,SSS Z||epoch_millis\",\n" +
" \"index\" : true,\n" +
" \"type\" : \"date\",\n" +
" \"doc_values\" : true\n" +
" }\n" +
" }\n" +
" },\n" +
" \"aliases\" : { }\n" +
" }";
public final static String GROUP_INDEX = "ks_kafka_group_metric";
public final static String GROUP_TEMPLATE = "{\n" +
" \"order\" : 10,\n" +
" \"index_patterns\" : [\n" +
" \"ks_kafka_group_metric*\"\n" +
" ],\n" +
" \"settings\" : {\n" +
" \"index\" : {\n" +
" \"number_of_shards\" : \"10\"\n" +
" }\n" +
" },\n" +
" \"mappings\" : {\n" +
" \"properties\" : {\n" +
" \"group\" : {\n" +
" \"type\" : \"keyword\"\n" +
" },\n" +
" \"partitionId\" : {\n" +
" \"type\" : \"long\"\n" +
" },\n" +
" \"routingValue\" : {\n" +
" \"type\" : \"text\",\n" +
" \"fields\" : {\n" +
" \"keyword\" : {\n" +
" \"ignore_above\" : 256,\n" +
" \"type\" : \"keyword\"\n" +
" }\n" +
" }\n" +
" },\n" +
" \"clusterPhyId\" : {\n" +
" \"type\" : \"long\"\n" +
" },\n" +
" \"topic\" : {\n" +
" \"type\" : \"keyword\"\n" +
" },\n" +
" \"metrics\" : {\n" +
" \"properties\" : {\n" +
" \"HealthScore\" : {\n" +
" \"type\" : \"float\"\n" +
" },\n" +
" \"Lag\" : {\n" +
" \"type\" : \"float\"\n" +
" },\n" +
" \"OffsetConsumed\" : {\n" +
" \"type\" : \"float\"\n" +
" },\n" +
" \"HealthCheckTotal\" : {\n" +
" \"type\" : \"float\"\n" +
" },\n" +
" \"HealthCheckPassed\" : {\n" +
" \"type\" : \"float\"\n" +
" }\n" +
" }\n" +
" },\n" +
" \"groupMetric\" : {\n" +
" \"type\" : \"keyword\"\n" +
" },\n" +
" \"key\" : {\n" +
" \"type\" : \"text\",\n" +
" \"fields\" : {\n" +
" \"keyword\" : {\n" +
" \"ignore_above\" : 256,\n" +
" \"type\" : \"keyword\"\n" +
" }\n" +
" }\n" +
" },\n" +
" \"timestamp\" : {\n" +
" \"format\" : \"yyyy-MM-dd HH:mm:ss Z||yyyy-MM-dd HH:mm:ss||yyyy-MM-dd HH:mm:ss.SSS Z||yyyy-MM-dd HH:mm:ss.SSS||yyyy-MM-dd HH:mm:ss,SSS||yyyy/MM/dd HH:mm:ss||yyyy-MM-dd HH:mm:ss,SSS Z||yyyy/MM/dd HH:mm:ss,SSS Z||epoch_millis\",\n" +
" \"index\" : true,\n" +
" \"type\" : \"date\",\n" +
" \"doc_values\" : true\n" +
" }\n" +
" }\n" +
" },\n" +
" \"aliases\" : { }\n" +
" }";
public final static String REPLICATION_INDEX = "ks_kafka_replication_metric";
public final static String REPLICATION_TEMPLATE = "{\n" +
" \"order\" : 10,\n" +
" \"index_patterns\" : [\n" +
" \"ks_kafka_partition_metric*\"\n" +
" ],\n" +
" \"settings\" : {\n" +
" \"index\" : {\n" +
" \"number_of_shards\" : \"10\"\n" +
" }\n" +
" },\n" +
" \"mappings\" : {\n" +
" \"properties\" : {\n" +
" \"brokerId\" : {\n" +
" \"type\" : \"long\"\n" +
" },\n" +
" \"partitionId\" : {\n" +
" \"type\" : \"long\"\n" +
" },\n" +
" \"routingValue\" : {\n" +
" \"type\" : \"text\",\n" +
" \"fields\" : {\n" +
" \"keyword\" : {\n" +
" \"ignore_above\" : 256,\n" +
" \"type\" : \"keyword\"\n" +
" }\n" +
" }\n" +
" },\n" +
" \"clusterPhyId\" : {\n" +
" \"type\" : \"long\"\n" +
" },\n" +
" \"topic\" : {\n" +
" \"type\" : \"keyword\"\n" +
" },\n" +
" \"metrics\" : {\n" +
" \"properties\" : {\n" +
" \"LogStartOffset\" : {\n" +
" \"type\" : \"float\"\n" +
" },\n" +
" \"Messages\" : {\n" +
" \"type\" : \"float\"\n" +
" },\n" +
" \"LogEndOffset\" : {\n" +
" \"type\" : \"float\"\n" +
" }\n" +
" }\n" +
" },\n" +
" \"key\" : {\n" +
" \"type\" : \"text\",\n" +
" \"fields\" : {\n" +
" \"keyword\" : {\n" +
" \"ignore_above\" : 256,\n" +
" \"type\" : \"keyword\"\n" +
" }\n" +
" }\n" +
" },\n" +
" \"timestamp\" : {\n" +
" \"format\" : \"yyyy-MM-dd HH:mm:ss Z||yyyy-MM-dd HH:mm:ss||yyyy-MM-dd HH:mm:ss.SSS Z||yyyy-MM-dd HH:mm:ss.SSS||yyyy-MM-dd HH:mm:ss,SSS||yyyy/MM/dd HH:mm:ss||yyyy-MM-dd HH:mm:ss,SSS Z||yyyy/MM/dd HH:mm:ss,SSS Z||epoch_millis\",\n" +
" \"index\" : true,\n" +
" \"type\" : \"date\",\n" +
" \"doc_values\" : true\n" +
" }\n" +
" }\n" +
" },\n" +
" \"aliases\" : { }\n" +
" }[root@10-255-0-23 template]# cat ks_kafka_replication_metric\n" +
"PUT _template/ks_kafka_replication_metric\n" +
"{\n" +
" \"order\" : 10,\n" +
" \"index_patterns\" : [\n" +
" \"ks_kafka_replication_metric*\"\n" +
" ],\n" +
" \"settings\" : {\n" +
" \"index\" : {\n" +
" \"number_of_shards\" : \"10\"\n" +
" }\n" +
" },\n" +
" \"mappings\" : {\n" +
" \"properties\" : {\n" +
" \"timestamp\" : {\n" +
" \"format\" : \"yyyy-MM-dd HH:mm:ss Z||yyyy-MM-dd HH:mm:ss||yyyy-MM-dd HH:mm:ss.SSS Z||yyyy-MM-dd HH:mm:ss.SSS||yyyy-MM-dd HH:mm:ss,SSS||yyyy/MM/dd HH:mm:ss||yyyy-MM-dd HH:mm:ss,SSS Z||yyyy/MM/dd HH:mm:ss,SSS Z||epoch_millis\",\n" +
" \"index\" : true,\n" +
" \"type\" : \"date\",\n" +
" \"doc_values\" : true\n" +
" }\n" +
" }\n" +
" },\n" +
" \"aliases\" : { }\n" +
" }";
}

View File

@@ -33,7 +33,7 @@ public class KafkaConstant {
public static final Integer DATA_VERSION_ONE = 1; public static final Integer DATA_VERSION_ONE = 1;
public static final Integer ADMIN_CLIENT_REQUEST_TIME_OUT_UNIT_MS = 3000; public static final Integer ADMIN_CLIENT_REQUEST_TIME_OUT_UNIT_MS = 5000;
public static final Integer KAFKA_SASL_SCRAM_ITERATIONS = 8192; public static final Integer KAFKA_SASL_SCRAM_ITERATIONS = 8192;
@@ -41,6 +41,8 @@ public class KafkaConstant {
public static final Long POLL_ONCE_TIMEOUT_UNIT_MS = 2000L; public static final Long POLL_ONCE_TIMEOUT_UNIT_MS = 2000L;
public static final String CONTROLLER_ROLE = "controller";
public static final Map<String, ConfigDef.ConfigKey> KAFKA_ALL_CONFIG_DEF_MAP = new ConcurrentHashMap<>(); public static final Map<String, ConfigDef.ConfigKey> KAFKA_ALL_CONFIG_DEF_MAP = new ConcurrentHashMap<>();
static { static {

View File

@@ -170,6 +170,7 @@ public class ReassignConverter {
detail.setOriginalBrokerIdList(CommonUtils.string2IntList(subJobPO.getOriginalBrokerIds())); detail.setOriginalBrokerIdList(CommonUtils.string2IntList(subJobPO.getOriginalBrokerIds()));
detail.setReassignBrokerIdList(CommonUtils.string2IntList(subJobPO.getReassignBrokerIds())); detail.setReassignBrokerIdList(CommonUtils.string2IntList(subJobPO.getReassignBrokerIds()));
detail.setStatus(subJobPO.getStatus()); detail.setStatus(subJobPO.getStatus());
detail.setOldReplicaNum(detail.getOriginalBrokerIdList().size());
ReassignSubJobExtendData extendData = ConvertUtil.str2ObjByJson(subJobPO.getExtendData(), ReassignSubJobExtendData.class); ReassignSubJobExtendData extendData = ConvertUtil.str2ObjByJson(subJobPO.getExtendData(), ReassignSubJobExtendData.class);
if (extendData != null) { if (extendData != null) {
@@ -217,6 +218,7 @@ public class ReassignConverter {
topicDetail.setPresentReplicaNum(partitionDetailList.get(0).getPresentReplicaNum()); topicDetail.setPresentReplicaNum(partitionDetailList.get(0).getPresentReplicaNum());
topicDetail.setNewReplicaNum(partitionDetailList.get(0).getNewReplicaNum()); topicDetail.setNewReplicaNum(partitionDetailList.get(0).getNewReplicaNum());
topicDetail.setOldReplicaNum(partitionDetailList.get(0).getOldReplicaNum());
topicDetail.setOriginalRetentionTimeUnitMs(partitionDetailList.get(0).getOriginalRetentionTimeUnitMs()); topicDetail.setOriginalRetentionTimeUnitMs(partitionDetailList.get(0).getOriginalRetentionTimeUnitMs());
topicDetail.setReassignRetentionTimeUnitMs(partitionDetailList.get(0).getReassignRetentionTimeUnitMs()); topicDetail.setReassignRetentionTimeUnitMs(partitionDetailList.get(0).getReassignRetentionTimeUnitMs());

View File

@@ -26,7 +26,7 @@ public enum HealthCheckNameEnum {
HealthCheckDimensionEnum.CLUSTER, HealthCheckDimensionEnum.CLUSTER,
"Controller", "Controller",
Constant.HC_CONFIG_NAME_PREFIX + "CLUSTER_NO_CONTROLLER", Constant.HC_CONFIG_NAME_PREFIX + "CLUSTER_NO_CONTROLLER",
"集群Controller数错误", "集群Controller数正常",
HealthCompareValueConfig.class HealthCompareValueConfig.class
), ),
@@ -34,7 +34,7 @@ public enum HealthCheckNameEnum {
HealthCheckDimensionEnum.BROKER, HealthCheckDimensionEnum.BROKER,
"RequestQueueSize", "RequestQueueSize",
Constant.HC_CONFIG_NAME_PREFIX + "BROKER_REQUEST_QUEUE_FULL", Constant.HC_CONFIG_NAME_PREFIX + "BROKER_REQUEST_QUEUE_FULL",
"Broker-RequestQueueSize被打满", "Broker-RequestQueueSize指标",
HealthCompareValueConfig.class HealthCompareValueConfig.class
), ),
@@ -42,7 +42,7 @@ public enum HealthCheckNameEnum {
HealthCheckDimensionEnum.BROKER, HealthCheckDimensionEnum.BROKER,
"NetworkProcessorAvgIdlePercent", "NetworkProcessorAvgIdlePercent",
Constant.HC_CONFIG_NAME_PREFIX + "BROKER_NETWORK_PROCESSOR_AVG_IDLE_TOO_LOW", Constant.HC_CONFIG_NAME_PREFIX + "BROKER_NETWORK_PROCESSOR_AVG_IDLE_TOO_LOW",
"Broker-NetworkProcessorAvgIdlePercent的Idle过低", "Broker-NetworkProcessorAvgIdlePercent指标",
HealthCompareValueConfig.class HealthCompareValueConfig.class
), ),
@@ -50,7 +50,7 @@ public enum HealthCheckNameEnum {
HealthCheckDimensionEnum.GROUP, HealthCheckDimensionEnum.GROUP,
"Group Re-Balance", "Group Re-Balance",
Constant.HC_CONFIG_NAME_PREFIX + "GROUP_RE_BALANCE_TOO_FREQUENTLY", Constant.HC_CONFIG_NAME_PREFIX + "GROUP_RE_BALANCE_TOO_FREQUENTLY",
"Group re-balance太频繁", "Group re-balance频率",
HealthDetectedInLatestMinutesConfig.class HealthDetectedInLatestMinutesConfig.class
), ),
@@ -66,7 +66,7 @@ public enum HealthCheckNameEnum {
HealthCheckDimensionEnum.TOPIC, HealthCheckDimensionEnum.TOPIC,
"UnderReplicaTooLong", "UnderReplicaTooLong",
Constant.HC_CONFIG_NAME_PREFIX + "TOPIC_UNDER_REPLICA_TOO_LONG", Constant.HC_CONFIG_NAME_PREFIX + "TOPIC_UNDER_REPLICA_TOO_LONG",
"Topic 长期处于未同步状态", "Topic 未同步持续时间",
HealthDetectedInLatestMinutesConfig.class HealthDetectedInLatestMinutesConfig.class
), ),

View File

@@ -1,54 +0,0 @@
package com.xiaojukeji.know.streaming.km.common.enums.metric;
/**
* @author: D10865
* @description:
* @date: Create on 2019/3/11 下午2:19
* @modified By D10865
*
* 不同维度的es监控数据
*/
public enum KafkaMetricIndexEnum {
/**
* topic 维度
*/
TOPIC_INFO("ks_kafka_topic_metric"),
/**
* 集群 维度
*/
CLUSTER_INFO("ks_kafka_cluster_metric"),
/**
* broker 维度
*/
BROKER_INFO("ks_kafka_broker_metric"),
/**
* partition 维度
*/
PARTITION_INFO("ks_kafka_partition_metric"),
/**
* group 维度
*/
GROUP_INFO("ks_kafka_group_metric"),
/**
* replication 维度
*/
REPLICATION_INFO("ks_kafka_replication_metric"),
;
private String index;
KafkaMetricIndexEnum(String index) {
this.index = index;
}
public String getIndex() {
return index;
}
}

View File

@@ -31,9 +31,11 @@ public enum VersionItemTypeEnum {
SERVICE_OP_PARTITION(320, "service_partition_operation"), SERVICE_OP_PARTITION(320, "service_partition_operation"),
SERVICE_OP_PARTITION_LEADER(321, "service_partition-leader_operation"),
SERVICE_OP_REASSIGNMENT(330, "service_reassign_operation"), SERVICE_OP_REASSIGNMENT(330, "service_reassign_operation"),
/** /**
* 前端操作 * 前端操作
*/ */

View File

@@ -241,4 +241,14 @@ public class CommonUtils {
} }
return intList; return intList;
} }
public static boolean isNumeric(String str){
for (int i = 0; i < str.length(); i++){
if (!Character.isDigit(str.charAt(i))){
return false;
}
}
return true;
}
} }

View File

@@ -113,7 +113,7 @@ public class BrokerMetadata implements Serializable {
brokerMetadata.getEndpointMap().put(endpoint.substring(0, idx1), new IpPortData(brokerHost, brokerPort)); brokerMetadata.getEndpointMap().put(endpoint.substring(0, idx1), new IpPortData(brokerHost, brokerPort));
if (KafkaConstant.EXTERNAL_KEY.equals(endpoint.substring(0, idx1))) { if (KafkaConstant.INTERNAL_KEY.equals(endpoint.substring(0, idx1))) {
// 优先使用internal的地址进行展示 // 优先使用internal的地址进行展示
brokerMetadata.setHost(brokerHost); brokerMetadata.setHost(brokerHost);
brokerMetadata.setPort(ConvertUtil.string2Integer(brokerPort)); brokerMetadata.setPort(ConvertUtil.string2Integer(brokerPort));

View File

@@ -9,6 +9,5 @@ build/
coverage coverage
versions/ versions/
debug.log debug.log
package-lock.json
yarn.lock yarn.lock
target target

View File

@@ -1,43 +1,65 @@
## 安装项目依赖 ## 前提
- 安装 lerna 通常情况下,您可以通过 [本地源码启动手册](https://github.com/didi/KnowStreaming/blob/master/docs/dev_guide/%E6%9C%AC%E5%9C%B0%E6%BA%90%E7%A0%81%E5%90%AF%E5%8A%A8%E6%89%8B%E5%86%8C.md) 来打包工程。如果您需要在本地独立启动或打包前端服务,请参考以下手册。
在进行以下的步骤之前,首先确保您已经安装了 `node`。如已安装,可以通过在终端执行 `node -v` 来获取到 node 版本,项目推荐使用 `node v12` 版本运行(例如 `node v12.22.12`)。
另外,`windows` 用户请在 `git bash` 下运行下面的命令。
## 一、进入 km-console 目录
在终端执行以下步骤时,需要先进入 `KnowStreaming/km-console` 目录。
## 二、安装项目依赖(必须)
1. 安装 lerna可选安装后可以直接通过 lerna 的全局指令管理项目,如果不了解 lerna 可以不安装)
``` ```
npm install -g lerna npm install -g lerna
``` ```
- 安装项目依赖 2. 安装项目依赖
``` ```
npm run i npm run i
``` ```
## 启动项目 我们默认保留了 `package-lock.json` 文件,以防止可能的依赖包自动升级导致的问题。依赖默认会通过 taobao 镜像 `https://registry.npmmirror.com/` 服务下载。
## 三、启动项目(可选,打包构建请直接看步骤三)
``` ```
npm run start npm run start
``` ```
### 环境信息 该指令会启动 `packages` 目录下的所有应用,如果需要单独启动应用,其查看下方 QA。
http://localhost:port 多集群管理应用会启动在 http://localhost:8000系统管理应用会占用 http://localhost:8001。
请确认 `8000``8001` 端口没有被其他应用占用。
## 构建项目 后端本地服务启动在 http://localhost:8080请求通过 webpack dev server 代理访问 8080 端口,需要启动后端服务后才能正常请求接口。
如果启动失败,可以参见另外一种本地启动方式 [本地源码启动手册](https://github.com/didi/KnowStreaming/blob/master/docs/dev_guide/%E6%9C%AC%E5%9C%B0%E6%BA%90%E7%A0%81%E5%90%AF%E5%8A%A8%E6%89%8B%E5%86%8C.md)
## 四、构建项目
``` ```
npm run build npm run build
``` ```
项目构建成功后,会存放到 km-rest/src/main/resources/tamplates 目录下。
## 目录结构 ## 目录结构
- packages - packages
- layout-clusters-fe: 基座应用 & 多集群管理 - layout-clusters-fe: 基座应用 & 多集群管理(其余应用启动需要首先启动该应用)
- config-manager-fe: 子应用 - 系统管理 - config-manager-fe: 子应用 - 系统管理
- tool: 启动 & 打包脚本
- ... - ...
## 常见问题 ## QA
Q: 在 `km-console` 目录下执行 `npm run start` 时看不到应用构建和热加载过程?如何启动单个应用?
Q: 执行 `npm run start` 时看不到应用构建和热加载过程?
A: 需要到具体的应用中执行 `npm run start`,例如 `cd packages/layout-clusters-fe` 后,执行 `npm run start` A: 需要到具体的应用中执行 `npm run start`,例如 `cd packages/layout-clusters-fe` 后,执行 `npm run start`
如遇到其它问题,请见 [faq](https://github.com/didi/KnowStreaming/blob/master/docs/user_guide/faq.md)。

8567
km-console/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -17,15 +17,15 @@
"eslint-plugin-react": "7.22.0", "eslint-plugin-react": "7.22.0",
"eslint-plugin-react-hooks": "^4.2.0", "eslint-plugin-react-hooks": "^4.2.0",
"husky": "4.3.7", "husky": "4.3.7",
"lerna": "^4.0.0", "lerna": "^5.5.0",
"lint-staged": "10.5.3", "lint-staged": "10.5.3",
"prettier": "2.3.2" "prettier": "2.3.2"
}, },
"scripts": { "scripts": {
"i": "npm install && lerna bootstrap", "i": "npm install && lerna bootstrap",
"clean": "rm -rf node_modules package-lock.json packages/*/node_modules packages/*/package-lock.json", "clean": "rm -rf node_modules package-lock.json packages/*/node_modules packages/*/package-lock.json",
"start": "sh ./tool/start.sh", "start": "lerna run start",
"build": "sh ./tool/build.sh", "build": "lerna run build",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0 && git add CHANGELOG.md", "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0 && git add CHANGELOG.md",
"cm": "git add . && cz" "cm": "git add . && cz"
}, },

View File

@@ -9,5 +9,4 @@ build/
coverage coverage
versions/ versions/
debug.log debug.log
package-lock.json
yarn.lock yarn.lock

View File

@@ -1,17 +1,21 @@
## 使用说明 ## 使用说明
### 依赖安装: ### 依赖安装(如在 km-console 目录下执行 npm run i 安装过依赖,这步可以省略)
``` ```
npm install npm install
``` ```
注意,这种方式只会安装当前应用的依赖。如果您不了解,推荐在 km-console 目录下执行 npm run i 安装依赖。
### 启动: ### 启动:
``` ```
npm run start npm run start
``` ```
该应用为子应用,启动后需要到基座应用中查看(需要启动基座应用,即 layout-clusters-fe地址为 http://localhost:8000
### 构建: ### 构建:
``` ```

File diff suppressed because it is too large Load Diff

View File

@@ -18,7 +18,7 @@
"scripts": { "scripts": {
"test": "echo \"Error: run tests from root\" && exit 1", "test": "echo \"Error: run tests from root\" && exit 1",
"start": "cross-env NODE_ENV=development webpack-dev-server", "start": "cross-env NODE_ENV=development webpack-dev-server",
"build": "rm -rf ../../pub/layout & cross-env NODE_ENV=production webpack --max_old_space_size=8000" "build": "cross-env NODE_ENV=production webpack --max_old_space_size=8000"
}, },
"dependencies": { "dependencies": {
"babel-preset-react-app": "^10.0.0", "babel-preset-react-app": "^10.0.0",
@@ -58,6 +58,7 @@
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.1", "@pmmmwh/react-refresh-webpack-plugin": "^0.5.1",
"@types/lodash": "^4.14.138", "@types/lodash": "^4.14.138",
"@types/react-dom": "^17.0.5", "@types/react-dom": "^17.0.5",
"@types/react-router": "5.1.18",
"@types/react-router-dom": "^5.3.3", "@types/react-router-dom": "^5.3.3",
"@types/single-spa-react": "^2.12.0", "@types/single-spa-react": "^2.12.0",
"@typescript-eslint/eslint-plugin": "4.13.0", "@typescript-eslint/eslint-plugin": "4.13.0",

View File

@@ -2,8 +2,8 @@ import React from 'react';
import { BrowserRouter as Router, Redirect, Switch } from 'react-router-dom'; import { BrowserRouter as Router, Redirect, Switch } from 'react-router-dom';
import _ from 'lodash'; import _ from 'lodash';
import './constants/axiosConfig'; import './constants/axiosConfig';
import dantdZhCN from 'knowdesign/lib/locale/zh_CN'; import dantdZhCN from 'knowdesign/es/locale/zh_CN';
import dantdEnUS from 'knowdesign/lib/locale/en_US'; import dantdEnUS from 'knowdesign/es/locale/en_US';
import intlZhCN from './locales/zh'; import intlZhCN from './locales/zh';
import intlEnUS from './locales/en'; import intlEnUS from './locales/en';
import { AppContainer, RouteGuard, DProLayout } from 'knowdesign'; import { AppContainer, RouteGuard, DProLayout } from 'knowdesign';

View File

@@ -1,6 +1,6 @@
import { DownOutlined } from '@ant-design/icons'; import { DownOutlined } from '@ant-design/icons';
import { Popover } from 'knowdesign'; import { Popover } from 'knowdesign';
import { TooltipPlacement } from 'knowdesign/lib/basic/tooltip'; import { TooltipPlacement } from 'knowdesign/es/basic/tooltip';
import React, { useState, useRef, useEffect } from 'react'; import React, { useState, useRef, useEffect } from 'react';
import './index.less'; import './index.less';
@@ -90,8 +90,9 @@ export default (props: PropsType) => {
return ( return (
<div <div
key={i} key={i}
className={`container-item ${curState.calculated ? (curState.isHideExpandNode ? 'show' : i >= curState.endI ? 'hide' : 'show') : '' className={`container-item ${
}`} curState.calculated ? (curState.isHideExpandNode ? 'show' : i >= curState.endI ? 'hide' : 'show') : ''
}`}
> >
{item} {item}
</div> </div>

View File

@@ -35,7 +35,16 @@ serviceInstance.interceptors.request.use(
// 响应拦截 // 响应拦截
serviceInstance.interceptors.response.use( serviceInstance.interceptors.response.use(
(config: any) => { (config: any) => {
return config.data; const res: { code: number; message: string; data: any } = config.data;
if (res.code !== 0 && res.code !== 200) {
const desc = res.message;
notification.error({
message: desc,
duration: 3,
});
throw res;
}
return res;
}, },
(err: any) => { (err: any) => {
const config = err.config; const config = err.config;

View File

@@ -73,12 +73,12 @@ const CheckboxGroupContainer = (props: CheckboxGroupType) => {
</Checkbox> </Checkbox>
</div> </div>
<Checkbox.Group disabled={disabled} style={{ width: '100%' }} value={checkedList} onChange={onCheckedChange}> <Checkbox.Group disabled={disabled} style={{ width: '100%' }} value={checkedList} onChange={onCheckedChange}>
<Row gutter={[34, 10]}> <Row gutter={[10, 10]}>
{options.map((option) => { {options.map((option) => {
return ( return (
<Col span={8} key={option.value}> <Col span={8} key={option.value}>
<Checkbox value={option.value} className="checkbox-content-ellipsis"> <Checkbox value={option.value} className="checkbox-content-ellipsis">
{option.label} {option.label.replace('Cluster-Load', '')}
</Checkbox> </Checkbox>
</Col> </Col>
); );

View File

@@ -20,7 +20,7 @@ import {
IconFont, IconFont,
} from 'knowdesign'; } from 'knowdesign';
import moment from 'moment'; import moment from 'moment';
import { CloseOutlined, LoadingOutlined, PlusOutlined } from '@ant-design/icons'; import { LoadingOutlined, PlusOutlined } from '@ant-design/icons';
import { defaultPagination } from 'constants/common'; import { defaultPagination } from 'constants/common';
import { RoleProps, PermissionNode, AssignUser, RoleOperate, FormItemPermission } from './config'; import { RoleProps, PermissionNode, AssignUser, RoleOperate, FormItemPermission } from './config';
import api from 'api'; import api from 'api';
@@ -50,11 +50,21 @@ const RoleDetailAndUpdate = forwardRef((props, ref): JSX.Element => {
useEffect(() => { useEffect(() => {
const globalPermissions = global.permissions; const globalPermissions = global.permissions;
if (globalPermissions && globalPermissions.length) { if (globalPermissions && globalPermissions.length) {
const sysPermissions = globalPermissions.map((sys: PermissionNode) => ({ const sysPermissions = globalPermissions.map((sys: PermissionNode) => {
id: sys.id, const result = {
name: sys.permissionName, id: sys.id,
options: sys.childList.map((node) => ({ label: node.permissionName, value: node.id })), name: sys.permissionName,
})); essentialPermission: undefined,
options: [],
};
result.options = sys.childList.map((node) => {
if (node.permissionName === '多集群管理查看' || node.permissionName === '系统管理查看') {
result.essentialPermission = { label: node.permissionName, value: node.id };
}
return { label: node.permissionName, value: node.id };
});
return result;
});
setPermissions(sysPermissions); setPermissions(sysPermissions);
} }
}, [global]); }, [global]);
@@ -79,7 +89,10 @@ const RoleDetailAndUpdate = forwardRef((props, ref): JSX.Element => {
form.validateFields().then((formData) => { form.validateFields().then((formData) => {
formData.permissionIdList.forEach((arr, i) => { formData.permissionIdList.forEach((arr, i) => {
// 如果分配的系统下的子权限,自动赋予该系统的权限 // 如果分配的系统下的子权限,自动赋予该系统的权限
if (arr !== null && arr.length) { if (!Array.isArray(arr)) {
arr = [];
}
if (arr?.length) {
arr.push(permissions[i].id); arr.push(permissions[i].id);
} }
}); });
@@ -209,10 +222,20 @@ const RoleDetailAndUpdate = forwardRef((props, ref): JSX.Element => {
<Form.Item <Form.Item
label="分配权限" label="分配权限"
name="permissionIdList" name="permissionIdList"
required
rules={[ rules={[
() => ({ () => ({
validator(_, value) { validator(_, value) {
if (Array.isArray(value) && value.some((item) => !!item.length)) { if (Array.isArray(value) && value.some((item) => !!item?.length)) {
const errs = [];
value.forEach((arr, i) => {
if (arr?.length && !arr.includes(permissions[i].essentialPermission.value)) {
errs.push(`[${permissions[i].essentialPermission.label}]`);
}
});
if (errs.length) {
return Promise.reject(`您必须分配 ${errs.join(' 和 ')} 权限`);
}
return Promise.resolve(); return Promise.resolve();
} }
return Promise.reject(new Error('请为角色至少分配一项权限')); return Promise.reject(new Error('请为角色至少分配一项权限'));

View File

@@ -59,5 +59,6 @@ export enum RoleOperate {
export interface FormItemPermission { export interface FormItemPermission {
id: number; id: number;
name: string; name: string;
essentialPermission: { label: string; value: number };
options: { label: string; value: number }[]; options: { label: string; value: number }[];
} }

View File

@@ -9,6 +9,5 @@ build/
coverage coverage
versions/ versions/
debug.log debug.log
package-lock.json
yarn.lock yarn.lock
.d1-workspace.json .d1-workspace.json

View File

@@ -1,17 +1,21 @@
## 使用说明 ## 使用说明
### 依赖安装: ### 依赖安装(如在 km-console 目录下执行 npm run i 安装过依赖,这步可以省略)
``` ```
npm install npm install
``` ```
注意,这种方式只会安装当前应用的依赖。如果您不了解,推荐在 km-console 目录下执行 npm run i 安装依赖。
### 启动: ### 启动:
``` ```
npm run start npm run start
``` ```
启动后访问地址为 http://localhost:8000
### 构建: ### 构建:
``` ```

View File

@@ -86,12 +86,12 @@ class CoverHtmlWebpackPlugin {
assetJson.reverse().forEach((item) => { assetJson.reverse().forEach((item) => {
if (/\.js$/.test(item)) { if (/\.js$/.test(item)) {
// if (item.includes('vendor~')) { if (item.includes('vendor~')) {
// vendors += `<script async src="${item}"></script>`; vendors += `<script async src="${item}"></script>`;
// } else { } else {
// TODO: entry 只有一个 // TODO: entry 只有一个
portalMap['@portal/layout'] = item; portalMap['@portal/layout'] = item;
// } }
} else if (/\.css$/.test(item)) { } else if (/\.css$/.test(item)) {
links += `<link href="${item}" rel="stylesheet">`; links += `<link href="${item}" rel="stylesheet">`;
} }

View File

@@ -9,7 +9,6 @@ const TerserJSPlugin = require('terser-webpack-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin'); const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const theme = require('./theme'); const theme = require('./theme');
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin'); const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
const HardSourceWebpackPlugin = require('hard-source-webpack-plugin');
const isProd = process.env.NODE_ENV === 'production'; const isProd = process.env.NODE_ENV === 'production';
const babelOptions = { const babelOptions = {
@@ -43,7 +42,6 @@ const babelOptions = {
module.exports = () => { module.exports = () => {
const cssFileName = isProd ? '[name]-[chunkhash].css' : '[name].css'; const cssFileName = isProd ? '[name]-[chunkhash].css' : '[name].css';
const plugins = [ const plugins = [
// !isProd && new HardSourceWebpackPlugin(),
new CoverHtmlWebpackPlugin(), new CoverHtmlWebpackPlugin(),
new ProgressBarPlugin(), new ProgressBarPlugin(),
new CaseSensitivePathsPlugin(), new CaseSensitivePathsPlugin(),
@@ -150,23 +148,21 @@ module.exports = () => {
], ],
}, },
optimization: Object.assign( optimization: Object.assign(
// {
// splitChunks: {
// cacheGroups: {
// vendor: {
// test: /[\\/]node_modules[\\/]/,
// chunks: 'all',
// name: 'vendor',
// priority: 10,
// enforce: true,
// minChunks: 1,
// maxSize: 3500000,
// },
// },
// },
// },
isProd isProd
? { ? {
splitChunks: {
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
chunks: 'all',
name: 'vendor',
priority: 10,
enforce: true,
minChunks: 1,
maxSize: 3000000,
},
},
},
minimizer: [ minimizer: [
new TerserJSPlugin({ new TerserJSPlugin({
cache: true, cache: true,

File diff suppressed because it is too large Load Diff

View File

@@ -17,7 +17,7 @@
"scripts": { "scripts": {
"test": "echo \"Error: run tests from root\" && exit 1", "test": "echo \"Error: run tests from root\" && exit 1",
"start": "cross-env NODE_ENV=development webpack-dev-server", "start": "cross-env NODE_ENV=development webpack-dev-server",
"build": "rm -rf ../../pub/layout & cross-env NODE_ENV=production webpack --max_old_space_size=8000" "build": "cross-env NODE_ENV=production webpack --max_old_space_size=8000"
}, },
"browserslist": { "browserslist": {
"production": [ "production": [
@@ -39,6 +39,7 @@
"@types/react-copy-to-clipboard": "^5.0.2", "@types/react-copy-to-clipboard": "^5.0.2",
"@types/react-dom": "^17.0.11", "@types/react-dom": "^17.0.11",
"@types/react-highlight-words": "^0.16.0", "@types/react-highlight-words": "^0.16.0",
"@types/react-router": "5.1.18",
"@types/react-router-dom": "^5.3.3", "@types/react-router-dom": "^5.3.3",
"@types/react-transition-group": "^4.2.2", "@types/react-transition-group": "^4.2.2",
"@types/react-virtualized": "^9.21.13", "@types/react-virtualized": "^9.21.13",
@@ -59,7 +60,8 @@
"single-spa": "5.9.3", "single-spa": "5.9.3",
"single-spa-react": "2.14.0", "single-spa-react": "2.14.0",
"webpack-bundle-analyzer": "^4.5.0", "webpack-bundle-analyzer": "^4.5.0",
"knowdesign": "1.3.7" "knowdesign": "1.3.7",
"tree-changes": "0.9.1"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.5.5", "@babel/core": "^7.5.5",

View File

@@ -4,8 +4,8 @@ import React, { useState, useEffect, useLayoutEffect } from 'react';
import { BrowserRouter, Switch, Route, useLocation, useHistory } from 'react-router-dom'; import { BrowserRouter, Switch, Route, useLocation, useHistory } from 'react-router-dom';
import { get as lodashGet } from 'lodash'; import { get as lodashGet } from 'lodash';
import { DProLayout, AppContainer, IconFont, Menu, Utils, Page403, Page404, Page500, Modal } from 'knowdesign'; import { DProLayout, AppContainer, IconFont, Menu, Utils, Page403, Page404, Page500, Modal } from 'knowdesign';
import dantdZhCN from 'knowdesign/lib/locale/zh_CN'; import dantdZhCN from 'knowdesign/es/locale/zh_CN';
import dantdEnUS from 'knowdesign/lib/locale/en_US'; import dantdEnUS from 'knowdesign/es/locale/en_US';
import { DotChartOutlined } from '@ant-design/icons'; import { DotChartOutlined } from '@ant-design/icons';
import { licenseEventBus } from './constants/axiosConfig'; import { licenseEventBus } from './constants/axiosConfig';
import intlZhCN from './locales/zh'; import intlZhCN from './locales/zh';
@@ -59,6 +59,7 @@ const logout = () => {
}).then((res) => { }).then((res) => {
window.location.href = '/login'; window.location.href = '/login';
}); });
localStorage.removeItem('userInfo');
}; };
const LicenseLimitModal = () => { const LicenseLimitModal = () => {
@@ -117,7 +118,7 @@ const AppContent = (props: { setlanguage: (language: string) => void }) => {
<DProLayout.Container <DProLayout.Container
headerProps={{ headerProps={{
title: ( title: (
<div> <div style={{ cursor: 'pointer' }}>
<img className="header-logo" src={ksLogo} /> <img className="header-logo" src={ksLogo} />
</div> </div>
), ),

View File

@@ -90,7 +90,7 @@ export default () => {
return ( return (
<div> <div>
<span style={{ display: 'inline-block', marginRight: '8px' }}>Similar Config</span> <span style={{ display: 'inline-block', marginRight: '8px' }}>Similar Config</span>
<Tooltip overlayClassName="rebalance-tooltip" title="所有broker配置是否一致"> <Tooltip overlayClassName="rebalance-tooltip" title="所有Broker配置是否一致">
<QuestionCircleOutlined /> <QuestionCircleOutlined />
</Tooltip> </Tooltip>
</div> </div>
@@ -111,7 +111,7 @@ export default () => {
]; ];
setCardData(cordRightMap); setCardData(cordRightMap);
}); });
Promise.all([brokerMetric, brokersState]).then((res) => { Promise.all([brokerMetric, brokersState]).finally(() => {
setLoading(false); setLoading(false);
}); });
}, [routeParams.clusterId]); }, [routeParams.clusterId]);

View File

@@ -1,12 +1,13 @@
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import { useParams } from 'react-router-dom'; import { useParams } from 'react-router-dom';
import CardBar from './index'; import CardBar from './index';
import { IconFont, Tag, Utils, Tooltip, Popover } from 'knowdesign'; import { IconFont, Tag, Utils, Tooltip, Popover, AppContainer } from 'knowdesign';
import api from '@src/api'; import api from '@src/api';
import StateChart from './StateChart'; import StateChart from './StateChart';
import ClusterNorms from '@src/pages/LoadRebalance/ClusterNorms'; import ClusterNorms from '@src/pages/LoadRebalance/ClusterNorms';
import { QuestionCircleOutlined } from '@ant-design/icons'; import { QuestionCircleOutlined } from '@ant-design/icons';
import moment from 'moment'; import moment from 'moment';
import { ClustersPermissionMap } from '@src/pages/CommonConfig';
const transUnitTimePro = (ms: number, num = 0) => { const transUnitTimePro = (ms: number, num = 0) => {
if (!ms) return ''; if (!ms) return '';
@@ -23,6 +24,7 @@ const transUnitTimePro = (ms: number, num = 0) => {
}; };
const LoadRebalanceCardBar = (props: any) => { const LoadRebalanceCardBar = (props: any) => {
const [global] = AppContainer.useGlobalValue();
const { clusterId } = useParams<{ const { clusterId } = useParams<{
clusterId: string; clusterId: string;
}>(); }>();
@@ -53,12 +55,14 @@ const LoadRebalanceCardBar = (props: any) => {
return ( return (
<div style={{ height: '20px' }}> <div style={{ height: '20px' }}>
<span style={{ display: 'inline-block', marginRight: '8px' }}>State</span> <span style={{ display: 'inline-block', marginRight: '8px' }}>State</span>
<IconFont {global.hasPermission(ClustersPermissionMap.REBALANCE_SETTING) && (
className="cutomIcon-config" <IconFont
style={{ fontSize: '15px' }} className="cutomIcon-config"
onClick={() => setNormsVisible(true)} style={{ fontSize: '15px' }}
type="icon-shezhi" onClick={() => setNormsVisible(true)}
></IconFont> type="icon-shezhi"
></IconFont>
)}
</div> </div>
); );
}, },

View File

@@ -1,18 +1,20 @@
import React, { forwardRef, useEffect, useImperativeHandle, useRef, useState } from 'react'; import React, { forwardRef, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
import { AppContainer, Button, Drawer, IconFont, message, Spin, Table, SingleChart, Utils, Tooltip } from 'knowdesign'; import { AppContainer, Drawer, Spin, Table, SingleChart, Utils, Tooltip } from 'knowdesign';
import moment from 'moment'; import moment from 'moment';
import api, { MetricType } from '@src/api'; import api, { MetricType } from '@src/api';
import { useParams } from 'react-router-dom'; import { useParams } from 'react-router-dom';
import { debounce } from 'lodash'; import { debounce } from 'lodash';
import { MetricDefaultChartDataType, MetricChartDataType, formatChartData, getDetailChartConfig } from './config'; import { MetricDefaultChartDataType, MetricChartDataType, formatChartData, getDetailChartConfig } from './config';
import { UNIT_MAP } from '@src/constants/chartConfig'; import { UNIT_MAP } from '@src/constants/chartConfig';
import { CloseOutlined } from '@ant-design/icons'; import RenderEmpty from '../RenderEmpty';
interface ChartDetailProps { interface ChartDetailProps {
metricType: MetricType; metricType: MetricType;
metricName: string; metricName: string;
queryLines: string[]; queryLines: string[];
onClose: () => void; setSliderRange: (range: string) => void;
// eslint-disable-next-line @typescript-eslint/ban-types
setDisposeChartInstance: Function;
} }
interface MetricTableInfo { interface MetricTableInfo {
@@ -24,6 +26,18 @@ interface MetricTableInfo {
color: string; color: string;
} }
interface ChartInfo {
chartInstance?: echarts.ECharts;
isLoadingAdditionData?: boolean;
isLoadedFullData?: boolean;
fullTimeRange?: readonly [number, number];
curTimeRange?: readonly [number, number];
sliderPos?: readonly [number, number];
transformUnit?: [string, number];
fullMetricData?: MetricChartDataType;
oldDataZoomOption?: any;
}
interface DataZoomEventProps { interface DataZoomEventProps {
type: 'datazoom'; type: 'datazoom';
// 缩放的开始位置的百分比0 - 100 // 缩放的开始位置的百分比0 - 100
@@ -34,8 +48,6 @@ interface DataZoomEventProps {
// 缩放区默认选中范围比例0.011 // 缩放区默认选中范围比例0.011
const DATA_ZOOM_DEFAULT_SCALE = 0.25; const DATA_ZOOM_DEFAULT_SCALE = 0.25;
// 选中范围最少展示的时间长度(默认 10 分钟),单位: ms
const LEAST_SELECTED_TIME_RANGE = 1 * 60 * 1000;
// 单次向服务器请求数据的范围(默认 6 小时,超过后采集频率间隔会变长),单位: ms // 单次向服务器请求数据的范围(默认 6 小时,超过后采集频率间隔会变长),单位: ms
const DEFAULT_REQUEST_TIME_RANGE = 6 * 60 * 60 * 1000; const DEFAULT_REQUEST_TIME_RANGE = 6 * 60 * 60 * 1000;
// 采样间隔,影响前端补点逻辑,单位: ms // 采样间隔,影响前端补点逻辑,单位: ms
@@ -47,70 +59,15 @@ const DEFAULT_ENTER_TIME_RANGE = 2 * 60 * 60 * 1000;
// 预缓存数据阈值,图表展示数据的开始时间处于前端缓存数据的时间范围的前 40% 时,向服务器请求数据 // 预缓存数据阈值,图表展示数据的开始时间处于前端缓存数据的时间范围的前 40% 时,向服务器请求数据
const PRECACHE_THRESHOLD = 0.4; const PRECACHE_THRESHOLD = 0.4;
// 表格列
const colunms = [
{
title: 'Host',
dataIndex: 'name',
width: 200,
render(name: string, record: any) {
return (
<div style={{ display: 'flex', alignItems: 'center' }}>
<div style={{ width: 8, height: 2, marginRight: 4, background: record.color }}></div>
<span>{name}</span>
</div>
);
},
},
{
title: 'Avg',
dataIndex: 'avg',
width: 120,
render(num: number) {
return num.toFixed(2);
},
},
{
title: 'Max',
dataIndex: 'max',
width: 120,
render(num: number, record: any) {
return (
<div>
<span>{num.toFixed(2)}</span>
</div>
);
},
},
{
title: 'Min',
dataIndex: 'min',
width: 120,
render(num: number, record: any) {
return (
<div>
<span>{num.toFixed(2)}</span>
</div>
);
},
},
{
title: 'Latest',
dataIndex: 'latest',
width: 120,
render(latest: number[]) {
return `${latest[1].toFixed(2)}`;
},
},
];
const ChartDetail = (props: ChartDetailProps) => { const ChartDetail = (props: ChartDetailProps) => {
const [global] = AppContainer.useGlobalValue(); const [global] = AppContainer.useGlobalValue();
const { clusterId } = useParams<{ const { clusterId } = useParams<{
clusterId: string; clusterId: string;
}>(); }>();
const { metricType, metricName, queryLines, onClose } = props; const { metricType, metricName, queryLines, setSliderRange, setDisposeChartInstance } = props;
// 初始化拖拽防抖函数
const debouncedZoomDrag = useRef(null);
// 存储图表相关的不需要触发渲染的数据,用于计算图表展示状态并进行操作 // 存储图表相关的不需要触发渲染的数据,用于计算图表展示状态并进行操作
const chartInfo = useRef( const chartInfo = useRef(
(() => { (() => {
@@ -119,16 +76,16 @@ const ChartDetail = (props: ChartDetailProps) => {
const curTimeRange = [curTime - DEFAULT_ENTER_TIME_RANGE, curTime] as const; const curTimeRange = [curTime - DEFAULT_ENTER_TIME_RANGE, curTime] as const;
return { return {
chartInstance: undefined as echarts.ECharts, chartInstance: undefined,
isLoadingAdditionData: false,
isLoadedFullData: false, isLoadedFullData: false,
fullTimeRange: curTimeRange, fullTimeRange: curTimeRange,
fullMetricData: {} as MetricChartDataType, fullMetricData: {} as MetricChartDataType,
curTimeRange, curTimeRange,
oldDataZoomOption: {} as any, oldDataZoomOption: {},
sliderPos: [0, 0] as readonly [number, number], sliderPos: [0, 0],
sliderRange: '', transformUnit: undefined,
transformUnit: undefined as [string, number], } as ChartInfo;
};
})() })()
); );
@@ -137,8 +94,76 @@ const ChartDetail = (props: ChartDetailProps) => {
const [curMetricData, setCurMetricData] = useState<MetricChartDataType>(); const [curMetricData, setCurMetricData] = useState<MetricChartDataType>();
// 图表数据的各项计算指标 // 图表数据的各项计算指标
const [tableInfo, setTableInfo] = useState<MetricTableInfo[]>([]); const [tableInfo, setTableInfo] = useState<MetricTableInfo[]>([]);
// 选中展示的图表 const [linesStatus, setLinesStatus] = useState<{
const [selectedLines, setSelectedLines] = useState<string[]>([]); [lineName: string]: boolean;
}>({});
// 表格列
const colunms = useMemo(
() => [
{
title: metricType === MetricType.Broker ? 'Host' : 'Topic',
dataIndex: 'name',
width: 200,
render(name: string, record: any) {
return (
<div style={{ display: 'flex', alignItems: 'center' }}>
<div style={{ width: 8, height: 2, marginRight: 4, background: record.color }}></div>
<span>{name}</span>
</div>
);
},
},
{
title: 'Avg',
dataIndex: 'avg',
width: 120,
render(num: number) {
return num.toFixed(2);
},
},
{
title: 'Max',
dataIndex: 'max',
width: 120,
render(num: number, record: any) {
return (
<div>
<span>{num.toFixed(2)}</span>
</div>
);
},
},
{
title: 'Min',
dataIndex: 'min',
width: 120,
render(num: number, record: any) {
return (
<div>
<span>{num.toFixed(2)}</span>
</div>
);
},
},
{
title: 'Latest',
dataIndex: 'latest',
width: 120,
render(latest: number[]) {
return `${latest[1].toFixed(2)}`;
},
},
],
[metricType]
);
const updateChartInfo = (changedInfo: ChartInfo) => {
chartInfo.current = {
...chartInfo.current,
...changedInfo,
};
};
// 请求图表数据 // 请求图表数据
const getMetricChartData = ([startTime, endTime]: readonly [number, number]) => { const getMetricChartData = ([startTime, endTime]: readonly [number, number]) => {
@@ -175,11 +200,10 @@ const ChartDetail = (props: ChartDetailProps) => {
// 如果滑块整体拖动,则只更新拖动后滑块的位(保留小数点后三位是防止低位值的干扰) // 如果滑块整体拖动,则只更新拖动后滑块的位(保留小数点后三位是防止低位值的干扰)
if (oldScale.toFixed(3) === newScale.toFixed(3)) { if (oldScale.toFixed(3) === newScale.toFixed(3)) {
chartInfo.current = { updateChartInfo({
...chartInfo.current,
sliderPos: [newStartSliderPos, newEndSliderPos], sliderPos: [newStartSliderPos, newEndSliderPos],
oldDataZoomOption: newDataZoomOption, oldDataZoomOption: newDataZoomOption,
}; });
renderTableInfo(); renderTableInfo();
return false; return false;
@@ -217,23 +241,14 @@ const ChartDetail = (props: ChartDetailProps) => {
} }
} else { } else {
// 3. 滑块拖动后缩放比例变小 // 3. 滑块拖动后缩放比例变小
// 判断拖动后选择的时间范围并提示
if (newEndSliderPos - newStartSliderPos < LEAST_SELECTED_TIME_RANGE) {
// TODO: 补充逻辑
updateChartData([oldStartTimestamp, oldEndTimestamp], [oldStartSliderPos, oldEndSliderPos]);
message.warning(`当前选择范围小于 ${LEAST_SELECTED_TIME_RANGE / 60 / 1000} 分钟,图表可能无数据`);
return true;
}
const isOldLarger = oldScale - DATA_ZOOM_DEFAULT_SCALE > 0.01; const isOldLarger = oldScale - DATA_ZOOM_DEFAULT_SCALE > 0.01;
const isNewLarger = newScale - DATA_ZOOM_DEFAULT_SCALE > 0.01; const isNewLarger = newScale - DATA_ZOOM_DEFAULT_SCALE > 0.01;
if (isOldLarger && isNewLarger) { if (isOldLarger && isNewLarger) {
// 如果拖拽前后比例均高于默认比例,则不对图表展示范围进行操作 // 如果拖拽前后比例均高于默认比例,则不对图表展示范围进行操作
chartInfo.current = { updateChartInfo({
...chartInfo.current,
sliderPos: [newStartSliderPos, newEndSliderPos], sliderPos: [newStartSliderPos, newEndSliderPos],
oldDataZoomOption: newDataZoomOption, oldDataZoomOption: newDataZoomOption,
}; });
renderTableInfo(); renderTableInfo();
return true; return true;
} else { } else {
@@ -259,79 +274,98 @@ const ChartDetail = (props: ChartDetailProps) => {
const updateChartData = (timeRange: [number, number], sliderPos: [number, number]) => { const updateChartData = (timeRange: [number, number], sliderPos: [number, number]) => {
const { const {
fullTimeRange: [fullStartTimestamp, fullEndTimestamp], fullTimeRange: [fullStartTimestamp, fullEndTimestamp],
fullMetricData,
isLoadedFullData, isLoadedFullData,
} = chartInfo.current; } = chartInfo.current;
let leftBoundaryTimestamp = Math.floor(timeRange[0]); const leftBoundaryTimestamp = Math.floor(timeRange[0]);
const isNeedCacheExtraData = leftBoundaryTimestamp < fullStartTimestamp + (fullEndTimestamp - fullStartTimestamp) * PRECACHE_THRESHOLD; const isNeedCacheExtraData = leftBoundaryTimestamp < fullStartTimestamp + (fullEndTimestamp - fullStartTimestamp) * PRECACHE_THRESHOLD;
let isRendered = false; let isRendered = false;
// 如果本地存储的数据足够展示或者已经获取到所有数据,则展示数据 // 如果本地存储的数据足够展示或者已经获取到所有数据,则展示数据
if (leftBoundaryTimestamp > fullStartTimestamp || isLoadedFullData) { if (leftBoundaryTimestamp > fullStartTimestamp || isLoadedFullData) {
chartInfo.current = { updateChartInfo({
...chartInfo.current,
curTimeRange: [leftBoundaryTimestamp > fullStartTimestamp ? leftBoundaryTimestamp : fullStartTimestamp, timeRange[1]], curTimeRange: [leftBoundaryTimestamp > fullStartTimestamp ? leftBoundaryTimestamp : fullStartTimestamp, timeRange[1]],
sliderPos, sliderPos,
}; });
renderNewMetricData(); renderNewMetricData();
isRendered = true; isRendered = true;
} }
if (!isLoadedFullData && isNeedCacheExtraData) { if (!isLoadedFullData && isNeedCacheExtraData) {
// 向服务器请求新的数据缓存 getAdditionChartData(!isRendered, leftBoundaryTimestamp, timeRange[1], sliderPos);
let reqEndTime = fullStartTimestamp; }
const requestArr: any[] = []; };
const requestTimeRanges: [number, number][] = [];
for (let i = 0; i < DEFAULT_REQUEST_COUNT; i++) {
setTimeout(() => {
const nextReqEndTime = reqEndTime - DEFAULT_REQUEST_TIME_RANGE;
requestArr.unshift(getMetricChartData([nextReqEndTime, reqEndTime]));
requestTimeRanges.unshift([nextReqEndTime, reqEndTime]);
reqEndTime = nextReqEndTime;
// 当最后一次请求发送后,处理返回 // 缓存增量的图表数据
if (i === DEFAULT_REQUEST_COUNT - 1) { const getAdditionChartData = (
Promise.all(requestArr).then((resList) => { needRender: boolean,
let isSettle = -1; leftBoundaryTimestamp: number,
// 填充增量的图表数据 rightBoundaryTimestamp: number,
resList.forEach((res: MetricDefaultChartDataType[], i) => { sliderPos?: [number, number]
// 图表没有返回数据的情况 ) => {
if (!res?.length) { const {
if (isSettle === -1) { fullTimeRange: [fullStartTimestamp, fullEndTimestamp],
chartInfo.current = { fullMetricData,
...chartInfo.current, isLoadingAdditionData,
// 标记数据已经全部加载完毕 } = chartInfo.current;
isLoadedFullData: true,
};
isSettle = i;
}
} else {
resolveAdditionChartData(res, requestTimeRanges[i]);
}
});
// 更新左侧边界为当前已获取到数据的最小边界
const curLocalStartTimestamp = Number(fullMetricData.metricLines.map((line) => line.data[0][0]).sort()[0]);
if (leftBoundaryTimestamp < curLocalStartTimestamp) {
leftBoundaryTimestamp = curLocalStartTimestamp;
}
chartInfo.current = { // 当前有缓存数据的任务时,直接退出
...chartInfo.current, if (isLoadingAdditionData) {
fullTimeRange: [reqEndTime - DEFAULT_REQUEST_TIME_RANGE, fullEndTimestamp], return false;
sliderPos, }
}; updateChartInfo({
if (!isRendered) { isLoadingAdditionData: true,
chartInfo.current = { });
...chartInfo.current,
curTimeRange: [leftBoundaryTimestamp, timeRange[1]], let reqEndTime = fullStartTimestamp;
}; const requestArr: any[] = [];
renderNewMetricData(); const requestTimeRanges: [number, number][] = [];
for (let i = 0; i < DEFAULT_REQUEST_COUNT; i++) {
setTimeout(() => {
const nextReqEndTime = reqEndTime - DEFAULT_REQUEST_TIME_RANGE;
requestArr.push(getMetricChartData([nextReqEndTime, reqEndTime]));
requestTimeRanges.push([nextReqEndTime, reqEndTime]);
reqEndTime = nextReqEndTime;
// 当最后一次请求发送后,处理返回
if (i === DEFAULT_REQUEST_COUNT - 1) {
Promise.all(requestArr).then((resList) => {
// 填充增量的图表数据
resList.forEach((res: MetricDefaultChartDataType[], i) => {
// 最后一个请求返回数据为空时,认为已获取到全部图表数据
if (!res?.length) {
// 标记数据已经全部加载完毕
i === resList.length - 1 &&
updateChartInfo({
isLoadedFullData: true,
});
} else {
// TODO: res 可能为 [],需要处理兼容
resolveAdditionChartData(res, requestTimeRanges[i]);
} }
}); });
}
}, i * 10); // 更新左侧边界为当前已获取到数据的最小边界
} const curLocalStartTimestamp = Number(fullMetricData.metricLines.map((line) => line?.data?.[0]?.[0]).sort()[0]);
if (leftBoundaryTimestamp < curLocalStartTimestamp) {
leftBoundaryTimestamp = curLocalStartTimestamp;
}
updateChartInfo({
fullTimeRange: [reqEndTime - DEFAULT_REQUEST_TIME_RANGE, fullEndTimestamp],
...(sliderPos ? { sliderPos } : {}),
isLoadingAdditionData: false,
});
if (needRender) {
updateChartInfo({
curTimeRange: [leftBoundaryTimestamp, rightBoundaryTimestamp],
});
renderNewMetricData();
}
});
}
}, i * 10);
} }
return true;
}; };
// 处理增量图表数据 // 处理增量图表数据
@@ -362,7 +396,7 @@ const ChartDetail = (props: ChartDetailProps) => {
}); });
}; };
// 根据需要展示的时间范围过滤出对应的数据展示 // 根据需要展示的时间范围过滤出对应的数据
const renderNewMetricData = () => { const renderNewMetricData = () => {
const { fullMetricData, curTimeRange } = chartInfo.current; const { fullMetricData, curTimeRange } = chartInfo.current;
const newMetricData = { ...fullMetricData }; const newMetricData = { ...fullMetricData };
@@ -378,12 +412,25 @@ const ChartDetail = (props: ChartDetailProps) => {
}); });
newMetricData.metricLines[i] = line; newMetricData.metricLines[i] = line;
}); });
// 只过滤出当前时间段有数据点的线条,确保 Table 统一展示 // 只过滤出当前时间段有数据点的线条,确保 Table 统一展示
newMetricData.metricLines = newMetricData.metricLines.filter((line) => line.data.length); newMetricData.metricLines = newMetricData.metricLines.filter((line) => line.data.length);
setCurMetricData(newMetricData); setCurMetricData(newMetricData);
setLinesStatus((curStatus) => {
// 过滤维持线条选中状态
const newLinesStatus = { ...curStatus };
const newLineNames = newMetricData.metricLines.map((line) => line.name);
newLineNames.forEach((name) => {
if (newLinesStatus[name] === undefined) {
newLinesStatus[name] = false;
}
});
return newLinesStatus;
});
}; };
// 计算当前选中范围 // 计算展示当前拖拽轴选中的时间范围
const calculateSliderRange = () => { const calculateSliderRange = () => {
const { sliderPos } = chartInfo.current; const { sliderPos } = chartInfo.current;
let minutes = Number(((sliderPos[1] - sliderPos[0]) / 60 / 1000).toFixed(2)); let minutes = Number(((sliderPos[1] - sliderPos[0]) / 60 / 1000).toFixed(2));
@@ -398,13 +445,11 @@ const ChartDetail = (props: ChartDetailProps) => {
hours = Number((hours % 24).toFixed(2)); hours = Number((hours % 24).toFixed(2));
} }
chartInfo.current = { const sliderRange = ` 当前选中范围: ${days > 0 ? `${days}` : ''}${hours > 0 ? `${hours} 小时 ` : ''}${minutes} 分钟`;
...chartInfo.current, setSliderRange(sliderRange);
sliderRange: ` 当前选中范围: ${days > 0 ? `${days}` : ''}${hours > 0 ? `${hours} 小时 ` : ''}${minutes} 分钟`,
};
}; };
// 遍历图表,获取需要的指标数据展示到 Table // 遍历图表,计算得到指标聚合数据展示到表格
const renderTableInfo = () => { const renderTableInfo = () => {
const tableData: MetricTableInfo[] = []; const tableData: MetricTableInfo[] = [];
const { sliderPos, chartInstance } = chartInfo.current; const { sliderPos, chartInstance } = chartInfo.current;
@@ -447,140 +492,131 @@ const ChartDetail = (props: ChartDetailProps) => {
calculateSliderRange(); calculateSliderRange();
setTableInfo(tableData); setTableInfo(tableData);
setSelectedLines(tableData.map((line) => line.name));
}; };
const tableLineChange = (keys: string[]) => { const tableLineChange = (keys: string[]) => {
const updatedLines: { [name: string]: boolean } = {}; const newLinesStatus = { ...linesStatus };
selectedLines.forEach((name) => !keys.includes(name) && (updatedLines[name] = false));
keys.forEach((name) => !selectedLines.includes(name) && (updatedLines[name] = true));
// 更新 Object.entries(newLinesStatus).forEach(([name, status]) => {
Object.keys(updatedLines).forEach((name) => { if (keys.includes(name)) {
chartInfo.current.chartInstance.dispatchAction({ !status && (newLinesStatus[name] = true);
type: 'legendToggleSelect', } else {
// 图例名称 status && (newLinesStatus[name] = false);
name: name, }
});
}); });
setSelectedLines(keys); setLinesStatus(newLinesStatus);
}; };
// 图表数据更新渲染后,更新图表拖拽轴信息并重新计算列表值
useEffect(() => { useEffect(() => {
if (curMetricData) { if (curMetricData) {
setTimeout(() => { setTimeout(() => {
// 新的图表数据渲染后,更新图表拖拽轴信息
chartInfo.current.oldDataZoomOption = (chartInfo.current.chartInstance.getOption() as any).dataZoom[0]; chartInfo.current.oldDataZoomOption = (chartInfo.current.chartInstance.getOption() as any).dataZoom[0];
}); });
renderTableInfo(); renderTableInfo();
} }
}, [curMetricData]); }, [curMetricData]);
// 更新图例选中状态
useEffect(() => {
Object.entries(linesStatus).map(([name, status]) => {
const type = status ? 'legendSelect' : 'legendUnSelect';
chartInfo.current.chartInstance.dispatchAction({
type,
name,
});
});
}, [linesStatus]);
// 进入详情时,首次获取数据 // 进入详情时,首次获取数据
useEffect(() => { useEffect(() => {
if (metricType && metricName) { if (metricType && metricName) {
setLoading(true); setLoading(true);
const { curTimeRange } = chartInfo.current; const { curTimeRange } = chartInfo.current;
getMetricChartData(curTimeRange).then((res: any[] | null) => { getMetricChartData(curTimeRange).then(
// 如果图表返回数据 (res: any[] | null) => {
if (res?.length) { // 如果图表返回数据
// 格式化图表需要的数据 if (res?.length) {
const formattedMetricData = ( // 格式化图表需要的数据
formatChartData( const formattedMetricData = (
res, formatChartData(
global.getMetricDefine || {}, res,
metricType, global.getMetricDefine || {},
curTimeRange, metricType,
DEFAULT_POINT_INTERVAL, curTimeRange,
false DEFAULT_POINT_INTERVAL,
) as MetricChartDataType[] false
)[0]; ) as MetricChartDataType[]
// 填充图表数据 )[0];
let initFullTimeRange = curTimeRange; // 填充图表数据
const pointsOfFirstLine = formattedMetricData.metricLines.find((line) => line.data.length).data; let initFullTimeRange = curTimeRange;
if (pointsOfFirstLine) { const pointsOfFirstLine = formattedMetricData.metricLines.find((line) => line.data.length).data;
initFullTimeRange = [pointsOfFirstLine[0][0] as number, pointsOfFirstLine[pointsOfFirstLine.length - 1][0] as number] as const; if (pointsOfFirstLine) {
} initFullTimeRange = [
pointsOfFirstLine[0][0] as number,
// 获取单位保存起来 pointsOfFirstLine[pointsOfFirstLine.length - 1][0] as number,
let transformUnit = undefined; ] as const;
Object.entries(UNIT_MAP).forEach((unit) => {
if (formattedMetricData.metricUnit.includes(unit[0])) {
transformUnit = unit;
} }
});
chartInfo.current = { // 获取单位保存起来
...chartInfo.current, let transformUnit = undefined;
fullMetricData: formattedMetricData, Object.entries(UNIT_MAP).forEach((unit) => {
fullTimeRange: [...initFullTimeRange], if (formattedMetricData.metricUnit.includes(unit[0])) {
curTimeRange: [...initFullTimeRange], transformUnit = unit;
sliderPos: [ }
initFullTimeRange[1] - (initFullTimeRange[1] - initFullTimeRange[0]) * DATA_ZOOM_DEFAULT_SCALE, });
initFullTimeRange[1],
], updateChartInfo({
transformUnit, fullMetricData: formattedMetricData,
}; fullTimeRange: [...initFullTimeRange],
setCurMetricData(formattedMetricData); curTimeRange: [...initFullTimeRange],
setLoading(false); sliderPos: [
} initFullTimeRange[1] - (initFullTimeRange[1] - initFullTimeRange[0]) * DATA_ZOOM_DEFAULT_SCALE,
}); initFullTimeRange[1],
],
transformUnit,
});
setCurMetricData(formattedMetricData);
const newLinesStatus: { [lineName: string]: boolean } = {};
formattedMetricData.metricLines.forEach((line) => {
newLinesStatus[line.name] = true;
});
setLinesStatus(newLinesStatus);
setLoading(false);
getAdditionChartData(false, initFullTimeRange[0], initFullTimeRange[1]);
}
},
() => setLoading(false)
);
} }
}, []); }, []);
const debounced = debounce(onDataZoomDrag, 300); debouncedZoomDrag.current = debounce(onDataZoomDrag, 300);
return ( return (
<Spin spinning={loading}> <Spin spinning={loading}>
<div className="chart-detail-modal-container"> <div className="chart-detail-modal-container">
{curMetricData && ( {curMetricData ? (
<> <>
<div className="detail-title">
<div className="left">
<div className="title">
<Tooltip
placement="bottomLeft"
title={() => {
let content = '';
const metricDefine = global.getMetricDefine(metricType, curMetricData.metricName);
if (metricDefine) {
content = metricDefine.desc;
}
return content;
}}
>
<span style={{ cursor: 'pointer' }}>
<span>{curMetricData.metricName}</span> <span className="unit">({curMetricData.metricUnit}) </span>
</span>
</Tooltip>
</div>
<div className="info">{chartInfo.current.sliderRange}</div>
</div>
<div className="right">
<Button type="text" size="small" onClick={onClose}>
<CloseOutlined />
</Button>
</div>
</div>
<SingleChart <SingleChart
chartTypeProp="line" chartTypeProp="line"
wrapStyle={{ wrapStyle={{
width: 'auto', width: 'auto',
height: 462, height: 462,
}} }}
// events 事件只注册一次,所以这里使用 ref 来执行防抖函数
onEvents={{ onEvents={{
dataZoom: (record: any) => { dataZoom: (record: any) => debouncedZoomDrag?.current(record),
debounced(record);
},
}} }}
showHeader={false}
propChartData={curMetricData.metricLines} propChartData={curMetricData.metricLines}
optionMergeProps={{ notMerge: true }} optionMergeProps={{ notMerge: true }}
getChartInstance={(chartInstance) => { getChartInstance={(chartInstance) => {
chartInfo.current = { setDisposeChartInstance(() => () => chartInstance.dispose());
...chartInfo.current, updateChartInfo({
chartInstance, chartInstance,
}; });
}} }}
{...getDetailChartConfig(`${curMetricData.metricName}{unit|${curMetricData.metricUnit}}`, chartInfo.current.sliderPos)} {...getDetailChartConfig(`${curMetricData.metricName}{unit|${curMetricData.metricUnit}}`, chartInfo.current.sliderPos)}
/> />
@@ -588,16 +624,10 @@ const ChartDetail = (props: ChartDetailProps) => {
className="detail-table" className="detail-table"
rowKey="name" rowKey="name"
rowSelection={{ rowSelection={{
// hideSelectAll: true,
preserveSelectedRowKeys: true, preserveSelectedRowKeys: true,
selectedRowKeys: selectedLines, selectedRowKeys: Object.entries(linesStatus)
// getCheckboxProps: (record) => { .filter(([, status]) => status)
// return selectedLines.length <= 1 && selectedLines.includes(record.name) .map(([name]) => name),
// ? {
// disabled: true,
// }
// : {};
// },
selections: [Table.SELECTION_INVERT, Table.SELECTION_NONE], selections: [Table.SELECTION_INVERT, Table.SELECTION_NONE],
onChange: (keys: string[]) => tableLineChange(keys), onChange: (keys: string[]) => tableLineChange(keys),
}} }}
@@ -610,6 +640,8 @@ const ChartDetail = (props: ChartDetailProps) => {
pagination={false} pagination={false}
/> />
</> </>
) : (
!loading && <RenderEmpty message="详情加载失败,请重试" height={400} />
)} )}
</div> </div>
</Spin> </Spin>
@@ -618,22 +650,46 @@ const ChartDetail = (props: ChartDetailProps) => {
// eslint-disable-next-line react/display-name // eslint-disable-next-line react/display-name
const ChartDrawer = forwardRef((_, ref) => { const ChartDrawer = forwardRef((_, ref) => {
const [global] = AppContainer.useGlobalValue();
const [visible, setVisible] = useState(false); const [visible, setVisible] = useState(false);
const [dashboardType, setDashboardType] = useState<MetricType>();
const [metricName, setMetricName] = useState<string>();
const [queryLines, setQueryLines] = useState<string[]>([]); const [queryLines, setQueryLines] = useState<string[]>([]);
const [sliderRange, setSliderRange] = useState<string>('');
const [disposeChartInstance, setDisposeChartInstance] = useState<() => void>(() => 0);
const [metricInfo, setMetricInfo] = useState<{
type: MetricType | undefined;
name: string;
unit: string;
desc: string;
}>({
type: undefined,
name: '',
unit: '',
desc: '',
});
const onOpen = (dashboardType: MetricType, metricName: string, queryLines: string[]) => { const onOpen = (dashboardType: MetricType, metricName: string, queryLines: string[]) => {
setDashboardType(dashboardType); const metricDefine = global.getMetricDefine(dashboardType, metricName);
setMetricName(metricName); setMetricInfo({
type: dashboardType,
name: metricName,
unit: metricDefine?.unit || '',
desc: metricDefine?.desc || '',
});
setQueryLines(queryLines); setQueryLines(queryLines);
setVisible(true); setVisible(true);
}; };
const onClose = () => { const onClose = () => {
setVisible(false); setVisible(false);
setDashboardType(undefined); setSliderRange('');
setMetricName(undefined); disposeChartInstance();
setDisposeChartInstance(() => () => 0);
setMetricInfo({
type: undefined,
name: '',
unit: '',
desc: '',
});
}; };
useImperativeHandle(ref, () => ({ useImperativeHandle(ref, () => ({
@@ -641,9 +697,36 @@ const ChartDrawer = forwardRef((_, ref) => {
})); }));
return ( return (
<Drawer width={1080} visible={visible} footer={null} closable={false} maskClosable={false} destroyOnClose={true} onClose={onClose}> <Drawer
{dashboardType && metricName && ( className="overview-chart-detail-drawer"
<ChartDetail metricType={dashboardType} metricName={metricName} queryLines={queryLines} onClose={onClose} /> width={1080}
visible={visible}
title={
<div className="detail-header">
<div className="title">
<Tooltip placement="bottomLeft" title={metricInfo.desc}>
<span style={{ cursor: 'pointer' }}>
<span>{metricInfo.name}</span> <span className="unit">({metricInfo.unit}) </span>
</span>
</Tooltip>
</div>
<div className="slider-info">{sliderRange}</div>
</div>
}
footer={null}
closable={true}
maskClosable={false}
destroyOnClose={true}
onClose={onClose}
>
{metricInfo.type && metricInfo.name && (
<ChartDetail
metricType={metricInfo.type}
metricName={metricInfo.name}
queryLines={queryLines}
setSliderRange={setSliderRange}
setDisposeChartInstance={setDisposeChartInstance}
/>
)} )}
</Drawer> </Drawer>
); );

View File

@@ -46,30 +46,42 @@ export const supplementaryPoints = (
extraCallback?: (point: [number, 0]) => any[] extraCallback?: (point: [number, 0]) => any[]
) => { ) => {
lines.forEach(({ data }) => { lines.forEach(({ data }) => {
// 获取未补点前线条的点的个数
let len = data.length; let len = data.length;
for (let i = 0; i < len; i++) { // 记录当前处理到的点的下标值
const timestamp = data[i][0] as number; let i = 0;
// 数组第一个点和最后一个点单独处理
for (; i < len; i++) {
if (i === 0) { if (i === 0) {
let firstPointTimestamp = data[0][0] as number; let firstPointTimestamp = data[0][0] as number;
while (firstPointTimestamp - interval > timeRange[0]) { while (firstPointTimestamp - interval > timeRange[0]) {
const prePointTimestamp = firstPointTimestamp - interval; const prevPointTimestamp = firstPointTimestamp - interval;
data.unshift(extraCallback ? extraCallback([prePointTimestamp, 0]) : [prePointTimestamp, 0]); data.unshift(extraCallback ? extraCallback([prevPointTimestamp, 0]) : [prevPointTimestamp, 0]);
firstPointTimestamp = prevPointTimestamp;
len++; len++;
i++; i++;
firstPointTimestamp = prePointTimestamp;
} }
} }
if (i === len - 1) { if (i === len - 1) {
let lastPointTimestamp = data[len - 1][0] as number; let lastPointTimestamp = data[i][0] as number;
while (lastPointTimestamp + interval < timeRange[1]) { while (lastPointTimestamp + interval < timeRange[1]) {
const next = lastPointTimestamp + interval; const nextPointTimestamp = lastPointTimestamp + interval;
data.push(extraCallback ? extraCallback([next, 0]) : [next, 0]); data.push(extraCallback ? extraCallback([nextPointTimestamp, 0]) : [nextPointTimestamp, 0]);
lastPointTimestamp = next; lastPointTimestamp = nextPointTimestamp;
}
break;
}
{
let timestamp = data[i][0] as number;
while (timestamp + interval < data[i + 1][0]) {
const nextPointTimestamp = timestamp + interval;
data.splice(i + 1, 0, extraCallback ? extraCallback([nextPointTimestamp, 0]) : [nextPointTimestamp, 0]);
timestamp = nextPointTimestamp;
len++;
i++;
} }
} else if (timestamp + interval < data[i + 1][0]) {
data.splice(i + 1, 0, extraCallback ? extraCallback([timestamp + interval, 0]) : [timestamp + interval, 0]);
len++;
} }
} }
}); });
@@ -135,18 +147,37 @@ export const formatChartData = (
}; };
const seriesCallback = (lines: { name: string; data: [number, string | number][] }[]) => { const seriesCallback = (lines: { name: string; data: [number, string | number][] }[]) => {
const len = CHART_COLOR_LIST.length;
// series 配置 // series 配置
return lines.map((line) => { return lines.map((line, i) => {
return { return {
...line, ...line,
lineStyle: { lineStyle: {
width: 1.5, width: 1.5,
}, },
connectNulls: false,
symbol: 'emptyCircle', symbol: 'emptyCircle',
symbolSize: 4, symbolSize: 4,
smooth: 0.25, smooth: 0.25,
areaStyle: { areaStyle: {
opacity: 0.02, color: {
type: 'linear',
x: 0,
y: 0,
x2: 0,
y2: 1,
colorStops: [
{
offset: 0,
color: CHART_COLOR_LIST[i % len] + '10',
},
{
offset: 1,
color: 'rgba(255,255,255,0)', // 100% 处的颜色
},
],
global: false, // 缺省为 false
},
}, },
}; };
}); });
@@ -189,6 +220,7 @@ export const getDetailChartConfig = (title: string, sliderPos: readonly [number,
startValue: sliderPos[0], startValue: sliderPos[0],
endValue: sliderPos[1], endValue: sliderPos[1],
zoomOnMouseWheel: false, zoomOnMouseWheel: false,
minValueSpan: 10 * 60 * 1000,
}, },
{ {
start: 0, start: 0,

View File

@@ -63,56 +63,63 @@
} }
} }
} }
.overview-chart-detail-drawer {
.chart-detail-modal-container { .dcloud-spin-nested-loading > div > .dcloud-spin.dcloud-spin-spinning {
position: relative; height: 300px;
.expand-icon-box { }
position: absolute; &.dcloud-drawer .dcloud-drawer-body {
z-index: 1000; padding: 0 20px;
top: 14px; }
right: 44px; .detail-header {
width: 24px; display: flex;
height: 24px; align-items: flex-end;
cursor: pointer; font-weight: normal;
font-size: 16px; .title {
text-align: center; font-family: @font-family-bold;
border-radius: 50%; font-size: 18px;
transition: background-color 0.3s ease; color: #495057;
.expand-icon { letter-spacing: 0;
color: #adb5bc; .unit {
line-height: 24px; font-family: @font-family-bold;
} font-size: 14px;
&:hover { letter-spacing: 0.5px;
background: rgba(33, 37, 41, 0.04);
.expand-icon {
color: #74788d;
} }
} }
.slider-info {
margin-left: 10px;
font-size: 12px;
font-family: @font-family;
color: #303a51;
}
} }
.detail-title { .chart-detail-modal-container {
display: flex; position: relative;
justify-content: space-between; overflow: hidden;
align-items: center; .expand-icon-box {
.left { position: absolute;
display: flex; z-index: 1000;
align-items: flex-end; top: 14px;
.title { right: 44px;
font-family: @font-family-bold; width: 24px;
font-size: 18px; height: 24px;
color: #495057; cursor: pointer;
letter-spacing: 0; font-size: 16px;
.unit { text-align: center;
font-family: @font-family-bold; border-radius: 50%;
font-size: 14px; transition: background-color 0.3s ease;
letter-spacing: 0.5px; .expand-icon {
color: #adb5bc;
line-height: 24px;
}
&:hover {
background: rgba(33, 37, 41, 0.04);
.expand-icon {
color: #74788d;
} }
} }
.info { }
margin-left: 10px; .detail-table {
} margin-top: 16px;
} }
} }
.detail-table {
margin-top: 16px;
}
} }

View File

@@ -216,8 +216,8 @@ const DashboardDragChart = (props: PropsType): JSX.Element => {
onChange={ksHeaderChange} onChange={ksHeaderChange}
nodeScopeModule={{ nodeScopeModule={{
customScopeList: scopeList, customScopeList: scopeList,
scopeName: `自定义 ${dashboardType === MetricType.Broker ? 'Broker' : 'Topic'} 范围`, scopeName: dashboardType === MetricType.Broker ? 'Broker' : 'Topic',
showSearch: dashboardType === MetricType.Topic, scopeLabel: `自定义 ${dashboardType === MetricType.Broker ? 'Broker' : 'Topic'} 范围`,
}} }}
indicatorSelectModule={{ indicatorSelectModule={{
hide: false, hide: false,

View File

@@ -0,0 +1,15 @@
import React from 'react';
const RenderEmpty = (props: { height?: string | number; message: string }) => {
const { height = 200, message } = props;
return (
<>
<div className="empty-panel" style={{ height }}>
<div className="img" />
<div className="text">{message}</div>
</div>
</>
);
};
export default RenderEmpty;

View File

@@ -26,8 +26,8 @@ const OptionsDefault = [
const NodeScope = ({ nodeScopeModule, change }: propsType) => { const NodeScope = ({ nodeScopeModule, change }: propsType) => {
const { const {
customScopeList: customList, customScopeList: customList,
scopeName = '自定义节点范围', scopeName = '',
showSearch = false, scopeLabel = '自定义范围',
searchPlaceholder = '输入内容进行搜索', searchPlaceholder = '输入内容进行搜索',
} = nodeScopeModule; } = nodeScopeModule;
const [topNum, setTopNum] = useState<number>(5); const [topNum, setTopNum] = useState<number>(5);
@@ -70,7 +70,7 @@ const NodeScope = ({ nodeScopeModule, change }: propsType) => {
change(checkedListTemp, false); change(checkedListTemp, false);
setIsTop(false); setIsTop(false);
setTopNum(null); setTopNum(null);
setInputValue(`已选${checkedListTemp?.length}`); setInputValue(`${checkedListTemp?.length}`);
setPopVisible(false); setPopVisible(false);
} }
}; };
@@ -109,7 +109,7 @@ const NodeScope = ({ nodeScopeModule, change }: propsType) => {
{/* <span>时间:</span> */} {/* <span>时间:</span> */}
<div className="flx_con"> <div className="flx_con">
<div className="flx_l"> <div className="flx_l">
<h6 className="time_title">top</h6> <h6 className="time_title"> top </h6>
<Radio.Group <Radio.Group
optionType="button" optionType="button"
buttonStyle="solid" buttonStyle="solid"
@@ -128,7 +128,7 @@ const NodeScope = ({ nodeScopeModule, change }: propsType) => {
</Radio.Group> </Radio.Group>
</div> </div>
<div className="flx_r"> <div className="flx_r">
<h6 className="time_title">{scopeName}</h6> <h6 className="time_title">{scopeLabel}</h6>
<div className="custom-scope"> <div className="custom-scope">
<div className="check-row"> <div className="check-row">
<Checkbox className="check-all" indeterminate={indeterminate} onChange={onCheckAllChange} checked={checkAll}> <Checkbox className="check-all" indeterminate={indeterminate} onChange={onCheckAllChange} checked={checkAll}>
@@ -136,9 +136,7 @@ const NodeScope = ({ nodeScopeModule, change }: propsType) => {
</Checkbox> </Checkbox>
<Input <Input
className="search-input" className="search-input"
suffix={ suffix={<IconFont type="icon-fangdajing" style={{ fontSize: '16px' }} />}
<IconFont type="icon-fangdajing" style={{ fontSize: '16px' }} />
}
size="small" size="small"
placeholder={searchPlaceholder} placeholder={searchPlaceholder}
onChange={(e) => setScopeSearchValue(e.target.value)} onChange={(e) => setScopeSearchValue(e.target.value)}
@@ -148,7 +146,7 @@ const NodeScope = ({ nodeScopeModule, change }: propsType) => {
<Checkbox.Group style={{ width: '100%' }} onChange={checkChange} value={checkedListTemp}> <Checkbox.Group style={{ width: '100%' }} onChange={checkChange} value={checkedListTemp}>
<Row gutter={[10, 12]}> <Row gutter={[10, 12]}>
{customList {customList
.filter((item) => !showSearch || item.label.includes(scopeSearchValue)) .filter((item) => item.label.includes(scopeSearchValue))
.map((item) => ( .map((item) => (
<Col span={12} key={item.value}> <Col span={12} key={item.value}>
<Checkbox value={item.value}>{item.label}</Checkbox> <Checkbox value={item.value}>{item.label}</Checkbox>
@@ -180,6 +178,7 @@ const NodeScope = ({ nodeScopeModule, change }: propsType) => {
return ( return (
<> <>
<div id="d-node-scope"> <div id="d-node-scope">
<div className="scope-title">{scopeName}</div>
<Popover <Popover
trigger={['click']} trigger={['click']}
visible={popVisible} visible={popVisible}

View File

@@ -1,5 +1,5 @@
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { Tooltip, Select, IconFont, Utils, Divider } from 'knowdesign'; import { Tooltip, Select, IconFont, Utils, Divider, Button } from 'knowdesign';
import moment from 'moment'; import moment from 'moment';
import { DRangeTime } from 'knowdesign'; import { DRangeTime } from 'knowdesign';
import IndicatorDrawer from './IndicatorDrawer'; import IndicatorDrawer from './IndicatorDrawer';
@@ -48,7 +48,7 @@ export interface IcustomScope {
export interface InodeScopeModule { export interface InodeScopeModule {
customScopeList: IcustomScope[]; customScopeList: IcustomScope[];
scopeName?: string; scopeName?: string;
showSearch?: boolean; scopeLabel?: string;
searchPlaceholder?: string; searchPlaceholder?: string;
change?: () => void; change?: () => void;
} }
@@ -138,9 +138,13 @@ const SingleChartHeader = ({
}; };
const reloadRangeTime = () => { const reloadRangeTime = () => {
const timeLen = rangeTime[1] - rangeTime[0] || 0; if (isRelativeRangeTime) {
const curTimeStamp = moment().valueOf(); const timeLen = rangeTime[1] - rangeTime[0] || 0;
setRangeTime([curTimeStamp - timeLen, curTimeStamp]); const curTimeStamp = moment().valueOf();
setRangeTime([curTimeStamp - timeLen, curTimeStamp]);
} else {
setRangeTime([...rangeTime]);
}
}; };
const openIndicatorDrawer = () => { const openIndicatorDrawer = () => {
@@ -174,12 +178,10 @@ const SingleChartHeader = ({
{!hideGridSelect && ( {!hideGridSelect && (
<Select className="grid-select" style={{ width: 70 }} value={gridNum} options={GRID_SIZE_OPTIONS} onChange={sizeChange} /> <Select className="grid-select" style={{ width: 70 }} value={gridNum} options={GRID_SIZE_OPTIONS} onChange={sizeChange} />
)} )}
<Divider type="vertical" style={{ height: 20, top: 0 }} /> {(!hideNodeScope || !hideGridSelect) && <Divider type="vertical" style={{ height: 20, top: 0 }} />}
<Tooltip title="点击指标筛选,可选择指标" placement="bottomRight"> <Button type="primary" onClick={openIndicatorDrawer}>
<div className="icon-box" onClick={openIndicatorDrawer}>
<IconFont className="icon" type="icon-shezhi1" /> </Button>
</div>
</Tooltip>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -3,8 +3,13 @@
@import '~knowdesign/es/basic/style/mixins/index'; @import '~knowdesign/es/basic/style/mixins/index';
#d-node-scope { #d-node-scope {
display: flex;
align-items: center;
position: relative; position: relative;
display: inline-block; .scope-title {
font-size: 14px;
color: #74788d;
}
.input-span { .input-span {
cursor: pointer; cursor: pointer;
} }
@@ -29,10 +34,10 @@
box-shadow: none; box-shadow: none;
} }
&.relativeTime { &.relativeTime {
width: 160px; width: 200px;
} }
&.absoluteTime { &.absoluteTime {
width: 300px; width: 200px;
} }
input { input {

View File

@@ -1,6 +1,6 @@
import { DownOutlined } from '@ant-design/icons'; import { DownOutlined } from '@ant-design/icons';
import { Popover } from 'knowdesign'; import { Popover } from 'knowdesign';
import { TooltipPlacement } from 'knowdesign/lib/basic/tooltip'; import { TooltipPlacement } from 'knowdesign/es/basic/tooltip';
import React, { useState, useRef, useEffect } from 'react'; import React, { useState, useRef, useEffect } from 'react';
import './index.less'; import './index.less';
@@ -93,8 +93,9 @@ export default (props: PropsType) => {
return ( return (
<div <div
key={i} key={i}
className={`container-item ${curState.calculated ? (curState.isHideExpandNode ? 'show' : i >= curState.endI ? 'hide' : 'show') : '' className={`container-item ${
}`} curState.calculated ? (curState.isHideExpandNode ? 'show' : i >= curState.endI ? 'hide' : 'show') : ''
}`}
> >
{item} {item}
</div> </div>

View File

@@ -30,8 +30,8 @@ const { TextArea } = Input;
const { Option } = Select; const { Option } = Select;
const jobNameMap: any = { const jobNameMap: any = {
expandAndReduce: '批量扩缩副本', expandAndReduce: '扩缩副本',
transfer: '批量迁移副本', transfer: '迁移副本',
}; };
interface DefaultConfig { interface DefaultConfig {
@@ -325,8 +325,7 @@ export default (props: DefaultConfig) => {
!jobId && !jobId &&
Utils.request(Api.getTopicMetaData(+routeParams.clusterId)) Utils.request(Api.getTopicMetaData(+routeParams.clusterId))
.then((res: any) => { .then((res: any) => {
const filterRes = res.filter((item: any) => item.type !== 1); const topics = (res || []).map((item: any) => {
const topics = (filterRes || []).map((item: any) => {
return { return {
label: item.topicName, label: item.topicName,
value: item.topicName, value: item.topicName,

View File

@@ -19,6 +19,7 @@ import {
Divider, Divider,
Transfer, Transfer,
IconFont, IconFont,
Tooltip,
} from 'knowdesign'; } from 'knowdesign';
import './index.less'; import './index.less';
import Api, { MetricType } from '@src/api/index'; import Api, { MetricType } from '@src/api/index';
@@ -31,8 +32,8 @@ const { TextArea } = Input;
const { Option } = Select; const { Option } = Select;
const jobNameMap: any = { const jobNameMap: any = {
expandAndReduce: '批量扩缩副本', expandAndReduce: '扩缩副本',
transfer: '批量迁移副本', transfer: '迁移副本',
}; };
interface DefaultConfig { interface DefaultConfig {
@@ -56,6 +57,7 @@ export default (props: DefaultConfig) => {
const [topicNewReplicas, setTopicNewReplicas] = useState([]); const [topicNewReplicas, setTopicNewReplicas] = useState([]);
const [needMovePartitions, setNeedMovePartitions] = useState([]); const [needMovePartitions, setNeedMovePartitions] = useState([]);
const [moveDataTimeRanges, setMoveDataTimeRanges] = useState([]); const [moveDataTimeRanges, setMoveDataTimeRanges] = useState([]);
const [moveDataTimeRangesType, setMoveDataTimeRangesType] = useState([]);
const [form] = Form.useForm(); const [form] = Form.useForm();
const [global] = AppContainer.useGlobalValue(); const [global] = AppContainer.useGlobalValue();
const [loadingTopic, setLoadingTopic] = useState<boolean>(true); const [loadingTopic, setLoadingTopic] = useState<boolean>(true);
@@ -142,8 +144,23 @@ export default (props: DefaultConfig) => {
title: '迁移数据时间范围', title: '迁移数据时间范围',
dataIndex: 'newRetentionMs', dataIndex: 'newRetentionMs',
render: (v: any, r: any, i: number) => { render: (v: any, r: any, i: number) => {
const selectAfter = (
<Select
onChange={(n: any) => {
const moveDataTimeRangesCopyType = JSON.parse(JSON.stringify(moveDataTimeRangesType));
moveDataTimeRangesCopyType[i] = n === 'h' ? 1 : 60;
setMoveDataTimeRangesType(moveDataTimeRangesCopyType);
}}
defaultValue="h"
style={{ width: 82 }}
>
<Option value="m">Minute</Option>
<Option value="h">Hour</Option>
</Select>
);
return ( return (
<InputNumber <InputNumber
width={80}
min={0} min={0}
max={99999} max={99999}
defaultValue={moveDataTimeRanges[i]} defaultValue={moveDataTimeRanges[i]}
@@ -153,8 +170,10 @@ export default (props: DefaultConfig) => {
moveDataTimeRangesCopy[i] = n; moveDataTimeRangesCopy[i] = n;
setMoveDataTimeRanges(moveDataTimeRangesCopy); setMoveDataTimeRanges(moveDataTimeRangesCopy);
}} }}
formatter={(value) => (value ? `${value} h` : '')} className={'move-dete-time-tanges'}
parser={(value) => value.replace('h', '')} // formatter={(value) => (value ? `${value} h` : '')}
// parser={(value) => value.replace('h', '')}
addonAfter={selectAfter}
></InputNumber> ></InputNumber>
); );
}, },
@@ -319,8 +338,7 @@ export default (props: DefaultConfig) => {
drawerVisible && drawerVisible &&
Utils.request(Api.getTopicMetaData(+routeParams.clusterId)) Utils.request(Api.getTopicMetaData(+routeParams.clusterId))
.then((res: any) => { .then((res: any) => {
const filterRes = res.filter((item: any) => item.type !== 1); const topics = (res || []).map((item: any) => {
const topics = (filterRes || []).map((item: any) => {
return { return {
label: item.topicName, label: item.topicName,
value: item.topicName, value: item.topicName,
@@ -402,7 +420,7 @@ export default (props: DefaultConfig) => {
originalBrokerIdList: taskPlanData[index].currentBrokerIdList, originalBrokerIdList: taskPlanData[index].currentBrokerIdList,
reassignBrokerIdList: taskPlanData[index].reassignBrokerIdList, reassignBrokerIdList: taskPlanData[index].reassignBrokerIdList,
originalRetentionTimeUnitMs: topicData[index].retentionMs, originalRetentionTimeUnitMs: topicData[index].retentionMs,
reassignRetentionTimeUnitMs: moveDataTimeRanges[index] * 60 * 60 * 1000, reassignRetentionTimeUnitMs: (moveDataTimeRanges[index] * 60 * 60 * 1000) / (moveDataTimeRangesType[index] || 1),
latestDaysAvgBytesInList: topicData[index].latestDaysAvgBytesInList, latestDaysAvgBytesInList: topicData[index].latestDaysAvgBytesInList,
latestDaysMaxBytesInList: topicData[index].latestDaysMaxBytesInList, latestDaysMaxBytesInList: topicData[index].latestDaysMaxBytesInList,
partitionPlanList: taskPlanData[index].partitionPlanList, partitionPlanList: taskPlanData[index].partitionPlanList,
@@ -476,6 +494,19 @@ export default (props: DefaultConfig) => {
setTopicSelectValue(v); setTopicSelectValue(v);
}} }}
options={topicMetaData} options={topicMetaData}
// 点击Tooltip会触发Select的下拉
// maxTagPlaceholder={(v) => {
// const tooltipValue = v
// .map((item) => {
// return item.value;
// })
// .join('、');
// return (
// <Tooltip visible={true} placement="topLeft" key={tooltipValue} title={tooltipValue}>
// <span>{'+' + v.length + '...'}</span>
// </Tooltip>
// );
// }}
></Select> ></Select>
</Form.Item> </Form.Item>
</Col> </Col>

View File

@@ -64,11 +64,6 @@
.task-form { .task-form {
margin-top: 16px; margin-top: 16px;
} }
.dcloud-select-selector {
max-height: 100px;
overflow: scroll;
}
} }
.preview-task-plan-drawer { .preview-task-plan-drawer {
@@ -80,4 +75,18 @@
background: #F8F9FA; background: #F8F9FA;
} }
} }
}
.move-dete-time-tanges{
.dcloud-input-number-input-wrap{
width: 80px;
}
.dcloud-input-number-wrapper{
.dcloud-select-selector{
border-top-left-radius: 0 !important;
border-bottom-left-radius: 0 !important;
background-color: inherit !important;
background: #F8F9FA;
}
}
} }

View File

@@ -70,7 +70,7 @@ const ClusterDetailSteps = {
}, },
}, },
{ {
target: '.single-cluster-detail .ks-chart-container-header .header-right .icon-box', target: '.single-cluster-detail .ks-chart-container-header .header-right .dcloud-btn',
title: '指标筛选', title: '指标筛选',
content: '点击这里可以对展示的图表进行筛选', content: '点击这里可以对展示的图表进行筛选',
placement: 'left-start' as const, placement: 'left-start' as const,

View File

@@ -1,29 +1,19 @@
import moment from 'moment'; import moment from 'moment';
export const CHART_COLOR_LIST = [ export const CHART_COLOR_LIST = [
'#657DFC', '#556ee6',
'#A7B1EB',
'#2AC8E4',
'#9DDEEB',
'#3991FF',
'#94BEF2', '#94BEF2',
'#95e7ff',
'#9DDEEB',
'#A7B1EB',
'#C2D0E3', '#C2D0E3',
'#F5B6B3',
'#85C80D',
'#C9E795',
'#A76CEC',
'#CCABF1', '#CCABF1',
'#FF9C1B',
'#F5C993',
'#FFC300',
'#F9D77B', '#F9D77B',
'#12CA7A', '#F5C993',
'#8BA3C4',
'#FF7066',
'#A7E6C7', '#A7E6C7',
'#F19FC9', '#F19FC9',
'#AEAEAE', '#F5B6B3',
'#D1D1D1', '#C9E795',
]; ];
export const UNIT_MAP = { export const UNIT_MAP = {

View File

@@ -12,20 +12,6 @@ export const leftMenus = (clusterId?: string) => ({
name: 'cluster', name: 'cluster',
path: 'cluster', path: 'cluster',
icon: 'icon-Cluster', icon: 'icon-Cluster',
children: [
{
name: 'overview',
path: '',
icon: '#icon-luoji',
},
process.env.BUSINESS_VERSION
? {
name: 'balance',
path: 'balance',
icon: '#icon-luoji',
}
: undefined,
].filter((m) => m),
}, },
{ {
name: 'broker', name: 'broker',
@@ -83,6 +69,25 @@ export const leftMenus = (clusterId?: string) => ({
// }, // },
// ], // ],
}, },
{
name: 'operation',
path: 'operation',
icon: 'icon-Jobs',
children: [
process.env.BUSINESS_VERSION
? {
name: 'balance',
path: 'balance',
icon: '#icon-luoji',
}
: undefined,
{
name: 'jobs',
path: 'jobs',
icon: 'icon-Jobs',
},
].filter((m) => m),
},
process.env.BUSINESS_VERSION process.env.BUSINESS_VERSION
? { ? {
name: 'produce-consume', name: 'produce-consume',
@@ -127,11 +132,6 @@ export const leftMenus = (clusterId?: string) => ({
// path: 'acls', // path: 'acls',
// icon: 'icon-wodegongzuotai', // icon: 'icon-wodegongzuotai',
// }, // },
{
name: 'jobs',
path: 'jobs',
icon: 'icon-Jobs',
},
].filter((m) => m), ].filter((m) => m),
}); });

View File

@@ -258,3 +258,25 @@ li {
} }
} }
} }
.empty-panel {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
margin-bottom: 18px;
.img {
width: 51px;
height: 34px;
margin-bottom: 7px;
background-size: cover;
background-image: url('./assets/empty.png');
}
.text {
font-size: 10px;
color: #919aac;
line-height: 20px;
}
}

View File

@@ -44,6 +44,10 @@ export default {
[`menu.${systemKey}.consumer-group.operating-state`]: 'Operating State', [`menu.${systemKey}.consumer-group.operating-state`]: 'Operating State',
[`menu.${systemKey}.consumer-group.group-list`]: 'GroupList', [`menu.${systemKey}.consumer-group.group-list`]: 'GroupList',
[`menu.${systemKey}.operation`]: 'Operation',
[`menu.${systemKey}.operation.balance`]: 'Load Rebalance',
[`menu.${systemKey}.operation.jobs`]: 'Job',
[`menu.${systemKey}.acls`]: 'ACLs', [`menu.${systemKey}.acls`]: 'ACLs',
[`menu.${systemKey}.jobs`]: 'Job', [`menu.${systemKey}.jobs`]: 'Job',

View File

@@ -5,7 +5,7 @@ import API from '../../api';
import { getControllerChangeLogListColumns, defaultPagination } from './config'; import { getControllerChangeLogListColumns, defaultPagination } from './config';
import BrokerDetail from '../BrokerDetail'; import BrokerDetail from '../BrokerDetail';
import BrokerHealthCheck from '@src/components/CardBar/BrokerHealthCheck'; import BrokerHealthCheck from '@src/components/CardBar/BrokerHealthCheck';
import DBreadcrumb from 'knowdesign/lib/extend/d-breadcrumb'; import DBreadcrumb from 'knowdesign/es/extend/d-breadcrumb';
import './index.less'; import './index.less';
const { request } = Utils; const { request } = Utils;

View File

@@ -2,7 +2,7 @@ import React from 'react';
import { MetricType } from '@src/api'; import { MetricType } from '@src/api';
import BrokerHealthCheck from '@src/components/CardBar/BrokerHealthCheck'; import BrokerHealthCheck from '@src/components/CardBar/BrokerHealthCheck';
import DashboardDragChart from '@src/components/DashboardDragChart'; import DashboardDragChart from '@src/components/DashboardDragChart';
import DBreadcrumb from 'knowdesign/lib/extend/d-breadcrumb'; import DBreadcrumb from 'knowdesign/es/extend/d-breadcrumb';
import { AppContainer } from 'knowdesign'; import { AppContainer } from 'knowdesign';
const BrokerDashboard = (): JSX.Element => { const BrokerDashboard = (): JSX.Element => {

View File

@@ -1,4 +1,4 @@
import React from 'react'; import React, { useEffect } from 'react';
import { Drawer, Form, Input, Space, Button, Checkbox, Utils, Row, Col, IconFont, Divider, message } from 'knowdesign'; import { Drawer, Form, Input, Space, Button, Checkbox, Utils, Row, Col, IconFont, Divider, message } from 'knowdesign';
import { useParams } from 'react-router-dom'; import { useParams } from 'react-router-dom';
import Api from '@src/api'; import Api from '@src/api';
@@ -31,6 +31,10 @@ export const ConfigurationEdit = (props: any) => {
}); });
}; };
React.useEffect(() => {
form.setFieldsValue(props.record);
}, [props.record]);
return ( return (
<Drawer <Drawer
title={ title={
@@ -44,6 +48,7 @@ export const ConfigurationEdit = (props: any) => {
visible={props.visible} visible={props.visible}
onClose={() => props.setVisible(false)} onClose={() => props.setVisible(false)}
maskClosable={false} maskClosable={false}
destroyOnClose
extra={ extra={
<Space> <Space>
<Button size="small" onClick={onClose}> <Button size="small" onClick={onClose}>
@@ -70,7 +75,7 @@ export const ConfigurationEdit = (props: any) => {
{props.record?.documentation || '-'} {props.record?.documentation || '-'}
</Col> </Col>
</Row> </Row>
<Form form={form} layout="vertical" initialValues={props.record}> <Form form={form} layout="vertical">
<Form.Item name="defaultValue" label="Kafka默认配置"> <Form.Item name="defaultValue" label="Kafka默认配置">
<Input disabled /> <Input disabled />
</Form.Item> </Form.Item>

View File

@@ -14,19 +14,49 @@ export const getBrokerListColumns = (arg?: any) => {
// eslint-disable-next-line react/display-name // eslint-disable-next-line react/display-name
render: (t: number, r: any) => { render: (t: number, r: any) => {
return r?.alive ? ( return r?.alive ? (
<a <>
onClick={() => { <a
window.location.hash = `brokerId=${t || t === 0 ? t : ''}&host=${r.host || ''}`; onClick={() => {
}} window.location.hash = `brokerId=${t || t === 0 ? t : ''}&host=${r.host || ''}`;
> }}
{t} >
</a> {t}
</a>
{r?.kafkaRoleList?.includes('controller') && (
<Tag
style={{
color: '#556EE6',
padding: '2px 5px',
background: '#eff1fd',
marginLeft: '4px',
transform: 'scale(0.83,0.83)',
}}
>
Controller
</Tag>
)}
</>
) : ( ) : (
<span>{t}</span> <>
<span>{t}</span>
{r?.kafkaRoleList?.includes('controller') && (
<Tag
style={{
color: '#556EE6',
padding: '2px 5px',
background: '#eff1fd',
marginLeft: '4px',
transform: 'scale(0.83,0.83)',
}}
>
Controller
</Tag>
)}
</>
); );
}, },
fixed: 'left', fixed: 'left',
width: 120, width: 150,
}, },
// { // {
// title: 'Rack', // title: 'Rack',

View File

@@ -7,7 +7,7 @@ import { dealTableRequestParams } from '../../constants/common';
import BrokerDetail from '../BrokerDetail'; import BrokerDetail from '../BrokerDetail';
import CardBar from '@src/components/CardBar'; import CardBar from '@src/components/CardBar';
import BrokerHealthCheck from '@src/components/CardBar/BrokerHealthCheck'; import BrokerHealthCheck from '@src/components/CardBar/BrokerHealthCheck';
import DBreadcrumb from 'knowdesign/lib/extend/d-breadcrumb'; import DBreadcrumb from 'knowdesign/es/extend/d-breadcrumb';
import './index.less'; import './index.less';
const { request } = Utils; const { request } = Utils;

View File

@@ -6,11 +6,16 @@ import { goLogin } from '@src/constants/axiosConfig';
// 权限对应表 // 权限对应表
export enum ClustersPermissionMap { export enum ClustersPermissionMap {
CLUSTERS_MANAGE = '多集群管理', CLUSTERS_MANAGE = '多集群管理',
CLUSTERS_MANAGE_VIEW = '多集群管理查看',
// Cluster // Cluster
CLUSTER_ADD = '接入集群', CLUSTER_ADD = '接入集群',
CLUSTER_DEL = '删除集群', CLUSTER_DEL = '删除集群',
CLUSTER_CHANGE_HEALTHY = 'Cluster-修改健康规则', CLUSTER_CHANGE_HEALTHY = 'Cluster-修改健康规则',
CLUSTER_CHANGE_INFO = 'Cluster-修改集群信息', CLUSTER_CHANGE_INFO = 'Cluster-修改集群信息',
// LoadReBalance
REBALANCE_CYCLE = 'Cluster-LoadReBalance-周期均衡',
REBALANCE_IMMEDIATE = 'Cluster-LoadReBalance-立即均衡',
REBALANCE_SETTING = 'Cluster-LoadReBalance-设置集群规格',
// Broker // Broker
BROKER_CHANGE_CONFIG = 'Broker-修改Broker配置', BROKER_CHANGE_CONFIG = 'Broker-修改Broker配置',
// Topic // Topic
@@ -19,6 +24,8 @@ export enum ClustersPermissionMap {
TOPIC_DEL = 'Topic-删除Topic', TOPIC_DEL = 'Topic-删除Topic',
TOPIC_EXPOND = 'Topic-扩分区', TOPIC_EXPOND = 'Topic-扩分区',
TOPIC_ADD = 'Topic-新增Topic', TOPIC_ADD = 'Topic-新增Topic',
TOPIC_MOVE_REPLICA = 'Topic-迁移副本',
TOPIC_CHANGE_REPLICA = 'Topic-扩缩副本',
// Consumers // Consumers
CONSUMERS_RESET_OFFSET = 'Consumers-重置Offset', CONSUMERS_RESET_OFFSET = 'Consumers-重置Offset',
// Test // Test

View File

@@ -1,5 +1,5 @@
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import { Button, DatePicker, Drawer, Form, notification, Radio, Utils, Space, Divider } from 'knowdesign'; import { Button, DatePicker, Drawer, Form, notification, Radio, Utils, Space, Divider, message } from 'knowdesign';
import { useParams } from 'react-router-dom'; import { useParams } from 'react-router-dom';
import EditTable from '../TestingProduce/component/EditTable'; import EditTable from '../TestingProduce/component/EditTable';
import Api from '@src/api/index'; import Api from '@src/api/index';
@@ -53,11 +53,28 @@ export default (props: any) => {
const [resetOffsetVisible, setResetOffsetVisible] = useState(false); const [resetOffsetVisible, setResetOffsetVisible] = useState(false);
const customFormRef: any = React.createRef(); const customFormRef: any = React.createRef();
const clusterPhyId = Number(routeParams.clusterId); const clusterPhyId = Number(routeParams.clusterId);
const [partitionIdList, setPartitionIdList] = useState([]);
useEffect(() => { useEffect(() => {
form.setFieldsValue({ form.setFieldsValue({
resetType: defaultResetType, resetType: defaultResetType,
}); });
}, []); }, []);
useEffect(() => {
Utils.request(Api.getTopicsMetaData(record?.topicName, +routeParams.clusterId))
.then((res: any) => {
const partitionLists = (res?.partitionIdList || []).map((item: any) => {
return {
label: item,
value: item,
};
});
setPartitionIdList(partitionLists);
})
.catch((err) => {
message.error(err);
});
}, []);
const confirm = () => { const confirm = () => {
let tableData; let tableData;
if (customFormRef.current) { if (customFormRef.current) {
@@ -160,8 +177,9 @@ export default (props: any) => {
colCustomConfigs={[ colCustomConfigs={[
{ {
title: 'PartitionID', title: 'PartitionID',
inputType: 'number', inputType: 'select',
placeholder: '请输入Partition', placeholder: '请输入Partition',
options: partitionIdList,
}, },
{ {
title: 'Offset', title: 'Offset',

View File

@@ -7,7 +7,7 @@ import { getOperatingStateListParams } from './interface';
import { useParams } from 'react-router-dom'; import { useParams } from 'react-router-dom';
import ConsumerGroupDetail from './ConsumerGroupDetail'; import ConsumerGroupDetail from './ConsumerGroupDetail';
import ConsumerGroupHealthCheck from '@src/components/CardBar/ConsumerGroupHealthCheck'; import ConsumerGroupHealthCheck from '@src/components/CardBar/ConsumerGroupHealthCheck';
import DBreadcrumb from 'knowdesign/lib/extend/d-breadcrumb'; import DBreadcrumb from 'knowdesign/es/extend/d-breadcrumb';
import { hashDataParse } from '@src/constants/common'; import { hashDataParse } from '@src/constants/common';
const { Option } = Select; const { Option } = Select;
@@ -30,7 +30,7 @@ const AutoPage = (props: any) => {
const searchFn = () => { const searchFn = () => {
const params: getOperatingStateListParams = { const params: getOperatingStateListParams = {
pageNo: pageIndex, pageNo: 1,
pageSize, pageSize,
fuzzySearchDTOList: [], fuzzySearchDTOList: [],
}; };

View File

@@ -61,9 +61,11 @@ const columns: any = [
const totalSize = r.totalSize ? Number(Utils.formatAssignSize(t, 'MB')) : 0; const totalSize = r.totalSize ? Number(Utils.formatAssignSize(t, 'MB')) : 0;
return ( return (
<div className="message-size"> <div className="message-size">
<Tooltip title={(movedSize > 0 && totalSize > 0 ? (movedSize / totalSize) * 100 : 0) + '%'}> <Tooltip
title={(movedSize === 0 && totalSize === 0 ? 100 : movedSize > 0 && totalSize > 0 ? (movedSize / totalSize) * 100 : 0) + '%'}
>
<Progress <Progress
percent={movedSize > 0 && totalSize > 0 ? (movedSize / totalSize) * 100 : 0} percent={movedSize === 0 && totalSize === 0 ? 100 : movedSize > 0 && totalSize > 0 ? (movedSize / totalSize) * 100 : 0}
strokeColor="#556EE6" strokeColor="#556EE6"
trailColor="#ECECF1" trailColor="#ECECF1"
showInfo={false} showInfo={false}

View File

@@ -237,12 +237,12 @@ const RebalancePlan = (props: PropsType) => {
<Descriptions.Item labelStyle={{ width: '100px' }} label="迁移副本数"> <Descriptions.Item labelStyle={{ width: '100px' }} label="迁移副本数">
{data?.replicas || '-'} {data?.replicas || '-'}
</Descriptions.Item> </Descriptions.Item>
<Descriptions.Item label="均衡阈值"> <Descriptions.Item label="均衡区间">
{data?.clusterBalanceIntervalList {data?.clusterBalanceIntervalList
? data?.clusterBalanceIntervalList?.map((item: any) => { ? data?.clusterBalanceIntervalList?.map((item: any) => {
return ( return (
<Tag style={{ padding: '4px 8px', backgroundColor: 'rgba(33,37,41,0.08)', marginRight: '4px' }} key={item?.priority}> <Tag style={{ padding: '4px 5px', backgroundColor: 'rgba(33,37,41,0.08)', marginRight: '4px' }} key={item?.priority}>
{item.type + ':' + item.intervalPercent + '%'} {item.type?.slice(0, 1).toUpperCase() + item.type?.slice(1) + ':' + ' ±' + item.intervalPercent + '%'}
</Tag> </Tag>
); );
}) })

View File

@@ -19,9 +19,9 @@ export const jobType = [
}, },
process.env.BUSSINESS_VERSION process.env.BUSSINESS_VERSION
? { ? {
label: '集群均衡', label: '集群均衡',
value: 2, value: 2,
} }
: undefined, : undefined,
].filter((t) => t); ].filter((t) => t);
@@ -75,6 +75,7 @@ export const getJobsListColumns = (arg?: any) => {
title: '任务ID', title: '任务ID',
dataIndex: 'id', dataIndex: 'id',
key: 'id', key: 'id',
width: 70,
}, },
{ {
title: '任务类型', title: '任务类型',
@@ -313,9 +314,13 @@ export const getTaskDetailsColumns = (arg?: any) => {
const totalSize = r.totalSize ? Number(Utils.formatAssignSize(t, 'MB')) : 0; const totalSize = r.totalSize ? Number(Utils.formatAssignSize(t, 'MB')) : 0;
return ( return (
<div className="message-size"> <div className="message-size">
<Tooltip title={(movedSize > 0 && totalSize > 0 ? (movedSize / totalSize) * 100 : 0) + '%'}> <Tooltip
title={
(r.success === r.total && r.total > 0 ? 100 : movedSize > 0 && totalSize > 0 ? (movedSize / totalSize) * 100 : 0) + '%'
}
>
<Progress <Progress
percent={movedSize > 0 && totalSize > 0 ? (movedSize / totalSize) * 100 : 0} percent={r.success === r.total && r.total > 0 ? 100 : movedSize > 0 && totalSize > 0 ? (movedSize / totalSize) * 100 : 0}
strokeColor="#556EE6" strokeColor="#556EE6"
showInfo={false} showInfo={false}
/> />
@@ -437,9 +442,13 @@ export const getMoveBalanceColumns = (arg?: any) => {
const totalSize = r.totalSize ? Number(Utils.formatAssignSize(t, 'MB')) : 0; const totalSize = r.totalSize ? Number(Utils.formatAssignSize(t, 'MB')) : 0;
return ( return (
<div className="message-size"> <div className="message-size">
<Tooltip title={(movedSize > 0 && totalSize > 0 ? (movedSize / totalSize) * 100 : 0) + '%'}> <Tooltip
title={
(r.success === r.total && r.total > 0 ? 100 : movedSize > 0 && totalSize > 0 ? (movedSize / totalSize) * 100 : 0) + '%'
}
>
<Progress <Progress
percent={movedSize > 0 && totalSize > 0 ? (movedSize / totalSize) * 100 : 0} percent={r.success === r.total && r.total > 0 ? 100 : movedSize > 0 && totalSize > 0 ? (movedSize / totalSize) * 100 : 0}
strokeColor="#556EE6" strokeColor="#556EE6"
showInfo={false} showInfo={false}
/> />

View File

@@ -4,7 +4,7 @@ import { ProTable, Drawer, Utils, AppContainer, Form, Select, Input, Button, mes
import API from '../../api'; import API from '../../api';
import { getJobsListColumns, defaultPagination, runningStatus, jobType } from './config'; import { getJobsListColumns, defaultPagination, runningStatus, jobType } from './config';
import JobsCheck from '@src/components/CardBar/JobsCheck'; import JobsCheck from '@src/components/CardBar/JobsCheck';
import DBreadcrumb from 'knowdesign/lib/extend/d-breadcrumb'; import DBreadcrumb from 'knowdesign/es/extend/d-breadcrumb';
import { ViewJobsProgress } from './ViewJobsProgress'; import { ViewJobsProgress } from './ViewJobsProgress';
import './index.less'; import './index.less';
import ReplicaChange from '@src/components/TopicJob/ReplicaChange'; import ReplicaChange from '@src/components/TopicJob/ReplicaChange';
@@ -209,7 +209,7 @@ const JobsList: React.FC = (props: any) => {
tableProps={{ tableProps={{
tableId: 'jobs_list', tableId: 'jobs_list',
showHeader: false, showHeader: false,
rowKey: 'jobs_list', rowKey: 'id',
loading: loading, loading: loading,
columns: getJobsListColumns({ onDelete, setViewProgress }), columns: getJobsListColumns({ onDelete, setViewProgress }),
dataSource: data, dataSource: data,

View File

@@ -168,7 +168,6 @@ const BalanceDrawer: React.FC<PropsType> = ({ onClose, visible, isCycle = false,
const init = () => { const init = () => {
if (formData && Object.keys(formData).length > 0) { if (formData && Object.keys(formData).length > 0) {
console.log(formData, '有FormData');
const tableData = formData?.clusterBalanceIntervalList?.map((item: any) => { const tableData = formData?.clusterBalanceIntervalList?.map((item: any) => {
const finfIndex = BalancedDimensions.findIndex((item1) => item1?.value === item?.type); const finfIndex = BalancedDimensions.findIndex((item1) => item1?.value === item?.type);
return { return {
@@ -201,7 +200,6 @@ const BalanceDrawer: React.FC<PropsType> = ({ onClose, visible, isCycle = false,
priority: index + 1, priority: index + 1,
}; };
}); });
console.log(res, '表单回显立即均衡');
setTableData(res); setTableData(res);
setDimension(['disk', 'bytesIn', 'bytesOut']); setDimension(['disk', 'bytesIn', 'bytesOut']);
setNodeTargetKeys([]); setNodeTargetKeys([]);
@@ -220,14 +218,12 @@ const BalanceDrawer: React.FC<PropsType> = ({ onClose, visible, isCycle = false,
throttleUnitB: values?.throttleUnitM * 1024 * 1024, throttleUnitB: values?.throttleUnitM * 1024 * 1024,
}; };
if (!isCycle) { if (values?.priority === 'throughput') {
if (values?.priority === 'throughput') { params.parallelNum = 0;
params.parallelNum = 0; params.executionStrategy = 1;
params.executionStrategy = 1; } else if (values?.priority === 'stability') {
} else if (values?.priority === 'stability') { params.parallelNum = 1;
params.parallelNum = 1; params.executionStrategy = 2;
params.executionStrategy = 2;
}
} }
if (formData?.jobId) { if (formData?.jobId) {
@@ -382,6 +378,8 @@ const BalanceDrawer: React.FC<PropsType> = ({ onClose, visible, isCycle = false,
const drawerClose = (isArg?: boolean) => { const drawerClose = (isArg?: boolean) => {
isArg ? onClose(isArg) : onClose(); isArg ? onClose(isArg) : onClose();
setParallelNum(0);
setExecutionStrategy(1);
form.resetFields(); form.resetFields();
}; };
@@ -540,17 +538,38 @@ const BalanceDrawer: React.FC<PropsType> = ({ onClose, visible, isCycle = false,
</Form.Item> </Form.Item>
<h6 className="form-title"></h6> <h6 className="form-title"></h6>
{!isCycle && ( {isCycle && (
<Form.Item label="" name="priority" rules={[{ required: true, message: 'Principle 不能为空' }]} initialValue="throughput"> <Form.Item
<Radio.Group onChange={priorityChange}> className="schedule-cron"
<Radio value="throughput"></Radio> name="scheduleCron"
<Radio value="stability"></Radio> label="任务周期"
<Radio value="custom"></Radio> rules={[
</Radio.Group> {
required: true,
message: `请输入!`,
},
{
validator: (_, value) => {
const valArr = value.split(' ');
if (valArr[1] === '*' || valArr[2] === '*') {
return Promise.reject(new Error('任务周期必须指定分钟、小时'));
}
return Promise.resolve();
},
},
]}
>
<CronInput />
</Form.Item> </Form.Item>
)} )}
<Form.Item label="" name="priority" rules={[{ required: true, message: 'Principle 不能为空' }]} initialValue="throughput">
{!isCycle && ( <Radio.Group onChange={priorityChange}>
<Radio value="throughput"></Radio>
<Radio value="stability"></Radio>
<Radio value="custom"></Radio>
</Radio.Group>
</Form.Item>
{
<Form.Item dependencies={['priority']} style={{ marginBottom: 0 }}> <Form.Item dependencies={['priority']} style={{ marginBottom: 0 }}>
{({ getFieldValue }) => {({ getFieldValue }) =>
getFieldValue('priority') === 'custom' ? ( getFieldValue('priority') === 'custom' ? (
@@ -600,9 +619,9 @@ const BalanceDrawer: React.FC<PropsType> = ({ onClose, visible, isCycle = false,
) : null ) : null
} }
</Form.Item> </Form.Item>
)} }
{isCycle && ( {/* {isCycle && (
<Form.Item <Form.Item
name="parallelNum" name="parallelNum"
label={ label={
@@ -622,9 +641,9 @@ const BalanceDrawer: React.FC<PropsType> = ({ onClose, visible, isCycle = false,
> >
<InputNumber min={0} max={999} placeholder="请输入任务并行度" style={{ width: '100%' }} /> <InputNumber min={0} max={999} placeholder="请输入任务并行度" style={{ width: '100%' }} />
</Form.Item> </Form.Item>
)} )} */}
{isCycle && ( {/* {isCycle && (
<Form.Item <Form.Item
className="schedule-cron" className="schedule-cron"
name="scheduleCron" name="scheduleCron"
@@ -647,9 +666,9 @@ const BalanceDrawer: React.FC<PropsType> = ({ onClose, visible, isCycle = false,
> >
<CronInput /> <CronInput />
</Form.Item> </Form.Item>
)} )} */}
{isCycle && ( {/* {isCycle && (
<Form.Item <Form.Item
name="executionStrategy" name="executionStrategy"
label={ label={
@@ -672,7 +691,7 @@ const BalanceDrawer: React.FC<PropsType> = ({ onClose, visible, isCycle = false,
<Radio value={2}>优先最小副本</Radio> <Radio value={2}>优先最小副本</Radio>
</Radio.Group> </Radio.Group>
</Form.Item> </Form.Item>
)} )} */}
<Form.Item <Form.Item
name="throttleUnitM" name="throttleUnitM"

View File

@@ -45,24 +45,57 @@ const HistoryDrawer: React.FC<PropsType> = ({ onClose, visible }) => {
// } // }
// }, // },
{ {
title: 'Disk均衡率', title: (
<span>
Disk<span style={{ fontSize: '12px', color: '#74788D' }}>{'(已均衡丨未均衡)'}</span>
</span>
),
dataIndex: 'disk', dataIndex: 'disk',
render: (text: any, row: any) => { render: (text: any, row: any) => {
return `${row?.sub?.disk?.successNu} (已均衡) / ${row?.sub?.disk?.failedNu} (未均衡)`; // return `${row?.sub?.disk?.successNu} 丨 ${row?.sub?.disk?.failedNu}`;
return (
<div className="balance-history-column">
<span>{row?.sub?.disk?.successNu}</span>
<span></span>
<span>{row?.sub?.disk?.failedNu}</span>
</div>
);
}, },
}, },
{ {
title: 'BytesIn均衡率', title: (
<span>
BytesIn<span style={{ fontSize: '12px', color: '#74788D' }}>{'(已均衡丨未均衡)'}</span>
</span>
),
dataIndex: 'bytesIn', dataIndex: 'bytesIn',
render: (text: any, row: any) => { render: (text: any, row: any) => {
return `${row?.sub?.bytesIn?.successNu} (已均衡) / ${row?.sub?.bytesIn?.failedNu} (未均衡)`; // return `${row?.sub?.bytesIn?.successNu} 丨 ${row?.sub?.bytesIn?.failedNu}`;
return (
<div className="balance-history-column">
<span>{row?.sub?.bytesIn?.successNu}</span>
<span></span>
<span>{row?.sub?.bytesIn?.failedNu}</span>
</div>
);
}, },
}, },
{ {
title: 'BytesOut均衡率', title: (
<span>
BytesOut<span style={{ fontSize: '12px', color: '#74788D' }}>{'(已均衡丨未均衡)'}</span>
</span>
),
dataIndex: 'bytesOut', dataIndex: 'bytesOut',
render: (text: any, row: any) => { render: (text: any, row: any) => {
return `${row?.sub?.bytesOut?.successNu} (已均衡) / ${row?.sub?.bytesOut?.failedNu} (未均衡)`; // return `${row?.sub?.bytesOut?.successNu} 丨 ${row?.sub?.bytesOut?.failedNu}`;
return (
<div className="balance-history-column">
<span>{row?.sub?.bytesOut?.successNu}</span>
<span></span>
<span>{row?.sub?.bytesOut?.failedNu}</span>
</div>
);
}, },
}, },
{ {
@@ -124,7 +157,7 @@ const HistoryDrawer: React.FC<PropsType> = ({ onClose, visible }) => {
}; };
const onTableChange = (curPagination: any) => { const onTableChange = (curPagination: any) => {
getList({ page: curPagination.current, size: curPagination.pageSize }); getList({ pageNo: curPagination.current, pageSize: curPagination.pageSize });
}; };
return ( return (

View File

@@ -143,3 +143,19 @@
// margin: 0 !important; // margin: 0 !important;
// } // }
} }
.balance-history-column{
display: flex;
&>span:nth-child(1){
width: 20px;
}
&>span:nth-child(2){
color: #74788d;
font-size: 12px;
opacity: 0.3;
}
&>span:last-child{
width: 20px;
margin-left: 8px;
}
}

View File

@@ -2,12 +2,13 @@ import React, { useState, useEffect, useRef } from 'react';
import { Select, Form, Utils, AppContainer, Input, Button, ProTable, Badge, Tag, SearchInput } from 'knowdesign'; import { Select, Form, Utils, AppContainer, Input, Button, ProTable, Badge, Tag, SearchInput } from 'knowdesign';
import BalanceDrawer from './BalanceDrawer'; import BalanceDrawer from './BalanceDrawer';
import HistoryDrawer from './HistoryDrawer'; import HistoryDrawer from './HistoryDrawer';
import DBreadcrumb from 'knowdesign/lib/extend/d-breadcrumb'; import DBreadcrumb from 'knowdesign/es/extend/d-breadcrumb';
import { getSizeAndUnit } from '../../constants/common'; import { getSizeAndUnit } from '../../constants/common';
import api from '../../api'; import api from '../../api';
import './index.less'; import './index.less';
import LoadRebalanceCardBar from '@src/components/CardBar/LoadRebalanceCardBar'; import LoadRebalanceCardBar from '@src/components/CardBar/LoadRebalanceCardBar';
import { BalanceFilter } from './BalanceFilter'; import { BalanceFilter } from './BalanceFilter';
import { ClustersPermissionMap } from '../CommonConfig';
const Balance_Status_OPTIONS = [ const Balance_Status_OPTIONS = [
{ {
@@ -288,21 +289,17 @@ const LoadBalance: React.FC = (props: any) => {
setVisible(false); setVisible(false);
}; };
const balanceClick = (val: boolean = false) => { const balanceClick = (val: boolean) => {
if (val) { Utils.request(api.getBalanceForm(global?.clusterInfo?.id), {
Utils.request(api.getBalanceForm(global?.clusterInfo?.id), { method: 'GET',
method: 'GET', })
.then((res: any) => {
const dataDe = res || {};
setCircleFormData(dataDe);
}) })
.then((res: any) => { .catch(() => {
const dataDe = res || {}; setCircleFormData(null);
setCircleFormData(dataDe); });
})
.catch(() => {
setCircleFormData(null);
});
} else {
setCircleFormData(null);
}
setIsCycle(val); setIsCycle(val);
setVisible(true); setVisible(true);
}; };
@@ -365,19 +362,23 @@ const LoadBalance: React.FC = (props: any) => {
value: searchValue, value: searchValue,
onChange: setSearchValue, onChange: setSearchValue,
placeholder: '请输入 Host', placeholder: '请输入 Host',
style: { width: '210px' }, style: { width: '248px' },
maxLength: 128, maxLength: 128,
}} }}
/> />
<Button type="primary" ghost onClick={() => setPlanVisible(true)}> <Button type="primary" ghost onClick={() => setPlanVisible(true)}>
</Button> </Button>
<Button type="primary" ghost onClick={() => balanceClick(true)}> {global.hasPermission(ClustersPermissionMap.REBALANCE_CYCLE) && (
<Button type="primary" ghost onClick={() => balanceClick(true)}>
</Button>
<Button type="primary" onClick={() => balanceClick(false)}> </Button>
)}
</Button> {global.hasPermission(ClustersPermissionMap.REBALANCE_IMMEDIATE) && (
<Button type="primary" onClick={() => balanceClick(false)}>
</Button>
)}
</div> </div>
</div> </div>
{filterList && filterList.length > 0 && ( {filterList && filterList.length > 0 && (

View File

@@ -13,7 +13,7 @@ const carouselList = [
<img className="carousel-eg-ctr-two-img img-one" src={egTwoContent} /> <img className="carousel-eg-ctr-two-img img-one" src={egTwoContent} />
<div className="carousel-eg-ctr-two-desc desc-one"> <div className="carousel-eg-ctr-two-desc desc-one">
<span>Github: </span> <span>Github: </span>
<span>4K</span> <span>5K</span>
<span>+ Star的项目 Know Streaming</span> <span>+ Star的项目 Know Streaming</span>
</div> </div>
<div className="carousel-eg-ctr-two-desc desc-two"> <div className="carousel-eg-ctr-two-desc desc-two">

View File

@@ -1,10 +1,8 @@
/* eslint-disable react/display-name */
import { Button, Divider, Drawer, Form, Input, InputNumber, message, Radio, Select, Spin, Space, Utils } from 'knowdesign'; import { Button, Divider, Drawer, Form, Input, InputNumber, message, Radio, Select, Spin, Space, Utils } from 'knowdesign';
import * as React from 'react'; import * as React from 'react';
import { useIntl } from 'react-intl'; import { useIntl } from 'react-intl';
import api from '../../api'; import api from '@src/api';
import { regClusterName, regUsername } from '../../constants/reg'; import { regClusterName, regUsername } from '@src/constants/reg';
import { bootstrapServersErrCodes, jmxErrCodes, zkErrCodes } from './config'; import { bootstrapServersErrCodes, jmxErrCodes, zkErrCodes } from './config';
import CodeMirrorFormItem from '@src/components/CodeMirrorFormItem'; import CodeMirrorFormItem from '@src/components/CodeMirrorFormItem';
@@ -16,48 +14,35 @@ const clientPropertiesPlaceholder = `用于创建Kafka客户端进行信息获
{ {
"security.protocol": "SASL_PLAINTEXT", "security.protocol": "SASL_PLAINTEXT",
"sasl.mechanism": "SCRAM-SHA-256", "sasl.mechanism": "SCRAM-SHA-256",
"sasl.jaas.config": "sasl.jaas.config": "org.apache.kafka.common.security.
"org.apache.kafka.common.security.scram. scram.ScramLoginModule required username=\\"xxxxxx\\" pass
ScramLoginModule required username="xxxxxx" word=\\"xxxxxx\\";"
password="xxxxxx";"
} }
`; `;
const AccessClusters = (props: any): JSX.Element => { const AccessClusters = (props: any): JSX.Element => {
const { afterSubmitSuccess, clusterInfo, visible } = props;
const intl = useIntl(); const intl = useIntl();
const [form] = Form.useForm(); const [form] = Form.useForm();
const { afterSubmitSuccess, infoLoading, clusterInfo, visible } = props;
const [loading, setLoading] = React.useState(false); const [loading, setLoading] = React.useState(false);
const [security, setSecurity] = React.useState(clusterInfo?.security || 'None'); const [curClusterInfo, setCurClusterInfo] = React.useState<any>({});
const [security, setSecurity] = React.useState(curClusterInfo?.security || 'None');
const [extra, setExtra] = React.useState({ const [extra, setExtra] = React.useState({
versionExtra: '', versionExtra: '',
zooKeeperExtra: '', zooKeeperExtra: '',
bootstrapExtra: '', bootstrapExtra: '',
jmxExtra: '', jmxExtra: '',
}); });
const [isLowVersion, setIsLowVersion] = React.useState<any>(false); const [isLowVersion, setIsLowVersion] = React.useState<boolean>(false);
const [zookeeperErrorStatus, setZookeeperErrorStatus] = React.useState<any>(false); const [zookeeperErrorStatus, setZookeeperErrorStatus] = React.useState<boolean>(false);
const lastFormItemValue = React.useRef({ const lastFormItemValue = React.useRef({
bootstrap: clusterInfo?.bootstrapServers || '', bootstrap: curClusterInfo?.bootstrapServers || '',
zookeeper: clusterInfo?.zookeeper || '', zookeeper: curClusterInfo?.zookeeper || '',
clientProperties: clusterInfo?.clientProperties || {}, clientProperties: curClusterInfo?.clientProperties || {},
}); });
React.useEffect(() => {
const showLowVersion = !(clusterInfo?.zookeeper || !clusterInfo?.kafkaVersion || clusterInfo?.kafkaVersion >= lowKafkaVersion);
lastFormItemValue.current.bootstrap = clusterInfo?.bootstrapServers || '';
lastFormItemValue.current.zookeeper = clusterInfo?.zookeeper || '';
lastFormItemValue.current.clientProperties = clusterInfo?.clientProperties || {};
setIsLowVersion(showLowVersion);
setExtra({
...extra,
versionExtra: showLowVersion ? intl.formatMessage({ id: 'access.cluster.low.version.tip' }) : '',
});
form.setFieldsValue({ ...clusterInfo });
}, [clusterInfo]);
const onHandleValuesChange = (value: any, allValues: any) => { const onHandleValuesChange = (value: any, allValues: any) => {
Object.keys(value).forEach((key) => { Object.keys(value).forEach((key) => {
switch (key) { switch (key) {
@@ -131,10 +116,10 @@ const AccessClusters = (props: any): JSX.Element => {
zookeeper: res.zookeeper || '', zookeeper: res.zookeeper || '',
}; };
setLoading(true); setLoading(true);
if (!isNaN(clusterInfo?.id)) { if (!isNaN(curClusterInfo?.id)) {
Utils.put(api.phyCluster, { Utils.put(api.phyCluster, {
...params, ...params,
id: clusterInfo?.id, id: curClusterInfo?.id,
}) })
.then(() => { .then(() => {
message.success('编辑成功'); message.success('编辑成功');
@@ -222,7 +207,11 @@ const AccessClusters = (props: any): JSX.Element => {
}); });
// 如果kafkaVersion小于最低版本则提示 // 如果kafkaVersion小于最低版本则提示
const showLowVersion = !(clusterInfo?.zookeeper || !clusterInfo?.kafkaVersion || clusterInfo?.kafkaVersion >= lowKafkaVersion); const showLowVersion = !(
curClusterInfo?.zookeeper ||
!curClusterInfo?.kafkaVersion ||
curClusterInfo?.kafkaVersion >= lowKafkaVersion
);
setIsLowVersion(showLowVersion); setIsLowVersion(showLowVersion);
setExtra({ setExtra({
...extraMsg, ...extraMsg,
@@ -235,6 +224,55 @@ const AccessClusters = (props: any): JSX.Element => {
}); });
}; };
React.useEffect(() => {
const showLowVersion = !(curClusterInfo?.zookeeper || !curClusterInfo?.kafkaVersion || curClusterInfo?.kafkaVersion >= lowKafkaVersion);
lastFormItemValue.current = {
bootstrap: curClusterInfo?.bootstrapServers || '',
zookeeper: curClusterInfo?.zookeeper || '',
clientProperties: curClusterInfo?.clientProperties || {},
};
setIsLowVersion(showLowVersion);
setExtra({
...extra,
versionExtra: showLowVersion ? intl.formatMessage({ id: 'access.cluster.low.version.tip' }) : '',
});
form.setFieldsValue({ ...curClusterInfo });
}, [curClusterInfo]);
React.useEffect(() => {
if (visible) {
if (clusterInfo?.id) {
setLoading(true);
Utils.request(api.getPhyClusterBasic(clusterInfo.id))
.then((res: any) => {
let jmxProperties = null;
try {
jmxProperties = JSON.parse(res?.jmxProperties);
} catch (err) {
console.error(err);
}
// 转化值对应成表单值
if (jmxProperties?.openSSL) {
jmxProperties.security = 'Password';
}
if (jmxProperties) {
res = Object.assign({}, res || {}, jmxProperties);
}
setCurClusterInfo(res);
setLoading(false);
})
.catch((err) => {
setCurClusterInfo(clusterInfo);
setLoading(false);
});
} else {
setCurClusterInfo(clusterInfo);
}
}
}, [visible, clusterInfo]);
return ( return (
<> <>
<Drawer <Drawer
@@ -259,16 +297,8 @@ const AccessClusters = (props: any): JSX.Element => {
placement="right" placement="right"
width={480} width={480}
> >
<Spin spinning={loading || !!infoLoading}> <Spin spinning={loading}>
<Form <Form form={form} layout="vertical" onValuesChange={onHandleValuesChange}>
form={form}
initialValues={{
security,
...clusterInfo,
}}
layout="vertical"
onValuesChange={onHandleValuesChange}
>
<Form.Item <Form.Item
name="name" name="name"
label="集群名称" label="集群名称"
@@ -280,11 +310,9 @@ const AccessClusters = (props: any): JSX.Element => {
if (!value) { if (!value) {
return Promise.reject('集群名称不能为空'); return Promise.reject('集群名称不能为空');
} }
if (value === curClusterInfo?.name) {
if (value === clusterInfo?.name) {
return Promise.resolve(); return Promise.resolve();
} }
if (value?.length > 128) { if (value?.length > 128) {
return Promise.reject('集群名称长度限制在1128字符'); return Promise.reject('集群名称长度限制在1128字符');
} }
@@ -310,13 +338,7 @@ const AccessClusters = (props: any): JSX.Element => {
<Form.Item <Form.Item
name="bootstrapServers" name="bootstrapServers"
label="Bootstrap Servers" label="Bootstrap Servers"
extra={ extra={<span className={extra.bootstrapExtra.includes('连接成功') ? 'error-extra-info' : ''}>{extra.bootstrapExtra}</span>}
extra.bootstrapExtra.includes('连接成功') ? (
<span>{extra.bootstrapExtra}</span>
) : (
<span className="error-extra-info">{extra.bootstrapExtra}</span>
)
}
validateTrigger={'onBlur'} validateTrigger={'onBlur'}
rules={[ rules={[
{ {
@@ -352,13 +374,7 @@ const AccessClusters = (props: any): JSX.Element => {
<Form.Item <Form.Item
name="zookeeper" name="zookeeper"
label="Zookeeper" label="Zookeeper"
extra={ extra={<span className={extra.zooKeeperExtra.includes('连接成功') ? 'error-extra-info' : ''}>{extra.zooKeeperExtra}</span>}
extra.zooKeeperExtra.includes('连接成功') ? (
<span>{extra.zooKeeperExtra}</span>
) : (
<span className="error-extra-info">{extra.zooKeeperExtra}</span>
)
}
validateStatus={zookeeperErrorStatus ? 'error' : 'success'} validateStatus={zookeeperErrorStatus ? 'error' : 'success'}
validateTrigger={'onBlur'} validateTrigger={'onBlur'}
rules={[ rules={[
@@ -461,7 +477,7 @@ const AccessClusters = (props: any): JSX.Element => {
style={{ width: '58%' }} style={{ width: '58%' }}
rules={[ rules={[
{ {
required: security === 'Password' || clusterInfo?.security === 'Password', required: security === 'Password' || curClusterInfo?.security === 'Password',
validator: async (rule: any, value: string) => { validator: async (rule: any, value: string) => {
if (!value) { if (!value) {
return Promise.reject('用户名不能为空'); return Promise.reject('用户名不能为空');
@@ -486,7 +502,7 @@ const AccessClusters = (props: any): JSX.Element => {
style={{ width: '38%', marginRight: 0 }} style={{ width: '38%', marginRight: 0 }}
rules={[ rules={[
{ {
required: security === 'Password' || clusterInfo?.security === 'Password', required: security === 'Password' || curClusterInfo?.security === 'Password',
validator: async (rule: any, value: string) => { validator: async (rule: any, value: string) => {
if (!value) { if (!value) {
return Promise.reject('密码不能为空'); return Promise.reject('密码不能为空');

View File

@@ -1,102 +1,108 @@
import { DoubleRightOutlined } from '@ant-design/icons'; import { DoubleRightOutlined } from '@ant-design/icons';
import { Checkbox } from 'knowdesign'; import { Checkbox } from 'knowdesign';
import { CheckboxValueType } from 'knowdesign/es/basic/checkbox/Group';
import { debounce } from 'lodash'; import { debounce } from 'lodash';
import React, { useEffect } from 'react'; import React, { useEffect, useState } from 'react';
const CheckboxGroup = Checkbox.Group; const CheckboxGroup = Checkbox.Group;
interface IVersion {
firstLine: string[];
leftVersions: string[];
}
const CustomCheckGroup = (props: { kafkaVersions: string[]; onChangeCheckGroup: any }) => { const CustomCheckGroup = (props: { kafkaVersions: string[]; onChangeCheckGroup: any }) => {
const { kafkaVersions, onChangeCheckGroup } = props; const { kafkaVersions: newVersions, onChangeCheckGroup } = props;
const [checkedKafkaVersion, setCheckedKafkaVersion] = React.useState<IVersion>({ const [versions, setVersions] = React.useState<string[]>([]);
firstLine: [], const [versionsState, setVersionsState] = React.useState<{
leftVersions: [], [key: string]: boolean;
}); }>({});
const [allVersion, setAllVersion] = React.useState<IVersion>({
firstLine: [],
leftVersions: [],
});
const [indeterminate, setIndeterminate] = React.useState(false); const [indeterminate, setIndeterminate] = React.useState(false);
const [checkAll, setCheckAll] = React.useState(true); const [checkAll, setCheckAll] = React.useState(true);
const [moreGroupWidth, setMoreGroupWidth] = React.useState(400); const [groupInfo, setGroupInfo] = useState({
width: 400,
num: 0,
});
const [showMore, setShowMore] = React.useState(false); const [showMore, setShowMore] = React.useState(false);
useEffect(() => {
document.addEventListener('click', handleDocumentClick);
return () => {
document.removeEventListener('click', handleDocumentClick);
};
}, []);
const handleDocumentClick = (e: Event) => { const handleDocumentClick = (e: Event) => {
setShowMore(false); setShowMore(false);
}; };
const setCheckAllStauts = (list: string[], otherList: string[]) => { const updateGroupInfo = () => {
onChangeCheckGroup([...list, ...otherList]);
setIndeterminate(!!list.length && list.length + otherList.length < kafkaVersions.length);
setCheckAll(list.length + otherList.length === kafkaVersions.length);
};
const getTwoPanelVersion = () => {
const width = (document.getElementsByClassName('custom-check-group')[0] as any)?.offsetWidth; const width = (document.getElementsByClassName('custom-check-group')[0] as any)?.offsetWidth;
const checkgroupWidth = width - 100 - 86; const checkgroupWidth = width - 100 - 86;
const num = (checkgroupWidth / 108) | 0; const num = (checkgroupWidth / 108) | 0;
const firstLine = Array.from(kafkaVersions).splice(0, num); setGroupInfo({
setMoreGroupWidth(num * 108 + 88 + 66); width: num * 108 + 88 + 66,
const leftVersions = Array.from(kafkaVersions).splice(num); num,
return { firstLine, leftVersions }; });
}; };
const onFirstVersionChange = (list: []) => { const getCheckedList = (
setCheckedKafkaVersion({ versionState: {
...checkedKafkaVersion, [key: string]: boolean;
firstLine: list, },
}); filterFunc: (item: [string, boolean], i: number) => boolean
) => {
setCheckAllStauts(list, checkedKafkaVersion.leftVersions); return Object.entries(versionState)
.filter(filterFunc)
.map(([key]) => key);
}; };
const onLeftVersionChange = (list: []) => { const onVersionsChange = (isFirstLine: boolean, list: CheckboxValueType[]) => {
setCheckedKafkaVersion({ const newVersionsState = { ...versionsState };
...checkedKafkaVersion, Object.keys(newVersionsState).forEach((key, i) => {
leftVersions: list, if (isFirstLine && i < groupInfo.num) {
newVersionsState[key] = list.includes(key);
} else if (!isFirstLine && i >= groupInfo.num) {
newVersionsState[key] = list.includes(key);
}
}); });
setCheckAllStauts(list, checkedKafkaVersion.firstLine); const checkedLen = Object.values(newVersionsState).filter((v) => v).length;
setVersionsState(newVersionsState);
setIndeterminate(checkedLen && checkedLen < newVersions.length);
setCheckAll(checkedLen === newVersions.length);
onChangeCheckGroup(getCheckedList(newVersionsState, ([, state]) => state));
}; };
const onCheckAllChange = (e: any) => { const onCheckAllChange = (e: any) => {
const versions = getTwoPanelVersion(); const checked = e.target.checked;
const newVersionsState = { ...versionsState };
setCheckedKafkaVersion( Object.keys(newVersionsState).forEach((key) => (newVersionsState[key] = checked));
e.target.checked
? versions
: {
firstLine: [],
leftVersions: [],
}
);
onChangeCheckGroup(e.target.checked ? [...versions.firstLine, ...versions.leftVersions] : []);
setVersionsState(newVersionsState);
setIndeterminate(false); setIndeterminate(false);
setCheckAll(e.target.checked); setCheckAll(checked);
onChangeCheckGroup(e.target.checked ? versions : []);
}; };
React.useEffect(() => { useEffect(() => {
const handleVersionLine = () => { const newVersionsState = { ...versionsState };
const versions = getTwoPanelVersion(); Object.keys(newVersionsState).forEach((key) => {
setAllVersion(versions); if (!newVersions.includes(key)) {
setCheckedKafkaVersion(versions); delete newVersionsState[key];
}; }
handleVersionLine(); });
newVersions.forEach((version) => {
if (!Object.keys(newVersionsState).includes(version)) {
newVersionsState[version] = true;
}
});
const checkedLen = Object.values(newVersionsState).filter((v) => v).length;
window.addEventListener('resize', handleVersionLine); //监听窗口大小改变 setVersions([...newVersions]);
return () => window.removeEventListener('resize', debounce(handleVersionLine, 500)); setVersionsState(newVersionsState);
setIndeterminate(checkedLen && checkedLen < newVersions.length);
setCheckAll(checkedLen === newVersions.length);
onChangeCheckGroup(getCheckedList(newVersionsState, ([, state]) => state));
}, [newVersions]);
useEffect(() => {
updateGroupInfo();
const listen = debounce(updateGroupInfo, 500);
window.addEventListener('resize', listen); //监听窗口大小改变
document.addEventListener('click', handleDocumentClick);
return () => {
window.removeEventListener('resize', listen);
document.removeEventListener('click', handleDocumentClick);
};
}, []); }, []);
return ( return (
@@ -107,17 +113,21 @@ const CustomCheckGroup = (props: { kafkaVersions: string[]; onChangeCheckGroup:
</Checkbox> </Checkbox>
</div> </div>
<CheckboxGroup options={allVersion.firstLine} value={checkedKafkaVersion.firstLine} onChange={onFirstVersionChange} /> <CheckboxGroup
options={Array.from(versions).splice(0, groupInfo.num)}
value={getCheckedList(versionsState, ([, state], i) => i < groupInfo.num && state)}
onChange={(list) => onVersionsChange(true, list)}
/>
{showMore ? ( {showMore ? (
<CheckboxGroup <CheckboxGroup
style={{ width: moreGroupWidth }} style={{ width: groupInfo.width }}
className="more-check-group" className="more-check-group"
options={allVersion.leftVersions} options={Array.from(versions).splice(groupInfo.num)}
value={checkedKafkaVersion.leftVersions} value={getCheckedList(versionsState, ([, state], i) => i >= groupInfo.num && state)}
onChange={onLeftVersionChange} onChange={(list) => onVersionsChange(false, list)}
/> />
) : null} ) : null}
{allVersion.leftVersions.length ? ( {versions.length > groupInfo.num ? (
<div className="more-btn" onClick={() => setShowMore(!showMore)}> <div className="more-btn" onClick={() => setShowMore(!showMore)}>
<a> <a>
{!showMore ? '展开更多' : '收起更多'} <DoubleRightOutlined style={{ transform: `rotate(${showMore ? '270' : '90'}deg)` }} /> {!showMore ? '展开更多' : '收起更多'} <DoubleRightOutlined style={{ transform: `rotate(${showMore ? '270' : '90'}deg)` }} />

View File

@@ -1,11 +1,10 @@
import React, { useEffect, useMemo, useRef, useState, useReducer } from 'react'; import React, { useEffect, useRef, useState } from 'react';
import { Slider, Input, Select, Checkbox, Button, Utils, Spin, IconFont, AppContainer } from 'knowdesign'; import { Slider, Input, Select, Checkbox, Button, Utils, Spin, IconFont, AppContainer } from 'knowdesign';
import API from '../../api'; import API from '@src/api';
import TourGuide, { MultiPageSteps } from '@src/components/TourGuide'; import TourGuide, { MultiPageSteps } from '@src/components/TourGuide';
import './index.less'; import './index.less';
import { healthSorceList, linesMetric, pointsMetric, sortFieldList, sortTypes, statusFilters } from './config'; import { healthSorceList, sortFieldList, sortTypes, statusFilters } from './config';
import { oneDayMillims } from '../../constants/common'; import ClusterList from './List';
import ListScroll from './List';
import AccessClusters from './AccessCluster'; import AccessClusters from './AccessCluster';
import CustomCheckGroup from './CustomCheckGroup'; import CustomCheckGroup from './CustomCheckGroup';
import { ClustersPermissionMap } from '../CommonConfig'; import { ClustersPermissionMap } from '../CommonConfig';
@@ -13,95 +12,85 @@ import { ClustersPermissionMap } from '../CommonConfig';
const CheckboxGroup = Checkbox.Group; const CheckboxGroup = Checkbox.Group;
const { Option } = Select; const { Option } = Select;
interface ClustersState {
liveCount: number;
downCount: number;
total: number;
}
export interface SearchParams {
healthScoreRange?: [number, number];
checkedKafkaVersions?: string[];
sortInfo?: {
sortField: string;
sortType: string;
};
keywords?: string;
clusterStatus?: number[];
isReloadAll?: boolean;
}
// 未接入集群默认页
const DefaultPage = (props: { setVisible: (visible: boolean) => void }) => {
return (
<div className="empty-page">
<div className="title">Kafka </div>
<div className="img">
<div className="img-card-1" />
<div className="img-card-2" />
<div className="img-card-3" />
</div>
<div>
<Button className="header-filter-top-button" type="primary" onClick={() => props.setVisible(true)}>
<span>
<IconFont type="icon-jiahao" />
<span className="text"></span>
</span>
</Button>
</div>
</div>
);
};
// 加载状态
const LoadingState = () => {
return (
<div style={{ height: '100%', display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
<Spin spinning={true} />
</div>
);
};
const MultiClusterPage = () => { const MultiClusterPage = () => {
const [run, setRun] = useState<boolean>(false);
const [global] = AppContainer.useGlobalValue(); const [global] = AppContainer.useGlobalValue();
const [statusList, setStatusList] = React.useState([1, 0]); const [pageLoading, setPageLoading] = useState(true);
const [accessClusterVisible, setAccessClusterVisible] = React.useState(false);
const [curClusterInfo, setCurClusterInfo] = useState<any>({});
const [kafkaVersions, setKafkaVersions] = React.useState<string[]>([]); const [kafkaVersions, setKafkaVersions] = React.useState<string[]>([]);
const [existKafkaVersion, setExistKafkaVersion] = React.useState<string[]>([]); const [existKafkaVersion, setExistKafkaVersion] = React.useState<string[]>([]);
const [visible, setVisible] = React.useState(false); const [stateInfo, setStateInfo] = React.useState<ClustersState>({
const [list, setList] = useState<[]>([]);
const [healthScoreRange, setHealthScoreRange] = React.useState([0, 100]);
const [checkedKafkaVersions, setCheckedKafkaVersions] = React.useState<string[]>([]);
const [sortInfo, setSortInfo] = React.useState({
sortField: 'HealthScore',
sortType: 'asc',
});
const [clusterLoading, setClusterLoading] = useState(true);
const [pageLoading, setPageLoading] = useState(true);
const [isReload, setIsReload] = useState(false);
const [versionLoading, setVersionLoading] = useState(true);
const [searchKeywords, setSearchKeywords] = useState('');
const [stateInfo, setStateInfo] = React.useState({
downCount: 0, downCount: 0,
liveCount: 0, liveCount: 0,
total: 0, total: 0,
}); });
const [pagination, setPagination] = useState({ // TODO: 首次进入因 searchParams 状态变化导致获取两次列表数据的问题
pageNo: 1, const [searchParams, setSearchParams] = React.useState<SearchParams>({
pageSize: 10, keywords: '',
total: 0, checkedKafkaVersions: [],
healthScoreRange: [0, 100],
sortInfo: {
sortField: 'HealthScore',
sortType: 'asc',
},
clusterStatus: [0, 1],
// 是否拉取当前所有数据
isReloadAll: false,
}); });
const searchKeyword = useRef(''); const searchKeyword = useRef('');
const isReload = useRef(false);
const getPhyClustersDashbord = (pageNo: number, pageSize: number) => { // 获取集群状态
const endTime = new Date().getTime();
const startTime = endTime - oneDayMillims;
const params = {
metricLines: {
endTime,
metricsNames: linesMetric,
startTime,
},
latestMetricNames: pointsMetric,
pageNo: pageNo || 1,
pageSize: pageSize || 10,
preciseFilterDTOList: [
{
fieldName: 'kafkaVersion',
fieldValueList: checkedKafkaVersions as (string | number)[],
},
],
rangeFilterDTOList: [
{
fieldMaxValue: healthScoreRange[1],
fieldMinValue: healthScoreRange[0],
fieldName: 'HealthScore',
},
],
searchKeywords,
...sortInfo,
};
if (statusList.length === 1) {
params.preciseFilterDTOList.push({
fieldName: 'Alive',
fieldValueList: statusList,
});
}
return Utils.post(API.phyClustersDashbord, params);
};
const getSupportKafkaVersion = () => {
Utils.request(API.supportKafkaVersion).then((res) => {
setKafkaVersions(Object.keys(res || {}));
});
};
const getExistKafkaVersion = () => {
setVersionLoading(true);
Utils.request(API.getClustersVersion)
.then((versions: string[]) => {
setExistKafkaVersion(versions || []);
setVersionLoading(false);
setCheckedKafkaVersions(versions || []);
})
.catch((err) => {
setVersionLoading(false);
});
};
const getPhyClusterState = () => { const getPhyClusterState = () => {
Utils.request(API.phyClusterState) Utils.request(API.phyClusterState)
.then((res: any) => { .then((res: any) => {
@@ -112,211 +101,224 @@ const MultiClusterPage = () => {
}); });
}; };
// 获取 kafka 全部版本
const getSupportKafkaVersion = () => {
Utils.request(API.supportKafkaVersion).then((res) => {
setKafkaVersions(Object.keys(res || {}));
});
};
const updateSearchParams = (params: SearchParams) => {
setSearchParams((curParams) => ({ ...curParams, isReloadAll: false, ...params }));
};
const searchParamsChangeFunc = {
// 健康分改变
onSilderChange: (value: [number, number]) =>
updateSearchParams({
healthScoreRange: value,
}),
// 排序信息改变
onSortInfoChange: (type: string, value: string) =>
updateSearchParams({
sortInfo: {
...searchParams.sortInfo,
[type]: value,
},
}),
// Live / Down 筛选
onClusterStatusChange: (list: number[]) =>
updateSearchParams({
clusterStatus: list,
}),
// 集群名称搜索项改变
onInputChange: () =>
updateSearchParams({
keywords: searchKeyword.current,
}),
// 集群版本筛选
onChangeCheckGroup: (list: string[]) => {
updateSearchParams({
checkedKafkaVersions: list,
isReloadAll: isReload.current,
});
isReload.current = false;
},
};
// 获取当前接入集群的 kafka 版本
const getExistKafkaVersion = (isReloadAll = false) => {
isReload.current = isReloadAll;
Utils.request(API.getClustersVersion).then((versions: string[]) => {
if (!Array.isArray(versions)) {
versions = [];
}
setExistKafkaVersion(versions.sort().reverse() || []);
});
};
// 接入/编辑集群
const showAccessCluster = (clusterInfo: any = {}) => {
setCurClusterInfo(clusterInfo);
setAccessClusterVisible(true);
};
// 接入/编辑集群回调
const afterAccessCluster = () => {
getPhyClusterState();
getExistKafkaVersion(true);
};
useEffect(() => { useEffect(() => {
getPhyClusterState(); getPhyClusterState();
getSupportKafkaVersion(); getSupportKafkaVersion();
getExistKafkaVersion(); getExistKafkaVersion();
}, []); }, []);
useEffect(() => {
if (!pageLoading && stateInfo.total) {
setRun(true);
}
}, [pageLoading, stateInfo]);
useEffect(() => {
if (versionLoading) return;
setClusterLoading(true);
getPhyClustersDashbord(pagination.pageNo, pagination.pageSize)
.then((res: any) => {
setPagination(res.pagination);
setList(res?.bizData || []);
return res;
})
.finally(() => {
setClusterLoading(false);
});
}, [sortInfo, checkedKafkaVersions, healthScoreRange, statusList, searchKeywords, isReload]);
const onSilderChange = (value: number[]) => {
setHealthScoreRange(value);
};
const onSelectChange = (type: string, value: string) => {
setSortInfo({
...sortInfo,
[type]: value,
});
};
const onStatusChange = (list: []) => {
setStatusList(list);
};
const onInputChange = (e: any) => {
const { value } = e.target;
setSearchKeywords(value.trim());
};
const onChangeCheckGroup = (list: []) => {
setCheckedKafkaVersions(list);
};
const afterSubmitSuccessAccessClusters = () => {
getPhyClusterState();
setIsReload(!isReload);
};
const renderEmpty = () => {
return (
<div className="empty-page">
<div className="title">Kafka </div>
<div className="img">
<div className="img-card-1" />
<div className="img-card-2" />
<div className="img-card-3" />
</div>
<div>
<Button className="header-filter-top-button" type="primary" onClick={() => setVisible(true)}>
<span>
<IconFont type="icon-jiahao" />
<span className="text"></span>
</span>
</Button>
</div>
</div>
);
};
const renderLoading = () => {
return (
<div style={{ height: '100%', display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
<Spin spinning={true} />
</div>
);
};
const renderContent = () => {
return (
<div className="multi-cluster-page" id="scrollableDiv">
<div className="multi-cluster-page-fixed">
<div className="content-container">
<div className="multi-cluster-header">
<div className="cluster-header-card">
<div className="cluster-header-card-bg-left"></div>
<div className="cluster-header-card-bg-right"></div>
<h5 className="header-card-title">
Clusters<span className="chinese-text"> </span>
</h5>
<div className="header-card-total">{stateInfo.total}</div>
<div className="header-card-info">
<div className="card-info-item card-info-item-live">
<div>
live
<span className="info-item-value">
<em>{stateInfo.liveCount}</em>
</span>
</div>
</div>
<div className="card-info-item card-info-item-down">
<div>
down
<span className="info-item-value">
<em>{stateInfo.downCount}</em>
</span>
</div>
</div>
</div>
</div>
<div className="cluster-header-filter">
<div className="header-filter-top">
<div className="header-filter-top-input">
<Input
onPressEnter={onInputChange}
onChange={(e) => (searchKeyword.current = e.target.value)}
allowClear
bordered={false}
placeholder="请输入ClusterName进行搜索"
suffix={<IconFont className="icon" type="icon-fangdajing" onClick={() => setSearchKeywords(searchKeyword.current)} />}
/>
</div>
{global.hasPermission && global.hasPermission(ClustersPermissionMap.CLUSTER_ADD) ? (
<>
<div className="header-filter-top-divider"></div>
<Button className="header-filter-top-button" type="primary" onClick={() => setVisible(true)}>
<IconFont type="icon-jiahao" />
<span className="text"></span>
</Button>
</>
) : (
<></>
)}
</div>
<div className="header-filter-bottom">
<div className="header-filter-bottom-item header-filter-bottom-item-checkbox">
<h3 className="header-filter-bottom-item-title"></h3>
<div className="header-filter-bottom-item-content flex">
{existKafkaVersion.length ? (
<CustomCheckGroup kafkaVersions={existKafkaVersion} onChangeCheckGroup={onChangeCheckGroup} />
) : null}
</div>
</div>
<div className="header-filter-bottom-item header-filter-bottom-item-slider">
<h3 className="header-filter-bottom-item-title title-right"></h3>
<div className="header-filter-bottom-item-content">
<Slider range step={20} defaultValue={[0, 100]} marks={healthSorceList} onAfterChange={onSilderChange} />
</div>
</div>
</div>
</div>
</div>
<div className="multi-cluster-filter">
<div className="multi-cluster-filter-select">
<Select
onChange={(value) => onSelectChange('sortField', value)}
defaultValue="HealthScore"
style={{ width: 170, marginRight: 12 }}
>
{sortFieldList.map((item) => (
<Option key={item.value} value={item.value}>
{item.label}
</Option>
))}
</Select>
<Select onChange={(value) => onSelectChange('sortType', value)} defaultValue="asc" style={{ width: 170 }}>
{sortTypes.map((item) => (
<Option key={item.value} value={item.value}>
{item.label}
</Option>
))}
</Select>
</div>
<div className="multi-cluster-filter-checkbox">
<CheckboxGroup options={statusFilters} value={statusList} onChange={onStatusChange} />
</div>
</div>
<div className="test-modal-23"></div>
</div>
</div>
<Spin spinning={clusterLoading}>{renderList}</Spin>
</div>
);
};
const renderList = useMemo(() => {
return <ListScroll list={list} pagination={pagination} loadMoreData={getPhyClustersDashbord} getPhyClusterState={getPhyClusterState} />;
}, [list, pagination]);
return ( return (
<> <>
<TourGuide guide={MultiPageSteps} run={run} /> {pageLoading ? (
{pageLoading ? renderLoading() : stateInfo.total ? renderContent() : renderEmpty()} <LoadingState />
) : !stateInfo?.total ? (
<DefaultPage setVisible={setAccessClusterVisible} />
) : (
<>
<div className="multi-cluster-page" id="scrollableDiv">
<div className="multi-cluster-page-fixed">
<div className="content-container">
<div className="multi-cluster-header">
<div className="cluster-header-card">
<div className="cluster-header-card-bg-left"></div>
<div className="cluster-header-card-bg-right"></div>
<h5 className="header-card-title">
Clusters<span className="chinese-text"> </span>
</h5>
<div className="header-card-total">{stateInfo.total}</div>
<div className="header-card-info">
<div className="card-info-item card-info-item-live">
<div>
live
<span className="info-item-value">
<em>{stateInfo.liveCount}</em>
</span>
</div>
</div>
<div className="card-info-item card-info-item-down">
<div>
down
<span className="info-item-value">
<em>{stateInfo.downCount}</em>
</span>
</div>
</div>
</div>
</div>
<div className="cluster-header-filter">
<div className="header-filter-top">
<div className="header-filter-top-input">
<Input
onPressEnter={searchParamsChangeFunc.onInputChange}
onChange={(e) => (searchKeyword.current = e.target.value)}
allowClear
bordered={false}
placeholder="请输入ClusterName进行搜索"
suffix={<IconFont className="icon" type="icon-fangdajing" onClick={searchParamsChangeFunc.onInputChange} />}
/>
</div>
{global.hasPermission && global.hasPermission(ClustersPermissionMap.CLUSTER_ADD) ? (
<>
<div className="header-filter-top-divider"></div>
<Button className="header-filter-top-button" type="primary" onClick={() => showAccessCluster()}>
<IconFont type="icon-jiahao" />
<span className="text"></span>
</Button>
</>
) : (
<></>
)}
</div>
<div className="header-filter-bottom">
<div className="header-filter-bottom-item header-filter-bottom-item-checkbox">
<h3 className="header-filter-bottom-item-title"></h3>
<div className="header-filter-bottom-item-content flex">
{existKafkaVersion.length ? (
<CustomCheckGroup
kafkaVersions={existKafkaVersion}
onChangeCheckGroup={searchParamsChangeFunc.onChangeCheckGroup}
/>
) : null}
</div>
</div>
<div className="header-filter-bottom-item header-filter-bottom-item-slider">
<h3 className="header-filter-bottom-item-title title-right"></h3>
<div className="header-filter-bottom-item-content">
<Slider
range
step={20}
defaultValue={[0, 100]}
marks={healthSorceList}
onAfterChange={searchParamsChangeFunc.onSilderChange}
/>
</div>
</div>
</div>
</div>
</div>
<div className="multi-cluster-filter">
<div className="multi-cluster-filter-select">
<Select
onChange={(value) => searchParamsChangeFunc.onSortInfoChange('sortField', value)}
defaultValue="HealthScore"
style={{ width: 170, marginRight: 12 }}
>
{sortFieldList.map((item) => (
<Option key={item.value} value={item.value}>
{item.label}
</Option>
))}
</Select>
<Select
onChange={(value) => searchParamsChangeFunc.onSortInfoChange('sortType', value)}
defaultValue="asc"
style={{ width: 170 }}
>
{sortTypes.map((item) => (
<Option key={item.value} value={item.value}>
{item.label}
</Option>
))}
</Select>
</div>
<div className="multi-cluster-filter-checkbox">
<CheckboxGroup
options={statusFilters}
value={searchParams.clusterStatus}
onChange={searchParamsChangeFunc.onClusterStatusChange}
/>
</div>
</div>
</div>
</div>
<div className="multi-cluster-page-dashboard">
<ClusterList
searchParams={searchParams}
showAccessCluster={showAccessCluster}
getPhyClusterState={getPhyClusterState}
getExistKafkaVersion={getExistKafkaVersion}
/>
</div>
</div>
{/* 引导页 */}
<TourGuide guide={MultiPageSteps} run={true} />
</>
)}
<AccessClusters <AccessClusters
visible={visible} clusterInfo={curClusterInfo}
setVisible={setVisible}
kafkaVersion={kafkaVersions} kafkaVersion={kafkaVersions}
afterSubmitSuccess={afterSubmitSuccessAccessClusters} visible={accessClusterVisible}
setVisible={setAccessClusterVisible}
afterSubmitSuccess={afterAccessCluster}
/> />
</> </>
); );

Some files were not shown because too many files have changed in this diff Show More