Compare commits
1 Commits
v1.0.7
...
feature/do
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8942760a5a |
31
README.md
@@ -1,6 +1,6 @@
|
|||||||
# kafka可视化管理平台
|
# kafka可视化管理平台
|
||||||
一款轻量级的kafka可视化管理平台,安装配置快捷、简单易用。
|
一款轻量级的kafka可视化管理平台,安装配置快捷、简单易用。
|
||||||
为了开发的省事,没有国际化支持,页面只支持中文展示。
|
为了开发的省事,没有国际化支持,只支持中文展示。
|
||||||
用过rocketmq-console吧,对,前端展示风格跟那个有点类似。
|
用过rocketmq-console吧,对,前端展示风格跟那个有点类似。
|
||||||
|
|
||||||
## 页面预览
|
## 页面预览
|
||||||
@@ -8,9 +8,7 @@
|
|||||||
## 集群迁移支持说明
|
## 集群迁移支持说明
|
||||||
当前主分支及日后版本不再提供消息同步、集群迁移的解决方案,如有需要,查看:[集群迁移说明](./document/datasync/集群迁移.md)
|
当前主分支及日后版本不再提供消息同步、集群迁移的解决方案,如有需要,查看:[集群迁移说明](./document/datasync/集群迁移.md)
|
||||||
## ACL说明
|
## ACL说明
|
||||||
最新代码运行即可看到acl菜单,将权限管理和认证的用户管理(SASL_SCRAM)进行了分离。分离之后,支持只开启SASL_SCRAM认证的时候(未开启鉴权),用户变更操作。或者使用其它认证机制下的权限管理操作(可视化的权限管理),但是可视化的认证用户管理目前只支持Scram。
|
acl配置说明,如果kafka集群启用了ACL,但是控制台没看到Acl菜单,可以查看:[Acl配置启用说明](./document/acl/Acl.md)
|
||||||
|
|
||||||
v1.0.6版本之前,如果kafka集群启用了ACL,但是控制台没看到Acl菜单,可以查看:[Acl配置启用说明](./document/acl/Acl.md)
|
|
||||||
## 功能支持
|
## 功能支持
|
||||||
* 多集群支持
|
* 多集群支持
|
||||||
* 集群信息
|
* 集群信息
|
||||||
@@ -18,18 +16,13 @@ v1.0.6版本之前,如果kafka集群启用了ACL,但是控制台没看到Acl
|
|||||||
* 消费组管理
|
* 消费组管理
|
||||||
* 消息管理
|
* 消息管理
|
||||||
* ACL
|
* ACL
|
||||||
* 客户端限流
|
|
||||||
* 运维
|
* 运维
|
||||||
|
|
||||||
功能明细看这个脑图:
|
功能明细看这个脑图:
|
||||||

|

|
||||||
|
|
||||||
## 安装包下载
|
## 安装包下载
|
||||||
点击下载(v1.0.6版本):[kafka-console-ui.zip](https://github.com/xxd763795151/kafka-console-ui/releases/download/v1.0.6/kafka-console-ui.zip)
|
点击下载(v1.0.4版本):[kafka-console-ui.zip](https://github.com/xxd763795151/kafka-console-ui/releases/download/v1.0.4/kafka-console-ui.zip)
|
||||||
|
|
||||||
如果安装包下载的比较慢,可以查看下面的源码打包说明,把代码下载下来,本地快速打包.
|
|
||||||
|
|
||||||
github下载慢也可以试试从gitee下载,点击下载[gitee来源kafka-console-ui.zip](https://gitee.com/xiaodong_xu/kafka-console-ui/releases/download/v1.0.6/kafka-console-ui.zip)
|
|
||||||
|
|
||||||
## 快速使用
|
## 快速使用
|
||||||
### Windows
|
### Windows
|
||||||
@@ -68,7 +61,7 @@ sh bin/shutdown.sh
|
|||||||
在新增集群的时候,除了集群地址还可以输入集群的其它属性配置,比如请求超时,ACL配置等。如果开启了ACL,切换到该集群的时候,导航栏上便会出现ACL菜单,支持进行相关操作(目前是基于SASL_SCRAM认证授权管理支持的最完善,其它的我也没验证过,虽然是我开发的,但是我也没具体全部验证这一块功能,授权部分应该是通用的)
|
在新增集群的时候,除了集群地址还可以输入集群的其它属性配置,比如请求超时,ACL配置等。如果开启了ACL,切换到该集群的时候,导航栏上便会出现ACL菜单,支持进行相关操作(目前是基于SASL_SCRAM认证授权管理支持的最完善,其它的我也没验证过,虽然是我开发的,但是我也没具体全部验证这一块功能,授权部分应该是通用的)
|
||||||
|
|
||||||
## kafka版本
|
## kafka版本
|
||||||
* 当前使用的kafka 3.2.0
|
* 当前使用的kafka 2.8.0
|
||||||
## 监控
|
## 监控
|
||||||
仅提供运维管理功能,监控、告警需要配合其它组件,如有需要,建议请查看:https://blog.csdn.net/x763795151/article/details/119705372
|
仅提供运维管理功能,监控、告警需要配合其它组件,如有需要,建议请查看:https://blog.csdn.net/x763795151/article/details/119705372
|
||||||
|
|
||||||
@@ -78,22 +71,10 @@ sh bin/shutdown.sh
|
|||||||
## 本地开发
|
## 本地开发
|
||||||
如果需要本地开发,开发环境配置查看:[本地开发](./document/develop/开发配置.md)
|
如果需要本地开发,开发环境配置查看:[本地开发](./document/develop/开发配置.md)
|
||||||
|
|
||||||
## 登录认证和权限
|
|
||||||
目前主分支不支持登录认证,感谢@dongyinuo 同学开发了一版支持登录认证,及相关的按钮权限(主要有两个角色:管理员和普通开发人员)。
|
|
||||||
在分支:feature/dongyinuo/20220501/devops 上。
|
|
||||||
如果有需要使用管理台登录认证的,可以切换到这个分支上进行打包,打包方式看 源码打包 说明。
|
|
||||||
默认登录账户:admin/kafka-console-ui521
|
|
||||||
|
|
||||||
## DockerCompose部署
|
|
||||||
感谢@wdkang123 同学分享的部署方式,如果有需要请查看[DockerCompose部署方式](./document/deploy/docker部署.md)
|
|
||||||
|
|
||||||
## 联系方式
|
## 联系方式
|
||||||
+ 微信群
|
+ 微信群
|
||||||
|
<img src="https://github.com/dongyinuo/kafka-console-ui/blob/feature/dongyinuo/add/contact/document/contact/weixin_contact.jpeg" width="40%"/>
|
||||||
<img src="./document/contact/weixin_contact.jpg" width="40%"/>
|
|
||||||
|
|
||||||
[//]: # (<img src="https://github.com/xxd763795151/kafka-console-ui/blob/main/document/contact/weixin_contact.jpg" width="40%"/>)
|
|
||||||
|
|
||||||
+ 若联系方式失效, 请联系加一下微信, 说明意图
|
+ 若联系方式失效, 请联系加一下微信, 说明意图
|
||||||
- xxd763795151
|
- xxd763795151
|
||||||
- wxid_7jy2ezljvebt12
|
- wxid_7jy2ezljvebt12
|
||||||
@@ -5,4 +5,4 @@ set JAVA_OPTS=-Xmx512m -Xms512m -Xmn256m -Xss256k
|
|||||||
set CONFIG_FILE=../config/application.yml
|
set CONFIG_FILE=../config/application.yml
|
||||||
set TARGET=../lib/kafka-console-ui.jar
|
set TARGET=../lib/kafka-console-ui.jar
|
||||||
set DATA_DIR=..
|
set DATA_DIR=..
|
||||||
"%JAVA_CMD%" -jar %TARGET% --spring.config.location=%CONFIG_FILE% --data.dir=%DATA_DIR%
|
%JAVA_CMD% -jar %TARGET% --spring.config.location=%CONFIG_FILE% --data.dir=%DATA_DIR%
|
||||||
@@ -26,7 +26,7 @@ kafka:
|
|||||||
其中说明了kafka.config.enable-acl配置项需要为true。
|
其中说明了kafka.config.enable-acl配置项需要为true。
|
||||||
|
|
||||||
注意:**现在不再支持这种方式了**
|
注意:**现在不再支持这种方式了**
|
||||||
## v1.0.6之前的版本说明
|
## 新版本说明
|
||||||
因为现在支持多集群配置,关于多集群配置,可以看主页说明的 配置集群 介绍。
|
因为现在支持多集群配置,关于多集群配置,可以看主页说明的 配置集群 介绍。
|
||||||
所以这里把这些额外的配置项都去掉了。
|
所以这里把这些额外的配置项都去掉了。
|
||||||
|
|
||||||
|
|||||||
BIN
document/contact/weixin_contact.jpeg
Normal file
|
After Width: | Height: | Size: 128 KiB |
|
Before Width: | Height: | Size: 178 KiB |
@@ -1,189 +0,0 @@
|
|||||||
# Docker/DockerCompose部署
|
|
||||||
|
|
||||||
# 1.快速上手
|
|
||||||
|
|
||||||
## 1.1 镜像拉取
|
|
||||||
|
|
||||||
```shell
|
|
||||||
docker pull wdkang/kafka-console-ui
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## 1.2 查看镜像
|
|
||||||
|
|
||||||
```shell
|
|
||||||
docker images
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## 1.3 启动服务
|
|
||||||
|
|
||||||
由于Docker内不会对数据进行持久化 所以这里推荐将数据目录映射到实体机中
|
|
||||||
|
|
||||||
详见 **2.数据持久**
|
|
||||||
|
|
||||||
```shell
|
|
||||||
docker run -d -p 7766:7766 wdkang/kafka-console-ui
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## 1.4 查看状态
|
|
||||||
|
|
||||||
```shell
|
|
||||||
docker ps -a
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## 1.5 查看日志
|
|
||||||
|
|
||||||
```shell
|
|
||||||
docker logs -f ${containerId}
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## 1.6 访问服务
|
|
||||||
|
|
||||||
```shell
|
|
||||||
http://localhost:7766
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# 2. 数据持久
|
|
||||||
|
|
||||||
推荐对数据进行持久化
|
|
||||||
|
|
||||||
## 2.1 新建目录
|
|
||||||
|
|
||||||
```shell
|
|
||||||
mkdir -p /home/kafka-console-ui/data /home/kafka-console-ui/log
|
|
||||||
cd /home/kafka-console-ui
|
|
||||||
```
|
|
||||||
|
|
||||||
## 2.2 启动服务
|
|
||||||
|
|
||||||
```shell
|
|
||||||
docker run -d -p 7766:7766 -v $PWD/data:/app/data -v $PWD/log:/app/log wdkang/kafka-console-ui
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# 3.自主打包
|
|
||||||
|
|
||||||
## 3.1 构建镜像
|
|
||||||
|
|
||||||
**前置需求**
|
|
||||||
|
|
||||||
(可根据自身情况修改Dockerfile)
|
|
||||||
|
|
||||||
下载[kafka-console-ui.zip](https://github.com/xxd763795151/kafka-console-ui/releases)包
|
|
||||||
|
|
||||||
解压后 将Dockerfile放入文件夹的根目录
|
|
||||||
|
|
||||||
**Dockerfile**
|
|
||||||
|
|
||||||
```dockerfile
|
|
||||||
# jdk
|
|
||||||
FROM openjdk:8-jdk-alpine
|
|
||||||
# label
|
|
||||||
LABEL by="https://github.com/xxd763795151/kafka-console-ui"
|
|
||||||
# root
|
|
||||||
RUN mkdir -p /app && cd /app
|
|
||||||
WORKDIR /app
|
|
||||||
# config log data
|
|
||||||
RUN mkdir -p /app/config && mkdir -p /app/log && mkdir -p /app/data && mkdir -p /app/lib
|
|
||||||
# add file
|
|
||||||
ADD ./lib/kafka-console-ui.jar /app/lib
|
|
||||||
ADD ./config /app/config
|
|
||||||
# port
|
|
||||||
EXPOSE 7766
|
|
||||||
# start server
|
|
||||||
CMD java -jar -Xmx512m -Xms512m -Xmn256m -Xss256k /app/lib/kafka-console-ui.jar --spring.config.location="/app/config/" --logging.home="/app/log" --data.dir="/app/data"
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
**进行打包**
|
|
||||||
|
|
||||||
在文件夹根目录下
|
|
||||||
|
|
||||||
(注意末尾有个点)
|
|
||||||
|
|
||||||
```shell
|
|
||||||
docker build -t ${your_docker_hub_addr} .
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## 3.2 上传镜像
|
|
||||||
|
|
||||||
```shell
|
|
||||||
docker push ${your_docker_hub_addr}
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# 4.容器编排
|
|
||||||
|
|
||||||
```dockerfile
|
|
||||||
# docker-compose 编排
|
|
||||||
version: '3'
|
|
||||||
services:
|
|
||||||
# 服务名
|
|
||||||
kafka-console-ui:
|
|
||||||
# 容器名
|
|
||||||
container_name: "kafka-console-ui"
|
|
||||||
# 端口
|
|
||||||
ports:
|
|
||||||
- "7766:7766"
|
|
||||||
# 持久化
|
|
||||||
volumes:
|
|
||||||
- ./data:/app/data
|
|
||||||
- ./log:/app/log
|
|
||||||
# 防止读写文件有问题
|
|
||||||
privileged: true
|
|
||||||
user: root
|
|
||||||
# 镜像地址
|
|
||||||
image: "wdkang/kafka-console-ui"
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## 4.1 拉取镜像
|
|
||||||
|
|
||||||
```shell
|
|
||||||
docker-compose pull kafka-console-ui
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## 4.2 构建启动
|
|
||||||
|
|
||||||
```shell
|
|
||||||
docker-compose up --detach --build kafka-console-ui
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## 4.3 查看状态
|
|
||||||
|
|
||||||
```shell
|
|
||||||
docker-compose ps -a
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## 4.3 停止服务
|
|
||||||
|
|
||||||
```shell
|
|
||||||
docker-compose down
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -12,11 +12,8 @@
|
|||||||
* scala 2.13
|
* scala 2.13
|
||||||
* maven >=3.6+
|
* maven >=3.6+
|
||||||
* webstorm
|
* webstorm
|
||||||
* Node
|
|
||||||
|
|
||||||
除了webstorm是开发前端的ide可以根据自己需要代替,jdk scala是必须有的。
|
除了webstorm是开发前端的ide可以根据自己需要代替,jdk scala是必须有的。
|
||||||
|
|
||||||
开发的时候,我本地用的node版本是v14.16.0,下载目录:https://nodejs.org/download/release/v14.16.0/ . 过高或过低版本是否适用,我也没测试过。
|
|
||||||
|
|
||||||
scala 2.13下载地址,在这个页面最下面:https://www.scala-lang.org/download/scala2.html
|
scala 2.13下载地址,在这个页面最下面:https://www.scala-lang.org/download/scala2.html
|
||||||
## 克隆代码
|
## 克隆代码
|
||||||
@@ -24,8 +21,7 @@ scala 2.13下载地址,在这个页面最下面:https://www.scala-lang.org/d
|
|||||||
## 后端配置
|
## 后端配置
|
||||||
1. 用idea打开项目
|
1. 用idea打开项目
|
||||||
2. 打开idea的Project Structure(Settings) -> Modules -> 设置src/main/scala为Sources,因为约定src/main/java是源码目录,所以这里要再加一个源码目录
|
2. 打开idea的Project Structure(Settings) -> Modules -> 设置src/main/scala为Sources,因为约定src/main/java是源码目录,所以这里要再加一个源码目录
|
||||||
3. 打开idea的Settings -> plugins 搜索scala plugin并安装,然后应该是要重启idea生效,这一步必须在第4步之前
|
3. 打开idea的Project Structure(Settings) -> Libraries 添加scala sdk,然后选择本地下载的scala 2.13的目录,确定添加进来(如果使用的idea可以直接勾选,也可以不用先下载到本地)
|
||||||
4. 打开idea的Project Structure(Settings) -> Libraries 添加scala sdk,然后选择本地下载的scala 2.13的目录,确定添加进来(如果使用的idea可以直接勾选,也可以不用先下载到本地)
|
|
||||||
## 前端
|
## 前端
|
||||||
前端代码在工程的ui目录下,找个前端开发的ide如web storm打开进行开发即可。
|
前端代码在工程的ui目录下,找个前端开发的ide如web storm打开进行开发即可。
|
||||||
|
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 99 KiB |
|
Before Width: | Height: | Size: 439 KiB After Width: | Height: | Size: 99 KiB |
@@ -29,6 +29,4 @@ package.bat
|
|||||||
cd kafka-console-ui
|
cd kafka-console-ui
|
||||||
# linux或mac执行
|
# linux或mac执行
|
||||||
sh package.sh
|
sh package.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
打包完成,会在target目录下生成一个kafka-console-ui.zip的安装包
|
|
||||||
26
pom.xml
@@ -10,7 +10,7 @@
|
|||||||
</parent>
|
</parent>
|
||||||
<groupId>com.xuxd</groupId>
|
<groupId>com.xuxd</groupId>
|
||||||
<artifactId>kafka-console-ui</artifactId>
|
<artifactId>kafka-console-ui</artifactId>
|
||||||
<version>1.0.7</version>
|
<version>1.0.4</version>
|
||||||
<name>kafka-console-ui</name>
|
<name>kafka-console-ui</name>
|
||||||
<description>Kafka console manage ui</description>
|
<description>Kafka console manage ui</description>
|
||||||
<properties>
|
<properties>
|
||||||
@@ -21,13 +21,18 @@
|
|||||||
<ui.path>${project.basedir}/ui</ui.path>
|
<ui.path>${project.basedir}/ui</ui.path>
|
||||||
<frontend-maven-plugin.version>1.11.0</frontend-maven-plugin.version>
|
<frontend-maven-plugin.version>1.11.0</frontend-maven-plugin.version>
|
||||||
<compiler.version>1.8</compiler.version>
|
<compiler.version>1.8</compiler.version>
|
||||||
<kafka.version>3.2.0</kafka.version>
|
<kafka.version>2.8.0</kafka.version>
|
||||||
<maven.assembly.plugin.version>3.0.0</maven.assembly.plugin.version>
|
<maven.assembly.plugin.version>3.0.0</maven.assembly.plugin.version>
|
||||||
<mybatis-plus-boot-starter.version>3.4.2</mybatis-plus-boot-starter.version>
|
<mybatis-plus-boot-starter.version>3.4.2</mybatis-plus-boot-starter.version>
|
||||||
<scala.version>2.13.6</scala.version>
|
<scala.version>2.13.6</scala.version>
|
||||||
<spring-framework.version>5.3.26</spring-framework.version>
|
<jwt.version>0.9.0</jwt.version>
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.jsonwebtoken</groupId>
|
||||||
|
<artifactId>jjwt</artifactId>
|
||||||
|
<version>${jwt.version}</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.scala-lang</groupId>
|
<groupId>org.scala-lang</groupId>
|
||||||
<artifactId>scala-library</artifactId>
|
<artifactId>scala-library</artifactId>
|
||||||
@@ -77,18 +82,6 @@
|
|||||||
<groupId>org.apache.kafka</groupId>
|
<groupId>org.apache.kafka</groupId>
|
||||||
<artifactId>kafka_2.13</artifactId>
|
<artifactId>kafka_2.13</artifactId>
|
||||||
<version>${kafka.version}</version>
|
<version>${kafka.version}</version>
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>com.typesafe.scala-logging</groupId>
|
|
||||||
<artifactId>scala-logging_2.13</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.typesafe.scala-logging</groupId>
|
|
||||||
<artifactId>scala-logging_2.13</artifactId>
|
|
||||||
<version>3.9.2</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -220,8 +213,7 @@
|
|||||||
<goal>npm</goal>
|
<goal>npm</goal>
|
||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
<!-- <arguments>install --registry=https://registry.npmjs.org/</arguments>-->
|
<arguments>install --registry=https://registry.npmjs.org/</arguments>
|
||||||
<arguments>install --registry=https://registry.npm.taobao.org</arguments>
|
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
<execution>
|
<execution>
|
||||||
|
|||||||
@@ -1,15 +1,18 @@
|
|||||||
package com.xuxd.kafka.console.beans;
|
package com.xuxd.kafka.console.beans;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.kafka.common.acl.*;
|
import org.apache.kafka.common.acl.AccessControlEntry;
|
||||||
|
import org.apache.kafka.common.acl.AccessControlEntryFilter;
|
||||||
|
import org.apache.kafka.common.acl.AclBinding;
|
||||||
|
import org.apache.kafka.common.acl.AclBindingFilter;
|
||||||
|
import org.apache.kafka.common.acl.AclOperation;
|
||||||
|
import org.apache.kafka.common.acl.AclPermissionType;
|
||||||
import org.apache.kafka.common.resource.PatternType;
|
import org.apache.kafka.common.resource.PatternType;
|
||||||
import org.apache.kafka.common.resource.ResourcePattern;
|
import org.apache.kafka.common.resource.ResourcePattern;
|
||||||
import org.apache.kafka.common.resource.ResourcePatternFilter;
|
import org.apache.kafka.common.resource.ResourcePatternFilter;
|
||||||
import org.apache.kafka.common.resource.ResourceType;
|
import org.apache.kafka.common.resource.ResourceType;
|
||||||
import org.apache.kafka.common.security.auth.KafkaPrincipal;
|
import org.apache.kafka.common.security.auth.KafkaPrincipal;
|
||||||
import org.apache.kafka.common.utils.SecurityUtils;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* kafka-console-ui.
|
* kafka-console-ui.
|
||||||
@@ -38,9 +41,7 @@ public class AclEntry {
|
|||||||
entry.setResourceType(binding.pattern().resourceType().name());
|
entry.setResourceType(binding.pattern().resourceType().name());
|
||||||
entry.setName(binding.pattern().name());
|
entry.setName(binding.pattern().name());
|
||||||
entry.setPatternType(binding.pattern().patternType().name());
|
entry.setPatternType(binding.pattern().patternType().name());
|
||||||
// entry.setPrincipal(KafkaPrincipal.fromString(binding.entry().principal()).getName());
|
entry.setPrincipal(KafkaPrincipal.fromString(binding.entry().principal()).getName());
|
||||||
// 3.x版本使用该方法
|
|
||||||
entry.setPrincipal(SecurityUtils.parseKafkaPrincipal(binding.entry().principal()).getName());
|
|
||||||
entry.setHost(binding.entry().host());
|
entry.setHost(binding.entry().host());
|
||||||
entry.setOperation(binding.entry().operation().name());
|
entry.setOperation(binding.entry().operation().name());
|
||||||
entry.setPermissionType(binding.entry().permissionType().name());
|
entry.setPermissionType(binding.entry().permissionType().name());
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package com.xuxd.kafka.console.beans;
|
||||||
|
|
||||||
|
public class KafkaConsoleException extends RuntimeException{
|
||||||
|
public KafkaConsoleException(String msg){
|
||||||
|
super(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,7 +11,7 @@ import lombok.Setter;
|
|||||||
**/
|
**/
|
||||||
public class ResponseData<T> {
|
public class ResponseData<T> {
|
||||||
|
|
||||||
public static final int SUCCESS_CODE = 0, FAILED_CODE = -9999;
|
public static final int SUCCESS_CODE = 0, TOKEN_ILLEGAL = -5000, FAILED_CODE = -9999;
|
||||||
|
|
||||||
public static final String SUCCESS_MSG = "success", FAILED_MSG = "failed";
|
public static final String SUCCESS_MSG = "success", FAILED_MSG = "failed";
|
||||||
|
|
||||||
@@ -58,6 +58,12 @@ public class ResponseData<T> {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ResponseData<T> failed(int code) {
|
||||||
|
this.code = code;
|
||||||
|
this.msg = FAILED_MSG;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public ResponseData<T> failed(String msg) {
|
public ResponseData<T> failed(String msg) {
|
||||||
this.code = FAILED_CODE;
|
this.code = FAILED_CODE;
|
||||||
this.msg = msg;
|
this.msg = msg;
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package com.xuxd.kafka.console.beans.annotation;
|
||||||
|
|
||||||
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
|
@Target({ElementType.TYPE, ElementType.METHOD})
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Documented
|
||||||
|
public @interface RequiredAuthorize {
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package com.xuxd.kafka.console.beans.dos;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.xuxd.kafka.console.beans.enums.Role;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@TableName("t_devops_user")
|
||||||
|
public class DevOpsUserDO {
|
||||||
|
|
||||||
|
@TableId(type = IdType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private String username;
|
||||||
|
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
private Role role;
|
||||||
|
|
||||||
|
private boolean delete;
|
||||||
|
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
private Date updateTime;
|
||||||
|
}
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
package com.xuxd.kafka.console.beans.dto;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author: xuxd
|
|
||||||
* @date: 2023/1/10 20:12
|
|
||||||
**/
|
|
||||||
@Data
|
|
||||||
public class AlterClientQuotaDTO {
|
|
||||||
|
|
||||||
private String type;
|
|
||||||
|
|
||||||
private List<String> types;
|
|
||||||
|
|
||||||
private List<String> names;
|
|
||||||
|
|
||||||
private String consumerRate;
|
|
||||||
|
|
||||||
private String producerRate;
|
|
||||||
|
|
||||||
private String requestPercentage;
|
|
||||||
|
|
||||||
private List<String> deleteConfigs;
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
package com.xuxd.kafka.console.beans.dto;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author: xuxd
|
|
||||||
* @date: 2023/1/9 21:53
|
|
||||||
**/
|
|
||||||
@Data
|
|
||||||
public class QueryClientQuotaDTO {
|
|
||||||
|
|
||||||
private List<String> types;
|
|
||||||
|
|
||||||
private List<String> names;
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package com.xuxd.kafka.console.beans.dto.user;
|
||||||
|
|
||||||
|
import com.xuxd.kafka.console.beans.enums.Role;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class AddUserDTO {
|
||||||
|
private String username;
|
||||||
|
private String password;
|
||||||
|
private Role role;
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package com.xuxd.kafka.console.beans.dto.user;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ListUserDTO {
|
||||||
|
private Long id;
|
||||||
|
private String username;
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package com.xuxd.kafka.console.beans.dto.user;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class LoginDTO {
|
||||||
|
private String username;
|
||||||
|
private String password;
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package com.xuxd.kafka.console.beans.dto.user;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class PasswordDTO {
|
||||||
|
private Long userId;
|
||||||
|
private String password;
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package com.xuxd.kafka.console.beans.dto.user;
|
||||||
|
|
||||||
|
import com.xuxd.kafka.console.beans.enums.Role;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class UpdateUserDTO {
|
||||||
|
private String username;
|
||||||
|
private String password;
|
||||||
|
private Role role;
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package com.xuxd.kafka.console.beans.enums;
|
||||||
|
|
||||||
|
public enum Role {
|
||||||
|
developer,
|
||||||
|
manager
|
||||||
|
}
|
||||||
@@ -1,82 +0,0 @@
|
|||||||
package com.xuxd.kafka.console.beans.vo;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.apache.kafka.common.config.internals.QuotaConfigs;
|
|
||||||
import org.apache.kafka.common.quota.ClientQuotaEntity;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author 晓东哥哥
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class ClientQuotaEntityVO {
|
|
||||||
|
|
||||||
private String user;
|
|
||||||
|
|
||||||
private String client;
|
|
||||||
|
|
||||||
private String ip;
|
|
||||||
|
|
||||||
private String consumerRate;
|
|
||||||
|
|
||||||
private String producerRate;
|
|
||||||
|
|
||||||
private String requestPercentage;
|
|
||||||
|
|
||||||
public static ClientQuotaEntityVO from(ClientQuotaEntity entity, List<String> entityTypes, Map<String, Object> config) {
|
|
||||||
ClientQuotaEntityVO entityVO = new ClientQuotaEntityVO();
|
|
||||||
Map<String, String> entries = entity.entries();
|
|
||||||
entityTypes.forEach(type -> {
|
|
||||||
switch (type) {
|
|
||||||
case ClientQuotaEntity.USER:
|
|
||||||
entityVO.setUser(entries.get(type));
|
|
||||||
break;
|
|
||||||
case ClientQuotaEntity.CLIENT_ID:
|
|
||||||
entityVO.setClient(entries.get(type));
|
|
||||||
break;
|
|
||||||
case ClientQuotaEntity.IP:
|
|
||||||
entityVO.setIp(entries.get(type));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
entityVO.setConsumerRate(convert(config.getOrDefault(QuotaConfigs.CONSUMER_BYTE_RATE_OVERRIDE_CONFIG, "")));
|
|
||||||
entityVO.setProducerRate(convert(config.getOrDefault(QuotaConfigs.PRODUCER_BYTE_RATE_OVERRIDE_CONFIG, "")));
|
|
||||||
entityVO.setRequestPercentage(config.getOrDefault(QuotaConfigs.REQUEST_PERCENTAGE_OVERRIDE_CONFIG, "").toString());
|
|
||||||
return entityVO;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static String convert(Object num) {
|
|
||||||
if (num == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (num instanceof String) {
|
|
||||||
if ((StringUtils.isBlank((String) num))) {
|
|
||||||
return (String) num;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (num instanceof Number) {
|
|
||||||
Number number = (Number) num;
|
|
||||||
double value = number.doubleValue();
|
|
||||||
double _1kb = 1024;
|
|
||||||
double _1mb = 1024 * _1kb;
|
|
||||||
if (value < _1kb) {
|
|
||||||
return value + " Byte";
|
|
||||||
}
|
|
||||||
if (value < _1mb) {
|
|
||||||
return String.format("%.1f KB", (value / _1kb));
|
|
||||||
}
|
|
||||||
if (value >= _1mb) {
|
|
||||||
return String.format("%.1f MB", (value / _1mb));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return String.valueOf(num);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.xuxd.kafka.console.beans.vo;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.xuxd.kafka.console.beans.enums.Role;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class DevOpsUserVO {
|
||||||
|
private Long id;
|
||||||
|
private String username;
|
||||||
|
private Role role;
|
||||||
|
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||||
|
private Date createTime;
|
||||||
|
}
|
||||||
16
src/main/java/com/xuxd/kafka/console/beans/vo/LoginVO.java
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
package com.xuxd.kafka.console.beans.vo;
|
||||||
|
|
||||||
|
import com.xuxd.kafka.console.beans.enums.Role;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class LoginVO {
|
||||||
|
private String token;
|
||||||
|
private Role role;
|
||||||
|
}
|
||||||
@@ -2,15 +2,20 @@ package com.xuxd.kafka.console.boot;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.xuxd.kafka.console.beans.dos.ClusterInfoDO;
|
import com.xuxd.kafka.console.beans.dos.ClusterInfoDO;
|
||||||
|
import com.xuxd.kafka.console.beans.dos.DevOpsUserDO;
|
||||||
import com.xuxd.kafka.console.config.KafkaConfig;
|
import com.xuxd.kafka.console.config.KafkaConfig;
|
||||||
import com.xuxd.kafka.console.dao.ClusterInfoMapper;
|
import com.xuxd.kafka.console.dao.ClusterInfoMapper;
|
||||||
|
import com.xuxd.kafka.console.dao.DevOpsUserMapper;
|
||||||
import com.xuxd.kafka.console.utils.ConvertUtil;
|
import com.xuxd.kafka.console.utils.ConvertUtil;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.xuxd.kafka.console.utils.Md5Utils;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.ObjectProvider;
|
import org.springframework.beans.factory.ObjectProvider;
|
||||||
import org.springframework.beans.factory.SmartInitializingSingleton;
|
import org.springframework.beans.factory.SmartInitializingSingleton;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package com.xuxd.kafka.console.boot;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.xuxd.kafka.console.beans.dos.DevOpsUserDO;
|
||||||
|
import com.xuxd.kafka.console.beans.enums.Role;
|
||||||
|
import com.xuxd.kafka.console.dao.DevOpsUserMapper;
|
||||||
|
import com.xuxd.kafka.console.utils.Md5Utils;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.SmartInitializingSingleton;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class InitSuperDevOpsUser implements SmartInitializingSingleton {
|
||||||
|
|
||||||
|
private final DevOpsUserMapper devOpsUserMapper;
|
||||||
|
public final static String SUPER_USERNAME = "admin";
|
||||||
|
|
||||||
|
@Value("${devops.password:kafka-console-ui521}")
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterSingletonsInstantiated() {
|
||||||
|
QueryWrapper<DevOpsUserDO> userDOQueryWrapper = new QueryWrapper<>();
|
||||||
|
userDOQueryWrapper.eq("username", SUPER_USERNAME);
|
||||||
|
DevOpsUserDO userDO = devOpsUserMapper.selectOne(userDOQueryWrapper);
|
||||||
|
if (userDO == null){
|
||||||
|
DevOpsUserDO devOpsUserDO = new DevOpsUserDO();
|
||||||
|
devOpsUserDO.setUsername(SUPER_USERNAME);
|
||||||
|
devOpsUserDO.setPassword(Md5Utils.MD5(password));
|
||||||
|
devOpsUserDO.setRole(Role.manager);
|
||||||
|
devOpsUserMapper.insert(devOpsUserDO);
|
||||||
|
} else {
|
||||||
|
userDO.setPassword(Md5Utils.MD5(password));
|
||||||
|
devOpsUserMapper.updateById(userDO);
|
||||||
|
}
|
||||||
|
log.info("init super devops user done, username = {}", SUPER_USERNAME);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
package com.xuxd.kafka.console.cache;
|
|
||||||
|
|
||||||
import com.google.common.cache.CacheBuilder;
|
|
||||||
import com.google.common.cache.CacheLoader;
|
|
||||||
import com.google.common.cache.LoadingCache;
|
|
||||||
import com.google.common.cache.RemovalListener;
|
|
||||||
import kafka.console.KafkaConsole;
|
|
||||||
|
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
public class TimeBasedCache<K, V> {
|
|
||||||
private LoadingCache<K, V> cache;
|
|
||||||
|
|
||||||
private KafkaConsole console;
|
|
||||||
|
|
||||||
public TimeBasedCache(CacheLoader<K, V> loader, RemovalListener<K, V> listener) {
|
|
||||||
cache = CacheBuilder.newBuilder()
|
|
||||||
.maximumSize(50) // maximum 100 records can be cached
|
|
||||||
.expireAfterAccess(30, TimeUnit.MINUTES) // cache will expire after 30 minutes of access
|
|
||||||
.removalListener(listener)
|
|
||||||
.build(loader);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public V get(K k) {
|
|
||||||
try {
|
|
||||||
return cache.get(k);
|
|
||||||
} catch (ExecutionException e) {
|
|
||||||
throw new RuntimeException("Get connection from cache error.", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -20,12 +20,6 @@ public class KafkaConfig {
|
|||||||
|
|
||||||
private Properties properties;
|
private Properties properties;
|
||||||
|
|
||||||
private boolean cacheAdminConnection;
|
|
||||||
|
|
||||||
private boolean cacheProducerConnection;
|
|
||||||
|
|
||||||
private boolean cacheConsumerConnection;
|
|
||||||
|
|
||||||
public String getBootstrapServer() {
|
public String getBootstrapServer() {
|
||||||
return bootstrapServer;
|
return bootstrapServer;
|
||||||
}
|
}
|
||||||
@@ -49,28 +43,4 @@ public class KafkaConfig {
|
|||||||
public void setProperties(Properties properties) {
|
public void setProperties(Properties properties) {
|
||||||
this.properties = properties;
|
this.properties = properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCacheAdminConnection() {
|
|
||||||
return cacheAdminConnection;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCacheAdminConnection(boolean cacheAdminConnection) {
|
|
||||||
this.cacheAdminConnection = cacheAdminConnection;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isCacheProducerConnection() {
|
|
||||||
return cacheProducerConnection;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCacheProducerConnection(boolean cacheProducerConnection) {
|
|
||||||
this.cacheProducerConnection = cacheProducerConnection;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isCacheConsumerConnection() {
|
|
||||||
return cacheConsumerConnection;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCacheConsumerConnection(boolean cacheConsumerConnection) {
|
|
||||||
this.cacheConsumerConnection = cacheConsumerConnection;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,13 @@
|
|||||||
package com.xuxd.kafka.console.config;
|
package com.xuxd.kafka.console.config;
|
||||||
|
|
||||||
import kafka.console.*;
|
import kafka.console.ClusterConsole;
|
||||||
|
import kafka.console.ConfigConsole;
|
||||||
|
import kafka.console.ConsumerConsole;
|
||||||
|
import kafka.console.KafkaAclConsole;
|
||||||
|
import kafka.console.KafkaConfigConsole;
|
||||||
|
import kafka.console.MessageConsole;
|
||||||
|
import kafka.console.OperationConsole;
|
||||||
|
import kafka.console.TopicConsole;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
@@ -45,7 +52,7 @@ public class KafkaConfiguration {
|
|||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public OperationConsole operationConsole(KafkaConfig config, TopicConsole topicConsole,
|
public OperationConsole operationConsole(KafkaConfig config, TopicConsole topicConsole,
|
||||||
ConsumerConsole consumerConsole) {
|
ConsumerConsole consumerConsole) {
|
||||||
return new OperationConsole(config, topicConsole, consumerConsole);
|
return new OperationConsole(config, topicConsole, consumerConsole);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,9 +60,4 @@ public class KafkaConfiguration {
|
|||||||
public MessageConsole messageConsole(KafkaConfig config) {
|
public MessageConsole messageConsole(KafkaConfig config) {
|
||||||
return new MessageConsole(config);
|
return new MessageConsole(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
|
||||||
public ClientQuotaConsole clientQuotaConsole(KafkaConfig config) {
|
|
||||||
return new ClientQuotaConsole(config);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -118,14 +118,4 @@ public class AclAuthController {
|
|||||||
return aclService.deleteConsumerAcl(param.toTopicEntry(), param.toGroupEntry());
|
return aclService.deleteConsumerAcl(param.toTopicEntry(), param.toGroupEntry());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* clear principal acls.
|
|
||||||
*
|
|
||||||
* @param param acl principal.
|
|
||||||
* @return true or false.
|
|
||||||
*/
|
|
||||||
@DeleteMapping("/clear")
|
|
||||||
public Object clearAcl(@RequestBody DeleteAclDTO param) {
|
|
||||||
return aclService.clearAcl(param.toUserEntry());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
package com.xuxd.kafka.console.controller;
|
package com.xuxd.kafka.console.controller;
|
||||||
|
|
||||||
import com.xuxd.kafka.console.beans.AclEntry;
|
|
||||||
import com.xuxd.kafka.console.beans.AclUser;
|
import com.xuxd.kafka.console.beans.AclUser;
|
||||||
|
import com.xuxd.kafka.console.beans.annotation.RequiredAuthorize;
|
||||||
import com.xuxd.kafka.console.service.AclService;
|
import com.xuxd.kafka.console.service.AclService;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
@@ -14,7 +13,7 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* kafka-console-ui. sasl scram user.
|
* kafka-console-ui.
|
||||||
*
|
*
|
||||||
* @author xuxd
|
* @author xuxd
|
||||||
* @date 2021-08-28 21:13:05
|
* @date 2021-08-28 21:13:05
|
||||||
@@ -32,17 +31,20 @@ public class AclUserController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping
|
@PostMapping
|
||||||
|
@RequiredAuthorize
|
||||||
public Object addOrUpdateUser(@RequestBody AclUser user) {
|
public Object addOrUpdateUser(@RequestBody AclUser user) {
|
||||||
return aclService.addOrUpdateUser(user.getUsername(), user.getPassword());
|
return aclService.addOrUpdateUser(user.getUsername(), user.getPassword());
|
||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping
|
@DeleteMapping
|
||||||
|
@RequiredAuthorize
|
||||||
public Object deleteUser(@RequestBody AclUser user) {
|
public Object deleteUser(@RequestBody AclUser user) {
|
||||||
return aclService.deleteUser(user.getUsername());
|
return aclService.deleteUser(user.getUsername());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@DeleteMapping("/auth")
|
@DeleteMapping("/auth")
|
||||||
|
@RequiredAuthorize
|
||||||
public Object deleteUserAndAuth(@RequestBody AclUser user) {
|
public Object deleteUserAndAuth(@RequestBody AclUser user) {
|
||||||
return aclService.deleteUserAndAuth(user.getUsername());
|
return aclService.deleteUserAndAuth(user.getUsername());
|
||||||
}
|
}
|
||||||
@@ -51,11 +53,4 @@ public class AclUserController {
|
|||||||
public Object getUserDetail(@RequestParam String username) {
|
public Object getUserDetail(@RequestParam String username) {
|
||||||
return aclService.getUserDetail(username);
|
return aclService.getUserDetail(username);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/scram")
|
|
||||||
public Object getSaslScramUserList(@RequestParam(required = false) String username) {
|
|
||||||
AclEntry entry = new AclEntry();
|
|
||||||
entry.setPrincipal(StringUtils.isNotBlank(username) ? username : null);
|
|
||||||
return aclService.getSaslScramUserList(entry);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,52 +0,0 @@
|
|||||||
package com.xuxd.kafka.console.controller;
|
|
||||||
|
|
||||||
import com.xuxd.kafka.console.beans.ResponseData;
|
|
||||||
import com.xuxd.kafka.console.beans.dto.AlterClientQuotaDTO;
|
|
||||||
import com.xuxd.kafka.console.beans.dto.QueryClientQuotaDTO;
|
|
||||||
import com.xuxd.kafka.console.service.ClientQuotaService;
|
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author: xuxd
|
|
||||||
* @date: 2023/1/9 21:50
|
|
||||||
**/
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/client/quota")
|
|
||||||
public class ClientQuotaController {
|
|
||||||
|
|
||||||
private final ClientQuotaService clientQuotaService;
|
|
||||||
|
|
||||||
public ClientQuotaController(ClientQuotaService clientQuotaService) {
|
|
||||||
this.clientQuotaService = clientQuotaService;
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/list")
|
|
||||||
public Object getClientQuotaConfigs(@RequestBody QueryClientQuotaDTO request) {
|
|
||||||
return clientQuotaService.getClientQuotaConfigs(request.getTypes(), request.getNames());
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping
|
|
||||||
public Object alterClientQuotaConfigs(@RequestBody AlterClientQuotaDTO request) {
|
|
||||||
if (request.getTypes().size() != 2) {
|
|
||||||
if (CollectionUtils.isEmpty(request.getTypes())
|
|
||||||
|| CollectionUtils.isEmpty(request.getNames())
|
|
||||||
|| request.getTypes().size() != request.getNames().size()) {
|
|
||||||
return ResponseData.create().failed("types length and names length is invalid.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return clientQuotaService.alterClientQuotaConfigs(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@DeleteMapping
|
|
||||||
public Object deleteClientQuotaConfigs(@RequestBody AlterClientQuotaDTO request) {
|
|
||||||
if (request.getTypes().size() != 2) {
|
|
||||||
if (CollectionUtils.isEmpty(request.getTypes())
|
|
||||||
|| CollectionUtils.isEmpty(request.getNames())
|
|
||||||
|| request.getTypes().size() != request.getNames().size()) {
|
|
||||||
return ResponseData.create().failed("types length and names length is invalid.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return clientQuotaService.deleteClientQuotaConfigs(request);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -3,13 +3,7 @@ package com.xuxd.kafka.console.controller;
|
|||||||
import com.xuxd.kafka.console.beans.dto.ClusterInfoDTO;
|
import com.xuxd.kafka.console.beans.dto.ClusterInfoDTO;
|
||||||
import com.xuxd.kafka.console.service.ClusterService;
|
import com.xuxd.kafka.console.service.ClusterService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* kafka-console-ui.
|
* kafka-console-ui.
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.xuxd.kafka.console.controller;
|
package com.xuxd.kafka.console.controller;
|
||||||
|
|
||||||
import com.xuxd.kafka.console.beans.ResponseData;
|
import com.xuxd.kafka.console.beans.ResponseData;
|
||||||
|
import com.xuxd.kafka.console.beans.annotation.RequiredAuthorize;
|
||||||
import com.xuxd.kafka.console.beans.dto.AlterConfigDTO;
|
import com.xuxd.kafka.console.beans.dto.AlterConfigDTO;
|
||||||
import com.xuxd.kafka.console.beans.enums.AlterType;
|
import com.xuxd.kafka.console.beans.enums.AlterType;
|
||||||
import com.xuxd.kafka.console.config.KafkaConfig;
|
import com.xuxd.kafka.console.config.KafkaConfig;
|
||||||
@@ -47,11 +48,13 @@ public class ConfigController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/topic")
|
@PostMapping("/topic")
|
||||||
|
@RequiredAuthorize
|
||||||
public Object setTopicConfig(@RequestBody AlterConfigDTO dto) {
|
public Object setTopicConfig(@RequestBody AlterConfigDTO dto) {
|
||||||
return configService.alterTopicConfig(dto.getEntity(), dto.to(), AlterType.SET);
|
return configService.alterTopicConfig(dto.getEntity(), dto.to(), AlterType.SET);
|
||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/topic")
|
@DeleteMapping("/topic")
|
||||||
|
@RequiredAuthorize
|
||||||
public Object deleteTopicConfig(@RequestBody AlterConfigDTO dto) {
|
public Object deleteTopicConfig(@RequestBody AlterConfigDTO dto) {
|
||||||
return configService.alterTopicConfig(dto.getEntity(), dto.to(), AlterType.DELETE);
|
return configService.alterTopicConfig(dto.getEntity(), dto.to(), AlterType.DELETE);
|
||||||
}
|
}
|
||||||
@@ -62,11 +65,13 @@ public class ConfigController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/broker")
|
@PostMapping("/broker")
|
||||||
|
@RequiredAuthorize
|
||||||
public Object setBrokerConfig(@RequestBody AlterConfigDTO dto) {
|
public Object setBrokerConfig(@RequestBody AlterConfigDTO dto) {
|
||||||
return configService.alterBrokerConfig(dto.getEntity(), dto.to(), AlterType.SET);
|
return configService.alterBrokerConfig(dto.getEntity(), dto.to(), AlterType.SET);
|
||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/broker")
|
@DeleteMapping("/broker")
|
||||||
|
@RequiredAuthorize
|
||||||
public Object deleteBrokerConfig(@RequestBody AlterConfigDTO dto) {
|
public Object deleteBrokerConfig(@RequestBody AlterConfigDTO dto) {
|
||||||
return configService.alterBrokerConfig(dto.getEntity(), dto.to(), AlterType.DELETE);
|
return configService.alterBrokerConfig(dto.getEntity(), dto.to(), AlterType.DELETE);
|
||||||
}
|
}
|
||||||
@@ -77,11 +82,13 @@ public class ConfigController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/broker/logger")
|
@PostMapping("/broker/logger")
|
||||||
|
@RequiredAuthorize
|
||||||
public Object setBrokerLoggerConfig(@RequestBody AlterConfigDTO dto) {
|
public Object setBrokerLoggerConfig(@RequestBody AlterConfigDTO dto) {
|
||||||
return configService.alterBrokerLoggerConfig(dto.getEntity(), dto.to(), AlterType.SET);
|
return configService.alterBrokerLoggerConfig(dto.getEntity(), dto.to(), AlterType.SET);
|
||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/broker/logger")
|
@DeleteMapping("/broker/logger")
|
||||||
|
@RequiredAuthorize
|
||||||
public Object deleteBrokerLoggerConfig(@RequestBody AlterConfigDTO dto) {
|
public Object deleteBrokerLoggerConfig(@RequestBody AlterConfigDTO dto) {
|
||||||
return configService.alterBrokerLoggerConfig(dto.getEntity(), dto.to(), AlterType.DELETE);
|
return configService.alterBrokerLoggerConfig(dto.getEntity(), dto.to(), AlterType.DELETE);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.xuxd.kafka.console.controller;
|
package com.xuxd.kafka.console.controller;
|
||||||
|
|
||||||
import com.xuxd.kafka.console.beans.ResponseData;
|
import com.xuxd.kafka.console.beans.ResponseData;
|
||||||
|
import com.xuxd.kafka.console.beans.annotation.RequiredAuthorize;
|
||||||
import com.xuxd.kafka.console.beans.dto.AddSubscriptionDTO;
|
import com.xuxd.kafka.console.beans.dto.AddSubscriptionDTO;
|
||||||
import com.xuxd.kafka.console.beans.dto.QueryConsumerGroupDTO;
|
import com.xuxd.kafka.console.beans.dto.QueryConsumerGroupDTO;
|
||||||
import com.xuxd.kafka.console.beans.dto.ResetOffsetDTO;
|
import com.xuxd.kafka.console.beans.dto.ResetOffsetDTO;
|
||||||
@@ -67,11 +68,13 @@ public class ConsumerController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/subscription")
|
@PostMapping("/subscription")
|
||||||
|
@RequiredAuthorize
|
||||||
public Object addSubscription(@RequestBody AddSubscriptionDTO subscriptionDTO) {
|
public Object addSubscription(@RequestBody AddSubscriptionDTO subscriptionDTO) {
|
||||||
return consumerService.addSubscription(subscriptionDTO.getGroupId(), subscriptionDTO.getTopic());
|
return consumerService.addSubscription(subscriptionDTO.getGroupId(), subscriptionDTO.getTopic());
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/reset/offset")
|
@PostMapping("/reset/offset")
|
||||||
|
@RequiredAuthorize
|
||||||
public Object restOffset(@RequestBody ResetOffsetDTO offsetDTO) {
|
public Object restOffset(@RequestBody ResetOffsetDTO offsetDTO) {
|
||||||
ResponseData res = ResponseData.create().failed("unknown");
|
ResponseData res = ResponseData.create().failed("unknown");
|
||||||
switch (offsetDTO.getLevel()) {
|
switch (offsetDTO.getLevel()) {
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
package com.xuxd.kafka.console.controller;
|
||||||
|
|
||||||
|
import com.xuxd.kafka.console.beans.ResponseData;
|
||||||
|
import com.xuxd.kafka.console.beans.annotation.RequiredAuthorize;
|
||||||
|
import com.xuxd.kafka.console.beans.dto.user.*;
|
||||||
|
import com.xuxd.kafka.console.beans.vo.DevOpsUserVO;
|
||||||
|
import com.xuxd.kafka.console.beans.vo.LoginVO;
|
||||||
|
import com.xuxd.kafka.console.service.DevOpsUserService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户管理
|
||||||
|
* @author dongyinuo
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@RequestMapping("/devops/user")
|
||||||
|
public class DevOpsUserController {
|
||||||
|
|
||||||
|
private final DevOpsUserService devOpsUserService;
|
||||||
|
|
||||||
|
@PostMapping("add")
|
||||||
|
@RequiredAuthorize
|
||||||
|
public ResponseData<Boolean> add(@RequestBody AddUserDTO addUserDTO){
|
||||||
|
return devOpsUserService.add(addUserDTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("update")
|
||||||
|
@RequiredAuthorize
|
||||||
|
public ResponseData<Boolean> update(@RequestBody UpdateUserDTO updateUserDTO){
|
||||||
|
return devOpsUserService.update(updateUserDTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping
|
||||||
|
@RequiredAuthorize
|
||||||
|
public ResponseData<Boolean> delete(@RequestParam Long id){
|
||||||
|
return devOpsUserService.delete(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("list")
|
||||||
|
@RequiredAuthorize
|
||||||
|
public ResponseData<List<DevOpsUserVO>> list(@ModelAttribute ListUserDTO listUserDTO){
|
||||||
|
return devOpsUserService.list(listUserDTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("login")
|
||||||
|
public ResponseData<LoginVO> login(@RequestBody LoginDTO loginDTO){
|
||||||
|
return devOpsUserService.login(loginDTO.getUsername(), loginDTO.getPassword());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,15 +1,14 @@
|
|||||||
package com.xuxd.kafka.console.controller;
|
package com.xuxd.kafka.console.controller;
|
||||||
|
|
||||||
import com.xuxd.kafka.console.beans.QueryMessage;
|
|
||||||
import com.xuxd.kafka.console.beans.ResponseData;
|
|
||||||
import com.xuxd.kafka.console.beans.SendMessage;
|
import com.xuxd.kafka.console.beans.SendMessage;
|
||||||
import com.xuxd.kafka.console.beans.dto.QueryMessageDTO;
|
import com.xuxd.kafka.console.beans.dto.QueryMessageDTO;
|
||||||
import com.xuxd.kafka.console.service.MessageService;
|
import com.xuxd.kafka.console.service.MessageService;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import java.util.List;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* kafka-console-ui.
|
* kafka-console-ui.
|
||||||
@@ -53,12 +52,4 @@ public class MessageController {
|
|||||||
public Object resend(@RequestBody SendMessage message) {
|
public Object resend(@RequestBody SendMessage message) {
|
||||||
return messageService.resend(message);
|
return messageService.resend(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping
|
|
||||||
public Object delete(@RequestBody List<QueryMessage> messages) {
|
|
||||||
if (CollectionUtils.isEmpty(messages)) {
|
|
||||||
return ResponseData.create().failed("params is null");
|
|
||||||
}
|
|
||||||
return messageService.delete(messages);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.xuxd.kafka.console.controller;
|
package com.xuxd.kafka.console.controller;
|
||||||
|
|
||||||
import com.xuxd.kafka.console.beans.TopicPartition;
|
import com.xuxd.kafka.console.beans.TopicPartition;
|
||||||
|
import com.xuxd.kafka.console.beans.annotation.RequiredAuthorize;
|
||||||
import com.xuxd.kafka.console.beans.dto.BrokerThrottleDTO;
|
import com.xuxd.kafka.console.beans.dto.BrokerThrottleDTO;
|
||||||
import com.xuxd.kafka.console.beans.dto.ProposedAssignmentDTO;
|
import com.xuxd.kafka.console.beans.dto.ProposedAssignmentDTO;
|
||||||
import com.xuxd.kafka.console.beans.dto.ReplicationDTO;
|
import com.xuxd.kafka.console.beans.dto.ReplicationDTO;
|
||||||
@@ -30,12 +31,14 @@ public class OperationController {
|
|||||||
private OperationService operationService;
|
private OperationService operationService;
|
||||||
|
|
||||||
@PostMapping("/sync/consumer/offset")
|
@PostMapping("/sync/consumer/offset")
|
||||||
|
@RequiredAuthorize
|
||||||
public Object syncConsumerOffset(@RequestBody SyncDataDTO dto) {
|
public Object syncConsumerOffset(@RequestBody SyncDataDTO dto) {
|
||||||
dto.getProperties().put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, dto.getAddress());
|
dto.getProperties().put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, dto.getAddress());
|
||||||
return operationService.syncConsumerOffset(dto.getGroupId(), dto.getTopic(), dto.getProperties());
|
return operationService.syncConsumerOffset(dto.getGroupId(), dto.getTopic(), dto.getProperties());
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/sync/min/offset/alignment")
|
@PostMapping("/sync/min/offset/alignment")
|
||||||
|
@RequiredAuthorize
|
||||||
public Object minOffsetAlignment(@RequestBody SyncDataDTO dto) {
|
public Object minOffsetAlignment(@RequestBody SyncDataDTO dto) {
|
||||||
dto.getProperties().put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, dto.getAddress());
|
dto.getProperties().put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, dto.getAddress());
|
||||||
return operationService.minOffsetAlignment(dto.getGroupId(), dto.getTopic(), dto.getProperties());
|
return operationService.minOffsetAlignment(dto.getGroupId(), dto.getTopic(), dto.getProperties());
|
||||||
@@ -47,6 +50,7 @@ public class OperationController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/sync/alignment")
|
@DeleteMapping("/sync/alignment")
|
||||||
|
@RequiredAuthorize
|
||||||
public Object deleteAlignment(@RequestParam Long id) {
|
public Object deleteAlignment(@RequestParam Long id) {
|
||||||
return operationService.deleteAlignmentById(id);
|
return operationService.deleteAlignmentById(id);
|
||||||
}
|
}
|
||||||
@@ -57,6 +61,7 @@ public class OperationController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/broker/throttle")
|
@PostMapping("/broker/throttle")
|
||||||
|
@RequiredAuthorize
|
||||||
public Object configThrottle(@RequestBody BrokerThrottleDTO dto) {
|
public Object configThrottle(@RequestBody BrokerThrottleDTO dto) {
|
||||||
return operationService.configThrottle(dto.getBrokerList(), dto.getUnit().toKb(dto.getThrottle()));
|
return operationService.configThrottle(dto.getBrokerList(), dto.getUnit().toKb(dto.getThrottle()));
|
||||||
}
|
}
|
||||||
@@ -77,6 +82,7 @@ public class OperationController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/replication/reassignments/proposed")
|
@PostMapping("/replication/reassignments/proposed")
|
||||||
|
@RequiredAuthorize
|
||||||
public Object proposedAssignments(@RequestBody ProposedAssignmentDTO dto) {
|
public Object proposedAssignments(@RequestBody ProposedAssignmentDTO dto) {
|
||||||
return operationService.proposedAssignments(dto.getTopic(), dto.getBrokers());
|
return operationService.proposedAssignments(dto.getTopic(), dto.getBrokers());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.xuxd.kafka.console.controller;
|
package com.xuxd.kafka.console.controller;
|
||||||
|
|
||||||
import com.xuxd.kafka.console.beans.ReplicaAssignment;
|
import com.xuxd.kafka.console.beans.ReplicaAssignment;
|
||||||
|
import com.xuxd.kafka.console.beans.annotation.RequiredAuthorize;
|
||||||
import com.xuxd.kafka.console.beans.dto.AddPartitionDTO;
|
import com.xuxd.kafka.console.beans.dto.AddPartitionDTO;
|
||||||
import com.xuxd.kafka.console.beans.dto.NewTopicDTO;
|
import com.xuxd.kafka.console.beans.dto.NewTopicDTO;
|
||||||
import com.xuxd.kafka.console.beans.dto.TopicThrottleDTO;
|
import com.xuxd.kafka.console.beans.dto.TopicThrottleDTO;
|
||||||
@@ -43,8 +44,9 @@ public class TopicController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping
|
@DeleteMapping
|
||||||
public Object deleteTopic(@RequestBody List<String> topics) {
|
@RequiredAuthorize
|
||||||
return topicService.deleteTopics(topics);
|
public Object deleteTopic(@RequestParam String topic) {
|
||||||
|
return topicService.deleteTopic(topic);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/partition")
|
@GetMapping("/partition")
|
||||||
@@ -53,11 +55,13 @@ public class TopicController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/new")
|
@PostMapping("/new")
|
||||||
|
@RequiredAuthorize
|
||||||
public Object createNewTopic(@RequestBody NewTopicDTO topicDTO) {
|
public Object createNewTopic(@RequestBody NewTopicDTO topicDTO) {
|
||||||
return topicService.createTopic(topicDTO.toNewTopic());
|
return topicService.createTopic(topicDTO.toNewTopic());
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/partition/new")
|
@PostMapping("/partition/new")
|
||||||
|
@RequiredAuthorize
|
||||||
public Object addPartition(@RequestBody AddPartitionDTO partitionDTO) {
|
public Object addPartition(@RequestBody AddPartitionDTO partitionDTO) {
|
||||||
String topic = partitionDTO.getTopic().trim();
|
String topic = partitionDTO.getTopic().trim();
|
||||||
int addNum = partitionDTO.getAddNum();
|
int addNum = partitionDTO.getAddNum();
|
||||||
@@ -80,11 +84,13 @@ public class TopicController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/replica/assignment")
|
@PostMapping("/replica/assignment")
|
||||||
|
@RequiredAuthorize
|
||||||
public Object updateReplicaAssignment(@RequestBody ReplicaAssignment assignment) {
|
public Object updateReplicaAssignment(@RequestBody ReplicaAssignment assignment) {
|
||||||
return topicService.updateReplicaAssignment(assignment);
|
return topicService.updateReplicaAssignment(assignment);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/replica/throttle")
|
@PostMapping("/replica/throttle")
|
||||||
|
@RequiredAuthorize
|
||||||
public Object configThrottle(@RequestBody TopicThrottleDTO dto) {
|
public Object configThrottle(@RequestBody TopicThrottleDTO dto) {
|
||||||
return topicService.configThrottle(dto.getTopic(), dto.getPartitions(), dto.getOperation());
|
return topicService.configThrottle(dto.getTopic(), dto.getPartitions(), dto.getOperation());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package com.xuxd.kafka.console.dao;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.xuxd.kafka.console.beans.dos.DevOpsUserDO;
|
||||||
|
|
||||||
|
public interface DevOpsUserMapper extends BaseMapper<DevOpsUserDO> {
|
||||||
|
}
|
||||||
@@ -6,25 +6,28 @@ import com.xuxd.kafka.console.config.ContextConfig;
|
|||||||
import com.xuxd.kafka.console.config.ContextConfigHolder;
|
import com.xuxd.kafka.console.config.ContextConfigHolder;
|
||||||
import com.xuxd.kafka.console.dao.ClusterInfoMapper;
|
import com.xuxd.kafka.console.dao.ClusterInfoMapper;
|
||||||
import com.xuxd.kafka.console.utils.ConvertUtil;
|
import com.xuxd.kafka.console.utils.ConvertUtil;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
import javax.servlet.Filter;
|
||||||
|
import javax.servlet.FilterChain;
|
||||||
|
import javax.servlet.ServletException;
|
||||||
|
import javax.servlet.ServletRequest;
|
||||||
|
import javax.servlet.ServletResponse;
|
||||||
|
import javax.servlet.annotation.WebFilter;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
|
|
||||||
import javax.servlet.*;
|
|
||||||
import javax.servlet.annotation.WebFilter;
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* kafka-console-ui.
|
* kafka-console-ui.
|
||||||
*
|
*
|
||||||
* @author xuxd
|
* @author xuxd
|
||||||
* @date 2022-01-05 19:56:25
|
* @date 2022-01-05 19:56:25
|
||||||
**/
|
**/
|
||||||
@WebFilter(filterName = "context-set-filter", urlPatterns = {"/acl/*", "/user/*", "/cluster/*", "/config/*", "/consumer/*", "/message/*", "/topic/*", "/op/*", "/client/*"})
|
@WebFilter(filterName = "context-set-filter", urlPatterns = {"/acl/*","/user/*","/cluster/*","/config/*","/consumer/*","/message/*","/topic/*","/op/*"})
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class ContextSetFilter implements Filter {
|
public class ContextSetFilter implements Filter {
|
||||||
|
|
||||||
@@ -39,9 +42,8 @@ public class ContextSetFilter implements Filter {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ClusterInfoMapper clusterInfoMapper;
|
private ClusterInfoMapper clusterInfoMapper;
|
||||||
|
|
||||||
@Override
|
@Override public void doFilter(ServletRequest req, ServletResponse response,
|
||||||
public void doFilter(ServletRequest req, ServletResponse response,
|
FilterChain chain) throws IOException, ServletException {
|
||||||
FilterChain chain) throws IOException, ServletException {
|
|
||||||
try {
|
try {
|
||||||
HttpServletRequest request = (HttpServletRequest) req;
|
HttpServletRequest request = (HttpServletRequest) req;
|
||||||
String uri = request.getRequestURI();
|
String uri = request.getRequestURI();
|
||||||
@@ -70,7 +72,6 @@ public class ContextSetFilter implements Filter {
|
|||||||
config.setProperties(ConvertUtil.toProperties(infoDO.getProperties()));
|
config.setProperties(ConvertUtil.toProperties(infoDO.getProperties()));
|
||||||
}
|
}
|
||||||
ContextConfigHolder.CONTEXT_CONFIG.set(config);
|
ContextConfigHolder.CONTEXT_CONFIG.set(config);
|
||||||
// log.info("current kafka config: {}", config);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
chain.doFilter(req, response);
|
chain.doFilter(req, response);
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.xuxd.kafka.console.interceptor;
|
package com.xuxd.kafka.console.interceptor;
|
||||||
|
|
||||||
import com.xuxd.kafka.console.beans.ResponseData;
|
import com.xuxd.kafka.console.utils.ResponseUtil;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||||
@@ -14,14 +13,13 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
|||||||
* @date 2021-10-19 14:32:18
|
* @date 2021-10-19 14:32:18
|
||||||
**/
|
**/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@ControllerAdvice(basePackages = "com.xuxd.kafka.console.controller")
|
@ControllerAdvice(basePackages = "com.xuxd.kafka.console")
|
||||||
public class GlobalExceptionHandler {
|
public class GlobalExceptionHandler {
|
||||||
|
|
||||||
@ExceptionHandler(value = Exception.class)
|
@ExceptionHandler(value = Exception.class)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Object exceptionHandler(HttpServletRequest req, Exception ex) throws Exception {
|
public Object exceptionHandler(Exception ex) {
|
||||||
|
|
||||||
log.error("exception handle: ", ex);
|
log.error("exception handle: ", ex);
|
||||||
return ResponseData.create().failed(ex.getMessage());
|
return ResponseUtil.error(ex.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,84 @@
|
|||||||
|
package com.xuxd.kafka.console.interceptor;
|
||||||
|
|
||||||
|
import com.xuxd.kafka.console.beans.ResponseData;
|
||||||
|
import com.xuxd.kafka.console.beans.annotation.RequiredAuthorize;
|
||||||
|
import com.xuxd.kafka.console.beans.enums.Role;
|
||||||
|
import com.xuxd.kafka.console.beans.vo.DevOpsUserVO;
|
||||||
|
import com.xuxd.kafka.console.service.DevOpsUserService;
|
||||||
|
import com.xuxd.kafka.console.utils.ContextUtil;
|
||||||
|
import com.xuxd.kafka.console.utils.ConvertUtil;
|
||||||
|
import com.xuxd.kafka.console.utils.JwtUtils;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.method.HandlerMethod;
|
||||||
|
import org.springframework.web.servlet.AsyncHandlerInterceptor;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
|
||||||
|
import static com.xuxd.kafka.console.beans.ResponseData.TOKEN_ILLEGAL;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class TokenInterceptor implements AsyncHandlerInterceptor {
|
||||||
|
|
||||||
|
private final static String TOKEN = "token";
|
||||||
|
private final DevOpsUserService devOpsUserService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||||
|
if (handler instanceof HandlerMethod){
|
||||||
|
String token = request.getHeader(TOKEN);
|
||||||
|
if (StringUtils.isBlank(token)){
|
||||||
|
log.info("token not exist");
|
||||||
|
write(response);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
String username = JwtUtils.parse(token);
|
||||||
|
if (StringUtils.isBlank(username)){
|
||||||
|
log.info("{} is wrongful", token);
|
||||||
|
write(response);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ResponseData<DevOpsUserVO> userVORsp = devOpsUserService.detail(username);
|
||||||
|
if (userVORsp == null || userVORsp.getData() == null){
|
||||||
|
log.info("{} not exist", username);
|
||||||
|
write(response);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ContextUtil.set(ContextUtil.USERNAME, username);
|
||||||
|
HandlerMethod method = (HandlerMethod)handler;
|
||||||
|
RequiredAuthorize annotation = method.getMethodAnnotation(RequiredAuthorize.class);
|
||||||
|
if (annotation != null){
|
||||||
|
DevOpsUserVO userVO = userVORsp.getData();
|
||||||
|
if (!userVO.getRole().equals(Role.manager)){
|
||||||
|
log.info("{},{} no permission", username, request.getRequestURI());
|
||||||
|
write(response);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void write(HttpServletResponse response){
|
||||||
|
PrintWriter writer = null;
|
||||||
|
try {
|
||||||
|
writer = response.getWriter();
|
||||||
|
writer.write(ConvertUtil.toJsonString(ResponseData.create().failed(TOKEN_ILLEGAL)));
|
||||||
|
} catch (Exception ignored){
|
||||||
|
} finally {
|
||||||
|
if (writer != null){
|
||||||
|
writer.flush();
|
||||||
|
writer.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package com.xuxd.kafka.console.interceptor;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class WebMvcConfig implements WebMvcConfigurer {
|
||||||
|
|
||||||
|
private final TokenInterceptor tokenInterceptor;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addInterceptors(InterceptorRegistry registry) {
|
||||||
|
registry.addInterceptor(tokenInterceptor)
|
||||||
|
.addPathPatterns("/**")
|
||||||
|
.excludePathPatterns("/devops/user/login");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -42,7 +42,4 @@ public interface AclService {
|
|||||||
|
|
||||||
ResponseData getUserDetail(String username);
|
ResponseData getUserDetail(String username);
|
||||||
|
|
||||||
ResponseData clearAcl(AclEntry entry);
|
|
||||||
|
|
||||||
ResponseData getSaslScramUserList(AclEntry entry);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
package com.xuxd.kafka.console.service;
|
|
||||||
|
|
||||||
import com.xuxd.kafka.console.beans.ResponseData;
|
|
||||||
import com.xuxd.kafka.console.beans.dto.AlterClientQuotaDTO;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author 晓东哥哥
|
|
||||||
*/
|
|
||||||
public interface ClientQuotaService {
|
|
||||||
|
|
||||||
ResponseData getClientQuotaConfigs(List<String> types, List<String> names);
|
|
||||||
|
|
||||||
ResponseData alterClientQuotaConfigs(AlterClientQuotaDTO request);
|
|
||||||
|
|
||||||
ResponseData deleteClientQuotaConfigs(AlterClientQuotaDTO request);
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package com.xuxd.kafka.console.service;
|
||||||
|
|
||||||
|
import com.xuxd.kafka.console.beans.ResponseData;
|
||||||
|
import com.xuxd.kafka.console.beans.dto.user.AddUserDTO;
|
||||||
|
import com.xuxd.kafka.console.beans.dto.user.ListUserDTO;
|
||||||
|
import com.xuxd.kafka.console.beans.dto.user.UpdateUserDTO;
|
||||||
|
import com.xuxd.kafka.console.beans.vo.DevOpsUserVO;
|
||||||
|
import com.xuxd.kafka.console.beans.vo.LoginVO;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface DevOpsUserService {
|
||||||
|
|
||||||
|
ResponseData<Boolean> add(AddUserDTO addUserDTO);
|
||||||
|
|
||||||
|
ResponseData<Boolean> update(UpdateUserDTO updateUserDTO);
|
||||||
|
|
||||||
|
ResponseData<Boolean> delete(Long id);
|
||||||
|
|
||||||
|
ResponseData<List<DevOpsUserVO>> list(ListUserDTO listUserDTO);
|
||||||
|
|
||||||
|
ResponseData<DevOpsUserVO> detail(String username);
|
||||||
|
|
||||||
|
ResponseData<LoginVO> login(String username, String password);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -4,8 +4,6 @@ import com.xuxd.kafka.console.beans.QueryMessage;
|
|||||||
import com.xuxd.kafka.console.beans.ResponseData;
|
import com.xuxd.kafka.console.beans.ResponseData;
|
||||||
import com.xuxd.kafka.console.beans.SendMessage;
|
import com.xuxd.kafka.console.beans.SendMessage;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* kafka-console-ui.
|
* kafka-console-ui.
|
||||||
*
|
*
|
||||||
@@ -25,6 +23,4 @@ public interface MessageService {
|
|||||||
ResponseData send(SendMessage message);
|
ResponseData send(SendMessage message);
|
||||||
|
|
||||||
ResponseData resend(SendMessage message);
|
ResponseData resend(SendMessage message);
|
||||||
|
|
||||||
ResponseData delete(List<QueryMessage> messages);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ import com.xuxd.kafka.console.beans.ReplicaAssignment;
|
|||||||
import com.xuxd.kafka.console.beans.ResponseData;
|
import com.xuxd.kafka.console.beans.ResponseData;
|
||||||
import com.xuxd.kafka.console.beans.enums.TopicThrottleSwitch;
|
import com.xuxd.kafka.console.beans.enums.TopicThrottleSwitch;
|
||||||
import com.xuxd.kafka.console.beans.enums.TopicType;
|
import com.xuxd.kafka.console.beans.enums.TopicType;
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.apache.kafka.clients.admin.NewTopic;
|
import org.apache.kafka.clients.admin.NewTopic;
|
||||||
|
|
||||||
@@ -21,7 +19,7 @@ public interface TopicService {
|
|||||||
|
|
||||||
ResponseData getTopicList(String topic, TopicType type);
|
ResponseData getTopicList(String topic, TopicType type);
|
||||||
|
|
||||||
ResponseData deleteTopics(Collection<String> topics);
|
ResponseData deleteTopic(String topic);
|
||||||
|
|
||||||
ResponseData getTopicPartitionInfo(String topic);
|
ResponseData getTopicPartitionInfo(String topic);
|
||||||
|
|
||||||
|
|||||||
@@ -10,23 +10,30 @@ import com.xuxd.kafka.console.config.ContextConfigHolder;
|
|||||||
import com.xuxd.kafka.console.dao.KafkaUserMapper;
|
import com.xuxd.kafka.console.dao.KafkaUserMapper;
|
||||||
import com.xuxd.kafka.console.service.AclService;
|
import com.xuxd.kafka.console.service.AclService;
|
||||||
import com.xuxd.kafka.console.utils.SaslUtil;
|
import com.xuxd.kafka.console.utils.SaslUtil;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Properties;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
import kafka.console.KafkaAclConsole;
|
import kafka.console.KafkaAclConsole;
|
||||||
import kafka.console.KafkaConfigConsole;
|
import kafka.console.KafkaConfigConsole;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.apache.kafka.clients.CommonClientConfigs;
|
||||||
|
import org.apache.kafka.clients.admin.ScramMechanism;
|
||||||
import org.apache.kafka.clients.admin.UserScramCredentialsDescription;
|
import org.apache.kafka.clients.admin.UserScramCredentialsDescription;
|
||||||
import org.apache.kafka.common.acl.AclBinding;
|
import org.apache.kafka.common.acl.AclBinding;
|
||||||
import org.apache.kafka.common.acl.AclOperation;
|
import org.apache.kafka.common.acl.AclOperation;
|
||||||
import org.apache.kafka.common.config.SaslConfigs;
|
import org.apache.kafka.common.config.SaslConfigs;
|
||||||
import org.apache.kafka.common.errors.SecurityDisabledException;
|
import org.apache.kafka.common.security.auth.SecurityProtocol;
|
||||||
import org.springframework.beans.factory.ObjectProvider;
|
import org.springframework.beans.factory.ObjectProvider;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import scala.Tuple2;
|
import scala.Tuple2;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import static com.xuxd.kafka.console.utils.SaslUtil.isEnableSasl;
|
import static com.xuxd.kafka.console.utils.SaslUtil.isEnableSasl;
|
||||||
import static com.xuxd.kafka.console.utils.SaslUtil.isEnableScram;
|
import static com.xuxd.kafka.console.utils.SaslUtil.isEnableScram;
|
||||||
|
|
||||||
@@ -132,52 +139,39 @@ public class AclServiceImpl implements AclService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override public ResponseData getAclList(AclEntry entry) {
|
@Override public ResponseData getAclList(AclEntry entry) {
|
||||||
List<AclBinding> aclBindingList = Collections.emptyList();
|
List<AclBinding> aclBindingList = entry.isNull() ? aclConsole.getAclList(null) : aclConsole.getAclList(entry);
|
||||||
try {
|
|
||||||
aclBindingList = entry.isNull() ? aclConsole.getAclList(null) : aclConsole.getAclList(entry);
|
|
||||||
}catch (Exception ex) {
|
|
||||||
if (ex.getCause() instanceof SecurityDisabledException) {
|
|
||||||
Throwable e = ex.getCause();
|
|
||||||
log.info("SecurityDisabledException: {}", e.getMessage());
|
|
||||||
Map<String, String> hint = new HashMap<>(2);
|
|
||||||
hint.put("hint", "Security Disabled: " + e.getMessage());
|
|
||||||
return ResponseData.create().data(hint).success();
|
|
||||||
}
|
|
||||||
throw new RuntimeException(ex.getCause());
|
|
||||||
}
|
|
||||||
// List<AclBinding> aclBindingList = entry.isNull() ? aclConsole.getAclList(null) : aclConsole.getAclList(entry);
|
|
||||||
List<AclEntry> entryList = aclBindingList.stream().map(x -> AclEntry.valueOf(x)).collect(Collectors.toList());
|
List<AclEntry> entryList = aclBindingList.stream().map(x -> AclEntry.valueOf(x)).collect(Collectors.toList());
|
||||||
Map<String, List<AclEntry>> entryMap = entryList.stream().collect(Collectors.groupingBy(AclEntry::getPrincipal));
|
Map<String, List<AclEntry>> entryMap = entryList.stream().collect(Collectors.groupingBy(AclEntry::getPrincipal));
|
||||||
Map<String, Object> resultMap = new HashMap<>();
|
Map<String, Object> resultMap = new HashMap<>();
|
||||||
entryMap.forEach((k, v) -> {
|
entryMap.forEach((k, v) -> {
|
||||||
Map<String, List<AclEntry>> map = v.stream().collect(Collectors.groupingBy(e -> e.getResourceType() + "#" + e.getName()));
|
Map<String, List<AclEntry>> map = v.stream().collect(Collectors.groupingBy(e -> e.getResourceType() + "#" + e.getName()));
|
||||||
// String username = SaslUtil.findUsername(ContextConfigHolder.CONTEXT_CONFIG.get().getProperties().getProperty(SaslConfigs.SASL_JAAS_CONFIG));
|
String username = SaslUtil.findUsername(ContextConfigHolder.CONTEXT_CONFIG.get().getProperties().getProperty(SaslConfigs.SASL_JAAS_CONFIG));
|
||||||
// if (k.equals(username)) {
|
if (k.equals(username)) {
|
||||||
// Map<String, Object> map2 = new HashMap<>(map);
|
Map<String, Object> map2 = new HashMap<>(map);
|
||||||
// Map<String, Object> userMap = new HashMap<>();
|
Map<String, Object> userMap = new HashMap<>();
|
||||||
// userMap.put("role", "admin");
|
userMap.put("role", "admin");
|
||||||
// map2.put("USER", userMap);
|
map2.put("USER", userMap);
|
||||||
// }
|
}
|
||||||
resultMap.put(k, map);
|
resultMap.put(k, map);
|
||||||
});
|
});
|
||||||
// if (entry.isNull() || StringUtils.isNotBlank(entry.getPrincipal())) {
|
if (entry.isNull() || StringUtils.isNotBlank(entry.getPrincipal())) {
|
||||||
// Map<String, UserScramCredentialsDescription> detailList = configConsole.getUserDetailList(StringUtils.isNotBlank(entry.getPrincipal()) ? Collections.singletonList(entry.getPrincipal()) : null);
|
Map<String, UserScramCredentialsDescription> detailList = configConsole.getUserDetailList(StringUtils.isNotBlank(entry.getPrincipal()) ? Collections.singletonList(entry.getPrincipal()) : null);
|
||||||
//
|
|
||||||
// detailList.values().forEach(u -> {
|
detailList.values().forEach(u -> {
|
||||||
// if (!resultMap.containsKey(u.name()) && !u.credentialInfos().isEmpty()) {
|
if (!resultMap.containsKey(u.name()) && !u.credentialInfos().isEmpty()) {
|
||||||
// String username = SaslUtil.findUsername(ContextConfigHolder.CONTEXT_CONFIG.get().getProperties().getProperty(SaslConfigs.SASL_JAAS_CONFIG));
|
String username = SaslUtil.findUsername(ContextConfigHolder.CONTEXT_CONFIG.get().getProperties().getProperty(SaslConfigs.SASL_JAAS_CONFIG));
|
||||||
// if (!u.name().equals(username)) {
|
if (!u.name().equals(username)) {
|
||||||
// resultMap.put(u.name(), Collections.emptyMap());
|
resultMap.put(u.name(), Collections.emptyMap());
|
||||||
// } else {
|
} else {
|
||||||
// Map<String, Object> map2 = new HashMap<>();
|
Map<String, Object> map2 = new HashMap<>();
|
||||||
// Map<String, Object> userMap = new HashMap<>();
|
Map<String, Object> userMap = new HashMap<>();
|
||||||
// userMap.put("role", "admin");
|
userMap.put("role", "admin");
|
||||||
// map2.put("USER", userMap);
|
map2.put("USER", userMap);
|
||||||
// resultMap.put(u.name(), map2);
|
resultMap.put(u.name(), map2);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// });
|
});
|
||||||
// }
|
}
|
||||||
|
|
||||||
return ResponseData.create().data(new CounterMap<>(resultMap)).success();
|
return ResponseData.create().data(new CounterMap<>(resultMap)).success();
|
||||||
}
|
}
|
||||||
@@ -242,37 +236,6 @@ public class AclServiceImpl implements AclService {
|
|||||||
return ResponseData.create().data(vo).success();
|
return ResponseData.create().data(vo).success();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResponseData clearAcl(AclEntry entry) {
|
|
||||||
log.info("Start clear acl, principal: {}", entry);
|
|
||||||
return aclConsole.deleteUserAcl(entry) ? ResponseData.create().success() : ResponseData.create().failed("操作失败");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResponseData getSaslScramUserList(AclEntry entry) {
|
|
||||||
Map<String, Object> resultMap = new HashMap<>();
|
|
||||||
if (entry.isNull() || StringUtils.isNotBlank(entry.getPrincipal())) {
|
|
||||||
Map<String, UserScramCredentialsDescription> detailList = configConsole.getUserDetailList(StringUtils.isNotBlank(entry.getPrincipal()) ? Collections.singletonList(entry.getPrincipal()) : null);
|
|
||||||
|
|
||||||
detailList.values().forEach(u -> {
|
|
||||||
if (!resultMap.containsKey(u.name()) && !u.credentialInfos().isEmpty()) {
|
|
||||||
String username = SaslUtil.findUsername(ContextConfigHolder.CONTEXT_CONFIG.get().getProperties().getProperty(SaslConfigs.SASL_JAAS_CONFIG));
|
|
||||||
if (!u.name().equals(username)) {
|
|
||||||
resultMap.put(u.name(), Collections.emptyMap());
|
|
||||||
} else {
|
|
||||||
Map<String, Object> map2 = new HashMap<>();
|
|
||||||
Map<String, Object> userMap = new HashMap<>();
|
|
||||||
userMap.put("role", "admin");
|
|
||||||
map2.put("USER", userMap);
|
|
||||||
resultMap.put(u.name(), map2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return ResponseData.create().data(new CounterMap<>(resultMap)).success();
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Override public void afterSingletonsInstantiated() {
|
// @Override public void afterSingletonsInstantiated() {
|
||||||
// if (kafkaConfig.isEnableAcl() && kafkaConfig.isAdminCreate()) {
|
// if (kafkaConfig.isEnableAcl() && kafkaConfig.isAdminCreate()) {
|
||||||
// log.info("Start create admin user, username: {}, password: {}", kafkaConfig.getAdminUsername(), kafkaConfig.getAdminPassword());
|
// log.info("Start create admin user, username: {}, password: {}", kafkaConfig.getAdminUsername(), kafkaConfig.getAdminPassword());
|
||||||
|
|||||||
@@ -1,172 +0,0 @@
|
|||||||
package com.xuxd.kafka.console.service.impl;
|
|
||||||
|
|
||||||
import com.xuxd.kafka.console.beans.ResponseData;
|
|
||||||
import com.xuxd.kafka.console.beans.dto.AlterClientQuotaDTO;
|
|
||||||
import com.xuxd.kafka.console.beans.vo.ClientQuotaEntityVO;
|
|
||||||
import com.xuxd.kafka.console.service.ClientQuotaService;
|
|
||||||
import kafka.console.ClientQuotaConsole;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.apache.kafka.common.config.internals.QuotaConfigs;
|
|
||||||
import org.apache.kafka.common.quota.ClientQuotaEntity;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import scala.Tuple2;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author 晓东哥哥
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@Service
|
|
||||||
public class ClientQuotaServiceImpl implements ClientQuotaService {
|
|
||||||
|
|
||||||
private final ClientQuotaConsole clientQuotaConsole;
|
|
||||||
|
|
||||||
private final Map<String, String> typeDict = new HashMap<>();
|
|
||||||
|
|
||||||
private final Map<String, String> configDict = new HashMap<>();
|
|
||||||
|
|
||||||
private final String USER = "user";
|
|
||||||
private final String CLIENT_ID = "client-id";
|
|
||||||
private final String IP = "ip";
|
|
||||||
private final String USER_CLIENT = "user&client-id";
|
|
||||||
|
|
||||||
{
|
|
||||||
typeDict.put(USER, ClientQuotaEntity.USER);
|
|
||||||
typeDict.put(CLIENT_ID, ClientQuotaEntity.CLIENT_ID);
|
|
||||||
typeDict.put(IP, ClientQuotaEntity.IP);
|
|
||||||
typeDict.put(USER_CLIENT, USER_CLIENT);
|
|
||||||
|
|
||||||
configDict.put("producerRate", QuotaConfigs.PRODUCER_BYTE_RATE_OVERRIDE_CONFIG);
|
|
||||||
configDict.put("consumerRate", QuotaConfigs.CONSUMER_BYTE_RATE_OVERRIDE_CONFIG);
|
|
||||||
configDict.put("requestPercentage", QuotaConfigs.REQUEST_PERCENTAGE_OVERRIDE_CONFIG);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ClientQuotaServiceImpl(ClientQuotaConsole clientQuotaConsole) {
|
|
||||||
this.clientQuotaConsole = clientQuotaConsole;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResponseData getClientQuotaConfigs(List<String> types, List<String> names) {
|
|
||||||
List<String> entityNames = names == null ? Collections.emptyList() : new ArrayList<>(names);
|
|
||||||
List<String> entityTypes = types.stream().map(e -> typeDict.get(e)).filter(e -> e != null).collect(Collectors.toList());
|
|
||||||
if (entityTypes.isEmpty() || entityTypes.size() != types.size()) {
|
|
||||||
throw new IllegalArgumentException("types illegal.");
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean userAndClientFilterClientOnly = false;
|
|
||||||
// only type: [user and client-id], type.size == 2
|
|
||||||
if (entityTypes.size() == 2) {
|
|
||||||
if (names.size() == 2 && StringUtils.isBlank(names.get(0)) && StringUtils.isNotBlank(names.get(1))) {
|
|
||||||
userAndClientFilterClientOnly = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Map<ClientQuotaEntity, Map<String, Object>> clientQuotasConfigs = clientQuotaConsole.getClientQuotasConfigs(entityTypes,
|
|
||||||
userAndClientFilterClientOnly ? Collections.emptyList() : entityNames);
|
|
||||||
|
|
||||||
List<ClientQuotaEntityVO> voList = clientQuotasConfigs.entrySet().stream().map(entry -> ClientQuotaEntityVO.from(
|
|
||||||
entry.getKey(), entityTypes, entry.getValue())).collect(Collectors.toList());
|
|
||||||
if (!userAndClientFilterClientOnly) {
|
|
||||||
return ResponseData.create().data(voList).success();
|
|
||||||
}
|
|
||||||
List<ClientQuotaEntityVO> list = voList.stream().filter(e -> names.get(1).equals(e.getClient())).collect(Collectors.toList());
|
|
||||||
|
|
||||||
return ResponseData.create().data(list).success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResponseData alterClientQuotaConfigs(AlterClientQuotaDTO request) {
|
|
||||||
|
|
||||||
if (StringUtils.isEmpty(request.getType()) || !typeDict.containsKey(request.getType())) {
|
|
||||||
return ResponseData.create().failed("Unknown type.");
|
|
||||||
}
|
|
||||||
|
|
||||||
List<String> types = new ArrayList<>();
|
|
||||||
List<String> names = new ArrayList<>();
|
|
||||||
parseTypesAndNames(request, types, names, request.getType());
|
|
||||||
Map<String, String> configsToBeAddedMap = new HashMap<>();
|
|
||||||
|
|
||||||
if (StringUtils.isNotEmpty(request.getProducerRate())) {
|
|
||||||
configsToBeAddedMap.put(QuotaConfigs.PRODUCER_BYTE_RATE_OVERRIDE_CONFIG, String.valueOf(Math.floor(Double.valueOf(request.getProducerRate()))));
|
|
||||||
}
|
|
||||||
if (StringUtils.isNotEmpty(request.getConsumerRate())) {
|
|
||||||
configsToBeAddedMap.put(QuotaConfigs.CONSUMER_BYTE_RATE_OVERRIDE_CONFIG, String.valueOf(Math.floor(Double.valueOf(request.getConsumerRate()))));
|
|
||||||
}
|
|
||||||
if (StringUtils.isNotEmpty(request.getRequestPercentage())) {
|
|
||||||
configsToBeAddedMap.put(QuotaConfigs.REQUEST_PERCENTAGE_OVERRIDE_CONFIG, String.valueOf(Math.floor(Double.valueOf(request.getRequestPercentage()))));
|
|
||||||
}
|
|
||||||
|
|
||||||
Tuple2<Object, String> tuple2 = clientQuotaConsole.addQuotaConfigs(types, names, configsToBeAddedMap);
|
|
||||||
if (!(Boolean) tuple2._1) {
|
|
||||||
return ResponseData.create().failed(tuple2._2);
|
|
||||||
}
|
|
||||||
if (CollectionUtils.isNotEmpty(request.getDeleteConfigs())) {
|
|
||||||
List<String> delete = request.getDeleteConfigs().stream().map(key -> configDict.get(key)).collect(Collectors.toList());
|
|
||||||
Tuple2<Object, String> tuple2Del = clientQuotaConsole.deleteQuotaConfigs(types, names, delete);
|
|
||||||
if (!(Boolean) tuple2Del._1) {
|
|
||||||
return ResponseData.create().failed(tuple2Del._2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ResponseData.create().success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResponseData deleteClientQuotaConfigs(AlterClientQuotaDTO request) {
|
|
||||||
if (StringUtils.isEmpty(request.getType()) || !typeDict.containsKey(request.getType())) {
|
|
||||||
return ResponseData.create().failed("Unknown type.");
|
|
||||||
}
|
|
||||||
List<String> types = new ArrayList<>();
|
|
||||||
List<String> names = new ArrayList<>();
|
|
||||||
parseTypesAndNames(request, types, names, request.getType());
|
|
||||||
List<String> configs = new ArrayList<>();
|
|
||||||
configs.add(QuotaConfigs.PRODUCER_BYTE_RATE_OVERRIDE_CONFIG);
|
|
||||||
configs.add(QuotaConfigs.CONSUMER_BYTE_RATE_OVERRIDE_CONFIG);
|
|
||||||
configs.add(QuotaConfigs.REQUEST_PERCENTAGE_OVERRIDE_CONFIG);
|
|
||||||
Tuple2<Object, String> tuple2 = clientQuotaConsole.deleteQuotaConfigs(types, names, configs);
|
|
||||||
if (!(Boolean) tuple2._1) {
|
|
||||||
return ResponseData.create().failed(tuple2._2);
|
|
||||||
}
|
|
||||||
return ResponseData.create().success();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void parseTypesAndNames(AlterClientQuotaDTO request, List<String> types, List<String> names, String type) {
|
|
||||||
switch (request.getType()) {
|
|
||||||
case USER:
|
|
||||||
getTypesAndNames(request, types, names, USER);
|
|
||||||
break;
|
|
||||||
case CLIENT_ID:
|
|
||||||
getTypesAndNames(request, types, names, CLIENT_ID);
|
|
||||||
break;
|
|
||||||
case IP:
|
|
||||||
getTypesAndNames(request, types, names, IP);
|
|
||||||
break;
|
|
||||||
case USER_CLIENT:
|
|
||||||
getTypesAndNames(request, types, names, USER);
|
|
||||||
getTypesAndNames(request, types, names, CLIENT_ID);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void getTypesAndNames(AlterClientQuotaDTO request, List<String> types, List<String> names, String type) {
|
|
||||||
int index = -1;
|
|
||||||
for (int i = 0; i < request.getTypes().size(); i++) {
|
|
||||||
if (type.equals(request.getTypes().get(i))) {
|
|
||||||
index = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (index < 0) {
|
|
||||||
throw new IllegalArgumentException("Does not contain the type:" + type);
|
|
||||||
}
|
|
||||||
types.add(request.getTypes().get(index));
|
|
||||||
if (CollectionUtils.isNotEmpty(request.getNames()) && request.getNames().size() > index) {
|
|
||||||
names.add(request.getNames().get(index));
|
|
||||||
} else {
|
|
||||||
names.add("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.xuxd.kafka.console.service.impl;
|
package com.xuxd.kafka.console.service.impl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.xuxd.kafka.console.beans.BrokerNode;
|
|
||||||
import com.xuxd.kafka.console.beans.ClusterInfo;
|
import com.xuxd.kafka.console.beans.ClusterInfo;
|
||||||
import com.xuxd.kafka.console.beans.ResponseData;
|
import com.xuxd.kafka.console.beans.ResponseData;
|
||||||
import com.xuxd.kafka.console.beans.dos.ClusterInfoDO;
|
import com.xuxd.kafka.console.beans.dos.ClusterInfoDO;
|
||||||
@@ -9,11 +8,15 @@ import com.xuxd.kafka.console.beans.vo.BrokerApiVersionVO;
|
|||||||
import com.xuxd.kafka.console.beans.vo.ClusterInfoVO;
|
import com.xuxd.kafka.console.beans.vo.ClusterInfoVO;
|
||||||
import com.xuxd.kafka.console.dao.ClusterInfoMapper;
|
import com.xuxd.kafka.console.dao.ClusterInfoMapper;
|
||||||
import com.xuxd.kafka.console.service.ClusterService;
|
import com.xuxd.kafka.console.service.ClusterService;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.*;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.TreeSet;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import kafka.console.ClusterConsole;
|
import kafka.console.ClusterConsole;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.kafka.clients.NodeApiVersions;
|
import org.apache.kafka.clients.NodeApiVersions;
|
||||||
@@ -27,7 +30,6 @@ import org.springframework.stereotype.Service;
|
|||||||
* @author xuxd
|
* @author xuxd
|
||||||
* @date 2021-10-08 14:23:09
|
* @date 2021-10-08 14:23:09
|
||||||
**/
|
**/
|
||||||
@Slf4j
|
|
||||||
@Service
|
@Service
|
||||||
public class ClusterServiceImpl implements ClusterService {
|
public class ClusterServiceImpl implements ClusterService {
|
||||||
|
|
||||||
@@ -43,12 +45,7 @@ public class ClusterServiceImpl implements ClusterService {
|
|||||||
|
|
||||||
@Override public ResponseData getClusterInfo() {
|
@Override public ResponseData getClusterInfo() {
|
||||||
ClusterInfo clusterInfo = clusterConsole.clusterInfo();
|
ClusterInfo clusterInfo = clusterConsole.clusterInfo();
|
||||||
Set<BrokerNode> nodes = clusterInfo.getNodes();
|
clusterInfo.setNodes(new TreeSet<>(clusterInfo.getNodes()));
|
||||||
if (nodes == null) {
|
|
||||||
log.error("集群节点信息为空,集群地址可能不正确或集群内没有活跃节点");
|
|
||||||
return ResponseData.create().failed("集群节点信息为空,集群地址可能不正确或集群内没有活跃节点");
|
|
||||||
}
|
|
||||||
clusterInfo.setNodes(new TreeSet<>(nodes));
|
|
||||||
return ResponseData.create().data(clusterInfo).success();
|
return ResponseData.create().data(clusterInfo).success();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,10 +70,6 @@ public class ClusterServiceImpl implements ClusterService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override public ResponseData updateClusterInfo(ClusterInfoDO infoDO) {
|
@Override public ResponseData updateClusterInfo(ClusterInfoDO infoDO) {
|
||||||
if (infoDO.getProperties() == null) {
|
|
||||||
// null 的话不更新,这个是bug,设置为空字符串解决
|
|
||||||
infoDO.setProperties("");
|
|
||||||
}
|
|
||||||
clusterInfoMapper.updateById(infoDO);
|
clusterInfoMapper.updateById(infoDO);
|
||||||
return ResponseData.create().success();
|
return ResponseData.create().success();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,99 @@
|
|||||||
|
package com.xuxd.kafka.console.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||||
|
import com.xuxd.kafka.console.beans.KafkaConsoleException;
|
||||||
|
import com.xuxd.kafka.console.beans.ResponseData;
|
||||||
|
import com.xuxd.kafka.console.beans.dos.DevOpsUserDO;
|
||||||
|
import com.xuxd.kafka.console.beans.dto.user.AddUserDTO;
|
||||||
|
import com.xuxd.kafka.console.beans.dto.user.ListUserDTO;
|
||||||
|
import com.xuxd.kafka.console.beans.dto.user.UpdateUserDTO;
|
||||||
|
import com.xuxd.kafka.console.beans.vo.DevOpsUserVO;
|
||||||
|
import com.xuxd.kafka.console.beans.vo.LoginVO;
|
||||||
|
import com.xuxd.kafka.console.boot.InitSuperDevOpsUser;
|
||||||
|
import com.xuxd.kafka.console.dao.DevOpsUserMapper;
|
||||||
|
import com.xuxd.kafka.console.service.DevOpsUserService;
|
||||||
|
import com.xuxd.kafka.console.utils.ConvertUtil;
|
||||||
|
import com.xuxd.kafka.console.utils.JwtUtils;
|
||||||
|
import com.xuxd.kafka.console.utils.Md5Utils;
|
||||||
|
import com.xuxd.kafka.console.utils.ResponseUtil;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class DevOpsServiceImpl implements DevOpsUserService {
|
||||||
|
|
||||||
|
private final DevOpsUserMapper devOpsUserMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseData<Boolean> add(AddUserDTO addUserDTO) {
|
||||||
|
QueryWrapper<DevOpsUserDO> queryWrapper = new QueryWrapper<DevOpsUserDO>();
|
||||||
|
queryWrapper.eq("username", addUserDTO.getUsername());
|
||||||
|
if (devOpsUserMapper.selectOne(queryWrapper) != null){
|
||||||
|
throw new KafkaConsoleException("账号已存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
addUserDTO.setPassword(Md5Utils.MD5(addUserDTO.getPassword()));
|
||||||
|
int ret = devOpsUserMapper.insert(ConvertUtil.copy(addUserDTO, DevOpsUserDO.class));
|
||||||
|
return ResponseUtil.success(ret > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseData<Boolean> update(UpdateUserDTO updateUserDTO) {
|
||||||
|
UpdateWrapper<DevOpsUserDO> updateWrapper = new UpdateWrapper<>();
|
||||||
|
if (updateUserDTO.getRole() != null){
|
||||||
|
updateWrapper.set("role", updateUserDTO.getRole());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotBlank(updateUserDTO.getPassword())){
|
||||||
|
updateWrapper.set("password", Md5Utils.MD5(updateUserDTO.getPassword()));
|
||||||
|
}
|
||||||
|
updateWrapper.eq("username", updateUserDTO.getUsername());
|
||||||
|
int ret = devOpsUserMapper.update(null, updateWrapper);
|
||||||
|
return ResponseUtil.success(ret > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseData<Boolean> delete(Long id) {
|
||||||
|
int ret = devOpsUserMapper.deleteById(id);
|
||||||
|
return ResponseUtil.success(ret > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseData<List<DevOpsUserVO>> list(ListUserDTO listUserDTO) {
|
||||||
|
QueryWrapper<DevOpsUserDO> queryWrapper = new QueryWrapper<DevOpsUserDO>();
|
||||||
|
if (listUserDTO.getId() != null){
|
||||||
|
queryWrapper.eq("id", listUserDTO.getId());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotBlank(listUserDTO.getUsername())){
|
||||||
|
queryWrapper.eq("username", listUserDTO.getUsername());
|
||||||
|
}
|
||||||
|
queryWrapper.ne("username", InitSuperDevOpsUser.SUPER_USERNAME);
|
||||||
|
List<DevOpsUserDO> userDOS = devOpsUserMapper.selectList(queryWrapper);
|
||||||
|
return ResponseUtil.success(ConvertUtil.copyList(userDOS, DevOpsUserVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseData<DevOpsUserVO> detail(String username) {
|
||||||
|
QueryWrapper<DevOpsUserDO> queryWrapper = new QueryWrapper<DevOpsUserDO>();
|
||||||
|
queryWrapper.eq("username", username);
|
||||||
|
DevOpsUserDO userDO = devOpsUserMapper.selectOne(queryWrapper);
|
||||||
|
return ResponseUtil.success(ConvertUtil.copy(userDO, DevOpsUserVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseData<LoginVO> login(String username, String password) {
|
||||||
|
QueryWrapper<DevOpsUserDO> queryWrapper = new QueryWrapper<DevOpsUserDO>();
|
||||||
|
queryWrapper.eq("username", username);
|
||||||
|
queryWrapper.eq("password", Md5Utils.MD5(password));
|
||||||
|
DevOpsUserDO userDO = devOpsUserMapper.selectOne(queryWrapper);
|
||||||
|
if (userDO == null){
|
||||||
|
throw new KafkaConsoleException("用户名或密码错误");
|
||||||
|
}
|
||||||
|
LoginVO loginVO = LoginVO.builder().role(userDO.getRole()).token(JwtUtils.sign(username)).build();
|
||||||
|
return ResponseUtil.success(loginVO);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -24,7 +24,6 @@ import kafka.console.TopicConsole;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.kafka.clients.admin.RecordsToDelete;
|
|
||||||
import org.apache.kafka.clients.admin.TopicDescription;
|
import org.apache.kafka.clients.admin.TopicDescription;
|
||||||
import org.apache.kafka.clients.consumer.ConsumerRecord;
|
import org.apache.kafka.clients.consumer.ConsumerRecord;
|
||||||
import org.apache.kafka.clients.producer.ProducerRecord;
|
import org.apache.kafka.clients.producer.ProducerRecord;
|
||||||
@@ -243,18 +242,6 @@ public class MessageServiceImpl implements MessageService, ApplicationContextAwa
|
|||||||
return success ? ResponseData.create().success("success: " + tuple2._2()) : ResponseData.create().failed(tuple2._2());
|
return success ? ResponseData.create().success("success: " + tuple2._2()) : ResponseData.create().failed(tuple2._2());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResponseData delete(List<QueryMessage> messages) {
|
|
||||||
Map<TopicPartition, RecordsToDelete> params = new HashMap<>(messages.size(), 1f);
|
|
||||||
|
|
||||||
messages.forEach(message -> {
|
|
||||||
params.put(new TopicPartition(message.getTopic(), message.getPartition()), RecordsToDelete.beforeOffset(message.getOffset()));
|
|
||||||
});
|
|
||||||
Tuple2<Object, String> tuple2 = messageConsole.delete(params);
|
|
||||||
boolean success = (boolean) tuple2._1();
|
|
||||||
return success ? ResponseData.create().success() : ResponseData.create().failed(tuple2._2());
|
|
||||||
}
|
|
||||||
|
|
||||||
private Map<TopicPartition, ConsumerRecord<byte[], byte[]>> searchRecordByOffset(QueryMessage queryMessage) {
|
private Map<TopicPartition, ConsumerRecord<byte[], byte[]>> searchRecordByOffset(QueryMessage queryMessage) {
|
||||||
Set<TopicPartition> partitions = getPartitions(queryMessage);
|
Set<TopicPartition> partitions = getPartitions(queryMessage);
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,16 @@ import com.xuxd.kafka.console.beans.vo.TopicDescriptionVO;
|
|||||||
import com.xuxd.kafka.console.beans.vo.TopicPartitionVO;
|
import com.xuxd.kafka.console.beans.vo.TopicPartitionVO;
|
||||||
import com.xuxd.kafka.console.service.TopicService;
|
import com.xuxd.kafka.console.service.TopicService;
|
||||||
import com.xuxd.kafka.console.utils.GsonUtil;
|
import com.xuxd.kafka.console.utils.GsonUtil;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
import kafka.console.MessageConsole;
|
import kafka.console.MessageConsole;
|
||||||
import kafka.console.TopicConsole;
|
import kafka.console.TopicConsole;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@@ -23,10 +33,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import scala.Tuple2;
|
import scala.Tuple2;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* kafka-console-ui.
|
* kafka-console-ui.
|
||||||
*
|
*
|
||||||
@@ -81,8 +87,8 @@ public class TopicServiceImpl implements TopicService {
|
|||||||
return ResponseData.create().data(topicDescriptions.stream().map(d -> TopicDescriptionVO.from(d))).success();
|
return ResponseData.create().data(topicDescriptions.stream().map(d -> TopicDescriptionVO.from(d))).success();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public ResponseData deleteTopics(Collection<String> topics) {
|
@Override public ResponseData deleteTopic(String topic) {
|
||||||
Tuple2<Object, String> tuple2 = topicConsole.deleteTopics(topics);
|
Tuple2<Object, String> tuple2 = topicConsole.deleteTopic(topic);
|
||||||
return (Boolean) tuple2._1 ? ResponseData.create().success() : ResponseData.create().failed(tuple2._2);
|
return (Boolean) tuple2._1 ? ResponseData.create().success() : ResponseData.create().failed(tuple2._2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
23
src/main/java/com/xuxd/kafka/console/utils/ContextUtil.java
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
package com.xuxd.kafka.console.utils;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class ContextUtil {
|
||||||
|
|
||||||
|
public static final String USERNAME = "username" ;
|
||||||
|
|
||||||
|
private static ThreadLocal<Map<String, Object>> context = ThreadLocal.withInitial(() -> new HashMap<>());
|
||||||
|
|
||||||
|
public static void set(String key, Object value){
|
||||||
|
context.get().put(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String get(String key){
|
||||||
|
return (String) context.get().get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void clear(){
|
||||||
|
context.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,17 +1,15 @@
|
|||||||
package com.xuxd.kafka.console.utils;
|
package com.xuxd.kafka.console.utils;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.cglib.beans.BeanCopier;
|
||||||
|
import org.springframework.objenesis.ObjenesisStd;
|
||||||
|
import org.springframework.util.ClassUtils;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Properties;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.util.ClassUtils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* kafka-console-ui.
|
* kafka-console-ui.
|
||||||
@@ -22,6 +20,47 @@ import org.springframework.util.ClassUtils;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class ConvertUtil {
|
public class ConvertUtil {
|
||||||
|
|
||||||
|
private static ThreadLocal<ObjenesisStd> objenesisStdThreadLocal = ThreadLocal.withInitial(ObjenesisStd::new);
|
||||||
|
private static ConcurrentHashMap<Class<?>, ConcurrentHashMap<Class<?>, BeanCopier>> cache = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
public static <T> T copy(Object source, Class<T> target) {
|
||||||
|
return copy(source, objenesisStdThreadLocal.get().newInstance(target));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> T copy(Object source, T target) {
|
||||||
|
if (null == source) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
BeanCopier beanCopier = getCacheBeanCopier(source.getClass(), target.getClass());
|
||||||
|
beanCopier.copy(source, target, null);
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> List<T> copyList(List<?> sources, Class<T> target) {
|
||||||
|
if (sources.isEmpty()) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
ArrayList<T> list = new ArrayList<>(sources.size());
|
||||||
|
ObjenesisStd objenesisStd = objenesisStdThreadLocal.get();
|
||||||
|
for (Object source : sources) {
|
||||||
|
if (source == null) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
T newInstance = objenesisStd.newInstance(target);
|
||||||
|
BeanCopier beanCopier = getCacheBeanCopier(source.getClass(), target);
|
||||||
|
beanCopier.copy(source, newInstance, null);
|
||||||
|
list.add(newInstance);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static <S, T> BeanCopier getCacheBeanCopier(Class<S> source, Class<T> target) {
|
||||||
|
ConcurrentHashMap<Class<?>, BeanCopier> copierConcurrentHashMap =
|
||||||
|
cache.computeIfAbsent(source, aClass -> new ConcurrentHashMap<>(16));
|
||||||
|
return copierConcurrentHashMap.computeIfAbsent(target, aClass -> BeanCopier.create(source, target, false));
|
||||||
|
}
|
||||||
|
|
||||||
public static Map<String, Object> toMap(Object src) {
|
public static Map<String, Object> toMap(Object src) {
|
||||||
Preconditions.checkNotNull(src);
|
Preconditions.checkNotNull(src);
|
||||||
Map<String, Object> res = new HashMap<>();
|
Map<String, Object> res = new HashMap<>();
|
||||||
|
|||||||
43
src/main/java/com/xuxd/kafka/console/utils/JwtUtils.java
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
package com.xuxd.kafka.console.utils;
|
||||||
|
|
||||||
|
import io.jsonwebtoken.Claims;
|
||||||
|
import io.jsonwebtoken.Jwts;
|
||||||
|
import io.jsonwebtoken.SignatureAlgorithm;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class JwtUtils {
|
||||||
|
|
||||||
|
private static final String ISSUER = "kafka-console-ui";
|
||||||
|
private static final long EXPIRE_TIME = 5 * 24 * 60 * 60 * 1000;
|
||||||
|
private static final String PRIVATE_KEY = "~hello!kafka=console^ui";
|
||||||
|
|
||||||
|
public static String sign(String username){
|
||||||
|
Map<String,Object> header = new HashMap<>();
|
||||||
|
header.put("typ","JWT");
|
||||||
|
header.put("alg","HS256");
|
||||||
|
Map<String,Object> claims = new HashMap<>();
|
||||||
|
claims.put("username", username);
|
||||||
|
return Jwts.builder()
|
||||||
|
.setIssuer(ISSUER)
|
||||||
|
.setHeader(header)
|
||||||
|
.setClaims(claims)
|
||||||
|
.setIssuedAt(new Date())
|
||||||
|
.setExpiration(new Date(System.currentTimeMillis() + EXPIRE_TIME))
|
||||||
|
.signWith(SignatureAlgorithm.HS256, PRIVATE_KEY)
|
||||||
|
.compact();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String parse(String token){
|
||||||
|
try{
|
||||||
|
Claims claims = Jwts.parser()
|
||||||
|
.setSigningKey(PRIVATE_KEY)
|
||||||
|
.parseClaimsJws(token).getBody();
|
||||||
|
return (String) claims.get("username");
|
||||||
|
}catch (Exception e){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
12
src/main/java/com/xuxd/kafka/console/utils/Md5Utils.java
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
package com.xuxd.kafka.console.utils;
|
||||||
|
|
||||||
|
import org.springframework.util.DigestUtils;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
|
public class Md5Utils {
|
||||||
|
|
||||||
|
public static String MD5(String s) {
|
||||||
|
return DigestUtils.md5DigestAsHex(s.getBytes(StandardCharsets.UTF_8));
|
||||||
|
}
|
||||||
|
}
|
||||||
15
src/main/java/com/xuxd/kafka/console/utils/ResponseUtil.java
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
package com.xuxd.kafka.console.utils;
|
||||||
|
|
||||||
|
import com.xuxd.kafka.console.beans.ResponseData;
|
||||||
|
|
||||||
|
public class ResponseUtil {
|
||||||
|
|
||||||
|
public static <T> ResponseData<T> success(T data) {
|
||||||
|
return ResponseData.create().data(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ResponseData<String> error(String msg) {
|
||||||
|
return ResponseData.create().failed(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -12,14 +12,6 @@ kafka:
|
|||||||
# 集群其它属性配置
|
# 集群其它属性配置
|
||||||
properties:
|
properties:
|
||||||
# request.timeout.ms: 5000
|
# request.timeout.ms: 5000
|
||||||
# 缓存连接,不缓存的情况下,每次请求建立连接. 即使每次请求建立连接,其实也很快,某些情况下开启ACL,查询可能很慢,可以设置连接缓存为true,
|
|
||||||
# 或者想提高查询速度,也可以设置下面连接缓存为true
|
|
||||||
# 缓存 admin client的连接
|
|
||||||
cache-admin-connection: false
|
|
||||||
# 缓存 producer的连接
|
|
||||||
cache-producer-connection: false
|
|
||||||
# 缓存 consumer的连接
|
|
||||||
cache-consumer-connection: false
|
|
||||||
|
|
||||||
spring:
|
spring:
|
||||||
application:
|
application:
|
||||||
|
|||||||
@@ -29,9 +29,23 @@ CREATE TABLE IF NOT EXISTS T_CLUSTER_INFO
|
|||||||
(
|
(
|
||||||
ID IDENTITY NOT NULL COMMENT '主键ID',
|
ID IDENTITY NOT NULL COMMENT '主键ID',
|
||||||
CLUSTER_NAME VARCHAR(128) NOT NULL DEFAULT '' COMMENT '集群名',
|
CLUSTER_NAME VARCHAR(128) NOT NULL DEFAULT '' COMMENT '集群名',
|
||||||
ADDRESS VARCHAR(1024) NOT NULL DEFAULT '' COMMENT '集群地址',
|
ADDRESS VARCHAR(256) NOT NULL DEFAULT '' COMMENT '集群地址',
|
||||||
PROPERTIES VARCHAR(1024) NOT NULL DEFAULT '' COMMENT '集群的其它属性配置',
|
PROPERTIES VARCHAR(512) NOT NULL DEFAULT '' COMMENT '集群的其它属性配置',
|
||||||
UPDATE_TIME TIMESTAMP NOT NULL DEFAULT NOW() COMMENT '更新时间',
|
UPDATE_TIME TIMESTAMP NOT NULL DEFAULT NOW() COMMENT '更新时间',
|
||||||
PRIMARY KEY (ID),
|
PRIMARY KEY (ID),
|
||||||
UNIQUE (CLUSTER_NAME)
|
UNIQUE (CLUSTER_NAME)
|
||||||
|
);
|
||||||
|
|
||||||
|
-- 用户表
|
||||||
|
CREATE TABLE IF NOT EXISTS T_DEVOPS_USER
|
||||||
|
(
|
||||||
|
ID IDENTITY NOT NULL COMMENT '主键ID',
|
||||||
|
USERNAME VARCHAR(50) NOT NULL DEFAULT '' COMMENT '用户名',
|
||||||
|
PASSWORD VARCHAR(50) NOT NULL DEFAULT '' COMMENT '密码',
|
||||||
|
`ROLE` VARCHAR(16) NOT NULL DEFAULT 'developer' COMMENT '角色',
|
||||||
|
`DELETE` TINYINT(1) NOT NULL DEFAULT '' COMMENT '删除标记',
|
||||||
|
CREATE_TIME TIMESTAMP NOT NULL DEFAULT NOW() COMMENT '创建时间',
|
||||||
|
UPDATE_TIME TIMESTAMP NOT NULL DEFAULT NOW() COMMENT '更新时间',
|
||||||
|
PRIMARY KEY (ID),
|
||||||
|
UNIQUE (USERNAME)
|
||||||
);
|
);
|
||||||
@@ -18,7 +18,6 @@ import org.apache.kafka.common.network.Selector
|
|||||||
import org.apache.kafka.common.protocol.Errors
|
import org.apache.kafka.common.protocol.Errors
|
||||||
import org.apache.kafka.common.requests._
|
import org.apache.kafka.common.requests._
|
||||||
import org.apache.kafka.common.utils.{KafkaThread, LogContext, Time}
|
import org.apache.kafka.common.utils.{KafkaThread, LogContext, Time}
|
||||||
import org.slf4j.{Logger, LoggerFactory}
|
|
||||||
|
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.util.Properties
|
import java.util.Properties
|
||||||
@@ -35,9 +34,7 @@ import scala.util.{Failure, Success, Try}
|
|||||||
* @author xuxd
|
* @author xuxd
|
||||||
* @date 2022-01-22 15:15:57
|
* @date 2022-01-22 15:15:57
|
||||||
* */
|
* */
|
||||||
object BrokerApiVersion{
|
object BrokerApiVersion extends Logging {
|
||||||
|
|
||||||
protected lazy val log : Logger = LoggerFactory.getLogger(this.getClass)
|
|
||||||
|
|
||||||
def listAllBrokerApiVersionInfo(): java.util.HashMap[Node, NodeApiVersions] = {
|
def listAllBrokerApiVersionInfo(): java.util.HashMap[Node, NodeApiVersions] = {
|
||||||
val res = new java.util.HashMap[Node, NodeApiVersions]()
|
val res = new java.util.HashMap[Node, NodeApiVersions]()
|
||||||
@@ -51,7 +48,7 @@ object BrokerApiVersion{
|
|||||||
case Success(v) => {
|
case Success(v) => {
|
||||||
res.put(broker, v)
|
res.put(broker, v)
|
||||||
}
|
}
|
||||||
case Failure(v) => log.error(s"${broker} -> ERROR: ${v}\n")
|
case Failure(v) => logger.error(s"${broker} -> ERROR: ${v}\n")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
@@ -152,12 +149,12 @@ object BrokerApiVersion{
|
|||||||
val response = sendAnyNode(request).asInstanceOf[MetadataResponse]
|
val response = sendAnyNode(request).asInstanceOf[MetadataResponse]
|
||||||
val errors = response.errors
|
val errors = response.errors
|
||||||
if (!errors.isEmpty) {
|
if (!errors.isEmpty) {
|
||||||
log.info(s"Metadata request contained errors: $errors")
|
logger.info(s"Metadata request contained errors: $errors")
|
||||||
}
|
}
|
||||||
|
|
||||||
// 在3.x版本中这个方法是buildCluster 代替cluster()了
|
// 在3.x版本中这个方法是buildCluster 代替cluster()了
|
||||||
response.buildCluster.nodes.asScala.toList
|
// response.buildCluster.nodes.asScala.toList
|
||||||
// response.cluster().nodes.asScala.toList
|
response.cluster().nodes.asScala.toList
|
||||||
}
|
}
|
||||||
|
|
||||||
def listAllBrokerVersionInfo(): Map[Node, Try[NodeApiVersions]] =
|
def listAllBrokerVersionInfo(): Map[Node, Try[NodeApiVersions]] =
|
||||||
@@ -280,40 +277,40 @@ object BrokerApiVersion{
|
|||||||
|
|
||||||
// 版本不一样,这个地方的兼容性问题也不一样了
|
// 版本不一样,这个地方的兼容性问题也不一样了
|
||||||
// 3.x版本用这个
|
// 3.x版本用这个
|
||||||
val networkClient = new NetworkClient(
|
// val networkClient = new NetworkClient(
|
||||||
selector,
|
// selector,
|
||||||
metadata,
|
// metadata,
|
||||||
clientId,
|
// clientId,
|
||||||
DefaultMaxInFlightRequestsPerConnection,
|
// DefaultMaxInFlightRequestsPerConnection,
|
||||||
DefaultReconnectBackoffMs,
|
// DefaultReconnectBackoffMs,
|
||||||
DefaultReconnectBackoffMax,
|
// DefaultReconnectBackoffMax,
|
||||||
DefaultSendBufferBytes,
|
// DefaultSendBufferBytes,
|
||||||
DefaultReceiveBufferBytes,
|
// DefaultReceiveBufferBytes,
|
||||||
requestTimeoutMs,
|
// requestTimeoutMs,
|
||||||
connectionSetupTimeoutMs,
|
// connectionSetupTimeoutMs,
|
||||||
connectionSetupTimeoutMaxMs,
|
// connectionSetupTimeoutMaxMs,
|
||||||
time,
|
// time,
|
||||||
true,
|
// true,
|
||||||
new ApiVersions,
|
// new ApiVersions,
|
||||||
logContext)
|
// logContext)
|
||||||
|
|
||||||
// val networkClient = new NetworkClient(
|
val networkClient = new NetworkClient(
|
||||||
// selector,
|
selector,
|
||||||
// metadata,
|
metadata,
|
||||||
// clientId,
|
clientId,
|
||||||
// DefaultMaxInFlightRequestsPerConnection,
|
DefaultMaxInFlightRequestsPerConnection,
|
||||||
// DefaultReconnectBackoffMs,
|
DefaultReconnectBackoffMs,
|
||||||
// DefaultReconnectBackoffMax,
|
DefaultReconnectBackoffMax,
|
||||||
// DefaultSendBufferBytes,
|
DefaultSendBufferBytes,
|
||||||
// DefaultReceiveBufferBytes,
|
DefaultReceiveBufferBytes,
|
||||||
// requestTimeoutMs,
|
requestTimeoutMs,
|
||||||
// connectionSetupTimeoutMs,
|
connectionSetupTimeoutMs,
|
||||||
// connectionSetupTimeoutMaxMs,
|
connectionSetupTimeoutMaxMs,
|
||||||
// ClientDnsLookup.USE_ALL_DNS_IPS,
|
ClientDnsLookup.USE_ALL_DNS_IPS,
|
||||||
// time,
|
time,
|
||||||
// true,
|
true,
|
||||||
// new ApiVersions,
|
new ApiVersions,
|
||||||
// logContext)
|
logContext)
|
||||||
|
|
||||||
val highLevelClient = new ConsumerNetworkClient(
|
val highLevelClient = new ConsumerNetworkClient(
|
||||||
logContext,
|
logContext,
|
||||||
|
|||||||
@@ -1,84 +0,0 @@
|
|||||||
package kafka.console
|
|
||||||
|
|
||||||
import com.xuxd.kafka.console.config.KafkaConfig
|
|
||||||
import org.apache.kafka.clients.admin.{Admin, AlterClientQuotasOptions}
|
|
||||||
import org.apache.kafka.common.quota.{ClientQuotaAlteration, ClientQuotaEntity, ClientQuotaFilter, ClientQuotaFilterComponent}
|
|
||||||
|
|
||||||
import java.util.Collections
|
|
||||||
import java.util.concurrent.TimeUnit
|
|
||||||
import scala.jdk.CollectionConverters.{IterableHasAsJava, ListHasAsScala, MapHasAsScala, SeqHasAsJava}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* client quota console.
|
|
||||||
*
|
|
||||||
* @author xuxd
|
|
||||||
* @date 2022-12-30 10:55:56
|
|
||||||
* */
|
|
||||||
class ClientQuotaConsole(config: KafkaConfig) extends KafkaConsole(config: KafkaConfig) with Logging {
|
|
||||||
|
|
||||||
|
|
||||||
def getClientQuotasConfigs(entityTypes: java.util.List[String], entityNames: java.util.List[String]): java.util.Map[ClientQuotaEntity, java.util.Map[String, Double]] = {
|
|
||||||
withAdminClientAndCatchError(admin => getAllClientQuotasConfigs(admin, entityTypes.asScala.toList, entityNames.asScala.toList),
|
|
||||||
e => {
|
|
||||||
log.error("getAllClientQuotasConfigs error.", e)
|
|
||||||
java.util.Collections.emptyMap()
|
|
||||||
})
|
|
||||||
}.asInstanceOf[java.util.Map[ClientQuotaEntity, java.util.Map[String, Double]]]
|
|
||||||
|
|
||||||
def addQuotaConfigs(entityTypes: java.util.List[String], entityNames: java.util.List[String], configsToBeAddedMap: java.util.Map[String, String]): (Boolean, String) = {
|
|
||||||
alterQuotaConfigs(entityTypes, entityNames, configsToBeAddedMap, Collections.emptyList())
|
|
||||||
}
|
|
||||||
|
|
||||||
def deleteQuotaConfigs(entityTypes: java.util.List[String], entityNames: java.util.List[String], configsToBeDeleted: java.util.List[String]): (Boolean, String) = {
|
|
||||||
alterQuotaConfigs(entityTypes, entityNames, Collections.emptyMap(), configsToBeDeleted)
|
|
||||||
}
|
|
||||||
|
|
||||||
def alterQuotaConfigs(entityTypes: java.util.List[String], entityNames: java.util.List[String], configsToBeAddedMap: java.util.Map[String, String], configsToBeDeleted: java.util.List[String]): (Boolean, String) = {
|
|
||||||
withAdminClientAndCatchError(admin => {
|
|
||||||
alterQuotaConfigsInner(admin, entityTypes.asScala.toList, entityNames.asScala.toList, configsToBeAddedMap.asScala.toMap, configsToBeDeleted.asScala.toSeq)
|
|
||||||
(true, "")
|
|
||||||
},
|
|
||||||
e => {
|
|
||||||
log.error("getAllClientQuotasConfigs error.", e)
|
|
||||||
(false, e.getMessage)
|
|
||||||
}).asInstanceOf[(Boolean, String)]
|
|
||||||
}
|
|
||||||
|
|
||||||
private def getAllClientQuotasConfigs(adminClient: Admin, entityTypes: List[String], entityNames: List[String]): java.util.Map[ClientQuotaEntity, java.util.Map[String, Double]] = {
|
|
||||||
val components = entityTypes.map(Some(_)).zipAll(entityNames.map(Some(_)), None, None).map { case (entityType, entityNameOpt) =>
|
|
||||||
entityNameOpt match {
|
|
||||||
case Some("") => ClientQuotaFilterComponent.ofDefaultEntity(entityType.get)
|
|
||||||
case Some(name) => ClientQuotaFilterComponent.ofEntity(entityType.get, name)
|
|
||||||
case None => ClientQuotaFilterComponent.ofEntityType(entityType.get)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
adminClient.describeClientQuotas(ClientQuotaFilter.containsOnly(components.asJava)).entities.get(30, TimeUnit.SECONDS)
|
|
||||||
}.asInstanceOf[java.util.Map[ClientQuotaEntity, java.util.Map[String, Double]]]
|
|
||||||
|
|
||||||
private def alterQuotaConfigsInner(adminClient: Admin, entityTypes: List[String], entityNames: List[String], configsToBeAddedMap: Map[String, String], configsToBeDeleted: Seq[String]) = {
|
|
||||||
// handle altering client/user quota configs
|
|
||||||
// val oldConfig = getAllClientQuotasConfigs(adminClient, entityTypes, entityNames)
|
|
||||||
// val invalidConfigs = configsToBeDeleted.filterNot(oldConfig.asScala.toMap.contains)
|
|
||||||
// if (invalidConfigs.nonEmpty)
|
|
||||||
// throw new InvalidConfigurationException(s"Invalid config(s): ${invalidConfigs.mkString(",")}")
|
|
||||||
|
|
||||||
val alterEntityNames = entityNames.map(en => if (en.nonEmpty) en else null)
|
|
||||||
// Explicitly populate a HashMap to ensure nulls are recorded properly.
|
|
||||||
val alterEntityMap = new java.util.HashMap[String, String]
|
|
||||||
entityTypes.zip(alterEntityNames).foreach { case (k, v) => alterEntityMap.put(k, v) }
|
|
||||||
val entity = new ClientQuotaEntity(alterEntityMap)
|
|
||||||
|
|
||||||
val alterOptions = new AlterClientQuotasOptions().validateOnly(false)
|
|
||||||
val alterOps = (configsToBeAddedMap.map { case (key, value) =>
|
|
||||||
val doubleValue = try value.toDouble catch {
|
|
||||||
case _: NumberFormatException =>
|
|
||||||
throw new IllegalArgumentException(s"Cannot parse quota configuration value for $key: $value")
|
|
||||||
}
|
|
||||||
new ClientQuotaAlteration.Op(key, doubleValue)
|
|
||||||
} ++ configsToBeDeleted.map(key => new ClientQuotaAlteration.Op(key, null))).asJavaCollection
|
|
||||||
|
|
||||||
adminClient.alterClientQuotas(Collections.singleton(new ClientQuotaAlteration(entity, alterOps)), alterOptions)
|
|
||||||
.all().get(60, TimeUnit.SECONDS)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,21 +1,18 @@
|
|||||||
package kafka.console
|
package kafka.console
|
||||||
|
|
||||||
import com.google.common.cache.{CacheLoader, RemovalListener, RemovalNotification}
|
|
||||||
import com.xuxd.kafka.console.cache.TimeBasedCache
|
|
||||||
import com.xuxd.kafka.console.config.{ContextConfigHolder, KafkaConfig}
|
import com.xuxd.kafka.console.config.{ContextConfigHolder, KafkaConfig}
|
||||||
import kafka.zk.AdminZkClient
|
import kafka.zk.{AdminZkClient, KafkaZkClient}
|
||||||
import org.apache.kafka.clients.admin._
|
import org.apache.kafka.clients.admin._
|
||||||
import org.apache.kafka.clients.consumer.{ConsumerConfig, KafkaConsumer, OffsetAndMetadata}
|
import org.apache.kafka.clients.consumer.{ConsumerConfig, KafkaConsumer, OffsetAndMetadata}
|
||||||
import org.apache.kafka.clients.producer.KafkaProducer
|
import org.apache.kafka.clients.producer.KafkaProducer
|
||||||
import org.apache.kafka.common.TopicPartition
|
import org.apache.kafka.common.TopicPartition
|
||||||
import org.apache.kafka.common.requests.ListOffsetsResponse
|
import org.apache.kafka.common.requests.ListOffsetsResponse
|
||||||
import org.apache.kafka.common.serialization.{ByteArrayDeserializer, ByteArraySerializer, StringSerializer}
|
import org.apache.kafka.common.serialization.{ByteArrayDeserializer, ByteArraySerializer, StringSerializer}
|
||||||
|
import org.apache.kafka.common.utils.Time
|
||||||
import org.slf4j.{Logger, LoggerFactory}
|
import org.slf4j.{Logger, LoggerFactory}
|
||||||
|
|
||||||
import java.util.Properties
|
import java.util.Properties
|
||||||
import java.util.concurrent.Executors
|
|
||||||
import scala.collection.{Map, Seq}
|
import scala.collection.{Map, Seq}
|
||||||
import scala.concurrent.{ExecutionContext, Future}
|
|
||||||
import scala.jdk.CollectionConverters.{MapHasAsJava, MapHasAsScala}
|
import scala.jdk.CollectionConverters.{MapHasAsJava, MapHasAsScala}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -30,13 +27,11 @@ class KafkaConsole(config: KafkaConfig) {
|
|||||||
|
|
||||||
protected def withAdminClient(f: Admin => Any): Any = {
|
protected def withAdminClient(f: Admin => Any): Any = {
|
||||||
|
|
||||||
val admin = if (config.isCacheAdminConnection()) AdminCache.cache.get(ContextConfigHolder.CONTEXT_CONFIG.get().getBootstrapServer()) else createAdminClient()
|
val admin = createAdminClient()
|
||||||
try {
|
try {
|
||||||
f(admin)
|
f(admin)
|
||||||
} finally {
|
} finally {
|
||||||
if (!config.isCacheAdminConnection) {
|
admin.close()
|
||||||
admin.close()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,40 +45,33 @@ class KafkaConsole(config: KafkaConfig) {
|
|||||||
|
|
||||||
protected def withConsumerAndCatchError(f: KafkaConsumer[Array[Byte], Array[Byte]] => Any, eh: Exception => Any,
|
protected def withConsumerAndCatchError(f: KafkaConsumer[Array[Byte], Array[Byte]] => Any, eh: Exception => Any,
|
||||||
extra: Properties = new Properties()): Any = {
|
extra: Properties = new Properties()): Any = {
|
||||||
// val props = getProps()
|
val props = getProps()
|
||||||
// props.putAll(extra)
|
props.putAll(extra)
|
||||||
// props.put(ConsumerConfig.CLIENT_ID_CONFIG, String.valueOf(System.currentTimeMillis()))
|
props.put(ConsumerConfig.CLIENT_ID_CONFIG, String.valueOf(System.currentTimeMillis()))
|
||||||
// val consumer = new KafkaConsumer(props, new ByteArrayDeserializer, new ByteArrayDeserializer)
|
val consumer = new KafkaConsumer(props, new ByteArrayDeserializer, new ByteArrayDeserializer)
|
||||||
ConsumerCache.setProperties(extra)
|
|
||||||
val consumer = if (config.isCacheConsumerConnection) ConsumerCache.cache.get(ContextConfigHolder.CONTEXT_CONFIG.get().getBootstrapServer()) else KafkaConsole.createByteArrayKVConsumer(extra)
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
f(consumer)
|
f(consumer)
|
||||||
} catch {
|
} catch {
|
||||||
case er: Exception => eh(er)
|
case er: Exception => eh(er)
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
ConsumerCache.clearProperties()
|
consumer.close()
|
||||||
if (!config.isCacheConsumerConnection) {
|
|
||||||
consumer.close()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected def withProducerAndCatchError(f: KafkaProducer[String, String] => Any, eh: Exception => Any,
|
protected def withProducerAndCatchError(f: KafkaProducer[String, String] => Any, eh: Exception => Any,
|
||||||
extra: Properties = new Properties()): Any = {
|
extra: Properties = new Properties()): Any = {
|
||||||
ProducerCache.setProperties(extra)
|
val props = getProps()
|
||||||
val producer = if (config.isCacheProducerConnection) ProducerCache.cache.get(ContextConfigHolder.CONTEXT_CONFIG.get().getBootstrapServer) else KafkaConsole.createProducer(extra)
|
props.putAll(extra)
|
||||||
|
props.put(ConsumerConfig.CLIENT_ID_CONFIG, String.valueOf(System.currentTimeMillis()))
|
||||||
|
val producer = new KafkaProducer[String, String](props, new StringSerializer, new StringSerializer)
|
||||||
try {
|
try {
|
||||||
f(producer)
|
f(producer)
|
||||||
} catch {
|
} catch {
|
||||||
case er: Exception => eh(er)
|
case er: Exception => eh(er)
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
ProducerCache.clearProperties()
|
producer.close()
|
||||||
if (!config.isCacheProducerConnection) {
|
|
||||||
producer.close()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,6 +79,7 @@ class KafkaConsole(config: KafkaConfig) {
|
|||||||
extra: Properties = new Properties()): Any = {
|
extra: Properties = new Properties()): Any = {
|
||||||
val props = getProps()
|
val props = getProps()
|
||||||
props.putAll(extra)
|
props.putAll(extra)
|
||||||
|
props.put(ConsumerConfig.CLIENT_ID_CONFIG, String.valueOf(System.currentTimeMillis()))
|
||||||
val producer = new KafkaProducer[Array[Byte], Array[Byte]](props, new ByteArraySerializer, new ByteArraySerializer)
|
val producer = new KafkaProducer[Array[Byte], Array[Byte]](props, new ByteArraySerializer, new ByteArraySerializer)
|
||||||
try {
|
try {
|
||||||
f(producer)
|
f(producer)
|
||||||
@@ -102,17 +91,14 @@ class KafkaConsole(config: KafkaConfig) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
protected def withZKClient(f: AdminZkClient => Any): Any = {
|
protected def withZKClient(f: AdminZkClient => Any): Any = {
|
||||||
// val zkClient = KafkaZkClient(config.getZookeeperAddr, false, 30000, 30000, Int.MaxValue, Time.SYSTEM)
|
val zkClient = KafkaZkClient(config.getZookeeperAddr, false, 30000, 30000, Int.MaxValue, Time.SYSTEM)
|
||||||
// 3.x
|
val adminZkClient = new AdminZkClient(zkClient)
|
||||||
// val zkClient = KafkaZkClient(config.getZookeeperAddr, false, 30000, 30000, Int.MaxValue, Time.SYSTEM, new ZKClientConfig(), "KafkaZkClient")
|
try {
|
||||||
// val adminZkClient = new AdminZkClient(zkClient)
|
f(adminZkClient)
|
||||||
// try {
|
} finally {
|
||||||
// f(adminZkClient)
|
zkClient.close()
|
||||||
// } finally {
|
}
|
||||||
// zkClient.close()
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected def createAdminClient(props: Properties): Admin = {
|
protected def createAdminClient(props: Properties): Admin = {
|
||||||
@@ -124,47 +110,20 @@ class KafkaConsole(config: KafkaConfig) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private def createAdminClient(): Admin = {
|
private def createAdminClient(): Admin = {
|
||||||
KafkaConsole.createAdminClient()
|
|
||||||
}
|
|
||||||
|
|
||||||
private def getProps(): Properties = {
|
|
||||||
KafkaConsole.getProps()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
object KafkaConsole {
|
|
||||||
val log: Logger = LoggerFactory.getLogger(this.getClass)
|
|
||||||
|
|
||||||
def createAdminClient(): Admin = {
|
|
||||||
Admin.create(getProps())
|
Admin.create(getProps())
|
||||||
}
|
}
|
||||||
|
|
||||||
def createByteArrayKVConsumer(extra: Properties) : KafkaConsumer[Array[Byte], Array[Byte]] = {
|
private def getProps(): Properties = {
|
||||||
val props = getProps()
|
|
||||||
props.putAll(extra)
|
|
||||||
props.put(ConsumerConfig.CLIENT_ID_CONFIG, String.valueOf(System.currentTimeMillis()))
|
|
||||||
new KafkaConsumer(props, new ByteArrayDeserializer, new ByteArrayDeserializer)
|
|
||||||
}
|
|
||||||
|
|
||||||
def createProducer(extra: Properties) : KafkaProducer[String, String] = {
|
|
||||||
val props = getProps()
|
|
||||||
props.putAll(extra)
|
|
||||||
new KafkaProducer(props, new StringSerializer, new StringSerializer)
|
|
||||||
}
|
|
||||||
|
|
||||||
def createByteArrayStringProducer(extra: Properties) : KafkaProducer[Array[Byte], Array[Byte]] = {
|
|
||||||
val props = getProps()
|
|
||||||
props.putAll(extra)
|
|
||||||
new KafkaProducer(props, new ByteArraySerializer, new ByteArraySerializer)
|
|
||||||
}
|
|
||||||
|
|
||||||
def getProps(): Properties = {
|
|
||||||
val props: Properties = new Properties();
|
val props: Properties = new Properties();
|
||||||
props.put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, ContextConfigHolder.CONTEXT_CONFIG.get().getBootstrapServer())
|
props.put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, ContextConfigHolder.CONTEXT_CONFIG.get().getBootstrapServer())
|
||||||
props.put(AdminClientConfig.REQUEST_TIMEOUT_MS_CONFIG, ContextConfigHolder.CONTEXT_CONFIG.get().getRequestTimeoutMs())
|
props.put(AdminClientConfig.REQUEST_TIMEOUT_MS_CONFIG, ContextConfigHolder.CONTEXT_CONFIG.get().getRequestTimeoutMs())
|
||||||
props.putAll(ContextConfigHolder.CONTEXT_CONFIG.get().getProperties())
|
props.putAll(ContextConfigHolder.CONTEXT_CONFIG.get().getProperties())
|
||||||
props
|
props
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
object KafkaConsole {
|
||||||
|
val log: Logger = LoggerFactory.getLogger(this.getClass)
|
||||||
|
|
||||||
def getCommittedOffsets(admin: Admin, groupId: String,
|
def getCommittedOffsets(admin: Admin, groupId: String,
|
||||||
timeoutMs: Integer): Map[TopicPartition, OffsetAndMetadata] = {
|
timeoutMs: Integer): Map[TopicPartition, OffsetAndMetadata] = {
|
||||||
@@ -215,88 +174,4 @@ object KafkaConsole {
|
|||||||
}.toMap
|
}.toMap
|
||||||
res
|
res
|
||||||
}
|
}
|
||||||
implicit val ec = ExecutionContext.fromExecutorService(Executors.newFixedThreadPool(2))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
object AdminCache {
|
|
||||||
|
|
||||||
private val log: Logger = LoggerFactory.getLogger(this.getClass)
|
|
||||||
|
|
||||||
private val cacheLoader = new CacheLoader[String, Admin] {
|
|
||||||
override def load(key: String): Admin = KafkaConsole.createAdminClient()
|
|
||||||
}
|
|
||||||
|
|
||||||
private val removeListener = new RemovalListener[String, Admin] {
|
|
||||||
override def onRemoval(notification: RemovalNotification[String, Admin]): Unit = {
|
|
||||||
Future {
|
|
||||||
log.warn("Close expired admin connection: {}", notification.getKey)
|
|
||||||
notification.getValue.close()
|
|
||||||
log.warn("Close expired admin connection complete: {}", notification.getKey)
|
|
||||||
}(KafkaConsole.ec)
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
val cache = new TimeBasedCache[String, Admin](cacheLoader, removeListener)
|
|
||||||
}
|
|
||||||
|
|
||||||
object ConsumerCache {
|
|
||||||
|
|
||||||
private val log: Logger = LoggerFactory.getLogger(this.getClass)
|
|
||||||
|
|
||||||
private val threadLocal = new ThreadLocal[Properties]
|
|
||||||
|
|
||||||
private val cacheLoader = new CacheLoader[String, KafkaConsumer[Array[Byte], Array[Byte]]] {
|
|
||||||
override def load(key: String): KafkaConsumer[Array[Byte], Array[Byte]] = KafkaConsole.createByteArrayKVConsumer(threadLocal.get())
|
|
||||||
}
|
|
||||||
|
|
||||||
private val removeListener = new RemovalListener[String, KafkaConsumer[Array[Byte], Array[Byte]]] {
|
|
||||||
override def onRemoval(notification: RemovalNotification[String, KafkaConsumer[Array[Byte], Array[Byte]]]): Unit = {
|
|
||||||
Future {
|
|
||||||
log.warn("Close expired consumer connection: {}", notification.getKey)
|
|
||||||
notification.getValue.close()
|
|
||||||
log.warn("Close expired consumer connection complete: {}", notification.getKey)
|
|
||||||
}(KafkaConsole.ec)
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
val cache = new TimeBasedCache[String, KafkaConsumer[Array[Byte], Array[Byte]]](cacheLoader, removeListener)
|
|
||||||
|
|
||||||
def setProperties(props : Properties) : Unit = {
|
|
||||||
threadLocal.set(props)
|
|
||||||
}
|
|
||||||
|
|
||||||
def clearProperties() : Unit = {
|
|
||||||
threadLocal.remove()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
object ProducerCache {
|
|
||||||
|
|
||||||
private val log: Logger = LoggerFactory.getLogger(this.getClass)
|
|
||||||
|
|
||||||
private val threadLocal = new ThreadLocal[Properties]
|
|
||||||
|
|
||||||
private val cacheLoader = new CacheLoader[String, KafkaProducer[String, String]] {
|
|
||||||
override def load(key: String): KafkaProducer[String, String] = KafkaConsole.createProducer(threadLocal.get())
|
|
||||||
}
|
|
||||||
|
|
||||||
private val removeListener = new RemovalListener[String, KafkaProducer[String, String]] {
|
|
||||||
override def onRemoval(notification: RemovalNotification[String, KafkaProducer[String, String]]): Unit = {
|
|
||||||
Future {
|
|
||||||
log.warn("Close expired producer connection: {}", notification.getKey)
|
|
||||||
notification.getValue.close()
|
|
||||||
log.warn("Close expired producer connection complete: {}", notification.getKey)
|
|
||||||
}(KafkaConsole.ec)
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
val cache = new TimeBasedCache[String, KafkaProducer[String, String]](cacheLoader, removeListener)
|
|
||||||
|
|
||||||
def setProperties(props : Properties) : Unit = {
|
|
||||||
threadLocal.set(props)
|
|
||||||
}
|
|
||||||
|
|
||||||
def clearProperties() : Unit = {
|
|
||||||
threadLocal.remove()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -4,14 +4,13 @@ import com.xuxd.kafka.console.beans.MessageFilter
|
|||||||
import com.xuxd.kafka.console.beans.enums.FilterType
|
import com.xuxd.kafka.console.beans.enums.FilterType
|
||||||
import com.xuxd.kafka.console.config.{ContextConfigHolder, KafkaConfig}
|
import com.xuxd.kafka.console.config.{ContextConfigHolder, KafkaConfig}
|
||||||
import org.apache.commons.lang3.StringUtils
|
import org.apache.commons.lang3.StringUtils
|
||||||
import org.apache.kafka.clients.admin.{DeleteRecordsOptions, RecordsToDelete}
|
|
||||||
import org.apache.kafka.clients.consumer.{ConsumerConfig, ConsumerRecord}
|
import org.apache.kafka.clients.consumer.{ConsumerConfig, ConsumerRecord}
|
||||||
import org.apache.kafka.clients.producer.ProducerRecord
|
import org.apache.kafka.clients.producer.ProducerRecord
|
||||||
import org.apache.kafka.common.TopicPartition
|
import org.apache.kafka.common.TopicPartition
|
||||||
|
|
||||||
import java.time.Duration
|
import java.time.Duration
|
||||||
import java.util
|
import java.util
|
||||||
import java.util.{Properties}
|
import java.util.Properties
|
||||||
import scala.collection.immutable
|
import scala.collection.immutable
|
||||||
import scala.jdk.CollectionConverters.{CollectionHasAsScala, MapHasAsScala, SeqHasAsJava}
|
import scala.jdk.CollectionConverters.{CollectionHasAsScala, MapHasAsScala, SeqHasAsJava}
|
||||||
|
|
||||||
@@ -128,7 +127,7 @@ class MessageConsole(config: KafkaConfig) extends KafkaConsole(config: KafkaConf
|
|||||||
record.offset(),
|
record.offset(),
|
||||||
record.timestamp(),
|
record.timestamp(),
|
||||||
record.timestampType(),
|
record.timestampType(),
|
||||||
// record.checksum(),
|
record.checksum(),
|
||||||
record.serializedKeySize(),
|
record.serializedKeySize(),
|
||||||
record.serializedValueSize(),
|
record.serializedValueSize(),
|
||||||
record.key(),
|
record.key(),
|
||||||
@@ -237,14 +236,4 @@ class MessageConsole(config: KafkaConfig) extends KafkaConsole(config: KafkaConf
|
|||||||
(false, e.getMessage)
|
(false, e.getMessage)
|
||||||
}).asInstanceOf[(Boolean, String)]
|
}).asInstanceOf[(Boolean, String)]
|
||||||
}
|
}
|
||||||
|
|
||||||
def delete(recordsToDelete: util.Map[TopicPartition, RecordsToDelete]): (Boolean, String) = {
|
|
||||||
withAdminClientAndCatchError(admin => {
|
|
||||||
admin.deleteRecords(recordsToDelete, withTimeoutMs(new DeleteRecordsOptions())).all().get()
|
|
||||||
(true, "")
|
|
||||||
}, e => {
|
|
||||||
log.error("delete message error.", e)
|
|
||||||
(false, "delete error :" + e.getMessage)
|
|
||||||
}).asInstanceOf[(Boolean, String)]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,17 +66,17 @@ class TopicConsole(config: KafkaConfig) extends KafkaConsole(config: KafkaConfig
|
|||||||
/**
|
/**
|
||||||
* delete topic by topic name.
|
* delete topic by topic name.
|
||||||
*
|
*
|
||||||
* @param topics topic name list.
|
* @param topic topic name.
|
||||||
* @return result or : fail message.
|
* @return result or : fail message.
|
||||||
*/
|
*/
|
||||||
def deleteTopics(topics: util.Collection[String]): (Boolean, String) = {
|
def deleteTopic(topic: String): (Boolean, String) = {
|
||||||
withAdminClientAndCatchError(admin => {
|
withAdminClientAndCatchError(admin => {
|
||||||
val timeoutMs = ContextConfigHolder.CONTEXT_CONFIG.get().getRequestTimeoutMs()
|
val timeoutMs = ContextConfigHolder.CONTEXT_CONFIG.get().getRequestTimeoutMs()
|
||||||
admin.deleteTopics(topics, new DeleteTopicsOptions().retryOnQuotaViolation(false)).all().get(timeoutMs, TimeUnit.MILLISECONDS)
|
admin.deleteTopics(Collections.singleton(topic), new DeleteTopicsOptions().retryOnQuotaViolation(false)).all().get(timeoutMs, TimeUnit.MILLISECONDS)
|
||||||
(true, "")
|
(true, "")
|
||||||
},
|
},
|
||||||
e => {
|
e => {
|
||||||
log.error("delete topic error, topic: " + topics, e)
|
log.error("delete topic error, topic: " + topic, e)
|
||||||
(false, e.getMessage)
|
(false, e.getMessage)
|
||||||
}).asInstanceOf[(Boolean, String)]
|
}).asInstanceOf[(Boolean, String)]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,48 +0,0 @@
|
|||||||
package com.xuxd.kafka.console.scala;
|
|
||||||
|
|
||||||
import com.xuxd.kafka.console.config.ContextConfig;
|
|
||||||
import com.xuxd.kafka.console.config.ContextConfigHolder;
|
|
||||||
import com.xuxd.kafka.console.config.KafkaConfig;
|
|
||||||
import kafka.console.ClientQuotaConsole;
|
|
||||||
import org.apache.kafka.common.config.internals.QuotaConfigs;
|
|
||||||
import org.apache.kafka.common.quota.ClientQuotaEntity;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class ClientQuotaConsoleTest {
|
|
||||||
|
|
||||||
String bootstrapServer = "localhost:9092";
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void testGetClientQuotasConfigs() {
|
|
||||||
ClientQuotaConsole console = new ClientQuotaConsole(new KafkaConfig());
|
|
||||||
ContextConfig config = new ContextConfig();
|
|
||||||
config.setBootstrapServer(bootstrapServer);
|
|
||||||
ContextConfigHolder.CONTEXT_CONFIG.set(config);
|
|
||||||
Map<ClientQuotaEntity, Map<String, Object>> configs = console.getClientQuotasConfigs(Arrays.asList(ClientQuotaEntity.USER, ClientQuotaEntity.CLIENT_ID), Arrays.asList("user1", "clientA"));
|
|
||||||
configs.forEach((k, v) -> {
|
|
||||||
System.out.println(k);
|
|
||||||
System.out.println(v);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void testAlterClientQuotasConfigs() {
|
|
||||||
ClientQuotaConsole console = new ClientQuotaConsole(new KafkaConfig());
|
|
||||||
ContextConfig config = new ContextConfig();
|
|
||||||
config.setBootstrapServer(bootstrapServer);
|
|
||||||
ContextConfigHolder.CONTEXT_CONFIG.set(config);
|
|
||||||
Map<String, String> configsToBeAddedMap = new HashMap<>();
|
|
||||||
configsToBeAddedMap.put(QuotaConfigs.PRODUCER_BYTE_RATE_OVERRIDE_CONFIG, "1024000000");
|
|
||||||
|
|
||||||
console.addQuotaConfigs(Arrays.asList(ClientQuotaEntity.USER), Arrays.asList("user-test"), configsToBeAddedMap);
|
|
||||||
console.addQuotaConfigs(Arrays.asList(ClientQuotaEntity.USER), Arrays.asList(""), configsToBeAddedMap);
|
|
||||||
console.addQuotaConfigs(Arrays.asList(ClientQuotaEntity.CLIENT_ID), Arrays.asList(""), configsToBeAddedMap);
|
|
||||||
console.addQuotaConfigs(Arrays.asList(ClientQuotaEntity.CLIENT_ID), Arrays.asList("clientA"), configsToBeAddedMap);
|
|
||||||
console.addQuotaConfigs(Arrays.asList(ClientQuotaEntity.USER, ClientQuotaEntity.CLIENT_ID), Arrays.asList("", ""), configsToBeAddedMap);
|
|
||||||
// console.deleteQuotaConfigs(Arrays.asList(ClientQuotaEntity.CLIENT_ID), Arrays.asList(""), Arrays.asList(QuotaConfigs.CONSUMER_BYTE_RATE_OVERRIDE_CONFIG));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
13125
ui/package-lock.json
generated
@@ -17,11 +17,6 @@
|
|||||||
"vuex": "^3.4.0"
|
"vuex": "^3.4.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@vue/cli-plugin-babel": "~4.5.0",
|
|
||||||
"@vue/cli-plugin-eslint": "~4.5.0",
|
|
||||||
"@vue/cli-plugin-router": "~4.5.0",
|
|
||||||
"@vue/cli-plugin-vuex": "~4.5.0",
|
|
||||||
"@vue/cli-service": "~4.5.0",
|
|
||||||
"@vue/eslint-config-prettier": "^6.0.0",
|
"@vue/eslint-config-prettier": "^6.0.0",
|
||||||
"babel-eslint": "^10.1.0",
|
"babel-eslint": "^10.1.0",
|
||||||
"eslint": "^6.7.2",
|
"eslint": "^6.7.2",
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 4.2 KiB |
|
Before Width: | Height: | Size: 4.2 KiB |
126
ui/src/App.vue
@@ -1,127 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div id="app">
|
<div id="app">
|
||||||
<div id="nav">
|
<router-view />
|
||||||
<h2 class="logo">Kafka 控制台</h2>
|
|
||||||
<router-link to="/" class="pad-l-r">主页</router-link>
|
|
||||||
<span>|</span
|
|
||||||
><router-link to="/cluster-page" class="pad-l-r">集群</router-link>
|
|
||||||
<span>|</span
|
|
||||||
><router-link to="/topic-page" class="pad-l-r">Topic</router-link>
|
|
||||||
<span>|</span
|
|
||||||
><router-link to="/group-page" class="pad-l-r">消费组</router-link>
|
|
||||||
<span>|</span
|
|
||||||
><router-link to="/message-page" class="pad-l-r">消息</router-link>
|
|
||||||
<span>|</span
|
|
||||||
><router-link to="/client-quota-page" class="pad-l-r">限流</router-link>
|
|
||||||
<span>|</span
|
|
||||||
><router-link to="/acl-page" class="pad-l-r">Acl</router-link>
|
|
||||||
<span>|</span
|
|
||||||
><router-link to="/op-page" class="pad-l-r">运维</router-link>
|
|
||||||
<span class="right">集群:{{ clusterName }}</span>
|
|
||||||
</div>
|
|
||||||
<router-view class="content" />
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
|
||||||
import { KafkaClusterApi } from "@/utils/api";
|
|
||||||
import request from "@/utils/request";
|
|
||||||
import { mapMutations, mapState } from "vuex";
|
|
||||||
import { getClusterInfo } from "@/utils/local-cache";
|
|
||||||
import notification from "ant-design-vue/lib/notification";
|
|
||||||
import { CLUSTER } from "@/store/mutation-types";
|
|
||||||
|
|
||||||
export default {
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
config: {},
|
|
||||||
};
|
|
||||||
},
|
|
||||||
created() {
|
|
||||||
const clusterInfo = getClusterInfo();
|
|
||||||
if (!clusterInfo) {
|
|
||||||
request({
|
|
||||||
url: KafkaClusterApi.peekClusterInfo.url,
|
|
||||||
method: KafkaClusterApi.peekClusterInfo.method,
|
|
||||||
}).then((res) => {
|
|
||||||
if (res.code == 0) {
|
|
||||||
this.switchCluster(res.data);
|
|
||||||
} else {
|
|
||||||
notification.error({
|
|
||||||
message: "error",
|
|
||||||
description: res.msg,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
this.switchCluster(clusterInfo);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
...mapState({
|
|
||||||
clusterName: (state) => state.clusterInfo.clusterName,
|
|
||||||
enableSasl: (state) => state.clusterInfo.enableSasl,
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
...mapMutations({
|
|
||||||
switchCluster: CLUSTER.SWITCH,
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
#app {
|
|
||||||
font-family: Avenir, Helvetica, Arial, sans-serif;
|
|
||||||
-webkit-font-smoothing: antialiased;
|
|
||||||
-moz-osx-font-smoothing: grayscale;
|
|
||||||
color: #2c3e50;
|
|
||||||
}
|
|
||||||
|
|
||||||
#app {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
#nav {
|
|
||||||
background-color: #9fe0e0;
|
|
||||||
font-size: large;
|
|
||||||
padding-top: 1%;
|
|
||||||
padding-bottom: 1%;
|
|
||||||
margin-bottom: 1%;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
#nav a {
|
|
||||||
font-weight: bold;
|
|
||||||
color: #2c3e50;
|
|
||||||
}
|
|
||||||
|
|
||||||
#nav a.router-link-exact-active {
|
|
||||||
color: #61c126;
|
|
||||||
}
|
|
||||||
|
|
||||||
.pad-l-r {
|
|
||||||
padding-left: 10px;
|
|
||||||
padding-right: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.content {
|
|
||||||
padding-left: 2%;
|
|
||||||
padding-right: 2%;
|
|
||||||
height: 90%;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
.logo {
|
|
||||||
float: left;
|
|
||||||
left: 1%;
|
|
||||||
top: 1%;
|
|
||||||
position: absolute;
|
|
||||||
}
|
|
||||||
.right {
|
|
||||||
float: right;
|
|
||||||
right: 1%;
|
|
||||||
top: 2%;
|
|
||||||
position: absolute;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
BIN
ui/src/assets/bg.png
Normal file
|
After Width: | Height: | Size: 206 KiB |
162
ui/src/components/Header.vue
Normal file
@@ -0,0 +1,162 @@
|
|||||||
|
<template>
|
||||||
|
<div id="main">
|
||||||
|
<div id="nav">
|
||||||
|
<h2 class="logo">Kafka 控制台</h2>
|
||||||
|
<span v-show="manager">
|
||||||
|
<router-link to="/home" class="pad-l-r">主页</router-link>
|
||||||
|
<span>|</span>
|
||||||
|
</span>
|
||||||
|
<span>
|
||||||
|
<router-link to="/cluster-page" class="pad-l-r">集群</router-link>
|
||||||
|
</span>
|
||||||
|
<span>
|
||||||
|
<span>|</span>
|
||||||
|
<router-link to="/topic-page" class="pad-l-r">Topic</router-link>
|
||||||
|
</span>
|
||||||
|
<span>
|
||||||
|
<span>|</span>
|
||||||
|
<router-link to="/group-page" class="pad-l-r">消费组</router-link>
|
||||||
|
</span>
|
||||||
|
<span>
|
||||||
|
<span>|</span>
|
||||||
|
<router-link to="/message-page" class="pad-l-r">消息</router-link>
|
||||||
|
</span>
|
||||||
|
<span v-show="manager && enableSasl">
|
||||||
|
<span>|</span>
|
||||||
|
<router-link to="/acl-page" class="pad-l-r">Acl</router-link>
|
||||||
|
</span>
|
||||||
|
<span>
|
||||||
|
<span>|</span>
|
||||||
|
<router-link to="/op-page" class="pad-l-r">运维</router-link>
|
||||||
|
</span>
|
||||||
|
<span v-show="manager">
|
||||||
|
<span>|</span>
|
||||||
|
<router-link to="/devops/user" class="pad-l-r">用户</router-link>
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<span class="right">
|
||||||
|
<span>集群:{{ clusterName }}</span>
|
||||||
|
<span> | </span>
|
||||||
|
<span @click="logout" style="cursor: pointer">登出</span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<router-view class="content" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
import { KafkaClusterApi } from "@/utils/api";
|
||||||
|
import request from "@/utils/request";
|
||||||
|
import { mapMutations, mapState } from "vuex";
|
||||||
|
import { getClusterInfo } from "@/utils/local-cache";
|
||||||
|
import notification from "ant-design-vue/lib/notification";
|
||||||
|
import { CLUSTER } from "@/store/mutation-types";
|
||||||
|
import {isManager} from "../utils/role";
|
||||||
|
import router from "../router";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "Header",
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
manager: isManager(),
|
||||||
|
config: {},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
const clusterInfo = getClusterInfo();
|
||||||
|
if (!clusterInfo) {
|
||||||
|
request({
|
||||||
|
url: KafkaClusterApi.peekClusterInfo.url,
|
||||||
|
method: KafkaClusterApi.peekClusterInfo.method,
|
||||||
|
}).then((res) => {
|
||||||
|
if (res.code == 0) {
|
||||||
|
this.switchCluster(res.data);
|
||||||
|
} else {
|
||||||
|
notification.error({
|
||||||
|
message: "error",
|
||||||
|
description: res.msg,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.switchCluster(clusterInfo);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapState({
|
||||||
|
clusterName: (state) => state.clusterInfo.clusterName,
|
||||||
|
enableSasl: (state) => state.clusterInfo.enableSasl,
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
...mapMutations({
|
||||||
|
switchCluster: CLUSTER.SWITCH,
|
||||||
|
}),
|
||||||
|
logout: function (){
|
||||||
|
localStorage.clear();
|
||||||
|
router.push("/")
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
#main {
|
||||||
|
font-family: Avenir, Helvetica, Arial, sans-serif;
|
||||||
|
-webkit-font-smoothing: antialiased;
|
||||||
|
-moz-osx-font-smoothing: grayscale;
|
||||||
|
color: #2c3e50;
|
||||||
|
}
|
||||||
|
|
||||||
|
#main {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
#nav {
|
||||||
|
background-color: #9fe0e0;
|
||||||
|
font-size: large;
|
||||||
|
padding-top: 1%;
|
||||||
|
padding-bottom: 1%;
|
||||||
|
margin-bottom: 1%;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
#nav a {
|
||||||
|
font-weight: bold;
|
||||||
|
color: #2c3e50;
|
||||||
|
}
|
||||||
|
|
||||||
|
#nav a.router-link-exact-active {
|
||||||
|
color: #61c126;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pad-l-r {
|
||||||
|
padding-left: 10px;
|
||||||
|
padding-right: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content {
|
||||||
|
padding-left: 2%;
|
||||||
|
padding-right: 2%;
|
||||||
|
height: 90%;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
.logo {
|
||||||
|
float: left;
|
||||||
|
left: 1%;
|
||||||
|
top: 1%;
|
||||||
|
position: absolute;
|
||||||
|
}
|
||||||
|
.cluster {
|
||||||
|
float: right;
|
||||||
|
right: 8%;
|
||||||
|
top: 2%;
|
||||||
|
position: absolute;
|
||||||
|
}
|
||||||
|
.right {
|
||||||
|
float: right;
|
||||||
|
right: 2%;
|
||||||
|
top: 2%;
|
||||||
|
position: absolute;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="hello">
|
|
||||||
<h1>{{ msg }}</h1>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
export default {
|
|
||||||
name: "HelloWorld",
|
|
||||||
props: {
|
|
||||||
msg: String,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<!-- Add "scoped" attribute to limit CSS to this component only -->
|
|
||||||
<style scoped>
|
|
||||||
h3 {
|
|
||||||
margin: 40px 0 0;
|
|
||||||
}
|
|
||||||
ul {
|
|
||||||
list-style-type: none;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
li {
|
|
||||||
display: inline-block;
|
|
||||||
margin: 0 10px;
|
|
||||||
}
|
|
||||||
a {
|
|
||||||
color: #42b983;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,12 +1,30 @@
|
|||||||
import Vue from "vue";
|
import Vue from "vue";
|
||||||
import VueRouter from "vue-router";
|
import VueRouter from "vue-router";
|
||||||
import Home from "../views/Home.vue";
|
import Home from "../views/home/Home.vue";
|
||||||
|
import Login from "@/views/login/index";
|
||||||
|
|
||||||
Vue.use(VueRouter);
|
Vue.use(VueRouter);
|
||||||
|
|
||||||
const routes = [
|
const routes = [
|
||||||
{
|
{
|
||||||
path: "/",
|
path: "/",
|
||||||
|
name: "Login",
|
||||||
|
component: Login,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "/main",
|
||||||
|
name: "Main",
|
||||||
|
component: () =>
|
||||||
|
import( "../components/Header"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "/devops/user",
|
||||||
|
name: "DevOpsUser",
|
||||||
|
component: () =>
|
||||||
|
import( "../views/user/index"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "/home",
|
||||||
name: "Home",
|
name: "Home",
|
||||||
component: Home,
|
component: Home,
|
||||||
},
|
},
|
||||||
@@ -49,12 +67,6 @@ const routes = [
|
|||||||
component: () =>
|
component: () =>
|
||||||
import(/* webpackChunkName: "cluster" */ "../views/message/Message.vue"),
|
import(/* webpackChunkName: "cluster" */ "../views/message/Message.vue"),
|
||||||
},
|
},
|
||||||
{
|
|
||||||
path: "/client-quota-page",
|
|
||||||
name: "ClientQuota",
|
|
||||||
component: () =>
|
|
||||||
import(/* webpackChunkName: "cluster" */ "../views/quota/ClientQuota.vue"),
|
|
||||||
},
|
|
||||||
];
|
];
|
||||||
|
|
||||||
const router = new VueRouter({
|
const router = new VueRouter({
|
||||||
|
|||||||
@@ -47,18 +47,6 @@ export const KafkaAclApi = {
|
|||||||
url: "/acl",
|
url: "/acl",
|
||||||
method: "delete",
|
method: "delete",
|
||||||
},
|
},
|
||||||
clearAcl: {
|
|
||||||
url: "/acl/clear",
|
|
||||||
method: "delete",
|
|
||||||
},
|
|
||||||
getSaslScramUserList: {
|
|
||||||
url: "/user/scram",
|
|
||||||
method: "get",
|
|
||||||
},
|
|
||||||
deleteSaslScramUser: {
|
|
||||||
url: "/user",
|
|
||||||
method: "delete",
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const KafkaConfigApi = {
|
export const KafkaConfigApi = {
|
||||||
@@ -104,6 +92,29 @@ export const KafkaConfigApi = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const DevOpsUserAPi = {
|
||||||
|
createUser: {
|
||||||
|
url: "/devops/user/add",
|
||||||
|
method: "post",
|
||||||
|
},
|
||||||
|
userList: {
|
||||||
|
url: "/devops/user/list",
|
||||||
|
method: "get",
|
||||||
|
},
|
||||||
|
deleteUser: {
|
||||||
|
url: "/devops/user/",
|
||||||
|
method: "delete",
|
||||||
|
},
|
||||||
|
updateUser: {
|
||||||
|
url: "/devops/user/update",
|
||||||
|
method: "post",
|
||||||
|
},
|
||||||
|
login: {
|
||||||
|
url: "/devops/user/login",
|
||||||
|
method: "post",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
export const KafkaTopicApi = {
|
export const KafkaTopicApi = {
|
||||||
getTopicNameList: {
|
getTopicNameList: {
|
||||||
url: "/topic",
|
url: "/topic",
|
||||||
@@ -288,23 +299,4 @@ export const KafkaMessageApi = {
|
|||||||
url: "/message/resend",
|
url: "/message/resend",
|
||||||
method: "post",
|
method: "post",
|
||||||
},
|
},
|
||||||
delete: {
|
|
||||||
url: "/message",
|
|
||||||
method: "delete",
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const KafkaClientQuotaApi = {
|
|
||||||
getClientQuotaConfigs: {
|
|
||||||
url: "/client/quota/list",
|
|
||||||
method: "post",
|
|
||||||
},
|
|
||||||
alterClientQuotaConfigs: {
|
|
||||||
url: "/client/quota",
|
|
||||||
method: "post",
|
|
||||||
},
|
|
||||||
deleteClientQuotaConfigs: {
|
|
||||||
url: "/client/quota",
|
|
||||||
method: "delete",
|
|
||||||
},
|
|
||||||
};
|
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
import router from "../router";
|
||||||
import notification from "ant-design-vue/es/notification";
|
import notification from "ant-design-vue/es/notification";
|
||||||
import { VueAxios } from "./axios";
|
import { VueAxios } from "./axios";
|
||||||
import { getClusterInfo } from "@/utils/local-cache";
|
import { getClusterInfo } from "@/utils/local-cache";
|
||||||
@@ -25,6 +26,7 @@ const errorHandler = (error) => {
|
|||||||
// request interceptor
|
// request interceptor
|
||||||
request.interceptors.request.use((config) => {
|
request.interceptors.request.use((config) => {
|
||||||
const clusterInfo = getClusterInfo();
|
const clusterInfo = getClusterInfo();
|
||||||
|
config.headers["token"] = localStorage.getItem('token');
|
||||||
if (clusterInfo) {
|
if (clusterInfo) {
|
||||||
config.headers["X-Cluster-Info-Id"] = clusterInfo.id;
|
config.headers["X-Cluster-Info-Id"] = clusterInfo.id;
|
||||||
// config.headers["X-Cluster-Info-Name"] = encodeURIComponent(clusterInfo.clusterName);
|
// config.headers["X-Cluster-Info-Name"] = encodeURIComponent(clusterInfo.clusterName);
|
||||||
@@ -34,6 +36,10 @@ request.interceptors.request.use((config) => {
|
|||||||
|
|
||||||
// response interceptor
|
// response interceptor
|
||||||
request.interceptors.response.use((response) => {
|
request.interceptors.response.use((response) => {
|
||||||
|
if (response.data.code === -5000){
|
||||||
|
router.push({ path:'/'})
|
||||||
|
return
|
||||||
|
}
|
||||||
return response.data;
|
return response.data;
|
||||||
}, errorHandler);
|
}, errorHandler);
|
||||||
|
|
||||||
|
|||||||
3
ui/src/utils/role.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
export function isManager() {
|
||||||
|
return 'manager' === localStorage.getItem("role");
|
||||||
|
}
|
||||||
87
ui/src/utils/validate.js
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
/**
|
||||||
|
* Created by PanJiaChen on 16/11/18.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} path
|
||||||
|
* @returns {Boolean}
|
||||||
|
*/
|
||||||
|
export function isExternal(path) {
|
||||||
|
return /^(https?:|mailto:|tel:)/.test(path)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} str
|
||||||
|
* @returns {Boolean}
|
||||||
|
*/
|
||||||
|
export function validUsername(str) {
|
||||||
|
const valid_map = ['admin', 'editor']
|
||||||
|
return valid_map.indexOf(str.trim()) >= 0
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} url
|
||||||
|
* @returns {Boolean}
|
||||||
|
*/
|
||||||
|
export function validURL(url) {
|
||||||
|
const reg = /^(https?|ftp):\/\/([a-zA-Z0-9.-]+(:[a-zA-Z0-9.&%$-]+)*@)*((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}|([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(:[0-9]+)*(\/($|[a-zA-Z0-9.,?'\\+&%$#=~_-]+))*$/
|
||||||
|
return reg.test(url)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} str
|
||||||
|
* @returns {Boolean}
|
||||||
|
*/
|
||||||
|
export function validLowerCase(str) {
|
||||||
|
const reg = /^[a-z]+$/
|
||||||
|
return reg.test(str)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} str
|
||||||
|
* @returns {Boolean}
|
||||||
|
*/
|
||||||
|
export function validUpperCase(str) {
|
||||||
|
const reg = /^[A-Z]+$/
|
||||||
|
return reg.test(str)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} str
|
||||||
|
* @returns {Boolean}
|
||||||
|
*/
|
||||||
|
export function validAlphabets(str) {
|
||||||
|
const reg = /^[A-Za-z]+$/
|
||||||
|
return reg.test(str)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} email
|
||||||
|
* @returns {Boolean}
|
||||||
|
*/
|
||||||
|
export function validEmail(email) {
|
||||||
|
const reg = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
|
||||||
|
return reg.test(email)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} str
|
||||||
|
* @returns {Boolean}
|
||||||
|
*/
|
||||||
|
export function isString(str) {
|
||||||
|
if (typeof str === 'string' || str instanceof String) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Array} arg
|
||||||
|
* @returns {Boolean}
|
||||||
|
*/
|
||||||
|
export function isArray(arg) {
|
||||||
|
if (typeof Array.isArray === 'undefined') {
|
||||||
|
return Object.prototype.toString.call(arg) === '[object Array]'
|
||||||
|
}
|
||||||
|
return Array.isArray(arg)
|
||||||
|
}
|
||||||
@@ -1,25 +1,465 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="content">
|
<div>
|
||||||
<a-tabs default-active-key="1" size="large" tabPosition="top">
|
<Header/>
|
||||||
<a-tab-pane key="1" tab="资源授权">
|
<div class="content">
|
||||||
<acl-list></acl-list>
|
<a-spin :spinning="loading">
|
||||||
</a-tab-pane>
|
<div class="acl">
|
||||||
<a-tab-pane key="2" tab="SaslScram用户管理">
|
<div id="components-form-acl-advanced-search">
|
||||||
<sasl-scram></sasl-scram>
|
<a-form
|
||||||
</a-tab-pane>
|
class="ant-advanced-search-form"
|
||||||
</a-tabs>
|
:form="form"
|
||||||
|
@submit="handleSearch"
|
||||||
|
>
|
||||||
|
<a-row :gutter="24">
|
||||||
|
<a-col :span="8">
|
||||||
|
<a-form-item :label="`用户名`">
|
||||||
|
<a-input
|
||||||
|
placeholder="username"
|
||||||
|
class="input-w"
|
||||||
|
v-decorator="['username']"
|
||||||
|
/>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
<a-col :span="8">
|
||||||
|
<a-form-item :label="`topic`">
|
||||||
|
<a-input
|
||||||
|
placeholder="topic"
|
||||||
|
class="input-w"
|
||||||
|
v-decorator="['topic']"
|
||||||
|
/>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
<a-col :span="8">
|
||||||
|
<a-form-item :label="`消费组`">
|
||||||
|
<a-input
|
||||||
|
placeholder="groupId"
|
||||||
|
class="input-w"
|
||||||
|
v-decorator="['groupId']"
|
||||||
|
/>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
|
||||||
|
<a-col :span="24" :style="{ textAlign: 'right' }">
|
||||||
|
<a-button type="primary" html-type="submit"> 搜索</a-button>
|
||||||
|
<a-button :style="{ marginLeft: '8px' }" @click="handleReset">
|
||||||
|
重置
|
||||||
|
</a-button>
|
||||||
|
</a-col>
|
||||||
|
</a-row>
|
||||||
|
</a-form>
|
||||||
|
</div>
|
||||||
|
<div class="operation-row-button">
|
||||||
|
<a-button type="primary" @click="updateUser">新增/更新用户</a-button>
|
||||||
|
<UpdateUser
|
||||||
|
:visible="showUpdateUser"
|
||||||
|
@updateUserDialogData="closeUpdateUserDialog"
|
||||||
|
></UpdateUser>
|
||||||
|
</div>
|
||||||
|
<a-table :columns="columns" :data-source="data" bordered>
|
||||||
|
<div slot="username" slot-scope="username">
|
||||||
|
<span>{{ username }}</span
|
||||||
|
><a-button
|
||||||
|
size="small"
|
||||||
|
shape="round"
|
||||||
|
type="dashed"
|
||||||
|
style="float: right"
|
||||||
|
@click="onUserDetail(username)"
|
||||||
|
>详情</a-button
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div slot="topicList" slot-scope="topicList, record">
|
||||||
|
<a
|
||||||
|
href="#"
|
||||||
|
v-for="t in topicList"
|
||||||
|
:key="t"
|
||||||
|
@click="onTopicDetail(t, record.username)"
|
||||||
|
><div style="border-bottom: 1px solid #e5e1e1">{{ t }}</div>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div slot="groupList" slot-scope="groupList, record">
|
||||||
|
<a
|
||||||
|
href="#"
|
||||||
|
v-for="t in groupList"
|
||||||
|
:key="t"
|
||||||
|
@click="onGroupDetail(t, record.username)"
|
||||||
|
><div style="border-bottom: 1px solid #e5e1e1">{{ t }}</div>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
slot="operation"
|
||||||
|
slot-scope="record"
|
||||||
|
v-show="!record.user || record.user.role != 'admin'"
|
||||||
|
>
|
||||||
|
<a-popconfirm
|
||||||
|
:title="'删除用户: ' + record.username + '及相关权限?'"
|
||||||
|
ok-text="确认"
|
||||||
|
cancel-text="取消"
|
||||||
|
@confirm="onDeleteUser(record)"
|
||||||
|
>
|
||||||
|
<a-button size="small" href="javascript:;" class="operation-btn"
|
||||||
|
>删除</a-button
|
||||||
|
>
|
||||||
|
</a-popconfirm>
|
||||||
|
<a-button
|
||||||
|
size="small"
|
||||||
|
href="javascript:;"
|
||||||
|
class="operation-btn"
|
||||||
|
@click="onManageProducerAuth(record)"
|
||||||
|
>管理生产权限
|
||||||
|
</a-button>
|
||||||
|
|
||||||
|
<a-button
|
||||||
|
size="small"
|
||||||
|
href="javascript:;"
|
||||||
|
class="operation-btn"
|
||||||
|
@click="onManageConsumerAuth(record)"
|
||||||
|
>管理消费权限
|
||||||
|
</a-button>
|
||||||
|
<a-button
|
||||||
|
size="small"
|
||||||
|
href="javascript:;"
|
||||||
|
class="operation-btn"
|
||||||
|
@click="onAddAuth(record)"
|
||||||
|
>增加权限
|
||||||
|
</a-button>
|
||||||
|
</div>
|
||||||
|
</a-table>
|
||||||
|
<UserDetail
|
||||||
|
:visible="openUserDetailDialog"
|
||||||
|
:username="selectDetail.username"
|
||||||
|
@userDetailDialog="closeUserDetailDialog"
|
||||||
|
></UserDetail>
|
||||||
|
<AclDetail
|
||||||
|
:visible="openAclDetailDialog"
|
||||||
|
:selectDetail="selectDetail"
|
||||||
|
@aclDetailDialog="closeAclDetailDialog"
|
||||||
|
></AclDetail>
|
||||||
|
<ManageProducerAuth
|
||||||
|
:visible="openManageProducerAuthDialog"
|
||||||
|
:record="selectRow"
|
||||||
|
@manageProducerAuthDialog="closeManageProducerAuthDialog"
|
||||||
|
></ManageProducerAuth>
|
||||||
|
<ManageConsumerAuth
|
||||||
|
:visible="openManageConsumerAuthDialog"
|
||||||
|
:record="selectRow"
|
||||||
|
@manageConsumerAuthDialog="closeManageConsumerAuthDialog"
|
||||||
|
></ManageConsumerAuth>
|
||||||
|
<AddAuth
|
||||||
|
:visible="openAddAuthDialog"
|
||||||
|
:record="selectRow"
|
||||||
|
@addAuthDialog="closeAddAuthDialog"
|
||||||
|
></AddAuth>
|
||||||
|
</div>
|
||||||
|
</a-spin>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import AclList from "@/views/acl/AclList";
|
import request from "@/utils/request";
|
||||||
import SaslScram from "@/views/acl/SaslScram";
|
import notification from "ant-design-vue/es/notification";
|
||||||
|
import UpdateUser from "@/views/acl/UpdateUser";
|
||||||
|
import { KafkaAclApi } from "@/utils/api";
|
||||||
|
import ManageProducerAuth from "@/views/acl/ManageProducerAuth";
|
||||||
|
import ManageConsumerAuth from "@/views/acl/ManageConsumerAuth";
|
||||||
|
import AddAuth from "@/views/acl/AddAuth";
|
||||||
|
import AclDetail from "@/views/acl/AclDetail";
|
||||||
|
import UserDetail from "@/views/acl/UserDetail";
|
||||||
|
import Header from "@/components/Header"
|
||||||
export default {
|
export default {
|
||||||
name: "Acl",
|
name: "Acl",
|
||||||
components: {
|
components: {
|
||||||
AclList,
|
UpdateUser,
|
||||||
SaslScram,
|
ManageProducerAuth,
|
||||||
|
ManageConsumerAuth,
|
||||||
|
AddAuth,
|
||||||
|
AclDetail,
|
||||||
|
UserDetail,
|
||||||
|
Header
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
queryParam: {},
|
||||||
|
data: [],
|
||||||
|
columns,
|
||||||
|
selectRow: {},
|
||||||
|
form: this.$form.createForm(this, { name: "advanced_search" }),
|
||||||
|
showUpdateUser: false,
|
||||||
|
deleteUserConfirm: false,
|
||||||
|
openManageProducerAuthDialog: false,
|
||||||
|
openManageConsumerAuthDialog: false,
|
||||||
|
openAddAuthDialog: false,
|
||||||
|
openAclDetailDialog: false,
|
||||||
|
openUserDetailDialog: false,
|
||||||
|
selectDetail: {
|
||||||
|
resourceName: "",
|
||||||
|
resourceType: "",
|
||||||
|
username: "",
|
||||||
|
},
|
||||||
|
loading: false,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
handleSearch(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
this.form.validateFields((error, values) => {
|
||||||
|
let queryParam = {};
|
||||||
|
if (values.username) {
|
||||||
|
queryParam.username = values.username;
|
||||||
|
}
|
||||||
|
if (values.topic) {
|
||||||
|
queryParam.resourceType = "TOPIC";
|
||||||
|
queryParam.resourceName = values.topic;
|
||||||
|
} else if (values.groupId) {
|
||||||
|
queryParam.resourceType = "GROUP";
|
||||||
|
queryParam.resourceName = values.groupId;
|
||||||
|
}
|
||||||
|
Object.assign(this.queryParam, queryParam);
|
||||||
|
this.getAclList();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
handleReset() {
|
||||||
|
this.form.resetFields();
|
||||||
|
},
|
||||||
|
|
||||||
|
updateUser() {
|
||||||
|
this.showUpdateUser = true;
|
||||||
|
},
|
||||||
|
closeUpdateUserDialog(data) {
|
||||||
|
this.showUpdateUser = data.show;
|
||||||
|
if (data.ok) {
|
||||||
|
this.getAclList();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onDeleteUser(row) {
|
||||||
|
this.loading = true;
|
||||||
|
request({
|
||||||
|
url: KafkaAclApi.deleteKafkaUser.url,
|
||||||
|
method: KafkaAclApi.deleteKafkaUser.method,
|
||||||
|
data: { username: row.username },
|
||||||
|
}).then((res) => {
|
||||||
|
this.loading = false;
|
||||||
|
this.getAclList();
|
||||||
|
if (res.code == 0) {
|
||||||
|
this.$message.success(res.msg);
|
||||||
|
} else {
|
||||||
|
this.$message.error(res.msg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
onManageProducerAuth(row) {
|
||||||
|
this.openManageProducerAuthDialog = true;
|
||||||
|
const rowData = {};
|
||||||
|
Object.assign(rowData, row);
|
||||||
|
this.selectRow = rowData;
|
||||||
|
},
|
||||||
|
onManageConsumerAuth(row) {
|
||||||
|
this.openManageConsumerAuthDialog = true;
|
||||||
|
const rowData = {};
|
||||||
|
Object.assign(rowData, row);
|
||||||
|
this.selectRow = rowData;
|
||||||
|
},
|
||||||
|
onAddAuth(row) {
|
||||||
|
this.openAddAuthDialog = true;
|
||||||
|
const rowData = {};
|
||||||
|
Object.assign(rowData, row);
|
||||||
|
this.selectRow = rowData;
|
||||||
|
},
|
||||||
|
onTopicDetail(topic, username) {
|
||||||
|
this.selectDetail.resourceType = "TOPIC";
|
||||||
|
this.selectDetail.resourceName = topic;
|
||||||
|
this.selectDetail.username = username;
|
||||||
|
this.openAclDetailDialog = true;
|
||||||
|
},
|
||||||
|
onGroupDetail(group, username) {
|
||||||
|
this.selectDetail.resourceType = "GROUP";
|
||||||
|
this.selectDetail.resourceName = group;
|
||||||
|
this.selectDetail.username = username;
|
||||||
|
this.openAclDetailDialog = true;
|
||||||
|
},
|
||||||
|
onUserDetail(username) {
|
||||||
|
this.selectDetail.username = username;
|
||||||
|
this.openUserDetailDialog = true;
|
||||||
|
},
|
||||||
|
closeManageProducerAuthDialog() {
|
||||||
|
this.openManageProducerAuthDialog = false;
|
||||||
|
this.getAclList();
|
||||||
|
},
|
||||||
|
closeManageConsumerAuthDialog() {
|
||||||
|
this.openManageConsumerAuthDialog = false;
|
||||||
|
this.getAclList();
|
||||||
|
},
|
||||||
|
closeAddAuthDialog(p) {
|
||||||
|
this.openAddAuthDialog = false;
|
||||||
|
if (p.refresh) {
|
||||||
|
this.getAclList();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
closeAclDetailDialog(p) {
|
||||||
|
this.openAclDetailDialog = false;
|
||||||
|
if (p.refresh) {
|
||||||
|
this.getAclList();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
closeUserDetailDialog() {
|
||||||
|
this.openUserDetailDialog = false;
|
||||||
|
},
|
||||||
|
getAclList() {
|
||||||
|
this.loading = true;
|
||||||
|
request({
|
||||||
|
url: KafkaAclApi.getAclList.url,
|
||||||
|
method: KafkaAclApi.getAclList.method,
|
||||||
|
data: this.queryParam,
|
||||||
|
}).then((response) => {
|
||||||
|
this.loading = false;
|
||||||
|
this.data.splice(0, this.data.length);
|
||||||
|
if (response.code != 0) {
|
||||||
|
notification.error({
|
||||||
|
message: response.msg,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (let k in response.data.map) {
|
||||||
|
let v = response.data.map[k];
|
||||||
|
let topicList = Object.keys(v)
|
||||||
|
.filter((e) => e.startsWith("TOPIC"))
|
||||||
|
.map((e) => e.split("#")[1]);
|
||||||
|
let groupList = Object.keys(v)
|
||||||
|
.filter((e) => e.startsWith("GROUP"))
|
||||||
|
.map((e) => e.split("#")[1]);
|
||||||
|
this.data.push({
|
||||||
|
key: k,
|
||||||
|
username: k,
|
||||||
|
topicList: topicList,
|
||||||
|
groupList: groupList,
|
||||||
|
user: response.data.map[k]["USER"],
|
||||||
|
});
|
||||||
|
this.data.sort((a, b) => a.username.localeCompare(b.username));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.getAclList();
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// function getAclList(data, requestParameters) {
|
||||||
|
// request({
|
||||||
|
// url: KafkaAclApi.getAclList.url,
|
||||||
|
// method: KafkaAclApi.getAclList.method,
|
||||||
|
// data: requestParameters,
|
||||||
|
// }).then((response) => {
|
||||||
|
// data.splice(0, data.length);
|
||||||
|
// if (response.code != 0) {
|
||||||
|
// notification.error({
|
||||||
|
// message: response.msg,
|
||||||
|
// });
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// for (let k in response.data.map) {
|
||||||
|
// let v = response.data.map[k];
|
||||||
|
// let topicList = Object.keys(v)
|
||||||
|
// .filter((e) => e.startsWith("TOPIC"))
|
||||||
|
// .map((e) => e.split("#")[1]);
|
||||||
|
// let groupList = Object.keys(v)
|
||||||
|
// .filter((e) => e.startsWith("GROUP"))
|
||||||
|
// .map((e) => e.split("#")[1]);
|
||||||
|
// data.push({
|
||||||
|
// key: k,
|
||||||
|
// username: k,
|
||||||
|
// topicList: topicList,
|
||||||
|
// groupList: groupList,
|
||||||
|
// user: response.data.map[k]["USER"],
|
||||||
|
// });
|
||||||
|
// data.sort((a, b) => a.username.localeCompare(b.username));
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
|
||||||
|
const columns = [
|
||||||
|
{
|
||||||
|
title: "用户名",
|
||||||
|
dataIndex: "username",
|
||||||
|
key: "username",
|
||||||
|
width: 300,
|
||||||
|
slots: { title: "username" },
|
||||||
|
scopedSlots: { customRender: "username" },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "topic列表",
|
||||||
|
dataIndex: "topicList",
|
||||||
|
key: "topicList",
|
||||||
|
slots: { title: "topicList" },
|
||||||
|
scopedSlots: { customRender: "topicList" },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "消费组列表",
|
||||||
|
dataIndex: "groupList",
|
||||||
|
key: "groupList",
|
||||||
|
slots: { title: "groupList" },
|
||||||
|
scopedSlots: { customRender: "groupList" },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "操作",
|
||||||
|
key: "operation",
|
||||||
|
scopedSlots: { customRender: "operation" },
|
||||||
|
width: 500,
|
||||||
|
},
|
||||||
|
];
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.acl {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ant-advanced-search-form {
|
||||||
|
padding: 24px;
|
||||||
|
background: #fbfbfb;
|
||||||
|
border: 1px solid #d9d9d9;
|
||||||
|
border-radius: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ant-advanced-search-form .ant-form-item {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ant-advanced-search-form .ant-form-item-control-wrapper {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#components-form-acl-advanced-search .ant-form {
|
||||||
|
max-width: none;
|
||||||
|
margin-bottom: 1%;
|
||||||
|
}
|
||||||
|
|
||||||
|
#components-form-acl-advanced-search .search-result-list {
|
||||||
|
margin-top: 16px;
|
||||||
|
border: 1px dashed #e9e9e9;
|
||||||
|
border-radius: 6px;
|
||||||
|
background-color: #fafafa;
|
||||||
|
min-height: 200px;
|
||||||
|
text-align: center;
|
||||||
|
padding-top: 80px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-w {
|
||||||
|
width: 400px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.operation-row-button {
|
||||||
|
height: 4%;
|
||||||
|
text-align: left;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.operation-btn {
|
||||||
|
margin-right: 3%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
@@ -1,449 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="acl">
|
|
||||||
<a-spin :spinning="loading">
|
|
||||||
<div class="acl">
|
|
||||||
<div id="components-form-acl-advanced-search">
|
|
||||||
<a-form
|
|
||||||
class="ant-advanced-search-form"
|
|
||||||
:form="form"
|
|
||||||
@submit="handleSearch"
|
|
||||||
>
|
|
||||||
<a-row :gutter="24">
|
|
||||||
<a-col :span="8">
|
|
||||||
<a-form-item :label="`主体`">
|
|
||||||
<a-input
|
|
||||||
placeholder="比如, 用户名"
|
|
||||||
class="input-w"
|
|
||||||
v-decorator="['username']"
|
|
||||||
/>
|
|
||||||
</a-form-item>
|
|
||||||
</a-col>
|
|
||||||
<a-col :span="8">
|
|
||||||
<a-form-item :label="`topic`">
|
|
||||||
<a-input
|
|
||||||
placeholder="topic"
|
|
||||||
class="input-w"
|
|
||||||
v-decorator="['topic']"
|
|
||||||
/>
|
|
||||||
</a-form-item>
|
|
||||||
</a-col>
|
|
||||||
<a-col :span="8">
|
|
||||||
<a-form-item :label="`消费组`">
|
|
||||||
<a-input
|
|
||||||
placeholder="groupId"
|
|
||||||
class="input-w"
|
|
||||||
v-decorator="['groupId']"
|
|
||||||
/>
|
|
||||||
</a-form-item>
|
|
||||||
</a-col>
|
|
||||||
|
|
||||||
<a-col :span="24" :style="{ textAlign: 'right' }">
|
|
||||||
<a-button type="primary" html-type="submit"> 搜索</a-button>
|
|
||||||
<a-button :style="{ marginLeft: '8px' }" @click="handleReset">
|
|
||||||
重置
|
|
||||||
</a-button>
|
|
||||||
</a-col>
|
|
||||||
</a-row>
|
|
||||||
</a-form>
|
|
||||||
</div>
|
|
||||||
<div class="operation-row-button">
|
|
||||||
<a-button type="primary" @click="onAddPrincipalAuth"
|
|
||||||
>新增主体权限</a-button
|
|
||||||
>
|
|
||||||
<span v-show="hint != ''" class="hint"
|
|
||||||
>broker未启用权限管理,所以不支持授权相关操作[{{ hint }}]</span
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
<a-table :columns="columns" :data-source="data" bordered>
|
|
||||||
<div slot="username" slot-scope="username">
|
|
||||||
<span>{{ username }}</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div slot="topicList" slot-scope="topicList, record">
|
|
||||||
<a
|
|
||||||
href="#"
|
|
||||||
v-for="t in topicList"
|
|
||||||
:key="t"
|
|
||||||
@click="onTopicDetail(t, record.username)"
|
|
||||||
><div style="border-bottom: 1px solid #e5e1e1">{{ t }}</div>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div slot="groupList" slot-scope="groupList, record">
|
|
||||||
<a
|
|
||||||
href="#"
|
|
||||||
v-for="t in groupList"
|
|
||||||
:key="t"
|
|
||||||
@click="onGroupDetail(t, record.username)"
|
|
||||||
><div style="border-bottom: 1px solid #e5e1e1">{{ t }}</div>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div slot="operation" slot-scope="record">
|
|
||||||
<a-button
|
|
||||||
size="small"
|
|
||||||
href="javascript:;"
|
|
||||||
class="operation-btn"
|
|
||||||
@click="onManageProducerAuth(record)"
|
|
||||||
>管理生产权限
|
|
||||||
</a-button>
|
|
||||||
|
|
||||||
<a-button
|
|
||||||
size="small"
|
|
||||||
href="javascript:;"
|
|
||||||
class="operation-btn"
|
|
||||||
@click="onManageConsumerAuth(record)"
|
|
||||||
>管理消费权限
|
|
||||||
</a-button>
|
|
||||||
<a-button
|
|
||||||
size="small"
|
|
||||||
href="javascript:;"
|
|
||||||
class="operation-btn"
|
|
||||||
@click="onAddAuth(record)"
|
|
||||||
>增加权限
|
|
||||||
</a-button>
|
|
||||||
<a-popconfirm
|
|
||||||
:title="'清除: ' + record.username + '所有资源权限?'"
|
|
||||||
ok-text="确认"
|
|
||||||
cancel-text="取消"
|
|
||||||
@confirm="onClearUserAcl(record)"
|
|
||||||
>
|
|
||||||
<a-button size="small" href="javascript:;" class="operation-btn"
|
|
||||||
>清除权限</a-button
|
|
||||||
>
|
|
||||||
</a-popconfirm>
|
|
||||||
</div>
|
|
||||||
</a-table>
|
|
||||||
<AclDetail
|
|
||||||
:visible="openAclDetailDialog"
|
|
||||||
:selectDetail="selectDetail"
|
|
||||||
@aclDetailDialog="closeAclDetailDialog"
|
|
||||||
></AclDetail>
|
|
||||||
<ManageProducerAuth
|
|
||||||
:visible="openManageProducerAuthDialog"
|
|
||||||
:record="selectRow"
|
|
||||||
@manageProducerAuthDialog="closeManageProducerAuthDialog"
|
|
||||||
></ManageProducerAuth>
|
|
||||||
<ManageConsumerAuth
|
|
||||||
:visible="openManageConsumerAuthDialog"
|
|
||||||
:record="selectRow"
|
|
||||||
@manageConsumerAuthDialog="closeManageConsumerAuthDialog"
|
|
||||||
></ManageConsumerAuth>
|
|
||||||
<AddAuth
|
|
||||||
:visible="openAddAuthDialog"
|
|
||||||
:record="selectRow"
|
|
||||||
@addAuthDialog="closeAddAuthDialog"
|
|
||||||
></AddAuth>
|
|
||||||
<AddPrincipalAuth
|
|
||||||
:visible="openAddPrincipalAuthDialog"
|
|
||||||
@closeAddPrincipalAuthDialog="closeAddPrincipalAuthDialog"
|
|
||||||
></AddPrincipalAuth>
|
|
||||||
</div>
|
|
||||||
</a-spin>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import request from "@/utils/request";
|
|
||||||
import notification from "ant-design-vue/es/notification";
|
|
||||||
import { KafkaAclApi } from "@/utils/api";
|
|
||||||
import ManageProducerAuth from "@/views/acl/ManageProducerAuth";
|
|
||||||
import ManageConsumerAuth from "@/views/acl/ManageConsumerAuth";
|
|
||||||
import AddAuth from "@/views/acl/AddAuth";
|
|
||||||
import AclDetail from "@/views/acl/AclDetail";
|
|
||||||
import AddPrincipalAuth from "@/views/acl/AddPrincipalAuth";
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: "AclList",
|
|
||||||
components: {
|
|
||||||
ManageProducerAuth,
|
|
||||||
ManageConsumerAuth,
|
|
||||||
AddAuth,
|
|
||||||
AclDetail,
|
|
||||||
AddPrincipalAuth,
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
queryParam: {},
|
|
||||||
data: [],
|
|
||||||
columns,
|
|
||||||
selectRow: {},
|
|
||||||
form: this.$form.createForm(this, { name: "advanced_search" }),
|
|
||||||
openManageProducerAuthDialog: false,
|
|
||||||
openManageConsumerAuthDialog: false,
|
|
||||||
openAddAuthDialog: false,
|
|
||||||
openAclDetailDialog: false,
|
|
||||||
openAddPrincipalAuthDialog: false,
|
|
||||||
selectDetail: {
|
|
||||||
resourceName: "",
|
|
||||||
resourceType: "",
|
|
||||||
username: "",
|
|
||||||
},
|
|
||||||
loading: false,
|
|
||||||
hint: "",
|
|
||||||
};
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
handleSearch(e) {
|
|
||||||
e.preventDefault();
|
|
||||||
this.form.validateFields((error, values) => {
|
|
||||||
let queryParam = {};
|
|
||||||
queryParam.username = values.username ? values.username : null;
|
|
||||||
// if (values.username) {
|
|
||||||
// queryParam.username = values.username;
|
|
||||||
// }
|
|
||||||
if (values.topic) {
|
|
||||||
queryParam.resourceType = "TOPIC";
|
|
||||||
queryParam.resourceName = values.topic;
|
|
||||||
} else if (values.groupId) {
|
|
||||||
queryParam.resourceType = "GROUP";
|
|
||||||
queryParam.resourceName = values.groupId;
|
|
||||||
}
|
|
||||||
Object.assign(this.queryParam, queryParam);
|
|
||||||
this.getAclList();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
handleReset() {
|
|
||||||
this.form.resetFields();
|
|
||||||
},
|
|
||||||
onClearUserAcl(row) {
|
|
||||||
this.loading = true;
|
|
||||||
request({
|
|
||||||
url: KafkaAclApi.clearAcl.url,
|
|
||||||
method: KafkaAclApi.clearAcl.method,
|
|
||||||
data: { username: row.username },
|
|
||||||
}).then((res) => {
|
|
||||||
this.loading = false;
|
|
||||||
this.getAclList();
|
|
||||||
if (res.code == 0) {
|
|
||||||
this.$message.success(res.msg);
|
|
||||||
} else {
|
|
||||||
this.$message.error(res.msg);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
onManageProducerAuth(row) {
|
|
||||||
this.openManageProducerAuthDialog = true;
|
|
||||||
const rowData = {};
|
|
||||||
Object.assign(rowData, row);
|
|
||||||
this.selectRow = rowData;
|
|
||||||
},
|
|
||||||
onManageConsumerAuth(row) {
|
|
||||||
this.openManageConsumerAuthDialog = true;
|
|
||||||
const rowData = {};
|
|
||||||
Object.assign(rowData, row);
|
|
||||||
this.selectRow = rowData;
|
|
||||||
},
|
|
||||||
onAddAuth(row) {
|
|
||||||
this.openAddAuthDialog = true;
|
|
||||||
const rowData = {};
|
|
||||||
Object.assign(rowData, row);
|
|
||||||
this.selectRow = rowData;
|
|
||||||
},
|
|
||||||
onTopicDetail(topic, username) {
|
|
||||||
this.selectDetail.resourceType = "TOPIC";
|
|
||||||
this.selectDetail.resourceName = topic;
|
|
||||||
this.selectDetail.username = username;
|
|
||||||
this.openAclDetailDialog = true;
|
|
||||||
},
|
|
||||||
onGroupDetail(group, username) {
|
|
||||||
this.selectDetail.resourceType = "GROUP";
|
|
||||||
this.selectDetail.resourceName = group;
|
|
||||||
this.selectDetail.username = username;
|
|
||||||
this.openAclDetailDialog = true;
|
|
||||||
},
|
|
||||||
onAddPrincipalAuth() {
|
|
||||||
this.openAddPrincipalAuthDialog = true;
|
|
||||||
},
|
|
||||||
closeManageProducerAuthDialog() {
|
|
||||||
this.openManageProducerAuthDialog = false;
|
|
||||||
this.getAclList();
|
|
||||||
},
|
|
||||||
closeManageConsumerAuthDialog() {
|
|
||||||
this.openManageConsumerAuthDialog = false;
|
|
||||||
this.getAclList();
|
|
||||||
},
|
|
||||||
closeAddAuthDialog(p) {
|
|
||||||
this.openAddAuthDialog = false;
|
|
||||||
if (p.refresh) {
|
|
||||||
this.getAclList();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
closeAddPrincipalAuthDialog(p) {
|
|
||||||
this.openAddPrincipalAuthDialog = false;
|
|
||||||
if (p.refresh) {
|
|
||||||
this.getAclList();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
closeAclDetailDialog(p) {
|
|
||||||
this.openAclDetailDialog = false;
|
|
||||||
if (p.refresh) {
|
|
||||||
this.getAclList();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
getAclList() {
|
|
||||||
this.loading = true;
|
|
||||||
request({
|
|
||||||
url: KafkaAclApi.getAclList.url,
|
|
||||||
method: KafkaAclApi.getAclList.method,
|
|
||||||
data: this.queryParam,
|
|
||||||
}).then((response) => {
|
|
||||||
this.loading = false;
|
|
||||||
this.data.splice(0, this.data.length);
|
|
||||||
if (response.code != 0) {
|
|
||||||
notification.error({
|
|
||||||
message: response.msg,
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!response.data.total && response.data.hint) {
|
|
||||||
this.hint = response.data.hint;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.hint = "";
|
|
||||||
for (let k in response.data.map) {
|
|
||||||
let v = response.data.map[k];
|
|
||||||
let topicList = Object.keys(v)
|
|
||||||
.filter((e) => e.startsWith("TOPIC"))
|
|
||||||
.map((e) => e.split("#")[1]);
|
|
||||||
let groupList = Object.keys(v)
|
|
||||||
.filter((e) => e.startsWith("GROUP"))
|
|
||||||
.map((e) => e.split("#")[1]);
|
|
||||||
this.data.push({
|
|
||||||
key: k,
|
|
||||||
username: k,
|
|
||||||
topicList: topicList,
|
|
||||||
groupList: groupList,
|
|
||||||
user: response.data.map[k]["USER"],
|
|
||||||
});
|
|
||||||
this.data.sort((a, b) => a.username.localeCompare(b.username));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
},
|
|
||||||
created() {
|
|
||||||
this.getAclList();
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
// function getAclList(data, requestParameters) {
|
|
||||||
// request({
|
|
||||||
// url: KafkaAclApi.getAclList.url,
|
|
||||||
// method: KafkaAclApi.getAclList.method,
|
|
||||||
// data: requestParameters,
|
|
||||||
// }).then((response) => {
|
|
||||||
// data.splice(0, data.length);
|
|
||||||
// if (response.code != 0) {
|
|
||||||
// notification.error({
|
|
||||||
// message: response.msg,
|
|
||||||
// });
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// for (let k in response.data.map) {
|
|
||||||
// let v = response.data.map[k];
|
|
||||||
// let topicList = Object.keys(v)
|
|
||||||
// .filter((e) => e.startsWith("TOPIC"))
|
|
||||||
// .map((e) => e.split("#")[1]);
|
|
||||||
// let groupList = Object.keys(v)
|
|
||||||
// .filter((e) => e.startsWith("GROUP"))
|
|
||||||
// .map((e) => e.split("#")[1]);
|
|
||||||
// data.push({
|
|
||||||
// key: k,
|
|
||||||
// username: k,
|
|
||||||
// topicList: topicList,
|
|
||||||
// groupList: groupList,
|
|
||||||
// user: response.data.map[k]["USER"],
|
|
||||||
// });
|
|
||||||
// data.sort((a, b) => a.username.localeCompare(b.username));
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
const columns = [
|
|
||||||
{
|
|
||||||
title: "主体标识",
|
|
||||||
dataIndex: "username", //历史原因使用变量username
|
|
||||||
key: "username",
|
|
||||||
width: 300,
|
|
||||||
slots: { title: "username" },
|
|
||||||
scopedSlots: { customRender: "username" },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "topic列表",
|
|
||||||
dataIndex: "topicList",
|
|
||||||
key: "topicList",
|
|
||||||
slots: { title: "topicList" },
|
|
||||||
scopedSlots: { customRender: "topicList" },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "消费组列表",
|
|
||||||
dataIndex: "groupList",
|
|
||||||
key: "groupList",
|
|
||||||
slots: { title: "groupList" },
|
|
||||||
scopedSlots: { customRender: "groupList" },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "操作",
|
|
||||||
key: "operation",
|
|
||||||
scopedSlots: { customRender: "operation" },
|
|
||||||
width: 500,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.acl {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ant-advanced-search-form {
|
|
||||||
padding: 24px;
|
|
||||||
background: #fbfbfb;
|
|
||||||
border: 1px solid #d9d9d9;
|
|
||||||
border-radius: 6px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ant-advanced-search-form .ant-form-item {
|
|
||||||
display: flex;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ant-advanced-search-form .ant-form-item-control-wrapper {
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#components-form-acl-advanced-search .ant-form {
|
|
||||||
max-width: none;
|
|
||||||
margin-bottom: 1%;
|
|
||||||
}
|
|
||||||
|
|
||||||
#components-form-acl-advanced-search .search-result-list {
|
|
||||||
margin-top: 16px;
|
|
||||||
border: 1px dashed #e9e9e9;
|
|
||||||
border-radius: 6px;
|
|
||||||
background-color: #fafafa;
|
|
||||||
min-height: 200px;
|
|
||||||
text-align: center;
|
|
||||||
padding-top: 80px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.input-w {
|
|
||||||
width: 400px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.operation-row-button {
|
|
||||||
height: 4%;
|
|
||||||
text-align: left;
|
|
||||||
margin-bottom: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.operation-btn {
|
|
||||||
margin-right: 3%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.hint {
|
|
||||||
margin-left: 1%;
|
|
||||||
color: red;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,154 +0,0 @@
|
|||||||
<template>
|
|
||||||
<a-modal
|
|
||||||
title="增加权限"
|
|
||||||
:visible="show"
|
|
||||||
:confirm-loading="confirmLoading"
|
|
||||||
:width="800"
|
|
||||||
@ok="handleOk"
|
|
||||||
@cancel="handleCancel"
|
|
||||||
okText="提交"
|
|
||||||
cancelText="取消"
|
|
||||||
:mask="false"
|
|
||||||
:destroyOnClose="true"
|
|
||||||
>
|
|
||||||
<a-form :form="form" :label-col="{ span: 5 }" :wrapper-col="{ span: 12 }">
|
|
||||||
<a-form-item label="主体标识">
|
|
||||||
<a-input
|
|
||||||
v-decorator="[
|
|
||||||
'username',
|
|
||||||
{ rules: [{ required: true, message: '请输入!' }] },
|
|
||||||
]"
|
|
||||||
/>
|
|
||||||
</a-form-item>
|
|
||||||
<a-form-item label="资源类型">
|
|
||||||
<a-radio-group
|
|
||||||
v-decorator="['resourceType', { initialValue: 'TOPIC' }]"
|
|
||||||
>
|
|
||||||
<a-radio value="TOPIC"> topic</a-radio>
|
|
||||||
<a-radio value="GROUP"> 消费组</a-radio>
|
|
||||||
</a-radio-group>
|
|
||||||
</a-form-item>
|
|
||||||
<a-form-item label="资源名称">
|
|
||||||
<a-input
|
|
||||||
v-decorator="[
|
|
||||||
'resourceName',
|
|
||||||
{ rules: [{ required: true, message: '请输入!' }] },
|
|
||||||
]"
|
|
||||||
placeholder="请输入topic或消费组名称"
|
|
||||||
/>
|
|
||||||
</a-form-item>
|
|
||||||
<a-form-item label="主机">
|
|
||||||
<a-input
|
|
||||||
v-decorator="[
|
|
||||||
'host',
|
|
||||||
{
|
|
||||||
rules: [{ required: true, message: '请输入!' }],
|
|
||||||
initialValue: '*',
|
|
||||||
},
|
|
||||||
]"
|
|
||||||
placeholder="请输入主机地址,比如:*,全部匹配"
|
|
||||||
/>
|
|
||||||
</a-form-item>
|
|
||||||
<a-form-item label="操作类型" has-feedback>
|
|
||||||
<a-select
|
|
||||||
v-decorator="[
|
|
||||||
'operation',
|
|
||||||
{ rules: [{ required: true, message: '请选择!' }] },
|
|
||||||
]"
|
|
||||||
placeholder="请选择!"
|
|
||||||
>
|
|
||||||
<a-select-option v-for="i in operations" :key="i">
|
|
||||||
{{ i }}</a-select-option
|
|
||||||
>
|
|
||||||
</a-select>
|
|
||||||
</a-form-item>
|
|
||||||
<a-form-item label="权限类型">
|
|
||||||
<a-radio-group
|
|
||||||
v-decorator="['permissionType', { initialValue: 'ALLOW' }]"
|
|
||||||
>
|
|
||||||
<a-radio value="ALLOW"> 允许</a-radio>
|
|
||||||
<a-radio value="DENY"> 拒绝</a-radio>
|
|
||||||
</a-radio-group>
|
|
||||||
</a-form-item>
|
|
||||||
</a-form>
|
|
||||||
</a-modal>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import { KafkaAclApi } from "@/utils/api";
|
|
||||||
import request from "@/utils/request";
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: "AddPrincipalAuth",
|
|
||||||
props: {
|
|
||||||
visible: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
formLayout: "horizontal",
|
|
||||||
form: this.$form.createForm(this, { name: "AddPrincipalAuthForm" }),
|
|
||||||
confirmLoading: false,
|
|
||||||
show: this.visible,
|
|
||||||
operations: operationList,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
visible(v) {
|
|
||||||
if (this.show != v) {
|
|
||||||
this.show = v;
|
|
||||||
if (this.show) {
|
|
||||||
this.getOperationList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
handleOk() {
|
|
||||||
const form = this.form;
|
|
||||||
form.validateFields((e, v) => {
|
|
||||||
if (e) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const param = Object.assign({}, v);
|
|
||||||
const api = KafkaAclApi.addAclAuth;
|
|
||||||
this.confirmLoading = true;
|
|
||||||
request({
|
|
||||||
url: api.url,
|
|
||||||
method: api.method,
|
|
||||||
data: param,
|
|
||||||
}).then((res) => {
|
|
||||||
this.confirmLoading = false;
|
|
||||||
if (res.code == 0) {
|
|
||||||
this.$message.success(res.msg);
|
|
||||||
this.$emit("closeAddPrincipalAuthDialog", { refresh: true });
|
|
||||||
} else {
|
|
||||||
this.$message.error(res.msg);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
},
|
|
||||||
handleCancel() {
|
|
||||||
this.$emit("closeAddPrincipalAuthDialog", { refresh: false });
|
|
||||||
},
|
|
||||||
getOperationList() {
|
|
||||||
request({
|
|
||||||
url: KafkaAclApi.getOperationList.url,
|
|
||||||
method: KafkaAclApi.getOperationList.method,
|
|
||||||
}).then((res) => {
|
|
||||||
if (res.code != 0) {
|
|
||||||
this.$message.error(res.msg);
|
|
||||||
} else {
|
|
||||||
operationList.splice(0, operationList.length);
|
|
||||||
operationList.push(...res.data);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
const operationList = [];
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped></style>
|
|
||||||
@@ -1,411 +0,0 @@
|
|||||||
<template>
|
|
||||||
<a-spin :spinning="loading">
|
|
||||||
<div class="acl">
|
|
||||||
<div id="components-form-acl-advanced-search">
|
|
||||||
<a-form
|
|
||||||
class="ant-advanced-search-form"
|
|
||||||
:form="form"
|
|
||||||
@submit="handleSearch"
|
|
||||||
>
|
|
||||||
<a-row :gutter="24">
|
|
||||||
<a-col :span="8">
|
|
||||||
<a-form-item :label="`用户名`">
|
|
||||||
<a-input
|
|
||||||
placeholder="username"
|
|
||||||
class="input-w"
|
|
||||||
v-decorator="['username']"
|
|
||||||
/>
|
|
||||||
</a-form-item>
|
|
||||||
</a-col>
|
|
||||||
<a-col :span="12" :style="{ textAlign: 'right' }">
|
|
||||||
<a-button type="primary" html-type="submit"> 搜索</a-button>
|
|
||||||
<a-button :style="{ marginLeft: '8px' }" @click="handleReset">
|
|
||||||
重置
|
|
||||||
</a-button>
|
|
||||||
</a-col>
|
|
||||||
</a-row>
|
|
||||||
</a-form>
|
|
||||||
</div>
|
|
||||||
<div class="operation-row-button">
|
|
||||||
<a-button type="primary" @click="updateUser">新增/更新用户</a-button>
|
|
||||||
<span class="hint" v-show="!enableSasl"
|
|
||||||
>未启用SASL SCRAM认证,不支持相关操作</span
|
|
||||||
>
|
|
||||||
<UpdateUser
|
|
||||||
:visible="showUpdateUser"
|
|
||||||
@updateUserDialogData="closeUpdateUserDialog"
|
|
||||||
></UpdateUser>
|
|
||||||
</div>
|
|
||||||
<a-table :columns="columns" :data-source="data" bordered>
|
|
||||||
<div slot="username" slot-scope="username">
|
|
||||||
<span>{{ username }}</span
|
|
||||||
><a-button
|
|
||||||
size="small"
|
|
||||||
shape="round"
|
|
||||||
type="dashed"
|
|
||||||
style="float: right"
|
|
||||||
@click="onUserDetail(username)"
|
|
||||||
>详情</a-button
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
slot="operation"
|
|
||||||
slot-scope="record"
|
|
||||||
v-show="!record.user || record.user.role != 'admin'"
|
|
||||||
>
|
|
||||||
<a-popconfirm
|
|
||||||
:title="'删除用户: ' + record.username + '?'"
|
|
||||||
ok-text="确认"
|
|
||||||
cancel-text="取消"
|
|
||||||
@confirm="onDeleteUser(record)"
|
|
||||||
>
|
|
||||||
<a-button size="small" href="javascript:;" class="operation-btn"
|
|
||||||
>删除</a-button
|
|
||||||
>
|
|
||||||
</a-popconfirm>
|
|
||||||
<a-button
|
|
||||||
size="small"
|
|
||||||
href="javascript:;"
|
|
||||||
class="operation-btn"
|
|
||||||
@click="onManageProducerAuth(record)"
|
|
||||||
>管理生产权限
|
|
||||||
</a-button>
|
|
||||||
|
|
||||||
<a-button
|
|
||||||
size="small"
|
|
||||||
href="javascript:;"
|
|
||||||
class="operation-btn"
|
|
||||||
@click="onManageConsumerAuth(record)"
|
|
||||||
>管理消费权限
|
|
||||||
</a-button>
|
|
||||||
<a-button
|
|
||||||
size="small"
|
|
||||||
href="javascript:;"
|
|
||||||
class="operation-btn"
|
|
||||||
@click="onAddAuth(record)"
|
|
||||||
>增加权限
|
|
||||||
</a-button>
|
|
||||||
<a-popconfirm
|
|
||||||
:title="'删除用户: ' + record.username + '及相关权限?'"
|
|
||||||
ok-text="确认"
|
|
||||||
cancel-text="取消"
|
|
||||||
@confirm="onDeleteUserAndAuth(record)"
|
|
||||||
>
|
|
||||||
<a-button size="small" href="javascript:;" class="operation-btn"
|
|
||||||
>彻底删除</a-button
|
|
||||||
>
|
|
||||||
</a-popconfirm>
|
|
||||||
</div>
|
|
||||||
</a-table>
|
|
||||||
<UserDetail
|
|
||||||
:visible="openUserDetailDialog"
|
|
||||||
:username="selectDetail.username"
|
|
||||||
@userDetailDialog="closeUserDetailDialog"
|
|
||||||
></UserDetail>
|
|
||||||
<AclDetail
|
|
||||||
:visible="openAclDetailDialog"
|
|
||||||
:selectDetail="selectDetail"
|
|
||||||
@aclDetailDialog="closeAclDetailDialog"
|
|
||||||
></AclDetail>
|
|
||||||
<ManageProducerAuth
|
|
||||||
:visible="openManageProducerAuthDialog"
|
|
||||||
:record="selectRow"
|
|
||||||
@manageProducerAuthDialog="closeManageProducerAuthDialog"
|
|
||||||
></ManageProducerAuth>
|
|
||||||
<ManageConsumerAuth
|
|
||||||
:visible="openManageConsumerAuthDialog"
|
|
||||||
:record="selectRow"
|
|
||||||
@manageConsumerAuthDialog="closeManageConsumerAuthDialog"
|
|
||||||
></ManageConsumerAuth>
|
|
||||||
<AddAuth
|
|
||||||
:visible="openAddAuthDialog"
|
|
||||||
:record="selectRow"
|
|
||||||
@addAuthDialog="closeAddAuthDialog"
|
|
||||||
></AddAuth>
|
|
||||||
</div>
|
|
||||||
</a-spin>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import request from "@/utils/request";
|
|
||||||
import notification from "ant-design-vue/es/notification";
|
|
||||||
import UpdateUser from "@/views/acl/UpdateUser";
|
|
||||||
import { KafkaAclApi } from "@/utils/api";
|
|
||||||
import ManageProducerAuth from "@/views/acl/ManageProducerAuth";
|
|
||||||
import ManageConsumerAuth from "@/views/acl/ManageConsumerAuth";
|
|
||||||
import AddAuth from "@/views/acl/AddAuth";
|
|
||||||
import AclDetail from "@/views/acl/AclDetail";
|
|
||||||
import UserDetail from "@/views/acl/UserDetail";
|
|
||||||
import { mapState } from "vuex";
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: "SaslScram",
|
|
||||||
components: {
|
|
||||||
UpdateUser,
|
|
||||||
ManageProducerAuth,
|
|
||||||
ManageConsumerAuth,
|
|
||||||
AddAuth,
|
|
||||||
AclDetail,
|
|
||||||
UserDetail,
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
queryParam: {},
|
|
||||||
data: [],
|
|
||||||
columns,
|
|
||||||
selectRow: {},
|
|
||||||
form: this.$form.createForm(this, { name: "advanced_search" }),
|
|
||||||
showUpdateUser: false,
|
|
||||||
deleteUserConfirm: false,
|
|
||||||
openManageProducerAuthDialog: false,
|
|
||||||
openManageConsumerAuthDialog: false,
|
|
||||||
openAddAuthDialog: false,
|
|
||||||
openAclDetailDialog: false,
|
|
||||||
openUserDetailDialog: false,
|
|
||||||
selectDetail: {
|
|
||||||
resourceName: "",
|
|
||||||
resourceType: "",
|
|
||||||
username: "",
|
|
||||||
},
|
|
||||||
loading: false,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
handleSearch(e) {
|
|
||||||
e.preventDefault();
|
|
||||||
this.form.validateFields((error, values) => {
|
|
||||||
let queryParam = {};
|
|
||||||
if (values.username) {
|
|
||||||
queryParam.username = values.username;
|
|
||||||
}
|
|
||||||
if (values.topic) {
|
|
||||||
queryParam.resourceType = "TOPIC";
|
|
||||||
queryParam.resourceName = values.topic;
|
|
||||||
} else if (values.groupId) {
|
|
||||||
queryParam.resourceType = "GROUP";
|
|
||||||
queryParam.resourceName = values.groupId;
|
|
||||||
}
|
|
||||||
this.queryParam = {};
|
|
||||||
Object.assign(this.queryParam, queryParam);
|
|
||||||
this.getSaslScramUserList();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
handleReset() {
|
|
||||||
this.form.resetFields();
|
|
||||||
},
|
|
||||||
|
|
||||||
updateUser() {
|
|
||||||
this.showUpdateUser = true;
|
|
||||||
},
|
|
||||||
closeUpdateUserDialog(data) {
|
|
||||||
this.showUpdateUser = data.show;
|
|
||||||
if (data.ok) {
|
|
||||||
this.getSaslScramUserList();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onDeleteUser(row) {
|
|
||||||
this.loading = true;
|
|
||||||
request({
|
|
||||||
url: KafkaAclApi.deleteSaslScramUser.url,
|
|
||||||
method: KafkaAclApi.deleteSaslScramUser.method,
|
|
||||||
data: { username: row.username },
|
|
||||||
}).then((res) => {
|
|
||||||
this.loading = false;
|
|
||||||
this.getSaslScramUserList();
|
|
||||||
if (res.code == 0) {
|
|
||||||
this.$message.success(res.msg);
|
|
||||||
} else {
|
|
||||||
this.$message.error(res.msg);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
onDeleteUserAndAuth(row) {
|
|
||||||
this.loading = true;
|
|
||||||
request({
|
|
||||||
url: KafkaAclApi.deleteKafkaUser.url,
|
|
||||||
method: KafkaAclApi.deleteKafkaUser.method,
|
|
||||||
data: { username: row.username },
|
|
||||||
}).then((res) => {
|
|
||||||
this.loading = false;
|
|
||||||
this.getSaslScramUserList();
|
|
||||||
if (res.code == 0) {
|
|
||||||
this.$message.success(res.msg);
|
|
||||||
} else {
|
|
||||||
this.$message.error(res.msg);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
onManageProducerAuth(row) {
|
|
||||||
this.openManageProducerAuthDialog = true;
|
|
||||||
const rowData = {};
|
|
||||||
Object.assign(rowData, row);
|
|
||||||
this.selectRow = rowData;
|
|
||||||
},
|
|
||||||
onManageConsumerAuth(row) {
|
|
||||||
this.openManageConsumerAuthDialog = true;
|
|
||||||
const rowData = {};
|
|
||||||
Object.assign(rowData, row);
|
|
||||||
this.selectRow = rowData;
|
|
||||||
},
|
|
||||||
onAddAuth(row) {
|
|
||||||
this.openAddAuthDialog = true;
|
|
||||||
const rowData = {};
|
|
||||||
Object.assign(rowData, row);
|
|
||||||
this.selectRow = rowData;
|
|
||||||
},
|
|
||||||
onTopicDetail(topic, username) {
|
|
||||||
this.selectDetail.resourceType = "TOPIC";
|
|
||||||
this.selectDetail.resourceName = topic;
|
|
||||||
this.selectDetail.username = username;
|
|
||||||
this.openAclDetailDialog = true;
|
|
||||||
},
|
|
||||||
onGroupDetail(group, username) {
|
|
||||||
this.selectDetail.resourceType = "GROUP";
|
|
||||||
this.selectDetail.resourceName = group;
|
|
||||||
this.selectDetail.username = username;
|
|
||||||
this.openAclDetailDialog = true;
|
|
||||||
},
|
|
||||||
onUserDetail(username) {
|
|
||||||
this.selectDetail.username = username;
|
|
||||||
this.openUserDetailDialog = true;
|
|
||||||
},
|
|
||||||
closeManageProducerAuthDialog() {
|
|
||||||
this.openManageProducerAuthDialog = false;
|
|
||||||
},
|
|
||||||
closeManageConsumerAuthDialog() {
|
|
||||||
this.openManageConsumerAuthDialog = false;
|
|
||||||
},
|
|
||||||
closeAddAuthDialog() {
|
|
||||||
this.openAddAuthDialog = false;
|
|
||||||
},
|
|
||||||
closeAclDetailDialog(p) {
|
|
||||||
this.openAclDetailDialog = false;
|
|
||||||
if (p.refresh) {
|
|
||||||
this.getSaslScramUserList();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
closeUserDetailDialog() {
|
|
||||||
this.openUserDetailDialog = false;
|
|
||||||
},
|
|
||||||
getSaslScramUserList() {
|
|
||||||
if (!this.enableSasl) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.loading = true;
|
|
||||||
request({
|
|
||||||
url: KafkaAclApi.getSaslScramUserList.url,
|
|
||||||
method: KafkaAclApi.getSaslScramUserList.method,
|
|
||||||
params: this.queryParam,
|
|
||||||
}).then((response) => {
|
|
||||||
this.loading = false;
|
|
||||||
this.data.splice(0, this.data.length);
|
|
||||||
if (response.code != 0) {
|
|
||||||
notification.error({
|
|
||||||
message: response.msg,
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for (let k in response.data.map) {
|
|
||||||
let v = response.data.map[k];
|
|
||||||
let topicList = Object.keys(v)
|
|
||||||
.filter((e) => e.startsWith("TOPIC"))
|
|
||||||
.map((e) => e.split("#")[1]);
|
|
||||||
let groupList = Object.keys(v)
|
|
||||||
.filter((e) => e.startsWith("GROUP"))
|
|
||||||
.map((e) => e.split("#")[1]);
|
|
||||||
this.data.push({
|
|
||||||
key: k,
|
|
||||||
username: k,
|
|
||||||
topicList: topicList,
|
|
||||||
groupList: groupList,
|
|
||||||
user: response.data.map[k]["USER"],
|
|
||||||
});
|
|
||||||
this.data.sort((a, b) => a.username.localeCompare(b.username));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
},
|
|
||||||
created() {
|
|
||||||
this.getSaslScramUserList();
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
...mapState({
|
|
||||||
enableSasl: (state) => state.clusterInfo.enableSasl,
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const columns = [
|
|
||||||
{
|
|
||||||
title: "用户名",
|
|
||||||
dataIndex: "username",
|
|
||||||
key: "username",
|
|
||||||
width: 300,
|
|
||||||
slots: { title: "username" },
|
|
||||||
scopedSlots: { customRender: "username" },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "操作",
|
|
||||||
key: "operation",
|
|
||||||
scopedSlots: { customRender: "operation" },
|
|
||||||
width: 500,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.acl {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ant-advanced-search-form {
|
|
||||||
padding: 24px;
|
|
||||||
background: #fbfbfb;
|
|
||||||
border: 1px solid #d9d9d9;
|
|
||||||
border-radius: 6px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ant-advanced-search-form .ant-form-item {
|
|
||||||
display: flex;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ant-advanced-search-form .ant-form-item-control-wrapper {
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#components-form-acl-advanced-search .ant-form {
|
|
||||||
max-width: none;
|
|
||||||
margin-bottom: 1%;
|
|
||||||
}
|
|
||||||
|
|
||||||
#components-form-acl-advanced-search .search-result-list {
|
|
||||||
margin-top: 16px;
|
|
||||||
border: 1px dashed #e9e9e9;
|
|
||||||
border-radius: 6px;
|
|
||||||
background-color: #fafafa;
|
|
||||||
min-height: 200px;
|
|
||||||
text-align: center;
|
|
||||||
padding-top: 80px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.input-w {
|
|
||||||
width: 400px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.operation-row-button {
|
|
||||||
height: 4%;
|
|
||||||
text-align: left;
|
|
||||||
margin-bottom: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.operation-btn {
|
|
||||||
margin-right: 3%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.hint {
|
|
||||||
margin-left: 1%;
|
|
||||||
color: red;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,43 +1,47 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="content">
|
<div>
|
||||||
<a-spin :spinning="loading">
|
<Header/>
|
||||||
<div class="body-c">
|
<div class="content">
|
||||||
<div class="cluster-id">
|
<a-spin :spinning="loading">
|
||||||
<h3>集群ID:{{ clusterId }}</h3>
|
<div class="body-c">
|
||||||
</div>
|
<div class="cluster-id">
|
||||||
|
<h3>集群ID:{{ clusterId }}</h3>
|
||||||
|
</div>
|
||||||
|
|
||||||
<a-table :columns="columns" :data-source="data" bordered row-key="id">
|
<a-table :columns="columns" :data-source="data" bordered row-key="id">
|
||||||
<div slot="addr" slot-scope="text, record">
|
<div slot="addr" slot-scope="text, record">
|
||||||
{{ record.host }}:{{ record.port }}
|
{{ record.host }}:{{ record.port }}
|
||||||
</div>
|
</div>
|
||||||
<div slot="controller" slot-scope="text">
|
<div slot="controller" slot-scope="text">
|
||||||
<span v-if="text" style="color: red">是</span><span v-else>否</span>
|
<span v-if="text" style="color: red">是</span><span v-else>否</span>
|
||||||
</div>
|
</div>
|
||||||
<div slot="operation" slot-scope="record" v-show="!record.internal">
|
<div slot="operation" slot-scope="record" v-show="!record.internal">
|
||||||
<a-button
|
<a-button
|
||||||
size="small"
|
v-show="manager"
|
||||||
href="javascript:;"
|
size="small"
|
||||||
class="operation-btn"
|
href="javascript:;"
|
||||||
@click="openBrokerConfigDialog(record, false)"
|
class="operation-btn"
|
||||||
|
@click="openBrokerConfigDialog(record, false)"
|
||||||
>属性配置
|
>属性配置
|
||||||
</a-button>
|
</a-button>
|
||||||
<a-button
|
<a-button
|
||||||
size="small"
|
size="small"
|
||||||
href="javascript:;"
|
href="javascript:;"
|
||||||
class="operation-btn"
|
class="operation-btn"
|
||||||
@click="openBrokerConfigDialog(record, true)"
|
@click="openBrokerConfigDialog(record, true)"
|
||||||
>日志配置
|
>日志配置
|
||||||
</a-button>
|
</a-button>
|
||||||
</div>
|
</div>
|
||||||
</a-table>
|
</a-table>
|
||||||
</div>
|
</div>
|
||||||
<BrokerConfig
|
<BrokerConfig
|
||||||
:visible="showBrokerConfigDialog"
|
:visible="showBrokerConfigDialog"
|
||||||
:id="this.select.idString"
|
:id="this.select.idString"
|
||||||
:is-logger-config="isLoggerConfig"
|
:is-logger-config="isLoggerConfig"
|
||||||
@closeBrokerConfigDialog="closeBrokerConfigDialog"
|
@closeBrokerConfigDialog="closeBrokerConfigDialog"
|
||||||
></BrokerConfig>
|
></BrokerConfig>
|
||||||
</a-spin>
|
</a-spin>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -46,12 +50,14 @@ import request from "@/utils/request";
|
|||||||
import { KafkaClusterApi } from "@/utils/api";
|
import { KafkaClusterApi } from "@/utils/api";
|
||||||
import BrokerConfig from "@/views/cluster/BrokerConfig";
|
import BrokerConfig from "@/views/cluster/BrokerConfig";
|
||||||
import notification from "ant-design-vue/lib/notification";
|
import notification from "ant-design-vue/lib/notification";
|
||||||
|
import Header from "@/components/Header"
|
||||||
|
import {isManager} from "../../utils/role";
|
||||||
export default {
|
export default {
|
||||||
name: "Topic",
|
name: "Topic",
|
||||||
components: { BrokerConfig },
|
components: { BrokerConfig, Header },
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
manager: isManager(),
|
||||||
data: [],
|
data: [],
|
||||||
columns,
|
columns,
|
||||||
loading: false,
|
loading: false,
|
||||||
|
|||||||
@@ -272,7 +272,6 @@ const columns = [
|
|||||||
dataIndex: "clientId",
|
dataIndex: "clientId",
|
||||||
key: "clientId",
|
key: "clientId",
|
||||||
scopedSlots: { customRender: "clientId" },
|
scopedSlots: { customRender: "clientId" },
|
||||||
width: 400,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "日志位点",
|
title: "日志位点",
|
||||||
|
|||||||
@@ -1,144 +1,148 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="content">
|
<div>
|
||||||
<a-spin :spinning="loading">
|
<Header/>
|
||||||
<div class="topic">
|
<div class="content">
|
||||||
<div id="form-consumer-group-advanced-search">
|
<a-spin :spinning="loading">
|
||||||
<a-form
|
<div class="topic">
|
||||||
class="ant-advanced-search-form"
|
<div id="form-consumer-group-advanced-search">
|
||||||
:form="form"
|
<a-form
|
||||||
@submit="handleSearch"
|
class="ant-advanced-search-form"
|
||||||
>
|
:form="form"
|
||||||
<a-row :gutter="24">
|
@submit="handleSearch"
|
||||||
<a-col :span="8">
|
|
||||||
<a-form-item :label="`消费组`">
|
|
||||||
<a-input
|
|
||||||
placeholder="groupId"
|
|
||||||
class="input-w"
|
|
||||||
v-decorator="['groupId']"
|
|
||||||
/>
|
|
||||||
</a-form-item>
|
|
||||||
</a-col>
|
|
||||||
<a-col :span="12">
|
|
||||||
<a-form-item :label="`状态`">
|
|
||||||
<a-checkbox-group
|
|
||||||
v-decorator="['states']"
|
|
||||||
style="width: 100%"
|
|
||||||
>
|
|
||||||
<a-row>
|
|
||||||
<a-col :span="8">
|
|
||||||
<a-checkbox value="Empty"> Empty</a-checkbox>
|
|
||||||
</a-col>
|
|
||||||
<a-col :span="8">
|
|
||||||
<a-checkbox value="PreparingRebalance">
|
|
||||||
PreparingRebalance
|
|
||||||
</a-checkbox>
|
|
||||||
</a-col>
|
|
||||||
<a-col :span="8">
|
|
||||||
<a-checkbox value="CompletingRebalance">
|
|
||||||
CompletingRebalance
|
|
||||||
</a-checkbox>
|
|
||||||
</a-col>
|
|
||||||
<a-col :span="8">
|
|
||||||
<a-checkbox value="Stable"> Stable</a-checkbox>
|
|
||||||
</a-col>
|
|
||||||
<a-col :span="8">
|
|
||||||
<a-checkbox value="Dead"> Dead</a-checkbox>
|
|
||||||
</a-col>
|
|
||||||
</a-row>
|
|
||||||
</a-checkbox-group>
|
|
||||||
</a-form-item>
|
|
||||||
</a-col>
|
|
||||||
|
|
||||||
<a-col :span="4" :style="{ textAlign: 'right' }">
|
|
||||||
<a-form-item>
|
|
||||||
<a-button type="primary" html-type="submit"> 搜索</a-button>
|
|
||||||
<a-button :style="{ marginLeft: '8px' }" @click="handleReset">
|
|
||||||
重置
|
|
||||||
</a-button>
|
|
||||||
</a-form-item>
|
|
||||||
</a-col>
|
|
||||||
</a-row>
|
|
||||||
</a-form>
|
|
||||||
</div>
|
|
||||||
<div class="operation-row-button">
|
|
||||||
<a-button type="primary" @click="openAddSubscriptionDialog"
|
|
||||||
>新增订阅</a-button
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
<a-table
|
|
||||||
:columns="columns"
|
|
||||||
:data-source="data"
|
|
||||||
bordered
|
|
||||||
row-key="groupId"
|
|
||||||
>
|
|
||||||
<div slot="members" slot-scope="text, record">
|
|
||||||
<a href="#" @click="openConsumerMemberDialog(record.groupId)"
|
|
||||||
>{{ text }}
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div slot="state" slot-scope="text">
|
|
||||||
{{ text }}
|
|
||||||
<!-- <span v-if="text" style="color: red">是</span><span v-else>否</span>-->
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div slot="operation" slot-scope="record" v-show="!record.internal">
|
|
||||||
<a-popconfirm
|
|
||||||
:title="'删除消费组: ' + record.groupId + '?'"
|
|
||||||
ok-text="确认"
|
|
||||||
cancel-text="取消"
|
|
||||||
@confirm="deleteGroup(record.groupId)"
|
|
||||||
>
|
>
|
||||||
<a-button size="small" href="javascript:;" class="operation-btn"
|
<a-row :gutter="24">
|
||||||
>删除
|
<a-col :span="8">
|
||||||
</a-button>
|
<a-form-item :label="`消费组`">
|
||||||
</a-popconfirm>
|
<a-input
|
||||||
<a-button
|
placeholder="groupId"
|
||||||
size="small"
|
class="input-w"
|
||||||
href="javascript:;"
|
v-decorator="['groupId']"
|
||||||
class="operation-btn"
|
/>
|
||||||
@click="openConsumerMemberDialog(record.groupId)"
|
</a-form-item>
|
||||||
>消费端
|
</a-col>
|
||||||
</a-button>
|
<a-col :span="12">
|
||||||
<a-button
|
<a-form-item :label="`状态`">
|
||||||
size="small"
|
<a-checkbox-group
|
||||||
href="javascript:;"
|
v-decorator="['states']"
|
||||||
class="operation-btn"
|
style="width: 100%"
|
||||||
@click="openConsumerDetailDialog(record.groupId)"
|
>
|
||||||
>消费详情
|
<a-row>
|
||||||
</a-button>
|
<a-col :span="8">
|
||||||
<a-button
|
<a-checkbox value="Empty"> Empty</a-checkbox>
|
||||||
size="small"
|
</a-col>
|
||||||
href="javascript:;"
|
<a-col :span="8">
|
||||||
class="operation-btn"
|
<a-checkbox value="PreparingRebalance">
|
||||||
@click="openOffsetPartitionDialog(record.groupId)"
|
PreparingRebalance
|
||||||
>位移分区
|
</a-checkbox>
|
||||||
</a-button>
|
</a-col>
|
||||||
|
<a-col :span="8">
|
||||||
|
<a-checkbox value="CompletingRebalance">
|
||||||
|
CompletingRebalance
|
||||||
|
</a-checkbox>
|
||||||
|
</a-col>
|
||||||
|
<a-col :span="8">
|
||||||
|
<a-checkbox value="Stable"> Stable</a-checkbox>
|
||||||
|
</a-col>
|
||||||
|
<a-col :span="8">
|
||||||
|
<a-checkbox value="Dead"> Dead</a-checkbox>
|
||||||
|
</a-col>
|
||||||
|
</a-row>
|
||||||
|
</a-checkbox-group>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
|
||||||
|
<a-col :span="4" :style="{ textAlign: 'right' }">
|
||||||
|
<a-form-item>
|
||||||
|
<a-button type="primary" html-type="submit"> 搜索</a-button>
|
||||||
|
<a-button :style="{ marginLeft: '8px' }" @click="handleReset">
|
||||||
|
重置
|
||||||
|
</a-button>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
</a-row>
|
||||||
|
</a-form>
|
||||||
</div>
|
</div>
|
||||||
</a-table>
|
<div v-show="manager" class="operation-row-button">
|
||||||
<Member
|
<a-button type="primary" @click="openAddSubscriptionDialog"
|
||||||
:visible="showConsumerGroupDialog"
|
>新增订阅</a-button
|
||||||
:group="selectDetail.resourceName"
|
>
|
||||||
@closeConsumerMemberDialog="closeConsumerDialog"
|
</div>
|
||||||
></Member>
|
<a-table
|
||||||
<ConsumerDetail
|
:columns="columns"
|
||||||
:visible="showConsumerDetailDialog"
|
:data-source="data"
|
||||||
:group="selectDetail.resourceName"
|
bordered
|
||||||
@closeConsumerDetailDialog="closeConsumerDetailDialog"
|
row-key="groupId"
|
||||||
>
|
>
|
||||||
</ConsumerDetail>
|
<div slot="members" slot-scope="text, record">
|
||||||
<AddSupscription
|
<a href="#" @click="openConsumerMemberDialog(record.groupId)"
|
||||||
:visible="showAddSubscriptionDialog"
|
>{{ text }}
|
||||||
@closeAddSubscriptionDialog="closeAddSubscriptionDialog"
|
</a>
|
||||||
>
|
</div>
|
||||||
</AddSupscription>
|
|
||||||
<OffsetTopicPartition
|
<div slot="state" slot-scope="text">
|
||||||
:visible="showOffsetPartitionDialog"
|
{{ text }}
|
||||||
:group="selectDetail.resourceName"
|
<!-- <span v-if="text" style="color: red">是</span><span v-else>否</span>-->
|
||||||
@closeOffsetPartitionDialog="closeOffsetPartitionDialog"
|
</div>
|
||||||
></OffsetTopicPartition>
|
|
||||||
</div>
|
<div slot="operation" slot-scope="record" v-show="!record.internal">
|
||||||
</a-spin>
|
<a-popconfirm
|
||||||
|
:title="'删除消费组: ' + record.groupId + '?'"
|
||||||
|
ok-text="确认"
|
||||||
|
cancel-text="取消"
|
||||||
|
@confirm="deleteGroup(record.groupId)"
|
||||||
|
>
|
||||||
|
<a-button v-show="manager" size="small" href="javascript:;" class="operation-btn"
|
||||||
|
>删除
|
||||||
|
</a-button>
|
||||||
|
</a-popconfirm>
|
||||||
|
<a-button
|
||||||
|
size="small"
|
||||||
|
href="javascript:;"
|
||||||
|
class="operation-btn"
|
||||||
|
@click="openConsumerMemberDialog(record.groupId)"
|
||||||
|
>消费端
|
||||||
|
</a-button>
|
||||||
|
<a-button
|
||||||
|
v-show="manager"
|
||||||
|
size="small"
|
||||||
|
href="javascript:;"
|
||||||
|
class="operation-btn"
|
||||||
|
@click="openConsumerDetailDialog(record.groupId)"
|
||||||
|
>消费详情
|
||||||
|
</a-button>
|
||||||
|
<a-button
|
||||||
|
size="small"
|
||||||
|
href="javascript:;"
|
||||||
|
class="operation-btn"
|
||||||
|
@click="openOffsetPartitionDialog(record.groupId)"
|
||||||
|
>位移分区
|
||||||
|
</a-button>
|
||||||
|
</div>
|
||||||
|
</a-table>
|
||||||
|
<Member
|
||||||
|
:visible="showConsumerGroupDialog"
|
||||||
|
:group="selectDetail.resourceName"
|
||||||
|
@closeConsumerMemberDialog="closeConsumerDialog"
|
||||||
|
></Member>
|
||||||
|
<ConsumerDetail
|
||||||
|
:visible="showConsumerDetailDialog"
|
||||||
|
:group="selectDetail.resourceName"
|
||||||
|
@closeConsumerDetailDialog="closeConsumerDetailDialog"
|
||||||
|
>
|
||||||
|
</ConsumerDetail>
|
||||||
|
<AddSupscription
|
||||||
|
:visible="showAddSubscriptionDialog"
|
||||||
|
@closeAddSubscriptionDialog="closeAddSubscriptionDialog"
|
||||||
|
>
|
||||||
|
</AddSupscription>
|
||||||
|
<OffsetTopicPartition
|
||||||
|
:visible="showOffsetPartitionDialog"
|
||||||
|
:group="selectDetail.resourceName"
|
||||||
|
@closeOffsetPartitionDialog="closeOffsetPartitionDialog"
|
||||||
|
></OffsetTopicPartition>
|
||||||
|
</div>
|
||||||
|
</a-spin>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -150,12 +154,14 @@ import Member from "@/views/group/Member";
|
|||||||
import ConsumerDetail from "@/views/group/ConsumerDetail";
|
import ConsumerDetail from "@/views/group/ConsumerDetail";
|
||||||
import AddSupscription from "@/views/group/AddSupscription";
|
import AddSupscription from "@/views/group/AddSupscription";
|
||||||
import OffsetTopicPartition from "@/views/group/OffsetTopicPartition";
|
import OffsetTopicPartition from "@/views/group/OffsetTopicPartition";
|
||||||
|
import Header from "@/components/Header"
|
||||||
|
import {isManager} from "../../utils/role";
|
||||||
export default {
|
export default {
|
||||||
name: "ConsumerGroup",
|
name: "ConsumerGroup",
|
||||||
components: { Member, ConsumerDetail, AddSupscription, OffsetTopicPartition },
|
components: { Member, ConsumerDetail, AddSupscription, OffsetTopicPartition, Header },
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
manager: isManager(),
|
||||||
queryParam: {},
|
queryParam: {},
|
||||||
data: [],
|
data: [],
|
||||||
columns,
|
columns,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<a-modal
|
<a-modal
|
||||||
title="消费端成员"
|
title="消费端成员"
|
||||||
:visible="show"
|
:visible="show"
|
||||||
:width="1300"
|
:width="1500"
|
||||||
:mask="false"
|
:mask="false"
|
||||||
:destroyOnClose="true"
|
:destroyOnClose="true"
|
||||||
:footer="null"
|
:footer="null"
|
||||||
@@ -96,19 +96,16 @@ const columns = [
|
|||||||
title: "成员ID",
|
title: "成员ID",
|
||||||
dataIndex: "memberId",
|
dataIndex: "memberId",
|
||||||
key: "memberId",
|
key: "memberId",
|
||||||
width: 300,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "客户端ID",
|
title: "客户端ID",
|
||||||
dataIndex: "clientId",
|
dataIndex: "clientId",
|
||||||
key: "clientId",
|
key: "clientId",
|
||||||
width: 300,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "实例ID",
|
title: "实例ID",
|
||||||
dataIndex: "groupInstanceId",
|
dataIndex: "groupInstanceId",
|
||||||
key: "groupInstanceId",
|
key: "groupInstanceId",
|
||||||
width: 150,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "主机",
|
title: "主机",
|
||||||
@@ -120,7 +117,6 @@ const columns = [
|
|||||||
dataIndex: "partitions",
|
dataIndex: "partitions",
|
||||||
key: "partitions",
|
key: "partitions",
|
||||||
scopedSlots: { customRender: "partitions" },
|
scopedSlots: { customRender: "partitions" },
|
||||||
width: 300,
|
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,35 +1,38 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="home">
|
<div>
|
||||||
<a-card title="控制台默认配置" class="card-style">
|
<Header/>
|
||||||
<p v-for="(v, k) in config" :key="k">{{ k }}={{ v }}</p>
|
<div class="content">
|
||||||
</a-card>
|
<a-card title="控制台默认配置" class="card-style">
|
||||||
<p></p>
|
<p v-for="(v, k) in config" :key="k">{{ k }}={{ v }}</p>
|
||||||
<hr />
|
</a-card>
|
||||||
<h3>kafka API 版本兼容性</h3>
|
<p></p>
|
||||||
<a-spin :spinning="apiVersionInfoLoading">
|
<hr />
|
||||||
<a-table
|
<h3>kafka API 版本兼容性</h3>
|
||||||
:columns="columns"
|
<a-spin :spinning="apiVersionInfoLoading">
|
||||||
:data-source="brokerApiVersionInfo"
|
<a-table
|
||||||
bordered
|
:columns="columns"
|
||||||
row-key="brokerId"
|
:data-source="brokerApiVersionInfo"
|
||||||
>
|
bordered
|
||||||
<div slot="operation" slot-scope="record">
|
row-key="brokerId"
|
||||||
<a-button
|
>
|
||||||
size="small"
|
<div slot="operation" slot-scope="record">
|
||||||
href="javascript:;"
|
<a-button
|
||||||
class="operation-btn"
|
size="small"
|
||||||
@click="openApiVersionInfoDialog(record)"
|
href="javascript:;"
|
||||||
|
class="operation-btn"
|
||||||
|
@click="openApiVersionInfoDialog(record)"
|
||||||
>详情
|
>详情
|
||||||
</a-button>
|
</a-button>
|
||||||
</div>
|
</div>
|
||||||
</a-table>
|
</a-table>
|
||||||
</a-spin>
|
</a-spin>
|
||||||
<VersionInfo
|
<VersionInfo
|
||||||
:version-info="apiVersionInfo"
|
:version-info="apiVersionInfo"
|
||||||
:visible="showApiVersionInfoDialog"
|
:visible="showApiVersionInfoDialog"
|
||||||
@closeApiVersionInfoDialog="closeApiVersionInfoDialog"
|
@closeApiVersionInfoDialog="closeApiVersionInfoDialog"
|
||||||
>
|
>
|
||||||
</VersionInfo>
|
</VersionInfo>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -39,9 +42,10 @@ import request from "@/utils/request";
|
|||||||
import { KafkaConfigApi, KafkaClusterApi } from "@/utils/api";
|
import { KafkaConfigApi, KafkaClusterApi } from "@/utils/api";
|
||||||
import notification from "ant-design-vue/lib/notification";
|
import notification from "ant-design-vue/lib/notification";
|
||||||
import VersionInfo from "@/views/home/VersionInfo";
|
import VersionInfo from "@/views/home/VersionInfo";
|
||||||
|
import Header from "@/components/Header"
|
||||||
export default {
|
export default {
|
||||||
name: "Home",
|
name: "Home",
|
||||||
components: { VersionInfo },
|
components: { VersionInfo, Header },
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
config: {},
|
config: {},
|
||||||
99
ui/src/views/login/index.vue
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
<template>
|
||||||
|
<div id="login">
|
||||||
|
<div class="kafka-console-ui">
|
||||||
|
<span style="font-size: xxx-large; font-weight: bold">kafka-console-ui</span>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<a-form
|
||||||
|
:form="form"
|
||||||
|
:label-col="{ span: 10 }"
|
||||||
|
:wrapper-col="{ span: 4 }"
|
||||||
|
@submit="handleSubmit"
|
||||||
|
>
|
||||||
|
<a-form-item label="账号">
|
||||||
|
<a-input
|
||||||
|
v-decorator="[
|
||||||
|
'username',
|
||||||
|
{ rules: [{ required: true, message: '请输入账号' }] },
|
||||||
|
]"
|
||||||
|
placeholder="请输入账号"
|
||||||
|
/>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="密码">
|
||||||
|
<a-input
|
||||||
|
v-decorator="[
|
||||||
|
'password',
|
||||||
|
{ rules: [{ required: true, message: '请输入密码' }] },
|
||||||
|
]"
|
||||||
|
placeholder="请输入密码"
|
||||||
|
/>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item :wrapper-col="{ span: 10, offset: 10 }">
|
||||||
|
<a-button type="primary" html-type="submit"> 提交 </a-button>
|
||||||
|
</a-form-item>
|
||||||
|
</a-form>
|
||||||
|
</div>
|
||||||
|
<router-view></router-view>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import notification from "ant-design-vue/lib/notification";
|
||||||
|
import request from "@/utils/request";
|
||||||
|
import { DevOpsUserAPi } from "@/utils/api";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'login',
|
||||||
|
data(){
|
||||||
|
return{
|
||||||
|
form: this.$form.createForm(this, { name: "coordinated" }),
|
||||||
|
}
|
||||||
|
},methods:{
|
||||||
|
handleSubmit(e){
|
||||||
|
e.preventDefault();
|
||||||
|
this.form.validateFields((err, values) => {
|
||||||
|
if (!err) {
|
||||||
|
if (values.configs) {
|
||||||
|
const config = {};
|
||||||
|
values.configs.split("\n").forEach((e) => {
|
||||||
|
const c = e.split("=");
|
||||||
|
if (c.length > 1) {
|
||||||
|
let k = c[0].trim(),
|
||||||
|
v = c[1].trim();
|
||||||
|
if (k && v) {
|
||||||
|
config[k] = v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
values.configs = config;
|
||||||
|
}
|
||||||
|
request({
|
||||||
|
url: DevOpsUserAPi.login.url,
|
||||||
|
method: DevOpsUserAPi.login.method,
|
||||||
|
data: values,
|
||||||
|
}).then((res) => {
|
||||||
|
if (res.code == 0) {
|
||||||
|
localStorage.setItem('token', res.data.token)
|
||||||
|
localStorage.setItem('role', res.data.role)
|
||||||
|
this.$router.push({ path:'/main'})
|
||||||
|
} else {
|
||||||
|
notification.error({
|
||||||
|
message: "error",
|
||||||
|
description: res.msg,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<style>
|
||||||
|
.kafka-console-ui{
|
||||||
|
text-align: center;
|
||||||
|
height: 100px;
|
||||||
|
margin-top: 50px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -1,196 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="tab-content">
|
|
||||||
<a-spin :spinning="loading">
|
|
||||||
<div>
|
|
||||||
<h4 class="hint-content">
|
|
||||||
注意:以下删除,将删除该分区比该偏移位点小的所有消息(不包含该位点)
|
|
||||||
</h4>
|
|
||||||
<hr />
|
|
||||||
</div>
|
|
||||||
<div id="search-offset-form-advanced-search">
|
|
||||||
<a-form
|
|
||||||
class="ant-advanced-search-form"
|
|
||||||
:form="form"
|
|
||||||
@submit="handleSearch"
|
|
||||||
>
|
|
||||||
<a-row :gutter="24">
|
|
||||||
<a-col :span="9">
|
|
||||||
<a-form-item label="topic">
|
|
||||||
<a-select
|
|
||||||
class="topic-select"
|
|
||||||
@change="handleTopicChange"
|
|
||||||
show-search
|
|
||||||
option-filter-prop="children"
|
|
||||||
v-decorator="[
|
|
||||||
'topic',
|
|
||||||
{
|
|
||||||
rules: [{ required: true, message: '请选择一个topic!' }],
|
|
||||||
},
|
|
||||||
]"
|
|
||||||
placeholder="请选择一个topic"
|
|
||||||
>
|
|
||||||
<a-select-option v-for="v in topicList" :key="v" :value="v">
|
|
||||||
{{ v }}
|
|
||||||
</a-select-option>
|
|
||||||
</a-select>
|
|
||||||
</a-form-item>
|
|
||||||
</a-col>
|
|
||||||
<a-col :span="6">
|
|
||||||
<a-form-item label="分区">
|
|
||||||
<a-select
|
|
||||||
class="type-select"
|
|
||||||
show-search
|
|
||||||
option-filter-prop="children"
|
|
||||||
v-model="selectPartition"
|
|
||||||
placeholder="请选择一个分区"
|
|
||||||
>
|
|
||||||
<a-select-option v-for="v in partitions" :key="v" :value="v">
|
|
||||||
<span v-if="v == -1">全部</span> <span v-else>{{ v }}</span>
|
|
||||||
</a-select-option>
|
|
||||||
</a-select>
|
|
||||||
</a-form-item>
|
|
||||||
</a-col>
|
|
||||||
<a-col :span="7">
|
|
||||||
<a-form-item label="偏移">
|
|
||||||
<a-input
|
|
||||||
v-decorator="[
|
|
||||||
'offset',
|
|
||||||
{
|
|
||||||
rules: [{ required: true, message: '请输入消息偏移!' }],
|
|
||||||
},
|
|
||||||
]"
|
|
||||||
placeholder="消息偏移"
|
|
||||||
/>
|
|
||||||
</a-form-item>
|
|
||||||
</a-col>
|
|
||||||
<a-col :span="2" :style="{ textAlign: 'right' }">
|
|
||||||
<a-form-item>
|
|
||||||
<a-button type="primary" html-type="submit"> 执行删除</a-button>
|
|
||||||
</a-form-item>
|
|
||||||
</a-col>
|
|
||||||
</a-row>
|
|
||||||
</a-form>
|
|
||||||
</div>
|
|
||||||
</a-spin>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import request from "@/utils/request";
|
|
||||||
import { KafkaMessageApi, KafkaTopicApi } from "@/utils/api";
|
|
||||||
import notification from "ant-design-vue/lib/notification";
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: "DeleteMessage",
|
|
||||||
props: {
|
|
||||||
topicList: {
|
|
||||||
type: Array,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
loading: false,
|
|
||||||
form: this.$form.createForm(this, { name: "message_search_offset" }),
|
|
||||||
partitions: [],
|
|
||||||
selectPartition: undefined,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
handleSearch(e) {
|
|
||||||
e.preventDefault();
|
|
||||||
this.form.validateFields((err, values) => {
|
|
||||||
if (!err) {
|
|
||||||
const data = Object.assign({}, values, {
|
|
||||||
partition: this.selectPartition,
|
|
||||||
});
|
|
||||||
this.loading = true;
|
|
||||||
request({
|
|
||||||
url: KafkaMessageApi.delete.url,
|
|
||||||
method: KafkaMessageApi.delete.method,
|
|
||||||
data: [data],
|
|
||||||
}).then((res) => {
|
|
||||||
this.loading = false;
|
|
||||||
if (res.code == 0) {
|
|
||||||
this.$message.success(res.msg);
|
|
||||||
} else {
|
|
||||||
notification.error({
|
|
||||||
message: "error",
|
|
||||||
description: res.msg,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
getPartitionInfo(topic) {
|
|
||||||
this.loading = true;
|
|
||||||
request({
|
|
||||||
url: KafkaTopicApi.getPartitionInfo.url + "?topic=" + topic,
|
|
||||||
method: KafkaTopicApi.getPartitionInfo.method,
|
|
||||||
}).then((res) => {
|
|
||||||
this.loading = false;
|
|
||||||
if (res.code != 0) {
|
|
||||||
notification.error({
|
|
||||||
message: "error",
|
|
||||||
description: res.msg,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
this.partitions = res.data.map((v) => v.partition);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
handleTopicChange(topic) {
|
|
||||||
this.selectPartition =
|
|
||||||
this.partitions.length > 0 ? this.partitions[0] : 0;
|
|
||||||
this.getPartitionInfo(topic);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.tab-content {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ant-advanced-search-form {
|
|
||||||
padding: 24px;
|
|
||||||
background: #fbfbfb;
|
|
||||||
border: 1px solid #d9d9d9;
|
|
||||||
border-radius: 6px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ant-advanced-search-form .ant-form-item {
|
|
||||||
display: flex;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ant-advanced-search-form .ant-form-item-control-wrapper {
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#components-form-topic-advanced-search .ant-form {
|
|
||||||
max-width: none;
|
|
||||||
margin-bottom: 1%;
|
|
||||||
}
|
|
||||||
|
|
||||||
#search-offset-form-advanced-search .search-result-list {
|
|
||||||
margin-top: 16px;
|
|
||||||
border: 1px dashed #e9e9e9;
|
|
||||||
border-radius: 6px;
|
|
||||||
background-color: #fafafa;
|
|
||||||
min-height: 200px;
|
|
||||||
text-align: center;
|
|
||||||
padding-top: 80px;
|
|
||||||
}
|
|
||||||
.topic-select {
|
|
||||||
width: 400px !important;
|
|
||||||
}
|
|
||||||
.type-select {
|
|
||||||
width: 200px !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.hint-content {
|
|
||||||
color: red;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,21 +1,21 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="content">
|
<div>
|
||||||
<a-spin :spinning="loading">
|
<Header/>
|
||||||
<a-tabs default-active-key="1" size="large" tabPosition="top">
|
<div class="content">
|
||||||
<a-tab-pane key="1" tab="根据时间查询消息">
|
<a-spin :spinning="loading">
|
||||||
<SearchByTime :topic-list="topicList"></SearchByTime>
|
<a-tabs default-active-key="1" size="large" tabPosition="top">
|
||||||
</a-tab-pane>
|
<a-tab-pane key="1" tab="根据时间查询消息">
|
||||||
<a-tab-pane key="2" tab="根据偏移查询消息">
|
<SearchByTime :topic-list="topicList"></SearchByTime>
|
||||||
<SearchByOffset :topic-list="topicList"></SearchByOffset>
|
</a-tab-pane>
|
||||||
</a-tab-pane>
|
<a-tab-pane key="2" tab="根据偏移查询消息">
|
||||||
<a-tab-pane key="3" tab="在线发送">
|
<SearchByOffset :topic-list="topicList"></SearchByOffset>
|
||||||
<SendMessage :topic-list="topicList"></SendMessage>
|
</a-tab-pane>
|
||||||
</a-tab-pane>
|
<a-tab-pane key="3" tab="在线发送">
|
||||||
<a-tab-pane key="4" tab="在线删除">
|
<SendMessage :topic-list="topicList"></SendMessage>
|
||||||
<DeleteMessage :topic-list="topicList"></DeleteMessage>
|
</a-tab-pane>
|
||||||
</a-tab-pane>
|
</a-tabs>
|
||||||
</a-tabs>
|
</a-spin>
|
||||||
</a-spin>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -26,10 +26,10 @@ import request from "@/utils/request";
|
|||||||
import { KafkaTopicApi } from "@/utils/api";
|
import { KafkaTopicApi } from "@/utils/api";
|
||||||
import notification from "ant-design-vue/lib/notification";
|
import notification from "ant-design-vue/lib/notification";
|
||||||
import SendMessage from "@/views/message/SendMessage";
|
import SendMessage from "@/views/message/SendMessage";
|
||||||
import DeleteMessage from "./DeleteMessage";
|
import Header from "@/components/Header"
|
||||||
export default {
|
export default {
|
||||||
name: "Message",
|
name: "Message",
|
||||||
components: { DeleteMessage, SearchByTime, SearchByOffset, SendMessage },
|
components: { SearchByTime, SearchByOffset, SendMessage, Header },
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
loading: false,
|
loading: false,
|
||||||
|
|||||||
@@ -132,9 +132,9 @@ export default {
|
|||||||
if (
|
if (
|
||||||
clusterInfo &&
|
clusterInfo &&
|
||||||
clusterInfo.id &&
|
clusterInfo.id &&
|
||||||
clusterInfo.id == this.clusterInfo.id
|
clusterInfo.id == this.clusterInfo.id &&
|
||||||
|
clusterInfo.clusterName != data.clusterName
|
||||||
) {
|
) {
|
||||||
// &&clusterInfo.clusterName != data.clusterName
|
|
||||||
this.switchCluster(data);
|
this.switchCluster(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,144 +1,147 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="content">
|
<div>
|
||||||
<div class="content-module">
|
<Header/>
|
||||||
<a-card title="集群管理" style="width: 100%; text-align: left">
|
<div class="content">
|
||||||
<p>
|
<div class="content-module">
|
||||||
<a-button type="primary" @click="openClusterInfoDialog">
|
<a-card title="集群管理" style="width: 100%; text-align: left">
|
||||||
集群切换
|
<p>
|
||||||
</a-button>
|
<a-button type="primary" @click="openClusterInfoDialog">
|
||||||
<label>说明:</label>
|
集群切换
|
||||||
<span
|
</a-button>
|
||||||
|
<label>说明:</label>
|
||||||
|
<span
|
||||||
>多集群管理:增加、删除集群配置,切换选中集群为当前操作集群。</span
|
>多集群管理:增加、删除集群配置,切换选中集群为当前操作集群。</span
|
||||||
>
|
>
|
||||||
</p>
|
</p>
|
||||||
</a-card>
|
</a-card>
|
||||||
</div>
|
</div>
|
||||||
<div class="content-module">
|
<div class="content-module" v-show="manager">
|
||||||
<a-card title="Broker管理" style="width: 100%; text-align: left">
|
<a-card title="Broker管理" style="width: 100%; text-align: left">
|
||||||
<p>
|
<p>
|
||||||
<a-button type="primary" @click="openConfigThrottleDialog">
|
<a-button type="primary" @click="openConfigThrottleDialog">
|
||||||
配置限流
|
配置限流
|
||||||
</a-button>
|
</a-button>
|
||||||
<label>说明:</label>
|
<label>说明:</label>
|
||||||
<span
|
<span
|
||||||
>设置指定broker上的topic的副本之间数据同步占用的带宽,这个设置是broker级别的,但是设置后还要去对应的topic上进行限流配置,指定对这个topic的相关副本进行限制</span
|
>设置指定broker上的topic的副本之间数据同步占用的带宽,这个设置是broker级别的,但是设置后还要去对应的topic上进行限流配置,指定对这个topic的相关副本进行限制</span
|
||||||
>
|
>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<a-button type="primary" @click="openRemoveThrottleDialog">
|
<a-button type="primary" @click="openRemoveThrottleDialog">
|
||||||
解除限流
|
解除限流
|
||||||
</a-button>
|
</a-button>
|
||||||
<label>说明:</label>
|
<label>说明:</label>
|
||||||
<span>解除指定broker上的topic副本之间数据同步占用的带宽限制</span>
|
<span>解除指定broker上的topic副本之间数据同步占用的带宽限制</span>
|
||||||
</p>
|
</p>
|
||||||
</a-card>
|
</a-card>
|
||||||
</div>
|
</div>
|
||||||
<div class="content-module">
|
<div class="content-module" v-show="manager">
|
||||||
<a-card title="副本管理" style="width: 100%; text-align: left">
|
<a-card title="副本管理" style="width: 100%; text-align: left">
|
||||||
<p>
|
<p>
|
||||||
<a-button type="primary" @click="openElectPreferredLeaderDialog">
|
<a-button type="primary" @click="openElectPreferredLeaderDialog">
|
||||||
首选副本作为leader
|
首选副本作为leader
|
||||||
</a-button>
|
</a-button>
|
||||||
<label>说明:</label>
|
<label>说明:</label>
|
||||||
<span>将集群中所有分区leader副本设置为首选副本</span>
|
<span>将集群中所有分区leader副本设置为首选副本</span>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<a-button type="primary" @click="openCurrentReassignmentsDialog">
|
<a-button type="primary" @click="openCurrentReassignmentsDialog">
|
||||||
副本变更详情
|
副本变更详情
|
||||||
</a-button>
|
</a-button>
|
||||||
<label>说明:</label>
|
<label>说明:</label>
|
||||||
<span>查看正在进行副本变更/重分配的任务,或者将其取消</span>
|
<span>查看正在进行副本变更/重分配的任务,或者将其取消</span>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<a-button type="primary" @click="openReplicaReassignDialog">
|
<a-button type="primary" @click="openReplicaReassignDialog">
|
||||||
副本重分配
|
副本重分配
|
||||||
</a-button>
|
</a-button>
|
||||||
<label>说明:</label>
|
<label>说明:</label>
|
||||||
<span
|
<span
|
||||||
>副本所在节点重新分配,打个比方,集群有6个节点,分区1的3个副本在节点1、2、3上,现在将它们重新分配到3、4、5上</span
|
>副本所在节点重新分配,打个比方,集群有6个节点,分区1的3个副本在节点1、2、3上,现在将它们重新分配到3、4、5上</span
|
||||||
>
|
>
|
||||||
</p>
|
</p>
|
||||||
</a-card>
|
</a-card>
|
||||||
</div>
|
</div>
|
||||||
<!-- 隐藏数据同步相关-->
|
<!-- 隐藏数据同步相关-->
|
||||||
<div class="content-module" v-show="false">
|
<div class="content-module" v-show="false">
|
||||||
<a-card title="数据同步" style="width: 100%; text-align: left">
|
<a-card title="数据同步" style="width: 100%; text-align: left">
|
||||||
<p v-show="true">
|
<p v-show="true">
|
||||||
<a-button type="primary" @click="openDataSyncSchemeDialog">
|
<a-button type="primary" @click="openDataSyncSchemeDialog">
|
||||||
数据同步方案
|
数据同步方案
|
||||||
</a-button>
|
</a-button>
|
||||||
<label>说明:</label>
|
<label>说明:</label>
|
||||||
<span>新老集群迁移、数据同步解决方案</span>
|
<span>新老集群迁移、数据同步解决方案</span>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<a-button type="primary" @click="openMinOffsetAlignmentDialog">
|
<a-button type="primary" @click="openMinOffsetAlignmentDialog">
|
||||||
最小位移对齐
|
最小位移对齐
|
||||||
</a-button>
|
</a-button>
|
||||||
<label>说明:</label>
|
<label>说明:</label>
|
||||||
<span
|
<span
|
||||||
>同步消费位点时需要获取两端集群中订阅分区的最小位移进行消费位点计算,如需后面同步消费位点,在进行数据同步前,先进行最小位移对齐,
|
>同步消费位点时需要获取两端集群中订阅分区的最小位移进行消费位点计算,如需后面同步消费位点,在进行数据同步前,先进行最小位移对齐,
|
||||||
点击右侧查看:</span
|
点击右侧查看:</span
|
||||||
><a href="javascript:;" @click="openOffsetAlignmentInfoDialog"
|
><a href="javascript:;" @click="openOffsetAlignmentInfoDialog"
|
||||||
>对齐信息</a
|
>对齐信息</a
|
||||||
>
|
>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<a-button type="primary" @click="openSyncConsumerOffsetDialog">
|
<a-button type="primary" @click="openSyncConsumerOffsetDialog">
|
||||||
同步消费位点
|
同步消费位点
|
||||||
</a-button>
|
</a-button>
|
||||||
<label>说明:</label>
|
<label>说明:</label>
|
||||||
<span
|
<span
|
||||||
>同步其它集群中指定消费组与订阅的topic的消费位点到当前集群上,该消费组在当前集群已存在,且双方订阅的topic分区信息一致</span
|
>同步其它集群中指定消费组与订阅的topic的消费位点到当前集群上,该消费组在当前集群已存在,且双方订阅的topic分区信息一致</span
|
||||||
>
|
>
|
||||||
</p>
|
</p>
|
||||||
</a-card>
|
</a-card>
|
||||||
|
</div>
|
||||||
|
<SyncConsumerOffset
|
||||||
|
:visible="syncData.showSyncConsumerOffsetDialog"
|
||||||
|
@closeSyncConsumerOffsetDialog="closeSyncConsumerOffsetDialog"
|
||||||
|
>
|
||||||
|
</SyncConsumerOffset>
|
||||||
|
<MinOffsetAlignment
|
||||||
|
:visible="syncData.showMinOffsetAlignmentDialog"
|
||||||
|
@closeMinOffsetAlignmentDialog="closeMinOffsetAlignmentDialog"
|
||||||
|
>
|
||||||
|
</MinOffsetAlignment>
|
||||||
|
<OffsetAlignmentTable
|
||||||
|
:visible="syncData.showOffsetAlignmentInfoDialog"
|
||||||
|
@closeOffsetAlignmentInfoDialog="closeOffsetAlignmentInfoDialog"
|
||||||
|
></OffsetAlignmentTable>
|
||||||
|
<ElectPreferredLeader
|
||||||
|
:visible="replicationManager.showElectPreferredLeaderDialog"
|
||||||
|
@closeElectPreferredLeaderDialog="closeElectPreferredLeaderDialog"
|
||||||
|
></ElectPreferredLeader>
|
||||||
|
<DataSyncScheme
|
||||||
|
:visible="syncData.showDataSyncSchemeDialog"
|
||||||
|
@closeDataSyncSchemeDialog="closeDataSyncSchemeDialog"
|
||||||
|
>
|
||||||
|
</DataSyncScheme>
|
||||||
|
<ConfigThrottle
|
||||||
|
:visible="brokerManager.showConfigThrottleDialog"
|
||||||
|
@closeConfigThrottleDialog="closeConfigThrottleDialog"
|
||||||
|
>
|
||||||
|
</ConfigThrottle>
|
||||||
|
<RemoveThrottle
|
||||||
|
:visible="brokerManager.showRemoveThrottleDialog"
|
||||||
|
@closeRemoveThrottleDialog="closeRemoveThrottleDialog"
|
||||||
|
>
|
||||||
|
</RemoveThrottle>
|
||||||
|
<CurrentReassignments
|
||||||
|
:visible="replicationManager.showCurrentReassignmentsDialog"
|
||||||
|
@closeCurrentReassignmentsDialog="closeCurrentReassignmentsDialog"
|
||||||
|
></CurrentReassignments>
|
||||||
|
<ClusterInfo
|
||||||
|
:visible="clusterManager.showClusterInfoDialog"
|
||||||
|
@closeClusterInfoDialog="closeClusterInfoDialog"
|
||||||
|
></ClusterInfo>
|
||||||
|
<ReplicaReassign
|
||||||
|
:visible="replicationManager.showReplicaReassignDialog"
|
||||||
|
@closeReplicaReassignDialog="closeReplicaReassignDialog"
|
||||||
|
>
|
||||||
|
</ReplicaReassign>
|
||||||
</div>
|
</div>
|
||||||
<SyncConsumerOffset
|
|
||||||
:visible="syncData.showSyncConsumerOffsetDialog"
|
|
||||||
@closeSyncConsumerOffsetDialog="closeSyncConsumerOffsetDialog"
|
|
||||||
>
|
|
||||||
</SyncConsumerOffset>
|
|
||||||
<MinOffsetAlignment
|
|
||||||
:visible="syncData.showMinOffsetAlignmentDialog"
|
|
||||||
@closeMinOffsetAlignmentDialog="closeMinOffsetAlignmentDialog"
|
|
||||||
>
|
|
||||||
</MinOffsetAlignment>
|
|
||||||
<OffsetAlignmentTable
|
|
||||||
:visible="syncData.showOffsetAlignmentInfoDialog"
|
|
||||||
@closeOffsetAlignmentInfoDialog="closeOffsetAlignmentInfoDialog"
|
|
||||||
></OffsetAlignmentTable>
|
|
||||||
<ElectPreferredLeader
|
|
||||||
:visible="replicationManager.showElectPreferredLeaderDialog"
|
|
||||||
@closeElectPreferredLeaderDialog="closeElectPreferredLeaderDialog"
|
|
||||||
></ElectPreferredLeader>
|
|
||||||
<DataSyncScheme
|
|
||||||
:visible="syncData.showDataSyncSchemeDialog"
|
|
||||||
@closeDataSyncSchemeDialog="closeDataSyncSchemeDialog"
|
|
||||||
>
|
|
||||||
</DataSyncScheme>
|
|
||||||
<ConfigThrottle
|
|
||||||
:visible="brokerManager.showConfigThrottleDialog"
|
|
||||||
@closeConfigThrottleDialog="closeConfigThrottleDialog"
|
|
||||||
>
|
|
||||||
</ConfigThrottle>
|
|
||||||
<RemoveThrottle
|
|
||||||
:visible="brokerManager.showRemoveThrottleDialog"
|
|
||||||
@closeRemoveThrottleDialog="closeRemoveThrottleDialog"
|
|
||||||
>
|
|
||||||
</RemoveThrottle>
|
|
||||||
<CurrentReassignments
|
|
||||||
:visible="replicationManager.showCurrentReassignmentsDialog"
|
|
||||||
@closeCurrentReassignmentsDialog="closeCurrentReassignmentsDialog"
|
|
||||||
></CurrentReassignments>
|
|
||||||
<ClusterInfo
|
|
||||||
:visible="clusterManager.showClusterInfoDialog"
|
|
||||||
@closeClusterInfoDialog="closeClusterInfoDialog"
|
|
||||||
></ClusterInfo>
|
|
||||||
<ReplicaReassign
|
|
||||||
:visible="replicationManager.showReplicaReassignDialog"
|
|
||||||
@closeReplicaReassignDialog="closeReplicaReassignDialog"
|
|
||||||
>
|
|
||||||
</ReplicaReassign>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -153,6 +156,8 @@ import RemoveThrottle from "@/views/op/RemoveThrottle";
|
|||||||
import CurrentReassignments from "@/views/op/CurrentReassignments";
|
import CurrentReassignments from "@/views/op/CurrentReassignments";
|
||||||
import ClusterInfo from "@/views/op/ClusterInfo";
|
import ClusterInfo from "@/views/op/ClusterInfo";
|
||||||
import ReplicaReassign from "@/views/op/ReplicaReassign";
|
import ReplicaReassign from "@/views/op/ReplicaReassign";
|
||||||
|
import Header from "@/components/Header"
|
||||||
|
import {isManager} from "../../utils/role";
|
||||||
export default {
|
export default {
|
||||||
name: "Operation",
|
name: "Operation",
|
||||||
components: {
|
components: {
|
||||||
@@ -166,9 +171,11 @@ export default {
|
|||||||
CurrentReassignments,
|
CurrentReassignments,
|
||||||
ClusterInfo,
|
ClusterInfo,
|
||||||
ReplicaReassign,
|
ReplicaReassign,
|
||||||
|
Header
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
manager: isManager(),
|
||||||
syncData: {
|
syncData: {
|
||||||
showSyncConsumerOffsetDialog: false,
|
showSyncConsumerOffsetDialog: false,
|
||||||
showMinOffsetAlignmentDialog: false,
|
showMinOffsetAlignmentDialog: false,
|
||||||
|
|||||||
@@ -1,207 +0,0 @@
|
|||||||
<script src="../../store/index.js"></script>
|
|
||||||
<template>
|
|
||||||
<a-modal
|
|
||||||
title="新增配置"
|
|
||||||
:visible="show"
|
|
||||||
:width="800"
|
|
||||||
:mask="false"
|
|
||||||
:destroyOnClose="true"
|
|
||||||
:footer="null"
|
|
||||||
:maskClosable="false"
|
|
||||||
@cancel="handleCancel"
|
|
||||||
>
|
|
||||||
<div>
|
|
||||||
<a-spin :spinning="loading">
|
|
||||||
<a-form
|
|
||||||
:form="form"
|
|
||||||
:label-col="{ span: 5 }"
|
|
||||||
:wrapper-col="{ span: 12 }"
|
|
||||||
@submit="handleSubmit"
|
|
||||||
>
|
|
||||||
<a-form-item label="用户" v-show="showUser">
|
|
||||||
<a-input
|
|
||||||
v-decorator="[
|
|
||||||
'user',
|
|
||||||
]"
|
|
||||||
placeholder="输入用户主体标识,比如:用户名,未指定表示用户默认设置"
|
|
||||||
/>
|
|
||||||
</a-form-item>
|
|
||||||
<a-form-item label="客户端ID" v-show="showClientId">
|
|
||||||
<a-input
|
|
||||||
v-decorator="[
|
|
||||||
'client',
|
|
||||||
]"
|
|
||||||
placeholder="输入用户客户端ID,未指定表示默认客户端设置"
|
|
||||||
/>
|
|
||||||
</a-form-item>
|
|
||||||
<a-form-item label="IP" v-show="showIP">
|
|
||||||
<a-input
|
|
||||||
v-decorator="[
|
|
||||||
'ip',
|
|
||||||
]"
|
|
||||||
placeholder="输入客户端IP"
|
|
||||||
/>
|
|
||||||
</a-form-item>
|
|
||||||
<a-form-item label="生产速率">
|
|
||||||
<a-input-number
|
|
||||||
:min="1"
|
|
||||||
:max="102400000"
|
|
||||||
v-decorator="[
|
|
||||||
'producerRate',
|
|
||||||
]"
|
|
||||||
/>
|
|
||||||
<a-select default-value="MB" v-model="producerRateUnit" style="width: 100px">
|
|
||||||
<a-select-option value="MB"> MB/s</a-select-option>
|
|
||||||
<a-select-option value="KB"> KB/s</a-select-option>
|
|
||||||
<a-select-option value="Byte"> Byte/s</a-select-option>
|
|
||||||
</a-select>
|
|
||||||
</a-form-item>
|
|
||||||
<a-form-item label="消费速率">
|
|
||||||
<a-input-number
|
|
||||||
:min="1"
|
|
||||||
:max="102400000"
|
|
||||||
v-decorator="[
|
|
||||||
'consumerRate',
|
|
||||||
]"
|
|
||||||
/>
|
|
||||||
<a-select default-value="MB" v-model="consumerRateUnit" style="width: 100px">
|
|
||||||
<a-select-option value="MB"> MB/s</a-select-option>
|
|
||||||
<a-select-option value="KB"> KB/s</a-select-option>
|
|
||||||
<a-select-option value="Byte"> Byte/s</a-select-option>
|
|
||||||
</a-select>
|
|
||||||
</a-form-item>
|
|
||||||
<a-form-item label="吞吐量">
|
|
||||||
<a-input-number
|
|
||||||
:min="1"
|
|
||||||
:max="102400000"
|
|
||||||
v-decorator="[
|
|
||||||
'requestPercentage',
|
|
||||||
]"
|
|
||||||
/>
|
|
||||||
</a-form-item>
|
|
||||||
<a-form-item :wrapper-col="{ span: 12, offset: 5 }">
|
|
||||||
<a-button type="primary" html-type="submit"> 提交</a-button>
|
|
||||||
</a-form-item>
|
|
||||||
</a-form>
|
|
||||||
</a-spin>
|
|
||||||
</div>
|
|
||||||
</a-modal>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import request from "@/utils/request";
|
|
||||||
import {KafkaClientQuotaApi} from "@/utils/api";
|
|
||||||
import notification from "ant-design-vue/es/notification";
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: "AddQuotaConfig",
|
|
||||||
props: {
|
|
||||||
visible: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
type: {
|
|
||||||
type: String,
|
|
||||||
default: "",
|
|
||||||
},
|
|
||||||
showClientId: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
showUser: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
showIP: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
show: this.visible,
|
|
||||||
data: [],
|
|
||||||
loading: false,
|
|
||||||
form: this.$form.createForm(this, {name: "coordinated"}),
|
|
||||||
producerRateUnit: "MB",
|
|
||||||
consumerRateUnit: "MB",
|
|
||||||
};
|
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
visible(v) {
|
|
||||||
this.show = v;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
handleSubmit() {
|
|
||||||
this.form.validateFields((err, values) => {
|
|
||||||
if (!err) {
|
|
||||||
const params = Object.assign({type: this.type}, values);
|
|
||||||
const unitMap = {MB: 1024 * 1024, KB: 1024, Byte: 1};
|
|
||||||
if (values.consumerRate) {
|
|
||||||
params.consumerRate = params.consumerRate * unitMap[this.consumerRateUnit];
|
|
||||||
}
|
|
||||||
if (values.producerRate) {
|
|
||||||
params.producerRate = params.producerRate * unitMap[this.producerRateUnit];
|
|
||||||
}
|
|
||||||
params.types = [];
|
|
||||||
params.names = [];
|
|
||||||
if (this.showUser) {
|
|
||||||
params.types.push("user");
|
|
||||||
if (params.user) {
|
|
||||||
params.names.push(params.user.trim());
|
|
||||||
} else {
|
|
||||||
params.names.push("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this.showClientId) {
|
|
||||||
params.types.push("client-id");
|
|
||||||
if (params.client) {
|
|
||||||
params.names.push(params.client.trim());
|
|
||||||
} else {
|
|
||||||
params.names.push("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this.showIP) {
|
|
||||||
params.types.push("ip");
|
|
||||||
if (params.ip) {
|
|
||||||
params.names.push(params.ip.trim());
|
|
||||||
} else {
|
|
||||||
params.names.push("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.loading = true;
|
|
||||||
request({
|
|
||||||
url: KafkaClientQuotaApi.alterClientQuotaConfigs.url,
|
|
||||||
method: KafkaClientQuotaApi.alterClientQuotaConfigs.method,
|
|
||||||
data: params,
|
|
||||||
}).then((res) => {
|
|
||||||
this.loading = false;
|
|
||||||
if (res.code == 0) {
|
|
||||||
this.$message.success(res.msg);
|
|
||||||
this.$emit("closeAddQuotaDialog", {refresh: true});
|
|
||||||
} else {
|
|
||||||
notification.error({
|
|
||||||
message: "error",
|
|
||||||
description: res.msg,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
handleCancel() {
|
|
||||||
this.data = [];
|
|
||||||
this.$emit("closeAddQuotaDialog", {refresh: false});
|
|
||||||
this.producerRateUnit = "MB";
|
|
||||||
this.consumerRateUnit = "MB";
|
|
||||||
},
|
|
||||||
create() {
|
|
||||||
this.producerRateUnit = "MB";
|
|
||||||
this.consumerRateUnit = "MB";
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped></style>
|
|
||||||