mirror of
https://github.com/didi/KnowStreaming.git
synced 2025-12-24 11:52:08 +08:00
@@ -53,11 +53,20 @@
|
||||
|
||||
## 2 相关文档
|
||||
|
||||
### 2.1 产品文档
|
||||
- [滴滴Logi-KafkaManager 安装手册](docs/install_guide/install_guide_cn.md)
|
||||
- [滴滴Logi-KafkaManager 接入集群](docs/user_guide/add_cluster/add_cluster.md)
|
||||
- [滴滴Logi-KafkaManager 用户使用手册](docs/user_guide/user_guide_cn.md)
|
||||
- [滴滴Logi-KafkaManager FAQ](docs/user_guide/faq.md)
|
||||
|
||||
### 2.2 社区文章
|
||||
- [滴滴云官网产品介绍](https://www.didiyun.com/production/logi-KafkaManager.html)
|
||||
- [7年沉淀之作--滴滴Logi日志服务套件](https://mp.weixin.qq.com/s/-KQp-Qo3WKEOc9wIR2iFnw)
|
||||
- [滴滴Logi-KafkaManager 一站式Kafka监控与管控平台](https://mp.weixin.qq.com/s/9qSZIkqCnU6u9nLMvOOjIQ)
|
||||
- [滴滴Logi-KafkaManager 开源之路](https://xie.infoq.cn/article/0223091a99e697412073c0d64)
|
||||
- [滴滴Logi-KafkaManager 系列视频教程](https://mp.weixin.qq.com/s/9X7gH0tptHPtfjPPSdGO8g)
|
||||
- [kafka实践(十五):滴滴开源Kafka管控平台 Logi-KafkaManager研究--A叶子叶来](https://blog.csdn.net/yezonggang/article/details/113106244)
|
||||
|
||||
## 3 滴滴Logi开源用户钉钉交流群
|
||||
|
||||

|
||||
|
||||
2
build.sh
2
build.sh
@@ -4,7 +4,7 @@ cd $workspace
|
||||
|
||||
## constant
|
||||
OUTPUT_DIR=./output
|
||||
KM_VERSION=2.2.0
|
||||
KM_VERSION=2.3.0
|
||||
APP_NAME=kafka-manager
|
||||
APP_DIR=${APP_NAME}-${KM_VERSION}
|
||||
|
||||
|
||||
17
docs/dev_guide/upgrade_manual/logi-km-v2.3.0.md
Normal file
17
docs/dev_guide/upgrade_manual/logi-km-v2.3.0.md
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
---
|
||||
|
||||

|
||||
|
||||
**一站式`Apache Kafka`集群指标监控与运维管控平台**
|
||||
|
||||
---
|
||||
|
||||
# 升级至`2.3.0`版本
|
||||
|
||||
`2.3.0`版本在`gateway_config`表增加了一个描述说明的字段,因此需要执行下面的sql进行字段的增加。
|
||||
|
||||
```sql
|
||||
ALTER TABLE `gateway_config`
|
||||
ADD COLUMN `description` TEXT NULL COMMENT '描述信息' AFTER `version`;
|
||||
```
|
||||
@@ -203,7 +203,8 @@ CREATE TABLE `gateway_config` (
|
||||
`type` varchar(128) NOT NULL DEFAULT '' COMMENT '配置类型',
|
||||
`name` varchar(128) NOT NULL DEFAULT '' COMMENT '配置名称',
|
||||
`value` text COMMENT '配置值',
|
||||
`version` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '版本信息',
|
||||
`version` bigint(20) unsigned NOT NULL DEFAULT '1' COMMENT '版本信息',
|
||||
`description` text COMMENT '描述信息',
|
||||
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`modify_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
|
||||
PRIMARY KEY (`id`),
|
||||
|
||||
@@ -5,16 +5,26 @@
|
||||
|
||||
**一站式`Apache Kafka`集群指标监控与运维管控平台**
|
||||
|
||||
|
||||
---
|
||||
|
||||
# 集群接入
|
||||
|
||||
集群的接入总共需要三个步骤,分别是:
|
||||
1. 接入物理集群
|
||||
2. 创建Region
|
||||
3. 创建逻辑集群
|
||||
## 主要概念讲解
|
||||
面对大规模集群、业务场景复杂的情况,引入Region、逻辑集群的概念
|
||||
- Region:划分部分Broker作为一个 Region,用Region定义资源划分的单位,提高扩展性和隔离性。如果部分Topic异常也不会影响大面积的Broker
|
||||
- 逻辑集群:逻辑集群由部分Region组成,便于对大规模集群按照业务划分、保障能力进行管理
|
||||

|
||||
|
||||
备注:接入集群需要2、3两步是因为普通用户的视角下,看到的都是逻辑集群,如果没有2、3两步,那么普通用户看不到任何信息。
|
||||
集群的接入总共需要三个步骤,分别是:
|
||||
1. 接入物理集群:填写机器地址、安全协议等配置信息,接入真实的物理集群
|
||||
2. 创建Region:将部分Broker划分为一个Region
|
||||
3. 创建逻辑集群:逻辑集群由部分Region组成,可根据业务划分、保障等级来创建相应的逻辑集群
|
||||
|
||||

|
||||
|
||||
|
||||
**备注:接入集群需要2、3两步是因为普通用户的视角下,看到的都是逻辑集群,如果没有2、3两步,那么普通用户看不到任何信息。**
|
||||
|
||||
|
||||
## 1、接入物理集群
|
||||
@@ -36,4 +46,4 @@
|
||||

|
||||
|
||||
|
||||
如上图所示,填写逻辑集群信息,然后点击确定,即可完成逻辑集群的创建。
|
||||
如上图所示,填写逻辑集群信息,然后点击确定,即可完成逻辑集群的创建。
|
||||
|
||||
BIN
docs/user_guide/add_cluster/assets/op_cluster_arch.png
Normal file
BIN
docs/user_guide/add_cluster/assets/op_cluster_arch.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 124 KiB |
BIN
docs/user_guide/add_cluster/assets/op_cluster_flow.png
Normal file
BIN
docs/user_guide/add_cluster/assets/op_cluster_flow.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 105 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 119 KiB |
@@ -10,7 +10,7 @@
|
||||
# FAQ
|
||||
|
||||
- 0、Github图裂问题解决
|
||||
- 1、Topic申请时没有可选择的集群?
|
||||
- 1、Topic申请、新建监控告警等操作时没有可选择的集群?
|
||||
- 2、逻辑集群 & Region的用途?
|
||||
- 3、登录失败?
|
||||
- 4、页面流量信息等无数据?
|
||||
@@ -37,9 +37,13 @@
|
||||
|
||||
---
|
||||
|
||||
### 1、Topic申请时没有可选择的集群?
|
||||
### 1、Topic申请、新建监控告警等操作时没有可选择的集群?
|
||||
|
||||
- 参看 [kafka-manager 接入集群](docs/user_guide/add_cluster/add_cluster.md) 手册,这里的Region和逻辑集群都必须添加。
|
||||
缺少逻辑集群导致的,在Topic管理、监控告警、集群管理这三个Tab下面都是普通用户视角,普通用户看到的集群都是逻辑集群,因此在这三个Tab下进行操作时,都需要有逻辑集群。
|
||||
|
||||
逻辑集群的创建参看:
|
||||
|
||||
- [kafka-manager 接入集群](docs/user_guide/add_cluster/add_cluster.md) 手册,这里的Region和逻辑集群都必须添加。
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
|
||||
- 应用(App):作为Kafka中的账户,使用AppID+password作为身份标识
|
||||
- 集群:可使用平台提供的共享集群,也可为某一应用申请单独的集群
|
||||
- Topic:可申请创建Topic或申请其他Topic的生产/消费权限。进行生产/消费时通过Topic+AppID进行身份鉴权
|
||||

|
||||
- Topic:可申请创建Topic或申请其他Topic的生产/消费权限。进行生产/消费时通过Topic+AppID进行身份鉴权
|
||||

|
||||
|
||||
## 应用申请
|
||||
应用(App)作为Kafka中的账户,使用AppID+password作为身份标识。对Topic进行生产/消费时通过Topic+AppID进行身份鉴权。
|
||||
@@ -104,5 +104,10 @@
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -47,4 +47,13 @@ public enum AccountRoleEnum {
|
||||
}
|
||||
return AccountRoleEnum.UNKNOWN;
|
||||
}
|
||||
|
||||
public static AccountRoleEnum getUserRoleEnum(String roleName) {
|
||||
for (AccountRoleEnum elem: AccountRoleEnum.values()) {
|
||||
if (elem.message.equalsIgnoreCase(roleName)) {
|
||||
return elem;
|
||||
}
|
||||
}
|
||||
return AccountRoleEnum.UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.xiaojukeji.kafka.manager.common.bizenum;
|
||||
|
||||
/**
|
||||
* 过期Topic状态
|
||||
* @author zengqiao
|
||||
* @date 21/01/25
|
||||
*/
|
||||
public enum TopicExpiredStatusEnum {
|
||||
ALREADY_NOTIFIED_AND_DELETED(-2, "已通知, 已下线"),
|
||||
ALREADY_NOTIFIED_AND_CAN_DELETE(-1, "已通知, 可下线"),
|
||||
ALREADY_EXPIRED_AND_WAIT_NOTIFY(0, "已过期, 待通知"),
|
||||
ALREADY_NOTIFIED_AND_WAIT_RESPONSE(1, "已通知, 待反馈"),
|
||||
|
||||
;
|
||||
|
||||
private int status;
|
||||
|
||||
private String message;
|
||||
|
||||
TopicExpiredStatusEnum(int status, String message) {
|
||||
this.status = status;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public int getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
}
|
||||
@@ -97,7 +97,7 @@ public class Result<T> implements Serializable {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static <T> Result<T> buildFailure(String message) {
|
||||
public static <T> Result<T> buildGatewayFailure(String message) {
|
||||
Result<T> result = new Result<T>();
|
||||
result.setCode(ResultStatus.GATEWAY_INVALID_REQUEST.getCode());
|
||||
result.setMessage(message);
|
||||
@@ -105,6 +105,14 @@ public class Result<T> implements Serializable {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static <T> Result<T> buildFailure(String message) {
|
||||
Result<T> result = new Result<T>();
|
||||
result.setCode(ResultStatus.FAIL.getCode());
|
||||
result.setMessage(message);
|
||||
result.setData(null);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Result buildFrom(ResultStatus resultStatus) {
|
||||
Result result = new Result();
|
||||
result.setCode(resultStatus.getCode());
|
||||
|
||||
@@ -12,6 +12,8 @@ public enum ResultStatus {
|
||||
|
||||
SUCCESS(Constant.SUCCESS, "success"),
|
||||
|
||||
FAIL(1, "操作失败"),
|
||||
|
||||
/**
|
||||
* 操作错误[1000, 2000)
|
||||
* ------------------------------------------------------------------------------------------
|
||||
@@ -91,6 +93,8 @@ public enum ResultStatus {
|
||||
|
||||
ZOOKEEPER_CONNECT_FAILED(8020, "zookeeper connect failed"),
|
||||
ZOOKEEPER_READ_FAILED(8021, "zookeeper read failed"),
|
||||
ZOOKEEPER_WRITE_FAILED(8022, "zookeeper write failed"),
|
||||
ZOOKEEPER_DELETE_FAILED(8023, "zookeeper delete failed"),
|
||||
|
||||
// 调用集群任务里面的agent失败
|
||||
CALL_CLUSTER_TASK_AGENT_FAILED(8030, " call cluster task agent failed"),
|
||||
|
||||
@@ -23,6 +23,8 @@ public class ClusterDetailDTO {
|
||||
|
||||
private String securityProperties;
|
||||
|
||||
private String jmxProperties;
|
||||
|
||||
private Integer status;
|
||||
|
||||
private Date gmtCreate;
|
||||
@@ -103,6 +105,14 @@ public class ClusterDetailDTO {
|
||||
this.securityProperties = securityProperties;
|
||||
}
|
||||
|
||||
public String getJmxProperties() {
|
||||
return jmxProperties;
|
||||
}
|
||||
|
||||
public void setJmxProperties(String jmxProperties) {
|
||||
this.jmxProperties = jmxProperties;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
@@ -176,8 +186,9 @@ public class ClusterDetailDTO {
|
||||
", bootstrapServers='" + bootstrapServers + '\'' +
|
||||
", kafkaVersion='" + kafkaVersion + '\'' +
|
||||
", idc='" + idc + '\'' +
|
||||
", mode='" + mode + '\'' +
|
||||
", mode=" + mode +
|
||||
", securityProperties='" + securityProperties + '\'' +
|
||||
", jmxProperties='" + jmxProperties + '\'' +
|
||||
", status=" + status +
|
||||
", gmtCreate=" + gmtCreate +
|
||||
", gmtModify=" + gmtModify +
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
package com.xiaojukeji.kafka.manager.common.entity.ao.config;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/9/7
|
||||
*/
|
||||
public class SinkTopicRequestTimeMetricsConfig {
|
||||
private Long clusterId;
|
||||
|
||||
private String topicName;
|
||||
|
||||
private Long startId;
|
||||
|
||||
private Long step;
|
||||
|
||||
public Long getClusterId() {
|
||||
return clusterId;
|
||||
}
|
||||
|
||||
public void setClusterId(Long clusterId) {
|
||||
this.clusterId = clusterId;
|
||||
}
|
||||
|
||||
public String getTopicName() {
|
||||
return topicName;
|
||||
}
|
||||
|
||||
public void setTopicName(String topicName) {
|
||||
this.topicName = topicName;
|
||||
}
|
||||
|
||||
public Long getStartId() {
|
||||
return startId;
|
||||
}
|
||||
|
||||
public void setStartId(Long startId) {
|
||||
this.startId = startId;
|
||||
}
|
||||
|
||||
public Long getStep() {
|
||||
return step;
|
||||
}
|
||||
|
||||
public void setStep(Long step) {
|
||||
this.step = step;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SinkTopicRequestTimeMetricsConfig{" +
|
||||
"clusterId=" + clusterId +
|
||||
", topicName='" + topicName + '\'' +
|
||||
", startId=" + startId +
|
||||
", step=" + step +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.xiaojukeji.kafka.manager.common.entity.dto.op;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 21/01/24
|
||||
*/
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@ApiModel(description="优选为Controller的候选者")
|
||||
public class ControllerPreferredCandidateDTO {
|
||||
@ApiModelProperty(value="集群ID")
|
||||
private Long clusterId;
|
||||
|
||||
@ApiModelProperty(value="优选为controller的BrokerId")
|
||||
private List<Integer> brokerIdList;
|
||||
|
||||
public Long getClusterId() {
|
||||
return clusterId;
|
||||
}
|
||||
|
||||
public void setClusterId(Long clusterId) {
|
||||
this.clusterId = clusterId;
|
||||
}
|
||||
|
||||
public List<Integer> getBrokerIdList() {
|
||||
return brokerIdList;
|
||||
}
|
||||
|
||||
public void setBrokerIdList(List<Integer> brokerIdList) {
|
||||
this.brokerIdList = brokerIdList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ControllerPreferredCandidateDTO{" +
|
||||
"clusterId=" + clusterId +
|
||||
", brokerIdList=" + brokerIdList +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -102,12 +102,11 @@ public class ClusterDTO {
|
||||
'}';
|
||||
}
|
||||
|
||||
public Boolean legal() {
|
||||
public boolean legal() {
|
||||
if (ValidateUtils.isNull(clusterName)
|
||||
|| ValidateUtils.isNull(zookeeper)
|
||||
|| ValidateUtils.isNull(idc)
|
||||
|| ValidateUtils.isNull(bootstrapServers)
|
||||
) {
|
||||
|| ValidateUtils.isNull(bootstrapServers)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -17,6 +17,8 @@ public class GatewayConfigDO {
|
||||
|
||||
private Long version;
|
||||
|
||||
private String description;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
private Date modifyTime;
|
||||
@@ -61,6 +63,14 @@ public class GatewayConfigDO {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
@@ -85,6 +95,7 @@ public class GatewayConfigDO {
|
||||
", name='" + name + '\'' +
|
||||
", value='" + value + '\'' +
|
||||
", version=" + version +
|
||||
", description='" + description + '\'' +
|
||||
", createTime=" + createTime +
|
||||
", modifyTime=" + modifyTime +
|
||||
'}';
|
||||
|
||||
@@ -28,7 +28,7 @@ public class ExpiredTopicVO {
|
||||
@ApiModelProperty(value = "负责人")
|
||||
private String principals;
|
||||
|
||||
@ApiModelProperty(value = "状态, -1:可下线, 0:过期待通知, 1+:已通知待反馈")
|
||||
@ApiModelProperty(value = "状态, -1:已通知可下线, 0:过期待通知, 1+:已通知待反馈")
|
||||
private Integer status;
|
||||
|
||||
public Long getClusterId() {
|
||||
|
||||
@@ -26,6 +26,9 @@ public class GatewayConfigVO {
|
||||
@ApiModelProperty(value="版本")
|
||||
private Long version;
|
||||
|
||||
@ApiModelProperty(value="描述说明")
|
||||
private String description;
|
||||
|
||||
@ApiModelProperty(value="创建时间")
|
||||
private Date createTime;
|
||||
|
||||
@@ -72,6 +75,14 @@ public class GatewayConfigVO {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
@@ -96,6 +107,7 @@ public class GatewayConfigVO {
|
||||
", name='" + name + '\'' +
|
||||
", value='" + value + '\'' +
|
||||
", version=" + version +
|
||||
", description='" + description + '\'' +
|
||||
", createTime=" + createTime +
|
||||
", modifyTime=" + modifyTime +
|
||||
'}';
|
||||
|
||||
@@ -60,6 +60,13 @@ public class JsonUtils {
|
||||
return JSON.parseObject(src, clazz);
|
||||
}
|
||||
|
||||
public static <T> List<T> stringToArrObj(String src, Class<T> clazz) {
|
||||
if (ValidateUtils.isBlank(src)) {
|
||||
return null;
|
||||
}
|
||||
return JSON.parseArray(src, clazz);
|
||||
}
|
||||
|
||||
public static List<TopicConnectionDO> parseTopicConnections(Long clusterId, JSONObject jsonObject, long postTime) {
|
||||
List<TopicConnectionDO> connectionDOList = new ArrayList<>();
|
||||
for (String clientType: jsonObject.keySet()) {
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.xiaojukeji.kafka.manager.common.utils;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -11,6 +12,20 @@ import java.util.Set;
|
||||
* @date 20/4/16
|
||||
*/
|
||||
public class ValidateUtils {
|
||||
/**
|
||||
* 任意一个为空, 则返回true
|
||||
*/
|
||||
public static boolean anyNull(Object... objects) {
|
||||
return Arrays.stream(objects).anyMatch(ValidateUtils::isNull);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是空字符串或者空
|
||||
*/
|
||||
public static boolean anyBlank(String... strings) {
|
||||
return Arrays.stream(strings).anyMatch(StringUtils::isBlank);
|
||||
}
|
||||
|
||||
/**
|
||||
* 为空
|
||||
*/
|
||||
|
||||
@@ -79,7 +79,7 @@ public class JmxConnectorWrap {
|
||||
try {
|
||||
Map<String, Object> environment = new HashMap<String, Object>();
|
||||
if (!ValidateUtils.isBlank(this.jmxConfig.getUsername()) && !ValidateUtils.isBlank(this.jmxConfig.getPassword())) {
|
||||
environment.put(javax.management.remote.JMXConnector.CREDENTIALS, Arrays.asList(this.jmxConfig.getUsername(), this.jmxConfig.getPassword()));
|
||||
environment.put(JMXConnector.CREDENTIALS, Arrays.asList(this.jmxConfig.getUsername(), this.jmxConfig.getPassword()));
|
||||
}
|
||||
if (jmxConfig.isOpenSSL() != null && this.jmxConfig.isOpenSSL()) {
|
||||
environment.put(Context.SECURITY_PROTOCOL, "ssl");
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
package com.xiaojukeji.kafka.manager.common.utils.ldap;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.naming.AuthenticationException;
|
||||
import javax.naming.Context;
|
||||
import javax.naming.NamingEnumeration;
|
||||
import javax.naming.NamingException;
|
||||
import javax.naming.directory.SearchControls;
|
||||
import javax.naming.directory.SearchResult;
|
||||
import javax.naming.ldap.InitialLdapContext;
|
||||
import javax.naming.ldap.LdapContext;
|
||||
import java.util.Hashtable;
|
||||
|
||||
@Component
|
||||
public class LDAPAuthentication {
|
||||
|
||||
@Value(value = "${ldap.url}")
|
||||
private String ldapUrl;
|
||||
|
||||
@Value(value = "${ldap.basedn}")
|
||||
private String ldapBasedn;
|
||||
|
||||
@Value(value = "${ldap.factory}")
|
||||
private String ldapFactory;
|
||||
|
||||
@Value(value = "${ldap.auth-user-registration-role}")
|
||||
private String authUserRegistrationRole;
|
||||
|
||||
@Value(value = "${ldap.security.authentication}")
|
||||
private String securityAuthentication;
|
||||
|
||||
@Value(value = "${ldap.security.principal}")
|
||||
private String securityPrincipal;
|
||||
|
||||
@Value(value = "${ldap.security.credentials}")
|
||||
private String securityCredentials;
|
||||
|
||||
private LdapContext getConnect() {
|
||||
Hashtable<String, String> env = new Hashtable<String, String>();
|
||||
env.put(Context.INITIAL_CONTEXT_FACTORY, ldapFactory);
|
||||
env.put(Context.PROVIDER_URL, ldapUrl + ldapBasedn);
|
||||
env.put(Context.SECURITY_AUTHENTICATION, securityAuthentication);
|
||||
|
||||
// 此处若不指定用户名和密码,则自动转换为匿名登录
|
||||
env.put(Context.SECURITY_PRINCIPAL, securityPrincipal);
|
||||
env.put(Context.SECURITY_CREDENTIALS, securityCredentials);
|
||||
try {
|
||||
return new InitialLdapContext(env, null);
|
||||
} catch (AuthenticationException e) {
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String getUserDN(String account,LdapContext ctx) {
|
||||
String userDN = "";
|
||||
try {
|
||||
SearchControls constraints = new SearchControls();
|
||||
constraints.setSearchScope(SearchControls.SUBTREE_SCOPE);
|
||||
NamingEnumeration<SearchResult> en = ctx.search("", "account=" + account, constraints);
|
||||
if (en == null || !en.hasMoreElements()) {
|
||||
return "";
|
||||
}
|
||||
// maybe more than one element
|
||||
while (en.hasMoreElements()) {
|
||||
Object obj = en.nextElement();
|
||||
if (obj instanceof SearchResult) {
|
||||
SearchResult si = (SearchResult) obj;
|
||||
userDN += si.getName();
|
||||
userDN += "," + ldapBasedn;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return userDN;
|
||||
}
|
||||
|
||||
/**
|
||||
* LDAP账密验证
|
||||
* @param account
|
||||
* @param password
|
||||
* @return
|
||||
*/
|
||||
public boolean authenricate(String account, String password) {
|
||||
LdapContext ctx = getConnect();
|
||||
|
||||
boolean valide = false;
|
||||
|
||||
try {
|
||||
String userDN = getUserDN(account,ctx);
|
||||
|
||||
ctx.addToEnvironment(Context.SECURITY_PRINCIPAL, userDN);
|
||||
ctx.addToEnvironment(Context.SECURITY_CREDENTIALS, password);
|
||||
ctx.reconnect(null);
|
||||
valide = true;
|
||||
} catch (AuthenticationException e) {
|
||||
System.out.println(e.toString());
|
||||
} catch (NamingException e) {
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
if(ctx!=null) {
|
||||
try {
|
||||
ctx.close();
|
||||
} catch (NamingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return valide;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -33,7 +33,9 @@ public class ZkPathUtil {
|
||||
|
||||
private static final String D_METRICS_CONFIG_ROOT_NODE = CONFIG_ROOT_NODE + ZOOKEEPER_SEPARATOR + "KafkaExMetrics";
|
||||
|
||||
public static final String D_CONTROLLER_CANDIDATES = CONFIG_ROOT_NODE + ZOOKEEPER_SEPARATOR + "extension/candidates";
|
||||
public static final String D_CONFIG_EXTENSION_ROOT_NODE = CONFIG_ROOT_NODE + ZOOKEEPER_SEPARATOR + "extension";
|
||||
|
||||
public static final String D_CONTROLLER_CANDIDATES = D_CONFIG_EXTENSION_ROOT_NODE + ZOOKEEPER_SEPARATOR + "candidates";
|
||||
|
||||
public static String getBrokerIdNodePath(Integer brokerId) {
|
||||
return BROKER_IDS_ROOT + ZOOKEEPER_SEPARATOR + String.valueOf(brokerId);
|
||||
@@ -111,6 +113,10 @@ public class ZkPathUtil {
|
||||
}
|
||||
|
||||
public static String getKafkaExtraMetricsPath(Integer brokerId) {
|
||||
return D_METRICS_CONFIG_ROOT_NODE + ZOOKEEPER_SEPARATOR + String.valueOf(brokerId);
|
||||
return D_METRICS_CONFIG_ROOT_NODE + ZOOKEEPER_SEPARATOR + brokerId;
|
||||
}
|
||||
|
||||
public static String getControllerCandidatePath(Integer brokerId) {
|
||||
return D_CONTROLLER_CANDIDATES + ZOOKEEPER_SEPARATOR + brokerId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.xiaojukeji.kafka.manager.common.utils;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class JsonUtilsTest {
|
||||
@Test
|
||||
public void testMapToJsonString() {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("key", "value");
|
||||
map.put("int", 1);
|
||||
String expectRes = "{\"key\":\"value\",\"int\":1}";
|
||||
Assert.assertEquals(expectRes, JsonUtils.toJSONString(map));
|
||||
}
|
||||
}
|
||||
@@ -94,6 +94,9 @@ import 'antd/es/divider/style';
|
||||
import Upload from 'antd/es/upload';
|
||||
import 'antd/es/upload/style';
|
||||
|
||||
import Transfer from 'antd/es/transfer';
|
||||
import 'antd/es/transfer/style';
|
||||
|
||||
import TimePicker from 'antd/es/time-picker';
|
||||
import 'antd/es/time-picker/style';
|
||||
|
||||
@@ -142,5 +145,6 @@ export {
|
||||
TimePicker,
|
||||
RangePickerValue,
|
||||
Badge,
|
||||
Popover
|
||||
Popover,
|
||||
Transfer
|
||||
};
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
.editor{
|
||||
height: 100%;
|
||||
position: absolute;
|
||||
left: -14%;
|
||||
left: -12%;
|
||||
width: 120%;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,24 +21,12 @@ class Monacoeditor extends React.Component<IEditorProps> {
|
||||
public state = {
|
||||
placeholder: '',
|
||||
};
|
||||
// public arr = '{"clusterId":95,"startId":37397856,"step":100,"topicName":"kmo_topic_metrics_tempory_zq"}';
|
||||
// public Ars(a: string) {
|
||||
// const obj = JSON.parse(a);
|
||||
// const newobj: any = {};
|
||||
// for (const item in obj) {
|
||||
// if (typeof obj[item] === 'object') {
|
||||
// this.Ars(obj[item]);
|
||||
// } else {
|
||||
// newobj[item] = obj[item];
|
||||
// }
|
||||
// }
|
||||
// return JSON.stringify(newobj);
|
||||
// }
|
||||
|
||||
public async componentDidMount() {
|
||||
const { value, onChange } = this.props;
|
||||
const format: any = await format2json(value);
|
||||
this.editor = monaco.editor.create(this.ref, {
|
||||
value: format.result,
|
||||
value: format.result || value,
|
||||
language: 'json',
|
||||
lineNumbers: 'off',
|
||||
scrollBeyondLastLine: false,
|
||||
@@ -48,7 +36,7 @@ class Monacoeditor extends React.Component<IEditorProps> {
|
||||
minimap: {
|
||||
enabled: false,
|
||||
},
|
||||
// automaticLayout: true, // 自动布局
|
||||
automaticLayout: true, // 自动布局
|
||||
glyphMargin: true, // 字形边缘 {},[]
|
||||
// useTabStops: false,
|
||||
// formatOnPaste: true,
|
||||
|
||||
@@ -130,6 +130,8 @@ class XForm extends React.Component<IXFormProps> {
|
||||
this.renderFormItem(formItem),
|
||||
)}
|
||||
{formItem.renderExtraElement ? formItem.renderExtraElement() : null}
|
||||
{/* 添加保存时间提示文案 */}
|
||||
{formItem.attrs?.prompttype ? <span style={{ color: "#cccccc", fontSize: '12px', lineHeight: '20px', display: 'block' }}>{formItem.attrs.prompttype}</span> : null}
|
||||
</Form.Item>
|
||||
);
|
||||
})}
|
||||
|
||||
@@ -67,7 +67,7 @@ export const timeMonthStr = 'YYYY/MM';
|
||||
// tslint:disable-next-line:max-line-length
|
||||
|
||||
export const indexUrl ={
|
||||
indexUrl:'https://github.com/didi/kafka-manager',
|
||||
indexUrl:'https://github.com/didi/Logi-KafkaManager/blob/master/docs/user_guide/kafka_metrics_desc.md', // 指标说明
|
||||
cagUrl:'https://github.com/didi/Logi-KafkaManager/blob/master/docs/user_guide/add_cluster/add_cluster.md', // 集群接入指南 Cluster access Guide
|
||||
}
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ export class ClusterConsumer extends SearchAndFilterContainer {
|
||||
<div className="k-row">
|
||||
<ul className="k-tab">
|
||||
<li>{this.props.tab}</li>
|
||||
{this.renderSearch()}
|
||||
{this.renderSearch('', '请输入消费组名称')}
|
||||
</ul>
|
||||
<Table
|
||||
columns={this.columns}
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
import * as React from 'react';
|
||||
|
||||
import { SearchAndFilterContainer } from 'container/search-filter';
|
||||
import { Table } from 'component/antd';
|
||||
import { Table, Button, Popconfirm, Modal, Transfer, notification } from 'component/antd';
|
||||
// import { Transfer } from 'antd'
|
||||
import { observer } from 'mobx-react';
|
||||
import { pagination } from 'constants/table';
|
||||
import Url from 'lib/url-parser';
|
||||
@@ -16,8 +17,12 @@ import { timeFormat } from 'constants/strategy';
|
||||
export class ClusterController extends SearchAndFilterContainer {
|
||||
public clusterId: number;
|
||||
|
||||
public state = {
|
||||
public state: any = {
|
||||
searchKey: '',
|
||||
searchCandidateKey: '',
|
||||
isCandidateModel: false,
|
||||
mockData: [],
|
||||
targetKeys: [],
|
||||
};
|
||||
|
||||
constructor(props: any) {
|
||||
@@ -37,6 +42,94 @@ export class ClusterController extends SearchAndFilterContainer {
|
||||
return data;
|
||||
}
|
||||
|
||||
public getCandidateData<T extends IController>(origin: T[]) {
|
||||
let data: T[] = origin;
|
||||
let { searchCandidateKey } = this.state;
|
||||
searchCandidateKey = (searchCandidateKey + '').trim().toLowerCase();
|
||||
|
||||
data = searchCandidateKey ? origin.filter((item: IController) =>
|
||||
(item.host !== undefined && item.host !== null) && item.host.toLowerCase().includes(searchCandidateKey as string),
|
||||
) : origin;
|
||||
return data;
|
||||
}
|
||||
|
||||
// 候选controller
|
||||
public renderCandidateController() {
|
||||
const columns = [
|
||||
{
|
||||
title: 'BrokerId',
|
||||
dataIndex: 'brokerId',
|
||||
key: 'brokerId',
|
||||
width: '20%',
|
||||
sorter: (a: IController, b: IController) => b.brokerId - a.brokerId,
|
||||
render: (r: string, t: IController) => {
|
||||
return (
|
||||
<a href={`${this.urlPrefix}/admin/broker-detail?clusterId=${this.clusterId}&brokerId=${t.brokerId}`}>{r}
|
||||
</a>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: 'BrokerHost',
|
||||
key: 'host',
|
||||
dataIndex: 'host',
|
||||
width: '20%',
|
||||
// render: (r: string, t: IController) => {
|
||||
// return (
|
||||
// <a href={`${this.urlPrefix}/admin/broker-detail?clusterId=${this.clusterId}&brokerId=${t.brokerId}`}>{r}
|
||||
// </a>
|
||||
// );
|
||||
// },
|
||||
},
|
||||
{
|
||||
title: 'Broker状态',
|
||||
key: 'status',
|
||||
dataIndex: 'status',
|
||||
width: '20%',
|
||||
render: (r: number, t: IController) => {
|
||||
return (
|
||||
<span>{r === 1 ? '不在线' : '在线'}</span>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
dataIndex: 'startTime',
|
||||
key: 'startTime',
|
||||
width: '25%',
|
||||
sorter: (a: IController, b: IController) => b.timestamp - a.timestamp,
|
||||
render: (t: number) => moment(t).format(timeFormat),
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
dataIndex: 'operation',
|
||||
key: 'operation',
|
||||
width: '15%',
|
||||
render: (r: string, t: IController) => {
|
||||
return (
|
||||
<Popconfirm
|
||||
title="确定删除?"
|
||||
onConfirm={() => this.deleteCandidateCancel(t)}
|
||||
cancelText="取消"
|
||||
okText="确认"
|
||||
>
|
||||
<a>删除</a>
|
||||
</Popconfirm>
|
||||
);
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<Table
|
||||
columns={columns}
|
||||
dataSource={this.getCandidateData(admin.controllerCandidate)}
|
||||
pagination={pagination}
|
||||
rowKey="key"
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
public renderController() {
|
||||
|
||||
const columns = [
|
||||
@@ -58,12 +151,6 @@ export class ClusterController extends SearchAndFilterContainer {
|
||||
key: 'host',
|
||||
dataIndex: 'host',
|
||||
width: '30%',
|
||||
// render: (r: string, t: IController) => {
|
||||
// return (
|
||||
// <a href={`${this.urlPrefix}/admin/broker-detail?clusterId=${this.clusterId}&brokerId=${t.brokerId}`}>{r}
|
||||
// </a>
|
||||
// );
|
||||
// },
|
||||
},
|
||||
{
|
||||
title: '变更时间',
|
||||
@@ -87,16 +174,104 @@ export class ClusterController extends SearchAndFilterContainer {
|
||||
|
||||
public componentDidMount() {
|
||||
admin.getControllerHistory(this.clusterId);
|
||||
admin.getCandidateController(this.clusterId);
|
||||
admin.getBrokersMetadata(this.clusterId);
|
||||
}
|
||||
|
||||
public addController = () => {
|
||||
this.setState({ isCandidateModel: true, targetKeys: [] })
|
||||
}
|
||||
|
||||
public addCandidateChange = (targetKeys: any) => {
|
||||
this.setState({ targetKeys })
|
||||
}
|
||||
|
||||
|
||||
|
||||
public handleCandidateCancel = () => {
|
||||
this.setState({ isCandidateModel: false });
|
||||
}
|
||||
|
||||
public handleCandidateOk = () => {
|
||||
let brokerIdList = this.state.targetKeys.map((item: any) => {
|
||||
return admin.brokersMetadata[item].brokerId
|
||||
})
|
||||
admin.addCandidateController(this.clusterId, brokerIdList).then(data => {
|
||||
notification.success({ message: '新增成功' });
|
||||
admin.getCandidateController(this.clusterId);
|
||||
}).catch(err => {
|
||||
notification.error({ message: '新增失败' });
|
||||
})
|
||||
this.setState({ isCandidateModel: false, targetKeys: [] });
|
||||
}
|
||||
|
||||
public deleteCandidateCancel = (target: any) => {
|
||||
admin.deleteCandidateCancel(this.clusterId, [target.brokerId]).then(() => {
|
||||
notification.success({ message: '删除成功' });
|
||||
});
|
||||
this.setState({ isCandidateModel: false });
|
||||
}
|
||||
|
||||
public renderAddCandidateController() {
|
||||
let filterControllerCandidate = admin.brokersMetadata.filter((item: any) => {
|
||||
return !admin.filtercontrollerCandidate.includes(item.brokerId)
|
||||
})
|
||||
|
||||
return (
|
||||
<Modal
|
||||
title="新增候选Controller"
|
||||
visible={this.state.isCandidateModel}
|
||||
// okText="确认"
|
||||
// cancelText="取消"
|
||||
maskClosable={false}
|
||||
// onOk={() => this.handleCandidateOk()}
|
||||
onCancel={() => this.handleCandidateCancel()}
|
||||
footer={<>
|
||||
<Button style={{ width: '60px' }} onClick={() => this.handleCandidateCancel()}>取消</Button>
|
||||
<Button disabled={this.state.targetKeys.length > 0 ? false : true} style={{ width: '60px' }} type="primary" onClick={() => this.handleCandidateOk()}>确定</Button>
|
||||
</>
|
||||
}
|
||||
>
|
||||
<Transfer
|
||||
dataSource={filterControllerCandidate}
|
||||
targetKeys={this.state.targetKeys}
|
||||
render={item => item.host}
|
||||
onChange={(targetKeys) => this.addCandidateChange(targetKeys)}
|
||||
titles={['未选', '已选']}
|
||||
locale={{
|
||||
itemUnit: '项',
|
||||
itemsUnit: '项',
|
||||
}}
|
||||
listStyle={{
|
||||
width: "45%",
|
||||
}}
|
||||
/>
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
|
||||
public render() {
|
||||
return (
|
||||
<div className="k-row">
|
||||
<ul className="k-tab">
|
||||
<li>
|
||||
<span>候选Controller</span>
|
||||
<span style={{ display: 'inline-block', color: "#a7a8a9", fontSize: '12px', marginLeft: '15px' }}>Controller将会优先从以下Broker中选举</span>
|
||||
</li>
|
||||
<div style={{ display: 'flex' }}>
|
||||
<div style={{ marginRight: '15px' }}>
|
||||
<Button onClick={() => this.addController()} type='primary'>新增候选Controller</Button>
|
||||
</div>
|
||||
{this.renderSearch('', '请查找Host', 'searchCandidateKey')}
|
||||
</div>
|
||||
</ul>
|
||||
{this.renderCandidateController()}
|
||||
<ul className="k-tab" style={{ marginTop: '10px' }}>
|
||||
<li>{this.props.tab}</li>
|
||||
{this.renderSearch('', '请输入Host')}
|
||||
</ul>
|
||||
{this.renderController()}
|
||||
{this.renderAddCandidateController()}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -94,4 +94,10 @@
|
||||
.region-prompt{
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.asd{
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
align-items: center;
|
||||
}
|
||||
@@ -32,9 +32,9 @@ export class ClusterDetail extends React.Component {
|
||||
}
|
||||
|
||||
public render() {
|
||||
let content = {} as IMetaData;
|
||||
content = admin.basicInfo ? admin.basicInfo : content;
|
||||
return (
|
||||
let content = {} as IMetaData;
|
||||
content = admin.basicInfo ? admin.basicInfo : content;
|
||||
return (
|
||||
<>
|
||||
<PageHeader
|
||||
className="detail topic-detail-header"
|
||||
@@ -46,7 +46,7 @@ export class ClusterDetail extends React.Component {
|
||||
<ClusterOverview basicInfo={content} />
|
||||
</TabPane>
|
||||
<TabPane tab="Topic信息" key="2">
|
||||
<ClusterTopic tab={'Topic信息'}/>
|
||||
<ClusterTopic tab={'Topic信息'} />
|
||||
</TabPane>
|
||||
<TabPane tab="Broker信息" key="3">
|
||||
<ClusterBroker tab={'Broker信息'} basicInfo={content} />
|
||||
@@ -60,11 +60,11 @@ export class ClusterDetail extends React.Component {
|
||||
<TabPane tab="逻辑集群信息" key="6">
|
||||
<LogicalCluster tab={'逻辑集群信息'} basicInfo={content} />
|
||||
</TabPane>
|
||||
<TabPane tab="Controller变更历史" key="7">
|
||||
<TabPane tab="Controller信息" key="7">
|
||||
<ClusterController tab={'Controller变更历史'} />
|
||||
</TabPane>
|
||||
<TabPane tab="限流信息" key="8">
|
||||
<CurrentLimiting tab={'限流信息'}/>
|
||||
<TabPane tab="限流信息" key="8">
|
||||
<CurrentLimiting tab={'限流信息'} />
|
||||
</TabPane>
|
||||
</Tabs>
|
||||
</>
|
||||
|
||||
@@ -12,6 +12,7 @@ import { urlPrefix } from 'constants/left-menu';
|
||||
import { indexUrl } from 'constants/strategy'
|
||||
import { region } from 'store';
|
||||
import './index.less';
|
||||
import Monacoeditor from 'component/editor/monacoEditor';
|
||||
import { getAdminClusterColumns } from '../config';
|
||||
|
||||
const { confirm } = Modal;
|
||||
@@ -132,6 +133,25 @@ export class ClusterList extends SearchAndFilterContainer {
|
||||
"security.protocol": "SASL_PLAINTEXT",
|
||||
"sasl.mechanism": "PLAIN",
|
||||
"sasl.jaas.config": "org.apache.kafka.common.security.plain.PlainLoginModule required username=\\"xxxxxx\\" password=\\"xxxxxx\\";"
|
||||
}`,
|
||||
rows: 8,
|
||||
},
|
||||
},
|
||||
{
|
||||
key: 'jmxProperties',
|
||||
label: 'JMX认证',
|
||||
type: 'text_area',
|
||||
rules: [{
|
||||
required: false,
|
||||
message: '请输入JMX认证',
|
||||
}],
|
||||
attrs: {
|
||||
placeholder: `请输入JMX认证,例如:
|
||||
{
|
||||
"maxConn": 10, #KM对单台Broker对最大连接数
|
||||
"username": "xxxxx", #用户名
|
||||
"password": "xxxxx", #密码
|
||||
"openSSL": true, #开启SSL,true表示开启SSL,false表示关闭
|
||||
}`,
|
||||
rows: 8,
|
||||
},
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import * as React from 'react';
|
||||
import { IUser, IUploadFile, IConfigure, IMetaData, IBrokersPartitions } from 'types/base-type';
|
||||
import { IUser, IUploadFile, IConfigure, IConfigGateway, IMetaData } from 'types/base-type';
|
||||
import { users } from 'store/users';
|
||||
import { version } from 'store/version';
|
||||
import { showApplyModal, showModifyModal, showConfigureModal } from 'container/modal/admin';
|
||||
import { showApplyModal, showApplyModalModifyPassword, showModifyModal, showConfigureModal, showConfigGatewayModal } from 'container/modal/admin';
|
||||
import { Popconfirm, Tooltip } from 'component/antd';
|
||||
import { admin } from 'store/admin';
|
||||
import { cellStyle } from 'constants/table';
|
||||
@@ -27,6 +27,7 @@ export const getUserColumns = () => {
|
||||
return (
|
||||
<span className="table-operation">
|
||||
<a onClick={() => showApplyModal(record)}>编辑</a>
|
||||
<a onClick={() => showApplyModalModifyPassword(record)}>修改密码</a>
|
||||
<Popconfirm
|
||||
title="确定删除?"
|
||||
onConfirm={() => users.deleteUser(record.username)}
|
||||
@@ -184,6 +185,87 @@ export const getConfigureColumns = () => {
|
||||
return columns;
|
||||
};
|
||||
|
||||
// 网关配置
|
||||
export const getConfigColumns = () => {
|
||||
const columns = [
|
||||
{
|
||||
title: '配置类型',
|
||||
dataIndex: 'type',
|
||||
key: 'type',
|
||||
width: '25%',
|
||||
ellipsis: true,
|
||||
sorter: (a: IConfigGateway, b: IConfigGateway) => a.type.charCodeAt(0) - b.type.charCodeAt(0),
|
||||
},
|
||||
{
|
||||
title: '配置键',
|
||||
dataIndex: 'name',
|
||||
key: 'name',
|
||||
width: '15%',
|
||||
ellipsis: true,
|
||||
sorter: (a: IConfigGateway, b: IConfigGateway) => a.name.charCodeAt(0) - b.name.charCodeAt(0),
|
||||
},
|
||||
{
|
||||
title: '配置值',
|
||||
dataIndex: 'value',
|
||||
key: 'value',
|
||||
width: '20%',
|
||||
ellipsis: true,
|
||||
sorter: (a: IConfigGateway, b: IConfigGateway) => a.value.charCodeAt(0) - b.value.charCodeAt(0),
|
||||
render: (t: string) => {
|
||||
return t.substr(0, 1) === '{' && t.substr(0, -1) === '}' ? JSON.stringify(JSON.parse(t), null, 4) : t;
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '修改时间',
|
||||
dataIndex: 'modifyTime',
|
||||
key: 'modifyTime',
|
||||
width: '15%',
|
||||
sorter: (a: IConfigGateway, b: IConfigGateway) => b.modifyTime - a.modifyTime,
|
||||
render: (t: number) => moment(t).format(timeFormat),
|
||||
},
|
||||
{
|
||||
title: '版本号',
|
||||
dataIndex: 'version',
|
||||
key: 'version',
|
||||
width: '10%',
|
||||
ellipsis: true,
|
||||
sorter: (a: IConfigGateway, b: IConfigGateway) => b.version.charCodeAt(0) - a.version.charCodeAt(0),
|
||||
},
|
||||
{
|
||||
title: '描述信息',
|
||||
dataIndex: 'description',
|
||||
key: 'description',
|
||||
width: '20%',
|
||||
ellipsis: true,
|
||||
onCell: () => ({
|
||||
style: {
|
||||
maxWidth: 180,
|
||||
...cellStyle,
|
||||
},
|
||||
}),
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: '10%',
|
||||
render: (text: string, record: IConfigGateway) => {
|
||||
return (
|
||||
<span className="table-operation">
|
||||
<a onClick={() => showConfigGatewayModal(record)}>编辑</a>
|
||||
<Popconfirm
|
||||
title="确定删除?"
|
||||
onConfirm={() => admin.deleteConfigGateway({ id: record.id })}
|
||||
cancelText="取消"
|
||||
okText="确认"
|
||||
>
|
||||
<a>删除</a>
|
||||
</Popconfirm>
|
||||
</span>);
|
||||
},
|
||||
},
|
||||
];
|
||||
return columns;
|
||||
};
|
||||
|
||||
const renderClusterHref = (value: number | string, item: IMetaData, key: number) => {
|
||||
return ( // 0 暂停监控--不可点击 1 监控中---可正常点击
|
||||
<>
|
||||
|
||||
@@ -3,11 +3,11 @@ import { SearchAndFilterContainer } from 'container/search-filter';
|
||||
import { Table, Button, Spin } from 'component/antd';
|
||||
import { admin } from 'store/admin';
|
||||
import { observer } from 'mobx-react';
|
||||
import { IConfigure } from 'types/base-type';
|
||||
import { IConfigure, IConfigGateway } from 'types/base-type';
|
||||
import { users } from 'store/users';
|
||||
import { pagination } from 'constants/table';
|
||||
import { getConfigureColumns } from './config';
|
||||
import { showConfigureModal } from 'container/modal/admin';
|
||||
import { getConfigureColumns, getConfigColumns } from './config';
|
||||
import { showConfigureModal, showConfigGatewayModal } from 'container/modal/admin';
|
||||
|
||||
@observer
|
||||
export class ConfigureManagement extends SearchAndFilterContainer {
|
||||
@@ -17,7 +17,12 @@ export class ConfigureManagement extends SearchAndFilterContainer {
|
||||
};
|
||||
|
||||
public componentDidMount() {
|
||||
admin.getConfigure();
|
||||
if (this.props.isShow) {
|
||||
admin.getGatewayList();
|
||||
admin.getGatewayType();
|
||||
} else {
|
||||
admin.getConfigure();
|
||||
}
|
||||
}
|
||||
|
||||
public getData<T extends IConfigure>(origin: T[]) {
|
||||
@@ -34,15 +39,34 @@ export class ConfigureManagement extends SearchAndFilterContainer {
|
||||
return data;
|
||||
}
|
||||
|
||||
public getGatewayData<T extends IConfigGateway>(origin: T[]) {
|
||||
let data: T[] = origin;
|
||||
let { searchKey } = this.state;
|
||||
searchKey = (searchKey + '').trim().toLowerCase();
|
||||
|
||||
data = searchKey ? origin.filter((item: IConfigGateway) =>
|
||||
((item.name !== undefined && item.name !== null) && item.name.toLowerCase().includes(searchKey as string))
|
||||
|| ((item.value !== undefined && item.value !== null) && item.value.toLowerCase().includes(searchKey as string))
|
||||
|| ((item.description !== undefined && item.description !== null) &&
|
||||
item.description.toLowerCase().includes(searchKey as string)),
|
||||
) : origin;
|
||||
return data;
|
||||
}
|
||||
|
||||
public renderTable() {
|
||||
return (
|
||||
<Spin spinning={users.loading}>
|
||||
<Table
|
||||
{this.props.isShow ? <Table
|
||||
rowKey="key"
|
||||
columns={getConfigColumns()}
|
||||
dataSource={this.getGatewayData(admin.configGatewayList)}
|
||||
pagination={pagination}
|
||||
/> : <Table
|
||||
rowKey="key"
|
||||
columns={getConfigureColumns()}
|
||||
dataSource={this.getData(admin.configureList)}
|
||||
pagination={pagination}
|
||||
/>
|
||||
/>}
|
||||
</Spin>
|
||||
|
||||
);
|
||||
@@ -53,7 +77,7 @@ export class ConfigureManagement extends SearchAndFilterContainer {
|
||||
<ul>
|
||||
{this.renderSearch('', '请输入配置键、值或描述')}
|
||||
<li className="right-btn-1">
|
||||
<Button type="primary" onClick={() => showConfigureModal()}>增加配置</Button>
|
||||
<Button type="primary" onClick={() => this.props.isShow ? showConfigGatewayModal() : showConfigureModal()}>增加配置</Button>
|
||||
</li>
|
||||
</ul>
|
||||
);
|
||||
|
||||
@@ -6,6 +6,7 @@ import { curveKeys, CURVE_KEY_MAP, PERIOD_RADIO_MAP, PERIOD_RADIO } from './conf
|
||||
import moment = require('moment');
|
||||
import { observer } from 'mobx-react';
|
||||
import { timeStampStr } from 'constants/strategy';
|
||||
import { adminMonitor } from 'store/admin-monitor';
|
||||
|
||||
@observer
|
||||
export class DataCurveFilter extends React.Component {
|
||||
@@ -21,6 +22,7 @@ export class DataCurveFilter extends React.Component {
|
||||
}
|
||||
|
||||
public refreshAll = () => {
|
||||
adminMonitor.setRequestId(null);
|
||||
Object.keys(curveKeys).forEach((c: curveKeys) => {
|
||||
const { typeInfo, curveInfo: option } = CURVE_KEY_MAP.get(c);
|
||||
const { parser } = typeInfo;
|
||||
@@ -32,7 +34,7 @@ export class DataCurveFilter extends React.Component {
|
||||
return (
|
||||
<>
|
||||
<Radio.Group onChange={this.radioChange} defaultValue={curveInfo.periodKey}>
|
||||
{PERIOD_RADIO.map(p => <Radio.Button key={p.key} value={p.key}>{p.label}</Radio.Button>)}
|
||||
{PERIOD_RADIO.map(p => <Radio.Button key={p.key} value={p.key}>{p.label}</Radio.Button>)}
|
||||
</Radio.Group>
|
||||
<DatePicker.RangePicker
|
||||
format={timeStampStr}
|
||||
|
||||
@@ -13,17 +13,20 @@ export class PlatformManagement extends React.Component {
|
||||
public render() {
|
||||
return (
|
||||
<>
|
||||
<Tabs activeKey={location.hash.substr(1) || '1'} type="card" onChange={handleTabKey}>
|
||||
<TabPane tab="应用管理" key="1">
|
||||
<AdminAppList />
|
||||
</TabPane>
|
||||
<TabPane tab="用户管理" key="2">
|
||||
<UserManagement />
|
||||
</TabPane>
|
||||
<TabPane tab="配置管理" key="3">
|
||||
<ConfigureManagement />
|
||||
</TabPane>
|
||||
</Tabs>
|
||||
<Tabs activeKey={location.hash.substr(1) || '1'} type="card" onChange={handleTabKey}>
|
||||
<TabPane tab="应用管理" key="1">
|
||||
<AdminAppList />
|
||||
</TabPane>
|
||||
<TabPane tab="用户管理" key="2">
|
||||
<UserManagement />
|
||||
</TabPane>
|
||||
<TabPane tab="平台配置" key="3">
|
||||
<ConfigureManagement isShow={false} />
|
||||
</TabPane>
|
||||
<TabPane tab="网关配置" key="4">
|
||||
<ConfigureManagement isShow={true} />
|
||||
</TabPane>
|
||||
</Tabs>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ export class UserManagement extends SearchAndFilterContainer {
|
||||
searchKey = (searchKey + '').trim().toLowerCase();
|
||||
|
||||
data = searchKey ? origin.filter((item: IUser) =>
|
||||
(item.username !== undefined && item.username !== null) && item.username.toLowerCase().includes(searchKey as string)) : origin ;
|
||||
(item.username !== undefined && item.username !== null) && item.username.toLowerCase().includes(searchKey as string)) : origin;
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import * as React from 'react';
|
||||
import { alarm } from 'store/alarm';
|
||||
import { IMonitorGroups } from 'types/base-type';
|
||||
import { getValueFromLocalStorage, setValueToLocalStorage } from 'lib/local-storage';
|
||||
import { getValueFromLocalStorage, setValueToLocalStorage, deleteValueFromLocalStorage } from 'lib/local-storage';
|
||||
import { VirtualScrollSelect } from '../../../component/virtual-scroll-select';
|
||||
|
||||
interface IAlarmSelectProps {
|
||||
@@ -36,6 +36,10 @@ export class AlarmSelect extends React.Component<IAlarmSelectProps> {
|
||||
onChange && onChange(params);
|
||||
}
|
||||
|
||||
public componentWillUnmount() {
|
||||
deleteValueFromLocalStorage('monitorGroups');
|
||||
}
|
||||
|
||||
public render() {
|
||||
const { value, isDisabled } = this.props;
|
||||
return (
|
||||
|
||||
@@ -9,6 +9,7 @@ import { pagination } from 'constants/table';
|
||||
import { urlPrefix } from 'constants/left-menu';
|
||||
import { alarm } from 'store/alarm';
|
||||
import 'styles/table-filter.less';
|
||||
import { Link } from 'react-router-dom';
|
||||
|
||||
@observer
|
||||
export class AlarmList extends SearchAndFilterContainer {
|
||||
@@ -24,7 +25,7 @@ export class AlarmList extends SearchAndFilterContainer {
|
||||
if (app.active !== '-1' || searchKey !== '') {
|
||||
data = origin.filter(d =>
|
||||
((d.name !== undefined && d.name !== null) && d.name.toLowerCase().includes(searchKey as string)
|
||||
|| ((d.operator !== undefined && d.operator !== null) && d.operator.toLowerCase().includes(searchKey as string)))
|
||||
|| ((d.operator !== undefined && d.operator !== null) && d.operator.toLowerCase().includes(searchKey as string)))
|
||||
&& (app.active === '-1' || d.appId === (app.active + '')),
|
||||
);
|
||||
} else {
|
||||
@@ -55,9 +56,7 @@ export class AlarmList extends SearchAndFilterContainer {
|
||||
{this.renderSearch('名称:', '请输入告警规则或者操作人')}
|
||||
<li className="right-btn-1">
|
||||
<Button type="primary">
|
||||
<a href={`${urlPrefix}/alarm/add`}>
|
||||
新增规则
|
||||
</a>
|
||||
<Link to={`/alarm/add`}>新增规则</Link>
|
||||
</Button>
|
||||
</li>
|
||||
</>
|
||||
@@ -68,6 +67,9 @@ export class AlarmList extends SearchAndFilterContainer {
|
||||
if (!alarm.monitorStrategies.length) {
|
||||
alarm.getMonitorStrategies();
|
||||
}
|
||||
if (!app.data.length) {
|
||||
app.getAppList();
|
||||
}
|
||||
}
|
||||
|
||||
public render() {
|
||||
|
||||
@@ -91,7 +91,7 @@ export class MyCluster extends SearchAndFilterContainer {
|
||||
],
|
||||
formData: {},
|
||||
visible: true,
|
||||
title: '申请集群',
|
||||
title: <div><span>申请集群</span><a className='applicationDocument' href="https://github.com/didi/Logi-KafkaManager/blob/master/docs/user_guide/resource_apply.md" target='_blank'>资源申请文档</a></div>,
|
||||
okText: '确认',
|
||||
onSubmit: (value: any) => {
|
||||
value.idc = region.currentRegion;
|
||||
|
||||
@@ -117,12 +117,12 @@ class DataMigrationFormTable extends React.Component<IFormTableProps> {
|
||||
key: 'maxThrottle',
|
||||
editable: true,
|
||||
}, {
|
||||
title: '迁移保存时间(h)',
|
||||
title: '迁移后Topic保存时间(h)',
|
||||
dataIndex: 'reassignRetentionTime',
|
||||
key: 'reassignRetentionTime',
|
||||
editable: true,
|
||||
}, {
|
||||
title: '原本保存时间(h)',
|
||||
title: '原Topic保存时间(h)',
|
||||
dataIndex: 'retentionTime',
|
||||
key: 'retentionTime', // originalRetentionTime
|
||||
width: '132px',
|
||||
|
||||
@@ -61,6 +61,7 @@ export const showEditClusterTopic = (item: IClusterTopics) => {
|
||||
attrs: {
|
||||
placeholder: '请输入保存时间',
|
||||
suffix: '小时',
|
||||
prompttype:'修改保存时间,预计一分钟左右生效!'
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
@@ -158,26 +158,26 @@ export const createMigrationTasks = () => {
|
||||
},
|
||||
{
|
||||
key: 'originalRetentionTime',
|
||||
label: '原本保存时间',
|
||||
label: '原Topic保存时间',
|
||||
rules: [{
|
||||
required: true,
|
||||
message: '请输入原本保存时间',
|
||||
message: '请输入原Topic保存时间',
|
||||
}],
|
||||
attrs: {
|
||||
disabled: true,
|
||||
placeholder: '请输入原本保存时间',
|
||||
placeholder: '请输入原Topic保存时间',
|
||||
suffix: '小时',
|
||||
},
|
||||
},
|
||||
{
|
||||
key: 'reassignRetentionTime',
|
||||
label: '迁移保存时间',
|
||||
label: '迁移后Topic保存时间',
|
||||
rules: [{
|
||||
required: true,
|
||||
message: '请输入迁移保存时间',
|
||||
message: '请输入迁移后Topic保存时间',
|
||||
}],
|
||||
attrs: {
|
||||
placeholder: '请输入迁移保存时间',
|
||||
placeholder: '请输入迁移后Topic保存时间',
|
||||
suffix: '小时',
|
||||
},
|
||||
},
|
||||
|
||||
@@ -24,26 +24,111 @@ export const showApplyModal = (record?: IUser) => {
|
||||
value: +item,
|
||||
})),
|
||||
rules: [{ required: true, message: '请选择角色' }],
|
||||
}, {
|
||||
key: 'password',
|
||||
label: '密码',
|
||||
type: FormItemType.inputPassword,
|
||||
rules: [{ required: !record, message: '请输入密码' }],
|
||||
},
|
||||
},
|
||||
// {
|
||||
// key: 'password',
|
||||
// label: '密码',
|
||||
// type: FormItemType.inputPassword,
|
||||
// rules: [{ required: !record, message: '请输入密码' }],
|
||||
// },
|
||||
],
|
||||
formData: record || {},
|
||||
visible: true,
|
||||
title: record ? '修改用户' : '新增用户',
|
||||
onSubmit: (value: IUser) => {
|
||||
if (record) {
|
||||
return users.modfiyUser(value).then(() => {
|
||||
message.success('操作成功');
|
||||
});
|
||||
return users.modfiyUser(value)
|
||||
}
|
||||
return users.addUser(value).then(() => {
|
||||
message.success('操作成功');
|
||||
});
|
||||
},
|
||||
};
|
||||
if(!record){
|
||||
let formMap: any = xFormModal.formMap
|
||||
formMap.splice(2, 0,{
|
||||
key: 'password',
|
||||
label: '密码',
|
||||
type: FormItemType.inputPassword,
|
||||
rules: [{ required: !record, message: '请输入密码' }],
|
||||
},)
|
||||
}
|
||||
wrapper.open(xFormModal);
|
||||
};
|
||||
|
||||
// const handleCfPassword = (rule:any, value:any, callback:any)=>{
|
||||
// if()
|
||||
// }
|
||||
export const showApplyModalModifyPassword = (record: IUser) => {
|
||||
const xFormModal:any = {
|
||||
formMap: [
|
||||
// {
|
||||
// key: 'oldPassword',
|
||||
// label: '旧密码',
|
||||
// type: FormItemType.inputPassword,
|
||||
// rules: [{
|
||||
// required: true,
|
||||
// message: '请输入旧密码',
|
||||
// }]
|
||||
// },
|
||||
{
|
||||
key: 'newPassword',
|
||||
label: '新密码',
|
||||
type: FormItemType.inputPassword,
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入新密码',
|
||||
}
|
||||
],
|
||||
attrs:{
|
||||
onChange:(e:any)=>{
|
||||
users.setNewPassWord(e.target.value)
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
key: 'confirmPassword',
|
||||
label: '确认密码',
|
||||
type: FormItemType.inputPassword,
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
message: '请确认密码',
|
||||
validator:(rule:any, value:any, callback:any) => {
|
||||
// 验证新密码的一致性
|
||||
if(users.newPassWord){
|
||||
if(value!==users.newPassWord){
|
||||
rule.message = "两次密码输入不一致";
|
||||
callback('两次密码输入不一致')
|
||||
}else{
|
||||
callback()
|
||||
}
|
||||
}else if(!value){
|
||||
rule.message = "请确认密码";
|
||||
callback('请确认密码');
|
||||
}else{
|
||||
callback()
|
||||
}
|
||||
},
|
||||
}
|
||||
],
|
||||
},
|
||||
],
|
||||
formData: record || {},
|
||||
visible: true,
|
||||
title: '修改密码',
|
||||
onSubmit: (value: IUser) => {
|
||||
let params:any = {
|
||||
username:record?.username,
|
||||
password:value.confirmPassword,
|
||||
role:record?.role,
|
||||
}
|
||||
return users.modfiyUser(params).then(() => {
|
||||
message.success('操作成功');
|
||||
});
|
||||
},
|
||||
}
|
||||
wrapper.open(xFormModal);
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as React from 'react';
|
||||
import { notification } from 'component/antd';
|
||||
import { IUploadFile, IConfigure } from 'types/base-type';
|
||||
import { notification, Select } from 'component/antd';
|
||||
import { IUploadFile, IConfigure, IConfigGateway } from 'types/base-type';
|
||||
import { version } from 'store/version';
|
||||
import { admin } from 'store/admin';
|
||||
import { wrapper } from 'store';
|
||||
@@ -97,8 +97,8 @@ const updateFormModal = (type: number) => {
|
||||
formMap[2].attrs = {
|
||||
accept: version.fileSuffix,
|
||||
},
|
||||
// tslint:disable-next-line:no-unused-expression
|
||||
wrapper.ref && wrapper.ref.updateFormMap$(formMap, wrapper.xFormWrapper.formData, true);
|
||||
// tslint:disable-next-line:no-unused-expression
|
||||
wrapper.ref && wrapper.ref.updateFormMap$(formMap, wrapper.xFormWrapper.formData, true);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -157,8 +157,8 @@ export const showModifyModal = (record: IUploadFile) => {
|
||||
|
||||
export const showConfigureModal = async (record?: IConfigure) => {
|
||||
if (record) {
|
||||
const result:any = await format2json(record.configValue);
|
||||
record.configValue = result.result;
|
||||
const result: any = await format2json(record.configValue);
|
||||
record.configValue = result.result || record.configValue;
|
||||
}
|
||||
const xFormModal = {
|
||||
formMap: [
|
||||
@@ -193,10 +193,69 @@ export const showConfigureModal = async (record?: IConfigure) => {
|
||||
return admin.editConfigure(value).then(data => {
|
||||
notification.success({ message: '编辑配置成功' });
|
||||
});
|
||||
} else {
|
||||
return admin.addNewConfigure(value).then(data => {
|
||||
notification.success({ message: '新建配置成功' });
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
wrapper.open(xFormModal);
|
||||
};
|
||||
|
||||
export const showConfigGatewayModal = async (record?: IConfigGateway) => {
|
||||
const xFormModal = {
|
||||
formMap: [
|
||||
{
|
||||
key: 'type',
|
||||
label: '配置类型',
|
||||
rules: [{ required: true, message: '请选择配置类型' }],
|
||||
type: "select",
|
||||
options: admin.gatewayType.map((item: any, index: number) => ({
|
||||
key: index,
|
||||
label: item.configName,
|
||||
value: item.configType,
|
||||
})),
|
||||
attrs: {
|
||||
disabled: record ? true : false,
|
||||
}
|
||||
}, {
|
||||
key: 'name',
|
||||
label: '配置键',
|
||||
rules: [{ required: true, message: '请输入配置键' }],
|
||||
attrs: {
|
||||
disabled: record ? true : false,
|
||||
},
|
||||
}, {
|
||||
key: 'value',
|
||||
label: '配置值',
|
||||
type: 'text_area',
|
||||
rules: [{
|
||||
required: true,
|
||||
message: '请输入配置值',
|
||||
}],
|
||||
}, {
|
||||
key: 'description',
|
||||
label: '描述',
|
||||
type: 'text_area',
|
||||
rules: [{ required: true, message: '请输入备注' }],
|
||||
},
|
||||
],
|
||||
formData: record || {},
|
||||
visible: true,
|
||||
isWaitting: true,
|
||||
title: `${record ? '编辑配置' : '新建配置'}`,
|
||||
onSubmit: async (parmas: IConfigGateway) => {
|
||||
if (record) {
|
||||
parmas.id = record.id;
|
||||
return admin.editConfigGateway(parmas).then(data => {
|
||||
notification.success({ message: '编辑配置成功' });
|
||||
});
|
||||
} else {
|
||||
return admin.addNewConfigGateway(parmas).then(data => {
|
||||
notification.success({ message: '新建配置成功' });
|
||||
});
|
||||
}
|
||||
return admin.addNewConfigure(value).then(data => {
|
||||
notification.success({ message: '新建配置成功' });
|
||||
});
|
||||
},
|
||||
};
|
||||
wrapper.open(xFormModal);
|
||||
|
||||
@@ -85,7 +85,7 @@ export const showEditModal = (record?: IAppItem, from?: string, isDisabled?: boo
|
||||
],
|
||||
formData: record,
|
||||
visible: true,
|
||||
title: isDisabled ? '详情' : record ? '编辑' : <div><span>应用申请</span><a className='applicationDocument' href="###" target='_blank'>应用申请文档</a></div>,
|
||||
title: isDisabled ? '详情' : record ? '编辑' : <div><span>应用申请</span><a className='applicationDocument' href="https://github.com/didi/Logi-KafkaManager/blob/master/docs/user_guide/resource_apply.md" target='_blank'>资源申请文档</a></div>,
|
||||
// customRenderElement: isDisabled ? '' : record ? '' : <span className="tips">集群资源充足时,预计1分钟自动审批通过</span>,
|
||||
isWaitting: true,
|
||||
onSubmit: (value: IAppItem) => {
|
||||
|
||||
@@ -20,14 +20,14 @@ export interface IRenderData {
|
||||
}
|
||||
|
||||
export const migrationModal = (renderData: IRenderData[]) => {
|
||||
const xFormWrapper = {
|
||||
const xFormWrapper = {
|
||||
type: 'drawer',
|
||||
visible: true,
|
||||
width: 1000,
|
||||
title: '新建迁移任务',
|
||||
customRenderElement: <WrappedDataMigrationFormTable data={renderData}/>,
|
||||
customRenderElement: <WrappedDataMigrationFormTable data={renderData} />,
|
||||
nofooter: true,
|
||||
noform: true,
|
||||
};
|
||||
wrapper.open(xFormWrapper as IXFormWrapper);
|
||||
wrapper.open(xFormWrapper as IXFormWrapper);
|
||||
};
|
||||
|
||||
@@ -75,8 +75,8 @@ export const showApprovalModal = (info: IOrderInfo, status: number, from?: strin
|
||||
// }],
|
||||
rules: [{
|
||||
required: true,
|
||||
message: '请输入大于12小于999的整数',
|
||||
pattern: /^([1-9]{1}[0-9]{2})$|^([2-9]{1}[0-9]{1})$|^(1[2-9]{1})$/,
|
||||
message: '请输入大于0小于10000的整数',
|
||||
pattern: /^\+?[1-9]\d{0,3}(\.\d*)?$/,
|
||||
}],
|
||||
}, {
|
||||
key: 'species',
|
||||
|
||||
@@ -88,7 +88,7 @@ export const applyTopic = () => {
|
||||
],
|
||||
formData: {},
|
||||
visible: true,
|
||||
title: '申请Topic',
|
||||
title: <div><span>申请Topic</span><a className='applicationDocument' href="https://github.com/didi/Logi-KafkaManager/blob/master/docs/user_guide/resource_apply.md" target='_blank'>资源申请文档</a></div>,
|
||||
okText: '确认',
|
||||
// customRenderElement: <span className="tips">集群资源充足时,预计1分钟自动审批通过</span>,
|
||||
isWaitting: true,
|
||||
|
||||
@@ -126,7 +126,7 @@ export class SearchAndFilterContainer extends React.Component<any, ISearchAndFil
|
||||
);
|
||||
}
|
||||
|
||||
public renderSearch(text?: string, placeholder?: string, keyName: string = 'searchKey') {
|
||||
public renderSearch(text?: string, placeholder?: string, keyName: string = 'searchKey',) {
|
||||
const value = this.state[keyName] as string;
|
||||
return (
|
||||
<li className="render-box">
|
||||
|
||||
@@ -101,7 +101,9 @@ export class ConnectInformation extends SearchAndFilterContainer {
|
||||
<>
|
||||
<div className="k-row" >
|
||||
<ul className="k-tab">
|
||||
<li>连接信息</li>
|
||||
<li>
|
||||
连接信息 <span style={{ color: '#a7a8a9', fontSize: '12px', padding: '0 15px' }}>展示近20分钟的连接信息</span>
|
||||
</li>
|
||||
{this.renderSearch('', '请输入连接信息', 'searchKey')}
|
||||
</ul>
|
||||
{this.renderConnectionInfo(this.getData(topic.connectionInfo))}
|
||||
|
||||
@@ -138,7 +138,7 @@ export class GroupID extends SearchAndFilterContainer {
|
||||
|
||||
public renderConsumerDetails() {
|
||||
const consumerGroup = this.consumerGroup;
|
||||
const columns = [{
|
||||
const columns: any = [{
|
||||
title: 'Partition ID',
|
||||
dataIndex: 'partitionId',
|
||||
key: 'partitionId',
|
||||
@@ -179,7 +179,8 @@ export class GroupID extends SearchAndFilterContainer {
|
||||
<>
|
||||
<div className="details-box">
|
||||
<b>{consumerGroup}</b>
|
||||
<div>
|
||||
<div style={{ display: 'flex' }}>
|
||||
{this.renderSearch('', '请输入Consumer ID')}
|
||||
<Button onClick={this.backToPage}>返回</Button>
|
||||
<Button onClick={this.updateDetailsStatus}>刷新</Button>
|
||||
<Button onClick={() => this.showResetOffset()}>重置Offset</Button>
|
||||
@@ -187,7 +188,7 @@ export class GroupID extends SearchAndFilterContainer {
|
||||
</div>
|
||||
<Table
|
||||
columns={columns}
|
||||
dataSource={topic.consumeDetails}
|
||||
dataSource={this.getDetailData(topic.consumeDetails)}
|
||||
rowKey="key"
|
||||
pagination={pagination}
|
||||
/>
|
||||
@@ -214,7 +215,12 @@ export class GroupID extends SearchAndFilterContainer {
|
||||
dataIndex: 'location',
|
||||
key: 'location',
|
||||
width: '34%',
|
||||
},
|
||||
}, {
|
||||
title: '状态',
|
||||
dataIndex: 'state',
|
||||
key: 'state',
|
||||
width: '34%',
|
||||
}
|
||||
];
|
||||
return (
|
||||
<>
|
||||
@@ -236,7 +242,17 @@ export class GroupID extends SearchAndFilterContainer {
|
||||
|
||||
data = searchKey ? origin.filter((item: IConsumerGroups) =>
|
||||
(item.consumerGroup !== undefined && item.consumerGroup !== null) && item.consumerGroup.toLowerCase().includes(searchKey as string),
|
||||
) : origin ;
|
||||
) : origin;
|
||||
return data;
|
||||
}
|
||||
|
||||
public getDetailData<T extends IConsumeDetails>(origin: T[]) {
|
||||
let data: T[] = origin;
|
||||
let { searchKey } = this.state;
|
||||
searchKey = (searchKey + '').trim().toLowerCase();
|
||||
data = searchKey ? origin.filter((item: IConsumeDetails) =>
|
||||
(item.clientId !== undefined && item.clientId !== null) && item.clientId.toLowerCase().includes(searchKey as string),
|
||||
) : origin;
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
@@ -71,32 +71,32 @@ class ResetOffset extends React.Component<any> {
|
||||
const { getFieldDecorator } = this.props.form;
|
||||
const { typeValue, offsetValue } = this.state;
|
||||
return (
|
||||
<>
|
||||
<Alert message="重置之前一定要关闭消费客户端!!!" type="warning" showIcon={true} />
|
||||
<Alert message="重置之前一定要关闭消费客户端!!!" type="warning" showIcon={true} />
|
||||
<Alert message="重置之前一定要关闭消费客户端!!!" type="warning" showIcon={true} className="mb-30"/>
|
||||
<>
|
||||
<Alert message="重置消费偏移前,请先关闭客户端,否则会重置失败 !!!" type="warning" showIcon={true} />
|
||||
<Alert message="关闭客户端后,请等待一分钟之后再重置消费偏移 !!!" type="warning" showIcon={true} />
|
||||
{/* <Alert message="重置之前一定要关闭消费客户端!!!" type="warning" showIcon={true} className="mb-30" /> */}
|
||||
<div className="o-container">
|
||||
<Form labelAlign="left" onSubmit={this.handleSubmit} >
|
||||
<Radio.Group onChange={this.onChangeType} value={typeValue}>
|
||||
<Radio.Group onChange={this.onChangeType} value={typeValue}>
|
||||
<Radio value="time"><span className="title-con">重置到指定时间</span></Radio>
|
||||
<Row>
|
||||
<Col span={26}>
|
||||
<Form.Item label="" >
|
||||
<Radio.Group
|
||||
onChange={this.onChangeOffset}
|
||||
value={offsetValue}
|
||||
disabled={typeValue === 'partition'}
|
||||
defaultValue="offset"
|
||||
className="mr-10"
|
||||
>
|
||||
<Radio.Button value="offset">最新offset</Radio.Button>
|
||||
<Radio.Button value="custom">自定义</Radio.Button>
|
||||
</Radio.Group>
|
||||
<Radio.Group
|
||||
onChange={this.onChangeOffset}
|
||||
value={offsetValue}
|
||||
disabled={typeValue === 'partition'}
|
||||
defaultValue="offset"
|
||||
className="mr-10"
|
||||
>
|
||||
<Radio.Button value="offset">最新offset</Radio.Button>
|
||||
<Radio.Button value="custom">自定义</Radio.Button>
|
||||
</Radio.Group>
|
||||
{typeValue === 'time' && offsetValue === 'custom' &&
|
||||
getFieldDecorator('timestamp', {
|
||||
rules: [{ required: false, message: '' }],
|
||||
initialValue: moment(),
|
||||
})(
|
||||
})(
|
||||
<DatePicker
|
||||
showTime={true}
|
||||
format={timeMinute}
|
||||
@@ -109,7 +109,7 @@ class ResetOffset extends React.Component<any> {
|
||||
</Col>
|
||||
</Row>
|
||||
<Radio value="partition"><span className="title-con">重置指定分区及偏移</span></Radio>
|
||||
</Radio.Group>
|
||||
</Radio.Group>
|
||||
<Row>
|
||||
<Form.Item>
|
||||
<Row>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import fetch, { formFetch } from './fetch';
|
||||
import { IUploadFile, IUser, IQuotaModelItem, ILimitsItem, ITopic, IOrderParams, ISample, IMigration, IExecute, IEepand, IUtils, ITopicMetriceParams, IRegister, IEditTopic, IExpand, IDeleteTopic, INewRegions, INewLogical, IRebalance, INewBulidEnums, ITrigger, IApprovalOrder, IMonitorSilences, IConfigure, IBatchApproval } from 'types/base-type';
|
||||
import { IUploadFile, IUser, IQuotaModelItem, ILimitsItem, ITopic, IOrderParams, ISample, IMigration, IExecute, IEepand, IUtils, ITopicMetriceParams, IRegister, IEditTopic, IExpand, IDeleteTopic, INewRegions, INewLogical, IRebalance, INewBulidEnums, ITrigger, IApprovalOrder, IMonitorSilences, IConfigure, IConfigGateway, IBatchApproval } from 'types/base-type';
|
||||
import { IRequestParams } from 'types/alarm';
|
||||
import { apiCache } from 'lib/api-cache';
|
||||
|
||||
@@ -442,6 +442,34 @@ export const deleteConfigure = (configKey: string) => {
|
||||
});
|
||||
};
|
||||
|
||||
export const getGatewayList = () => {
|
||||
return fetch(`/rd/gateway-configs`);
|
||||
};
|
||||
|
||||
export const getGatewayType = () => {
|
||||
return fetch(`/op/gateway-configs/type-enums`);
|
||||
};
|
||||
|
||||
export const addNewConfigGateway = (params: IConfigGateway) => {
|
||||
return fetch(`/op/gateway-configs`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(params),
|
||||
});
|
||||
};
|
||||
|
||||
export const editConfigGateway = (params: IConfigGateway) => {
|
||||
return fetch(`/op/gateway-configs`, {
|
||||
method: 'PUT',
|
||||
body: JSON.stringify(params),
|
||||
});
|
||||
};
|
||||
export const deleteConfigGateway = (params: IConfigure) => {
|
||||
return fetch(`/op/gateway-configs`, {
|
||||
method: 'DELETE',
|
||||
body: JSON.stringify(params),
|
||||
});
|
||||
};
|
||||
|
||||
export const getDataCenter = () => {
|
||||
return fetch(`/normal/configs/idc`);
|
||||
};
|
||||
@@ -530,6 +558,23 @@ export const getControllerHistory = (clusterId: number) => {
|
||||
return fetch(`/rd/clusters/${clusterId}/controller-history`);
|
||||
};
|
||||
|
||||
export const getCandidateController = (clusterId: number) => {
|
||||
return fetch(`/rd/clusters/${clusterId}/controller-preferred-candidates`);
|
||||
};
|
||||
|
||||
export const addCandidateController = (params:any) => {
|
||||
return fetch(`/op/cluster-controller/preferred-candidates`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(params),
|
||||
});
|
||||
};
|
||||
|
||||
export const deleteCandidateCancel = (params:any)=>{
|
||||
return fetch(`/op/cluster-controller/preferred-candidates`, {
|
||||
method: 'DELETE',
|
||||
body: JSON.stringify(params),
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 运维管控 broker
|
||||
*/
|
||||
|
||||
@@ -77,7 +77,7 @@ export const getControlMetricOption = (type: IOptionType, data: IClusterMetrics[
|
||||
name = '条';
|
||||
data.map(item => {
|
||||
item.messagesInPerSec = item.messagesInPerSec !== null ? Number(item.messagesInPerSec.toFixed(2)) : null;
|
||||
});
|
||||
});
|
||||
break;
|
||||
case 'brokerNum':
|
||||
case 'topicNum':
|
||||
@@ -224,7 +224,7 @@ export const getClusterMetricOption = (type: IOptionType, record: IClusterMetric
|
||||
name = '条';
|
||||
data.map(item => {
|
||||
item.messagesInPerSec = item.messagesInPerSec !== null ? Number(item.messagesInPerSec.toFixed(2)) : null;
|
||||
});
|
||||
});
|
||||
break;
|
||||
default:
|
||||
const { name: unitName, data: xData } = dealFlowData(metricTypeMap[type], data);
|
||||
@@ -248,8 +248,8 @@ export const getClusterMetricOption = (type: IOptionType, record: IClusterMetric
|
||||
const unitSeries = item.data[item.seriesName] !== null ? Number(item.data[item.seriesName]) : null;
|
||||
// tslint:disable-next-line:max-line-length
|
||||
result += '<span style="display:inline-block;margin-right:0px;border-radius:10px;width:9px;height:9px;background-color:' + item.color + '"></span>';
|
||||
if ( (item.data.produceThrottled && item.seriesName === 'appIdBytesInPerSec')
|
||||
|| (item.data.consumeThrottled && item.seriesName === 'appIdBytesOutPerSec') ) {
|
||||
if ((item.data.produceThrottled && item.seriesName === 'appIdBytesInPerSec')
|
||||
|| (item.data.consumeThrottled && item.seriesName === 'appIdBytesOutPerSec')) {
|
||||
return result += item.seriesName + ': ' + unitSeries + '(被限流)' + '<br>';
|
||||
}
|
||||
return result += item.seriesName + ': ' + unitSeries + '<br>';
|
||||
@@ -317,7 +317,7 @@ export const getMonitorMetricOption = (seriesName: string, data: IMetricPoint[])
|
||||
if (ele.name === item.seriesName) {
|
||||
// tslint:disable-next-line:max-line-length
|
||||
result += '<span style="display:inline-block;margin-right:0px;border-radius:10px;width:9px;height:9px;background-color:' + item.color + '"></span>';
|
||||
return result += item.seriesName + ': ' + (item.data.value === null ? '' : item.data.value.toFixed(2)) + '<br>';
|
||||
return result += item.seriesName + ': ' + (item.data.value === null ? '' : item.data.value.toFixed(2)) + '<br>';
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3,6 +3,11 @@ import { observable, action } from 'mobx';
|
||||
import { getBrokersMetricsHistory } from 'lib/api';
|
||||
import { IClusterMetrics } from 'types/base-type';
|
||||
|
||||
const STATUS = {
|
||||
PENDING: 'pending',
|
||||
REJECT: 'reject',
|
||||
FULLFILLED: 'fullfilled'
|
||||
}
|
||||
class AdminMonitor {
|
||||
@observable
|
||||
public currentClusterId = null as number;
|
||||
@@ -33,33 +38,42 @@ class AdminMonitor {
|
||||
@action.bound
|
||||
public setBrokersChartsData(data: IClusterMetrics[]) {
|
||||
this.brokersMetricsHistory = data;
|
||||
this.setRequestId(null);
|
||||
this.setRequestId(STATUS.FULLFILLED);
|
||||
Promise.all(this.taskQueue).then(() => {
|
||||
this.setRequestId(null);
|
||||
this.taskQueue = [];
|
||||
})
|
||||
return data;
|
||||
}
|
||||
public taskQueue = [] as any[];
|
||||
|
||||
public getBrokersMetricsList = async (startTime: string, endTime: string) => {
|
||||
if (this.requestId && this.requestId !== 'error') {
|
||||
return new Promise((res, rej) => {
|
||||
window.setTimeout(() => {
|
||||
if (this.requestId === 'error') {
|
||||
rej();
|
||||
} else {
|
||||
if (this.requestId) {
|
||||
//逐条定时查询任务状态
|
||||
const p = new Promise((res, rej) => {
|
||||
const timer = window.setInterval(() => {
|
||||
if (this.requestId === STATUS.REJECT) {
|
||||
rej(this.brokersMetricsHistory);
|
||||
window.clearInterval(timer);
|
||||
} else if (this.requestId === STATUS.FULLFILLED) {
|
||||
res(this.brokersMetricsHistory);
|
||||
window.clearInterval(timer);
|
||||
}
|
||||
}, 800); // TODO: 该实现方式待优化
|
||||
}, (this.taskQueue.length + 1) * 100);
|
||||
});
|
||||
this.taskQueue.push(p);
|
||||
return p;
|
||||
}
|
||||
|
||||
this.setRequestId('requesting');
|
||||
this.setRequestId(STATUS.PENDING);
|
||||
return getBrokersMetricsHistory(this.currentClusterId, this.currentBrokerId, startTime, endTime)
|
||||
.then(this.setBrokersChartsData).catch(() => this.setRequestId('error'));
|
||||
.then(this.setBrokersChartsData).catch(() => this.setRequestId(STATUS.REJECT));
|
||||
}
|
||||
|
||||
public getBrokersChartsData = async (startTime: string, endTime: string, reload?: boolean) => {
|
||||
if (this.brokersMetricsHistory && !reload) {
|
||||
return new Promise(res => res(this.brokersMetricsHistory));
|
||||
}
|
||||
|
||||
return this.getBrokersMetricsList(startTime, endTime);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { observable, action } from 'mobx';
|
||||
import { INewBulidEnums, ILabelValue, IClusterReal, IOptionType, IClusterMetrics, IClusterTopics, IKafkaFiles, IMetaData, IConfigure, IBrokerData, IOffset, IController, IBrokersBasicInfo, IBrokersStatus, IBrokersTopics, IBrokersPartitions, IBrokersAnalysis, IAnalysisTopicVO, IBrokersMetadata, IBrokersRegions, IThrottles, ILogicalCluster, INewRegions, INewLogical, ITaskManage, IPartitionsLocation, ITaskType, ITasksEnums, ITasksMetaData, ITaskStatusDetails, IKafkaRoles, IEnumsMap, IStaffSummary, IBill, IBillDetail } from 'types/base-type';
|
||||
import { INewBulidEnums, ILabelValue, IClusterReal, IOptionType, IClusterMetrics, IClusterTopics, IKafkaFiles, IMetaData, IConfigure, IConfigGateway, IBrokerData, IOffset, IController, IBrokersBasicInfo, IBrokersStatus, IBrokersTopics, IBrokersPartitions, IBrokersAnalysis, IAnalysisTopicVO, IBrokersMetadata, IBrokersRegions, IThrottles, ILogicalCluster, INewRegions, INewLogical, ITaskManage, IPartitionsLocation, ITaskType, ITasksEnums, ITasksMetaData, ITaskStatusDetails, IKafkaRoles, IEnumsMap, IStaffSummary, IBill, IBillDetail } from 'types/base-type';
|
||||
import {
|
||||
deleteCluster,
|
||||
getBasicInfo,
|
||||
@@ -12,7 +12,12 @@ import {
|
||||
getConfigure,
|
||||
addNewConfigure,
|
||||
editConfigure,
|
||||
addNewConfigGateway,
|
||||
deleteConfigure,
|
||||
getGatewayList,
|
||||
getGatewayType,
|
||||
editConfigGateway,
|
||||
deleteConfigGateway,
|
||||
getDataCenter,
|
||||
getClusterBroker,
|
||||
getClusterConsumer,
|
||||
@@ -49,6 +54,9 @@ import {
|
||||
getStaffSummary,
|
||||
getBillStaffSummary,
|
||||
getBillStaffDetail,
|
||||
getCandidateController,
|
||||
addCandidateController,
|
||||
deleteCandidateCancel
|
||||
} from 'lib/api';
|
||||
import { getControlMetricOption, getClusterMetricOption } from 'lib/line-charts-config';
|
||||
|
||||
@@ -59,6 +67,7 @@ import { transBToMB } from 'lib/utils';
|
||||
|
||||
import moment from 'moment';
|
||||
import { timestore } from './time';
|
||||
import { message } from 'component/antd';
|
||||
|
||||
class Admin {
|
||||
@observable
|
||||
@@ -97,6 +106,12 @@ class Admin {
|
||||
@observable
|
||||
public configureList: IConfigure[] = [];
|
||||
|
||||
@observable
|
||||
public configGatewayList: IConfigGateway[] = [];
|
||||
|
||||
@observable
|
||||
public gatewayType: [];
|
||||
|
||||
@observable
|
||||
public dataCenterList: string[] = [];
|
||||
|
||||
@@ -142,6 +157,12 @@ class Admin {
|
||||
@observable
|
||||
public controllerHistory: IController[] = [];
|
||||
|
||||
@observable
|
||||
public controllerCandidate: IController[] = [];
|
||||
|
||||
@observable
|
||||
public filtercontrollerCandidate: string = '';
|
||||
|
||||
@observable
|
||||
public brokersPartitions: IBrokersPartitions[] = [];
|
||||
|
||||
@@ -152,7 +173,7 @@ class Admin {
|
||||
public brokersAnalysisTopic: IAnalysisTopicVO[] = [];
|
||||
|
||||
@observable
|
||||
public brokersMetadata: IBrokersMetadata[] = [];
|
||||
public brokersMetadata: IBrokersMetadata[] | any = [];
|
||||
|
||||
@observable
|
||||
public brokersRegions: IBrokersRegions[] = [];
|
||||
@@ -206,10 +227,10 @@ class Admin {
|
||||
public kafkaRoles: IKafkaRoles[];
|
||||
|
||||
@observable
|
||||
public controlType: IOptionType = 'byteIn/byteOut' ;
|
||||
public controlType: IOptionType = 'byteIn/byteOut';
|
||||
|
||||
@observable
|
||||
public type: IOptionType = 'byteIn/byteOut' ;
|
||||
public type: IOptionType = 'byteIn/byteOut';
|
||||
|
||||
@observable
|
||||
public currentClusterId = null as number;
|
||||
@@ -241,7 +262,7 @@ class Admin {
|
||||
|
||||
@action.bound
|
||||
public setClusterRealTime(data: IClusterReal) {
|
||||
this.clusterRealData = data;
|
||||
this.clusterRealData = data;
|
||||
this.getRealClusterLoading(false);
|
||||
}
|
||||
|
||||
@@ -284,7 +305,7 @@ class Admin {
|
||||
return {
|
||||
...item,
|
||||
label: item.fileName,
|
||||
value: item.fileName + ',' + item.fileMd5,
|
||||
value: item.fileName + ',' + item.fileMd5,
|
||||
};
|
||||
}));
|
||||
}
|
||||
@@ -306,6 +327,20 @@ class Admin {
|
||||
}) : [];
|
||||
}
|
||||
|
||||
@action.bound
|
||||
public setConfigGatewayList(data: IConfigGateway[]) {
|
||||
this.configGatewayList = data ? data.map((item, index) => {
|
||||
item.key = index;
|
||||
return item;
|
||||
}) : [];
|
||||
}
|
||||
|
||||
@action.bound
|
||||
public setConfigGatewayType(data: any) {
|
||||
this.setLoading(false);
|
||||
this.gatewayType = data || [];
|
||||
}
|
||||
|
||||
@action.bound
|
||||
public setDataCenter(data: string[]) {
|
||||
this.dataCenterList = data || [];
|
||||
@@ -335,6 +370,17 @@ class Admin {
|
||||
}) : [];
|
||||
}
|
||||
|
||||
@action.bound
|
||||
public setCandidateController(data: IController[]) {
|
||||
this.controllerCandidate = data ? data.map((item, index) => {
|
||||
item.key = index;
|
||||
return item;
|
||||
}) : [];
|
||||
this.filtercontrollerCandidate = data?data.map((item,index)=>{
|
||||
return item.brokerId
|
||||
}).join(','):''
|
||||
}
|
||||
|
||||
@action.bound
|
||||
public setBrokersBasicInfo(data: IBrokersBasicInfo) {
|
||||
this.brokersBasicInfo = data;
|
||||
@@ -356,10 +402,10 @@ class Admin {
|
||||
this.replicaStatus = data.brokerReplicaStatusList.slice(1);
|
||||
|
||||
this.bytesInStatus.forEach((item, index) => {
|
||||
this.peakValueList.push({ name: peakValueMap[index], value: item});
|
||||
this.peakValueList.push({ name: peakValueMap[index], value: item });
|
||||
});
|
||||
this.replicaStatus.forEach((item, index) => {
|
||||
this.copyValueList.push({name: copyValueMap[index], value: item});
|
||||
this.copyValueList.push({ name: copyValueMap[index], value: item });
|
||||
});
|
||||
}
|
||||
|
||||
@@ -415,16 +461,16 @@ class Admin {
|
||||
}
|
||||
|
||||
@action.bound
|
||||
public setBrokersMetadata(data: IBrokersMetadata[]) {
|
||||
this.brokersMetadata = data ? data.map((item, index) => {
|
||||
item.key = index;
|
||||
return {
|
||||
...item,
|
||||
text: `${item.host} (BrokerID:${item.brokerId})`,
|
||||
label: item.host,
|
||||
value: item.brokerId,
|
||||
};
|
||||
}) : [];
|
||||
public setBrokersMetadata(data: IBrokersMetadata[]|any) {
|
||||
this.brokersMetadata = data ? data.map((item:any, index:any) => {
|
||||
item.key = index;
|
||||
return {
|
||||
...item,
|
||||
text: `${item.host} (BrokerID:${item.brokerId})`,
|
||||
label: item.host,
|
||||
value: item.brokerId,
|
||||
};
|
||||
}) : [];
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@@ -461,9 +507,9 @@ class Admin {
|
||||
@action.bound
|
||||
public setLogicalClusters(data: ILogicalCluster[]) {
|
||||
this.logicalClusters = data ? data.map((item, index) => {
|
||||
item.key = index;
|
||||
return item;
|
||||
}) : [];
|
||||
item.key = index;
|
||||
return item;
|
||||
}) : [];
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@@ -474,25 +520,25 @@ class Admin {
|
||||
@action.bound
|
||||
public setClustersThrottles(data: IThrottles[]) {
|
||||
this.clustersThrottles = data ? data.map((item, index) => {
|
||||
item.key = index;
|
||||
return item;
|
||||
}) : [];
|
||||
item.key = index;
|
||||
return item;
|
||||
}) : [];
|
||||
}
|
||||
|
||||
@action.bound
|
||||
public setPartitionsLocation(data: IPartitionsLocation[]) {
|
||||
this.partitionsLocation = data ? data.map((item, index) => {
|
||||
item.key = index;
|
||||
return item;
|
||||
}) : [];
|
||||
item.key = index;
|
||||
return item;
|
||||
}) : [];
|
||||
}
|
||||
|
||||
@action.bound
|
||||
public setTaskManagement(data: ITaskManage[]) {
|
||||
this.taskManagement = data ? data.map((item, index) => {
|
||||
item.key = index;
|
||||
return item;
|
||||
}) : [];
|
||||
item.key = index;
|
||||
return item;
|
||||
}) : [];
|
||||
}
|
||||
|
||||
@action.bound
|
||||
@@ -568,7 +614,7 @@ class Admin {
|
||||
return deleteCluster(clusterId).then(() => this.getMetaData(true));
|
||||
}
|
||||
|
||||
public getPeakFlowChartData(value: ILabelValue[], map: string []) {
|
||||
public getPeakFlowChartData(value: ILabelValue[], map: string[]) {
|
||||
return getPieChartOption(value, map);
|
||||
}
|
||||
|
||||
@@ -627,6 +673,30 @@ class Admin {
|
||||
deleteConfigure(configKey).then(() => this.getConfigure());
|
||||
}
|
||||
|
||||
public getGatewayList() {
|
||||
getGatewayList().then(this.setConfigGatewayList);
|
||||
}
|
||||
|
||||
public getGatewayType() {
|
||||
this.setLoading(true);
|
||||
getGatewayType().then(this.setConfigGatewayType);
|
||||
}
|
||||
|
||||
public addNewConfigGateway(params: IConfigGateway) {
|
||||
return addNewConfigGateway(params).then(() => this.getGatewayList());
|
||||
}
|
||||
|
||||
public editConfigGateway(params: IConfigGateway) {
|
||||
return editConfigGateway(params).then(() => this.getGatewayList());
|
||||
}
|
||||
|
||||
public deleteConfigGateway(params: any) {
|
||||
deleteConfigGateway(params).then(() => {
|
||||
// message.success('删除成功')
|
||||
this.getGatewayList()
|
||||
});
|
||||
}
|
||||
|
||||
public getDataCenter() {
|
||||
getDataCenter().then(this.setDataCenter);
|
||||
}
|
||||
@@ -643,6 +713,20 @@ class Admin {
|
||||
return getControllerHistory(clusterId).then(this.setControllerHistory);
|
||||
}
|
||||
|
||||
public getCandidateController(clusterId: number) {
|
||||
return getCandidateController(clusterId).then(data=>{
|
||||
return this.setCandidateController(data)
|
||||
});
|
||||
}
|
||||
|
||||
public addCandidateController(clusterId: number, brokerIdList: any) {
|
||||
return addCandidateController({clusterId, brokerIdList}).then(()=>this.getCandidateController(clusterId));
|
||||
}
|
||||
|
||||
public deleteCandidateCancel(clusterId: number, brokerIdList: any){
|
||||
return deleteCandidateCancel({clusterId, brokerIdList}).then(()=>this.getCandidateController(clusterId));
|
||||
}
|
||||
|
||||
public getBrokersBasicInfo(clusterId: number, brokerId: number) {
|
||||
return getBrokersBasicInfo(clusterId, brokerId).then(this.setBrokersBasicInfo);
|
||||
}
|
||||
|
||||
@@ -181,6 +181,7 @@ class Alarm {
|
||||
public modifyMonitorStrategy(params: IRequestParams) {
|
||||
return modifyMonitorStrategy(params).then(() => {
|
||||
message.success('操作成功');
|
||||
window.location.href = `${urlPrefix}/alarm`;
|
||||
}).finally(() => this.setLoading(false));
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,9 @@ export class Users {
|
||||
@observable
|
||||
public staff: IStaff[] = [];
|
||||
|
||||
@observable
|
||||
public newPassWord: any = null;
|
||||
|
||||
@action.bound
|
||||
public setAccount(data: IUser) {
|
||||
setCookie([{ key: 'role', value: `${data.role}`, time: 1 }]);
|
||||
@@ -42,6 +45,11 @@ export class Users {
|
||||
this.loading = value;
|
||||
}
|
||||
|
||||
@action.bound
|
||||
public setNewPassWord(value: boolean) {
|
||||
this.newPassWord = value;
|
||||
}
|
||||
|
||||
public getAccount() {
|
||||
getAccount().then(this.setAccount);
|
||||
}
|
||||
|
||||
@@ -190,6 +190,7 @@ export interface IUser {
|
||||
chineseName?: string;
|
||||
department?: string;
|
||||
key?: number;
|
||||
confirmPassword?:string
|
||||
}
|
||||
|
||||
export interface IOffset {
|
||||
@@ -486,6 +487,17 @@ export interface IConfigure {
|
||||
key?: number;
|
||||
}
|
||||
|
||||
export interface IConfigGateway {
|
||||
id: number;
|
||||
key?: number;
|
||||
modifyTime: number;
|
||||
name: string;
|
||||
value: string;
|
||||
version: string;
|
||||
type: string;
|
||||
description: string;
|
||||
}
|
||||
|
||||
export interface IEepand {
|
||||
brokerIdList: number[];
|
||||
clusterId: number;
|
||||
@@ -650,8 +662,10 @@ export interface IBrokerData {
|
||||
export interface IController {
|
||||
brokerId: number;
|
||||
host: string;
|
||||
timestamp: number;
|
||||
version: number;
|
||||
timestamp?: number;
|
||||
version?: number;
|
||||
startTime?: number;
|
||||
status?: number;
|
||||
key?: number;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,10 +15,7 @@ import com.xiaojukeji.kafka.manager.common.zookeeper.znode.brokers.TopicMetadata
|
||||
import com.xiaojukeji.kafka.manager.common.zookeeper.ZkConfigImpl;
|
||||
import com.xiaojukeji.kafka.manager.dao.ControllerDao;
|
||||
import com.xiaojukeji.kafka.manager.common.utils.jmx.JmxConnectorWrap;
|
||||
import com.xiaojukeji.kafka.manager.dao.TopicDao;
|
||||
import com.xiaojukeji.kafka.manager.dao.gateway.AuthorityDao;
|
||||
import com.xiaojukeji.kafka.manager.service.service.JmxService;
|
||||
import com.xiaojukeji.kafka.manager.service.utils.ConfigUtils;
|
||||
import com.xiaojukeji.kafka.manager.service.zookeeper.*;
|
||||
import com.xiaojukeji.kafka.manager.service.service.ClusterService;
|
||||
import com.xiaojukeji.kafka.manager.common.zookeeper.ZkPathUtil;
|
||||
@@ -49,15 +46,6 @@ public class PhysicalClusterMetadataManager {
|
||||
@Autowired
|
||||
private ClusterService clusterService;
|
||||
|
||||
@Autowired
|
||||
private ConfigUtils configUtils;
|
||||
|
||||
@Autowired
|
||||
private TopicDao topicDao;
|
||||
|
||||
@Autowired
|
||||
private AuthorityDao authorityDao;
|
||||
|
||||
private final static Map<Long, ClusterDO> CLUSTER_MAP = new ConcurrentHashMap<>();
|
||||
|
||||
private final static Map<Long, ControllerData> CONTROLLER_DATA_MAP = new ConcurrentHashMap<>();
|
||||
@@ -133,7 +121,7 @@ public class PhysicalClusterMetadataManager {
|
||||
zkConfig.watchChildren(ZkPathUtil.BROKER_IDS_ROOT, brokerListener);
|
||||
|
||||
//增加Topic监控
|
||||
TopicStateListener topicListener = new TopicStateListener(clusterDO.getId(), zkConfig, topicDao, authorityDao);
|
||||
TopicStateListener topicListener = new TopicStateListener(clusterDO.getId(), zkConfig);
|
||||
topicListener.init();
|
||||
zkConfig.watchChildren(ZkPathUtil.BROKER_TOPICS_ROOT, topicListener);
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.xiaojukeji.kafka.manager.common.entity.Result;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.ResultStatus;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.ao.ClusterDetailDTO;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.ao.cluster.ControllerPreferredCandidate;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.dto.op.ControllerPreferredCandidateDTO;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.vo.normal.cluster.ClusterNameDTO;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.ClusterDO;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.ClusterMetricsDO;
|
||||
@@ -43,7 +44,7 @@ public interface ClusterService {
|
||||
|
||||
ClusterNameDTO getClusterName(Long logicClusterId);
|
||||
|
||||
ResultStatus deleteById(Long clusterId);
|
||||
ResultStatus deleteById(Long clusterId, String operator);
|
||||
|
||||
/**
|
||||
* 获取优先被选举为controller的broker
|
||||
@@ -51,4 +52,20 @@ public interface ClusterService {
|
||||
* @return void
|
||||
*/
|
||||
Result<List<ControllerPreferredCandidate>> getControllerPreferredCandidates(Long clusterId);
|
||||
|
||||
/**
|
||||
* 增加优先被选举为controller的broker
|
||||
* @param clusterId 集群ID
|
||||
* @param brokerIdList brokerId列表
|
||||
* @return
|
||||
*/
|
||||
Result addControllerPreferredCandidates(Long clusterId, List<Integer> brokerIdList);
|
||||
|
||||
/**
|
||||
* 减少优先被选举为controller的broker
|
||||
* @param clusterId 集群ID
|
||||
* @param brokerIdList brokerId列表
|
||||
* @return
|
||||
*/
|
||||
Result deleteControllerPreferredCandidates(Long clusterId, List<Integer> brokerIdList);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
package com.xiaojukeji.kafka.manager.service.service;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.bizenum.ModuleEnum;
|
||||
import com.xiaojukeji.kafka.manager.common.bizenum.OperateEnum;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.dto.rd.OperateRecordDTO;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.OperateRecordDO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author zhongyuankai
|
||||
@@ -12,5 +15,7 @@ import java.util.List;
|
||||
public interface OperateRecordService {
|
||||
int insert(OperateRecordDO operateRecordDO);
|
||||
|
||||
int insert(String operator, ModuleEnum module, String resourceName, OperateEnum operate, Map<String, String> content);
|
||||
|
||||
List<OperateRecordDO> queryByCondt(OperateRecordDTO dto);
|
||||
}
|
||||
|
||||
@@ -26,4 +26,20 @@ public interface ZookeeperService {
|
||||
* @return 操作结果
|
||||
*/
|
||||
Result<List<Integer>> getControllerPreferredCandidates(Long clusterId);
|
||||
|
||||
/**
|
||||
* 增加优先被选举为controller的broker
|
||||
* @param clusterId 集群ID
|
||||
* @param brokerId brokerId
|
||||
* @return
|
||||
*/
|
||||
Result addControllerPreferredCandidate(Long clusterId, Integer brokerId);
|
||||
|
||||
/**
|
||||
* 减少优先被选举为controller的broker
|
||||
* @param clusterId 集群ID
|
||||
* @param brokerId brokerId
|
||||
* @return
|
||||
*/
|
||||
Result deleteControllerPreferredCandidate(Long clusterId, Integer brokerId);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ public interface AppService {
|
||||
* @param appDO appDO
|
||||
* @return int
|
||||
*/
|
||||
ResultStatus addApp(AppDO appDO);
|
||||
ResultStatus addApp(AppDO appDO, String operator);
|
||||
|
||||
/**
|
||||
* 删除数据
|
||||
|
||||
@@ -60,10 +60,8 @@ public class AppServiceImpl implements AppService {
|
||||
@Autowired
|
||||
private OperateRecordService operateRecordService;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public ResultStatus addApp(AppDO appDO) {
|
||||
public ResultStatus addApp(AppDO appDO, String operator) {
|
||||
try {
|
||||
if (appDao.insert(appDO) < 1) {
|
||||
LOGGER.warn("class=AppServiceImpl||method=addApp||AppDO={}||msg=add fail,{}",appDO,ResultStatus.MYSQL_ERROR.getMessage());
|
||||
@@ -75,6 +73,15 @@ public class AppServiceImpl implements AppService {
|
||||
kafkaUserDO.setOperation(OperationStatusEnum.CREATE.getCode());
|
||||
kafkaUserDO.setUserType(0);
|
||||
kafkaUserDao.insert(kafkaUserDO);
|
||||
|
||||
Map<String, String> content = new HashMap<>();
|
||||
content.put("appId", appDO.getAppId());
|
||||
content.put("name", appDO.getName());
|
||||
content.put("applicant", appDO.getApplicant());
|
||||
content.put("password", appDO.getPassword());
|
||||
content.put("principals", appDO.getPrincipals());
|
||||
content.put("description", appDO.getDescription());
|
||||
operateRecordService.insert(operator, ModuleEnum.APP, appDO.getName(), OperateEnum.ADD, content);
|
||||
} catch (DuplicateKeyException e) {
|
||||
LOGGER.error("class=AppServiceImpl||method=addApp||errMsg={}||appDO={}|", e.getMessage(), appDO, e);
|
||||
return ResultStatus.RESOURCE_ALREADY_EXISTED;
|
||||
@@ -141,6 +148,12 @@ public class AppServiceImpl implements AppService {
|
||||
appDO.setDescription(dto.getDescription());
|
||||
|
||||
if (appDao.updateById(appDO) > 0) {
|
||||
Map<String, String> content = new HashMap<>();
|
||||
content.put("appId", appDO.getAppId());
|
||||
content.put("name", appDO.getName());
|
||||
content.put("principals", appDO.getPrincipals());
|
||||
content.put("description", appDO.getDescription());
|
||||
operateRecordService.insert(operator, ModuleEnum.APP, appDO.getName(), OperateEnum.EDIT, content);
|
||||
return ResultStatus.SUCCESS;
|
||||
}
|
||||
} catch (DuplicateKeyException e) {
|
||||
|
||||
@@ -221,13 +221,24 @@ public class GatewayConfigServiceImpl implements GatewayConfigService {
|
||||
if (ValidateUtils.isNull(oldGatewayConfigDO)) {
|
||||
return Result.buildFrom(ResultStatus.RESOURCE_NOT_EXIST);
|
||||
}
|
||||
|
||||
if (!oldGatewayConfigDO.getName().equals(newGatewayConfigDO.getName())
|
||||
|| !oldGatewayConfigDO.getType().equals(newGatewayConfigDO.getType())
|
||||
|| ValidateUtils.isBlank(newGatewayConfigDO.getValue())) {
|
||||
return Result.buildFrom(ResultStatus.PARAM_ILLEGAL);
|
||||
}
|
||||
newGatewayConfigDO.setVersion(oldGatewayConfigDO.getVersion() + 1);
|
||||
if (gatewayConfigDao.updateById(oldGatewayConfigDO) > 0) {
|
||||
|
||||
// 获取当前同类配置, 插入之后需要增大这个version
|
||||
List<GatewayConfigDO> gatewayConfigDOList = gatewayConfigDao.getByConfigType(newGatewayConfigDO.getType());
|
||||
Long version = 1L;
|
||||
for (GatewayConfigDO elem: gatewayConfigDOList) {
|
||||
if (elem.getVersion() > version) {
|
||||
version = elem.getVersion() + 1L;
|
||||
}
|
||||
}
|
||||
|
||||
newGatewayConfigDO.setVersion(version);
|
||||
if (gatewayConfigDao.updateById(newGatewayConfigDO) > 0) {
|
||||
return Result.buildSuc();
|
||||
}
|
||||
return Result.buildFrom(ResultStatus.MYSQL_ERROR);
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.xiaojukeji.kafka.manager.service.service.impl;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.bizenum.DBStatusEnum;
|
||||
import com.xiaojukeji.kafka.manager.common.bizenum.ModuleEnum;
|
||||
import com.xiaojukeji.kafka.manager.common.bizenum.OperateEnum;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.Result;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.ResultStatus;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.ao.ClusterDetailDTO;
|
||||
@@ -15,10 +17,7 @@ import com.xiaojukeji.kafka.manager.dao.ClusterMetricsDao;
|
||||
import com.xiaojukeji.kafka.manager.dao.ControllerDao;
|
||||
import com.xiaojukeji.kafka.manager.service.cache.LogicalClusterMetadataManager;
|
||||
import com.xiaojukeji.kafka.manager.service.cache.PhysicalClusterMetadataManager;
|
||||
import com.xiaojukeji.kafka.manager.service.service.ClusterService;
|
||||
import com.xiaojukeji.kafka.manager.service.service.ConsumerService;
|
||||
import com.xiaojukeji.kafka.manager.service.service.RegionService;
|
||||
import com.xiaojukeji.kafka.manager.service.service.ZookeeperService;
|
||||
import com.xiaojukeji.kafka.manager.service.service.*;
|
||||
import com.xiaojukeji.kafka.manager.service.utils.ConfigUtils;
|
||||
import org.apache.zookeeper.ZooKeeper;
|
||||
import org.slf4j.Logger;
|
||||
@@ -65,6 +64,9 @@ public class ClusterServiceImpl implements ClusterService {
|
||||
@Autowired
|
||||
private ZookeeperService zookeeperService;
|
||||
|
||||
@Autowired
|
||||
private OperateRecordService operateRecordService;
|
||||
|
||||
@Override
|
||||
public ResultStatus addNew(ClusterDO clusterDO, String operator) {
|
||||
if (ValidateUtils.isNull(clusterDO) || ValidateUtils.isNull(operator)) {
|
||||
@@ -74,6 +76,12 @@ public class ClusterServiceImpl implements ClusterService {
|
||||
return ResultStatus.ZOOKEEPER_CONNECT_FAILED;
|
||||
}
|
||||
try {
|
||||
Map<String, String> content = new HashMap<>();
|
||||
content.put("zk address", clusterDO.getZookeeper());
|
||||
content.put("bootstrap servers", clusterDO.getBootstrapServers());
|
||||
content.put("security properties", clusterDO.getSecurityProperties());
|
||||
content.put("jmx properties", clusterDO.getJmxProperties());
|
||||
operateRecordService.insert(operator, ModuleEnum.CLUSTER, clusterDO.getClusterName(), OperateEnum.ADD, content);
|
||||
if (clusterDao.insert(clusterDO) <= 0) {
|
||||
LOGGER.error("add new cluster failed, clusterDO:{}.", clusterDO);
|
||||
return ResultStatus.MYSQL_ERROR;
|
||||
@@ -103,6 +111,12 @@ public class ClusterServiceImpl implements ClusterService {
|
||||
// 不允许修改zk地址
|
||||
return ResultStatus.CHANGE_ZOOKEEPER_FORBIDDEN;
|
||||
}
|
||||
Map<String, String> content = new HashMap<>();
|
||||
content.put("cluster id", clusterDO.getId().toString());
|
||||
content.put("security properties", clusterDO.getSecurityProperties());
|
||||
content.put("jmx properties", clusterDO.getJmxProperties());
|
||||
operateRecordService.insert(operator, ModuleEnum.CLUSTER, clusterDO.getClusterName(), OperateEnum.EDIT, content);
|
||||
|
||||
clusterDO.setStatus(originClusterDO.getStatus());
|
||||
return updateById(clusterDO);
|
||||
}
|
||||
@@ -201,7 +215,7 @@ public class ClusterServiceImpl implements ClusterService {
|
||||
if (zk != null) {
|
||||
zk.close();
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -254,12 +268,15 @@ public class ClusterServiceImpl implements ClusterService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultStatus deleteById(Long clusterId) {
|
||||
public ResultStatus deleteById(Long clusterId, String operator) {
|
||||
List<RegionDO> regionDOList = regionService.getByClusterId(clusterId);
|
||||
if (!ValidateUtils.isEmptyList(regionDOList)) {
|
||||
return ResultStatus.OPERATION_FORBIDDEN;
|
||||
}
|
||||
try {
|
||||
Map<String, String> content = new HashMap<>();
|
||||
content.put("cluster id", clusterId.toString());
|
||||
operateRecordService.insert(operator, ModuleEnum.CLUSTER, String.valueOf(clusterId), OperateEnum.DELETE, content);
|
||||
if (clusterDao.deleteById(clusterId) <= 0) {
|
||||
LOGGER.error("delete cluster failed, clusterId:{}.", clusterId);
|
||||
return ResultStatus.MYSQL_ERROR;
|
||||
@@ -273,8 +290,9 @@ public class ClusterServiceImpl implements ClusterService {
|
||||
|
||||
private ClusterDetailDTO getClusterDetailDTO(ClusterDO clusterDO, Boolean needDetail) {
|
||||
if (ValidateUtils.isNull(clusterDO)) {
|
||||
return null;
|
||||
return new ClusterDetailDTO();
|
||||
}
|
||||
|
||||
ClusterDetailDTO dto = new ClusterDetailDTO();
|
||||
dto.setClusterId(clusterDO.getId());
|
||||
dto.setClusterName(clusterDO.getClusterName());
|
||||
@@ -283,6 +301,7 @@ public class ClusterServiceImpl implements ClusterService {
|
||||
dto.setKafkaVersion(physicalClusterMetadataManager.getKafkaVersionFromCache(clusterDO.getId()));
|
||||
dto.setIdc(configUtils.getIdc());
|
||||
dto.setSecurityProperties(clusterDO.getSecurityProperties());
|
||||
dto.setJmxProperties(clusterDO.getJmxProperties());
|
||||
dto.setStatus(clusterDO.getStatus());
|
||||
dto.setGmtCreate(clusterDO.getGmtCreate());
|
||||
dto.setGmtModify(clusterDO.getGmtModify());
|
||||
@@ -321,4 +340,39 @@ public class ClusterServiceImpl implements ClusterService {
|
||||
}
|
||||
return Result.buildSuc(controllerPreferredCandidateList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result addControllerPreferredCandidates(Long clusterId, List<Integer> brokerIdList) {
|
||||
if (ValidateUtils.isNull(clusterId) || ValidateUtils.isEmptyList(brokerIdList)) {
|
||||
return Result.buildFrom(ResultStatus.PARAM_ILLEGAL);
|
||||
}
|
||||
|
||||
// 增加的BrokerId需要判断是否存活
|
||||
for (Integer brokerId: brokerIdList) {
|
||||
if (!PhysicalClusterMetadataManager.isBrokerAlive(clusterId, brokerId)) {
|
||||
return Result.buildFrom(ResultStatus.BROKER_NOT_EXIST);
|
||||
}
|
||||
|
||||
Result result = zookeeperService.addControllerPreferredCandidate(clusterId, brokerId);
|
||||
if (result.failed()) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return Result.buildSuc();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result deleteControllerPreferredCandidates(Long clusterId, List<Integer> brokerIdList) {
|
||||
if (ValidateUtils.isNull(clusterId) || ValidateUtils.isEmptyList(brokerIdList)) {
|
||||
return Result.buildFrom(ResultStatus.PARAM_ILLEGAL);
|
||||
}
|
||||
|
||||
for (Integer brokerId: brokerIdList) {
|
||||
Result result = zookeeperService.deleteControllerPreferredCandidate(clusterId, brokerId);
|
||||
if (result.failed()) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return Result.buildSuc();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ public class ConsumerServiceImpl implements ConsumerService {
|
||||
}
|
||||
summary.setState(consumerGroupSummary.state());
|
||||
|
||||
java.util.Iterator<scala.collection.immutable.List<AdminClient.ConsumerSummary>> it = JavaConversions.asJavaIterator(consumerGroupSummary.consumers().iterator());
|
||||
Iterator<scala.collection.immutable.List<AdminClient.ConsumerSummary>> it = JavaConversions.asJavaIterator(consumerGroupSummary.consumers().iterator());
|
||||
while (it.hasNext()) {
|
||||
List<AdminClient.ConsumerSummary> consumerSummaryList = JavaConversions.asJavaList(it.next());
|
||||
for (AdminClient.ConsumerSummary consumerSummary: consumerSummaryList) {
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package com.xiaojukeji.kafka.manager.service.service.impl;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.bizenum.ModuleEnum;
|
||||
import com.xiaojukeji.kafka.manager.common.bizenum.OperateEnum;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.dto.rd.OperateRecordDTO;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.OperateRecordDO;
|
||||
import com.xiaojukeji.kafka.manager.common.utils.JsonUtils;
|
||||
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
|
||||
import com.xiaojukeji.kafka.manager.dao.OperateRecordDao;
|
||||
import com.xiaojukeji.kafka.manager.service.service.OperateRecordService;
|
||||
@@ -10,6 +13,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author zhongyuankai
|
||||
@@ -25,6 +29,17 @@ public class OperateRecordServiceImpl implements OperateRecordService {
|
||||
return operateRecordDao.insert(operateRecordDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insert(String operator, ModuleEnum module, String resourceName, OperateEnum operate, Map<String, String> content) {
|
||||
OperateRecordDO operateRecordDO = new OperateRecordDO();
|
||||
operateRecordDO.setOperator(operator);
|
||||
operateRecordDO.setModuleId(module.getCode());
|
||||
operateRecordDO.setResource(resourceName);
|
||||
operateRecordDO.setOperateId(operate.getCode());
|
||||
operateRecordDO.setContent(JsonUtils.toJSONString(content));
|
||||
return insert(operateRecordDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OperateRecordDO> queryByCondt(OperateRecordDTO dto) {
|
||||
return operateRecordDao.queryByCondt(
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package com.xiaojukeji.kafka.manager.service.service.impl;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.bizenum.KafkaClientEnum;
|
||||
import com.xiaojukeji.kafka.manager.common.bizenum.ModuleEnum;
|
||||
import com.xiaojukeji.kafka.manager.common.bizenum.OperateEnum;
|
||||
import com.xiaojukeji.kafka.manager.common.bizenum.TopicAuthorityEnum;
|
||||
import com.xiaojukeji.kafka.manager.common.constant.KafkaConstant;
|
||||
import com.xiaojukeji.kafka.manager.common.constant.KafkaMetricsCollections;
|
||||
import com.xiaojukeji.kafka.manager.common.constant.TopicCreationConstant;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.Result;
|
||||
@@ -80,6 +83,9 @@ public class TopicManagerServiceImpl implements TopicManagerService {
|
||||
@Autowired
|
||||
private RegionService regionService;
|
||||
|
||||
@Autowired
|
||||
private OperateRecordService operateRecordService;
|
||||
|
||||
@Override
|
||||
public List<TopicDO> listAll() {
|
||||
try {
|
||||
@@ -293,6 +299,10 @@ public class TopicManagerServiceImpl implements TopicManagerService {
|
||||
Map<String, TopicDO> topicMap) {
|
||||
List<TopicDTO> dtoList = new ArrayList<>();
|
||||
for (String topicName: PhysicalClusterMetadataManager.getTopicNameList(clusterDO.getId())) {
|
||||
if (topicName.equals(KafkaConstant.COORDINATOR_TOPIC_NAME) || topicName.equals(KafkaConstant.TRANSACTION_TOPIC_NAME)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
LogicalClusterDO logicalClusterDO = logicalClusterMetadataManager.getTopicLogicalCluster(
|
||||
clusterDO.getId(),
|
||||
topicName
|
||||
@@ -336,6 +346,12 @@ public class TopicManagerServiceImpl implements TopicManagerService {
|
||||
if (ValidateUtils.isNull(topicDO)) {
|
||||
return ResultStatus.TOPIC_NOT_EXIST;
|
||||
}
|
||||
|
||||
Map<String, Object> content = new HashMap<>(2);
|
||||
content.put("clusterId", clusterId);
|
||||
content.put("topicName", topicName);
|
||||
recordOperation(content, topicName, operator);
|
||||
|
||||
topicDO.setDescription(description);
|
||||
if (topicDao.updateByName(topicDO) > 0) {
|
||||
return ResultStatus.SUCCESS;
|
||||
@@ -359,6 +375,12 @@ public class TopicManagerServiceImpl implements TopicManagerService {
|
||||
return ResultStatus.APP_NOT_EXIST;
|
||||
}
|
||||
|
||||
Map<String, Object> content = new HashMap<>(4);
|
||||
content.put("clusterId", clusterId);
|
||||
content.put("topicName", topicName);
|
||||
content.put("appId", appId);
|
||||
recordOperation(content, topicName, operator);
|
||||
|
||||
TopicDO topicDO = topicDao.getByTopicName(clusterId, topicName);
|
||||
if (ValidateUtils.isNull(topicDO)) {
|
||||
// 不存在, 则需要插入
|
||||
@@ -389,6 +411,16 @@ public class TopicManagerServiceImpl implements TopicManagerService {
|
||||
return ResultStatus.MYSQL_ERROR;
|
||||
}
|
||||
|
||||
private void recordOperation(Map<String, Object> content, String topicName, String operator) {
|
||||
OperateRecordDO operateRecordDO = new OperateRecordDO();
|
||||
operateRecordDO.setModuleId(ModuleEnum.TOPIC.getCode());
|
||||
operateRecordDO.setOperateId(OperateEnum.EDIT.getCode());
|
||||
operateRecordDO.setResource(topicName);
|
||||
operateRecordDO.setContent(JsonUtils.toJSONString(content));
|
||||
operateRecordDO.setOperator(operator);
|
||||
operateRecordService.insert(operateRecordDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteByTopicName(Long clusterId, String topicName) {
|
||||
try {
|
||||
|
||||
@@ -70,4 +70,58 @@ public class ZookeeperServiceImpl implements ZookeeperService {
|
||||
}
|
||||
return Result.buildFrom(ResultStatus.ZOOKEEPER_READ_FAILED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result addControllerPreferredCandidate(Long clusterId, Integer brokerId) {
|
||||
if (ValidateUtils.isNull(clusterId)) {
|
||||
return Result.buildFrom(ResultStatus.PARAM_ILLEGAL);
|
||||
}
|
||||
ZkConfigImpl zkConfig = PhysicalClusterMetadataManager.getZKConfig(clusterId);
|
||||
if (ValidateUtils.isNull(zkConfig)) {
|
||||
return Result.buildFrom(ResultStatus.ZOOKEEPER_CONNECT_FAILED);
|
||||
}
|
||||
|
||||
try {
|
||||
if (zkConfig.checkPathExists(ZkPathUtil.getControllerCandidatePath(brokerId))) {
|
||||
// 节点已经存在, 则直接忽略
|
||||
return Result.buildSuc();
|
||||
}
|
||||
|
||||
if (!zkConfig.checkPathExists(ZkPathUtil.D_CONFIG_EXTENSION_ROOT_NODE)) {
|
||||
zkConfig.setOrCreatePersistentNodeStat(ZkPathUtil.D_CONFIG_EXTENSION_ROOT_NODE, "");
|
||||
}
|
||||
|
||||
if (!zkConfig.checkPathExists(ZkPathUtil.D_CONTROLLER_CANDIDATES)) {
|
||||
zkConfig.setOrCreatePersistentNodeStat(ZkPathUtil.D_CONTROLLER_CANDIDATES, "");
|
||||
}
|
||||
|
||||
zkConfig.setOrCreatePersistentNodeStat(ZkPathUtil.getControllerCandidatePath(brokerId), "");
|
||||
return Result.buildSuc();
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("class=ZookeeperServiceImpl||method=addControllerPreferredCandidate||clusterId={}||brokerId={}||errMsg={}||", clusterId, brokerId, e.getMessage());
|
||||
}
|
||||
return Result.buildFrom(ResultStatus.ZOOKEEPER_WRITE_FAILED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result deleteControllerPreferredCandidate(Long clusterId, Integer brokerId) {
|
||||
if (ValidateUtils.isNull(clusterId)) {
|
||||
return Result.buildFrom(ResultStatus.PARAM_ILLEGAL);
|
||||
}
|
||||
ZkConfigImpl zkConfig = PhysicalClusterMetadataManager.getZKConfig(clusterId);
|
||||
if (ValidateUtils.isNull(zkConfig)) {
|
||||
return Result.buildFrom(ResultStatus.ZOOKEEPER_CONNECT_FAILED);
|
||||
}
|
||||
|
||||
try {
|
||||
if (!zkConfig.checkPathExists(ZkPathUtil.getControllerCandidatePath(brokerId))) {
|
||||
return Result.buildSuc();
|
||||
}
|
||||
zkConfig.delete(ZkPathUtil.getControllerCandidatePath(brokerId));
|
||||
return Result.buildSuc();
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("class=ZookeeperServiceImpl||method=deleteControllerPreferredCandidate||clusterId={}||brokerId={}||errMsg={}||", clusterId, brokerId, e.getMessage());
|
||||
}
|
||||
return Result.buildFrom(ResultStatus.ZOOKEEPER_DELETE_FAILED);
|
||||
}
|
||||
}
|
||||
@@ -44,7 +44,7 @@ public class TopicCommands {
|
||||
);
|
||||
|
||||
// 生成分配策略
|
||||
scala.collection.Map<Object, scala.collection.Seq<Object>> replicaAssignment =
|
||||
scala.collection.Map<Object, Seq<Object>> replicaAssignment =
|
||||
AdminUtils.assignReplicasToBrokers(
|
||||
convert2BrokerMetadataSeq(brokerIdList),
|
||||
partitionNum,
|
||||
@@ -177,7 +177,7 @@ public class TopicCommands {
|
||||
)
|
||||
);
|
||||
|
||||
Map<TopicAndPartition, scala.collection.Seq<Object>> existingAssignJavaMap =
|
||||
Map<TopicAndPartition, Seq<Object>> existingAssignJavaMap =
|
||||
JavaConversions.asJavaMap(existingAssignScalaMap);
|
||||
// 新增分区的分配策略和旧的分配策略合并
|
||||
Map<Object, Seq<Object>> targetMap = new HashMap<>();
|
||||
|
||||
@@ -5,8 +5,6 @@ import com.xiaojukeji.kafka.manager.common.zookeeper.znode.brokers.TopicMetadata
|
||||
import com.xiaojukeji.kafka.manager.common.zookeeper.StateChangeListener;
|
||||
import com.xiaojukeji.kafka.manager.common.zookeeper.ZkConfigImpl;
|
||||
import com.xiaojukeji.kafka.manager.common.zookeeper.ZkPathUtil;
|
||||
import com.xiaojukeji.kafka.manager.dao.TopicDao;
|
||||
import com.xiaojukeji.kafka.manager.dao.gateway.AuthorityDao;
|
||||
import com.xiaojukeji.kafka.manager.service.cache.PhysicalClusterMetadataManager;
|
||||
import com.xiaojukeji.kafka.manager.service.cache.ThreadPool;
|
||||
import org.apache.zookeeper.data.Stat;
|
||||
@@ -24,28 +22,17 @@ import java.util.concurrent.*;
|
||||
* @date 20/5/14
|
||||
*/
|
||||
public class TopicStateListener implements StateChangeListener {
|
||||
private final static Logger LOGGER = LoggerFactory.getLogger(TopicStateListener.class);
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(TopicStateListener.class);
|
||||
|
||||
private Long clusterId;
|
||||
|
||||
private ZkConfigImpl zkConfig;
|
||||
|
||||
private TopicDao topicDao;
|
||||
|
||||
private AuthorityDao authorityDao;
|
||||
|
||||
public TopicStateListener(Long clusterId, ZkConfigImpl zkConfig) {
|
||||
this.clusterId = clusterId;
|
||||
this.zkConfig = zkConfig;
|
||||
}
|
||||
|
||||
public TopicStateListener(Long clusterId, ZkConfigImpl zkConfig, TopicDao topicDao, AuthorityDao authorityDao) {
|
||||
this.clusterId = clusterId;
|
||||
this.zkConfig = zkConfig;
|
||||
this.topicDao = topicDao;
|
||||
this.authorityDao = authorityDao;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
try {
|
||||
@@ -53,7 +40,7 @@ public class TopicStateListener implements StateChangeListener {
|
||||
FutureTask[] taskList = new FutureTask[topicNameList.size()];
|
||||
for (int i = 0; i < topicNameList.size(); i++) {
|
||||
String topicName = topicNameList.get(i);
|
||||
taskList[i] = new FutureTask(new Callable() {
|
||||
taskList[i] = new FutureTask(new Callable<Object>() {
|
||||
@Override
|
||||
public Object call() throws Exception {
|
||||
processTopicAdded(topicName);
|
||||
@@ -65,7 +52,6 @@ public class TopicStateListener implements StateChangeListener {
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("init topics metadata failed, clusterId:{}.", clusterId, e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -92,8 +78,6 @@ public class TopicStateListener implements StateChangeListener {
|
||||
private void processTopicDelete(String topicName) {
|
||||
LOGGER.warn("delete topic, clusterId:{} topicName:{}.", clusterId, topicName);
|
||||
PhysicalClusterMetadataManager.removeTopicMetadata(clusterId, topicName);
|
||||
topicDao.removeTopicInCache(clusterId, topicName);
|
||||
authorityDao.removeAuthorityInCache(clusterId, topicName);
|
||||
}
|
||||
|
||||
private void processTopicAdded(String topicName) {
|
||||
@@ -122,4 +106,4 @@ public class TopicStateListener implements StateChangeListener {
|
||||
LOGGER.error("add topic failed, clusterId:{} topicMetadata:{}.", clusterId, topicMetadata, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,4 @@ public interface TopicDao {
|
||||
List<TopicDO> listAll();
|
||||
|
||||
TopicDO getTopic(Long clusterId, String topicName, String appId);
|
||||
|
||||
TopicDO removeTopicInCache(Long clusterId, String topicName);
|
||||
}
|
||||
@@ -16,8 +16,6 @@ public interface AppDao {
|
||||
*/
|
||||
int insert(AppDO appDO);
|
||||
|
||||
int insertIgnoreGatewayDB(AppDO appDO);
|
||||
|
||||
/**
|
||||
* 删除appId
|
||||
* @param appName App名称
|
||||
@@ -60,6 +58,4 @@ public interface AppDao {
|
||||
* @return int
|
||||
*/
|
||||
int updateById(AppDO appDO);
|
||||
|
||||
List<AppDO> listNewAll();
|
||||
}
|
||||
@@ -15,8 +15,6 @@ public interface AuthorityDao {
|
||||
*/
|
||||
int insert(AuthorityDO authorityDO);
|
||||
|
||||
int replaceIgnoreGatewayDB(AuthorityDO authorityDO);
|
||||
|
||||
/**
|
||||
* 获取权限
|
||||
* @param clusterId 集群id
|
||||
@@ -38,7 +36,5 @@ public interface AuthorityDao {
|
||||
|
||||
Map<String, Map<Long, Map<String, AuthorityDO>>> getAllAuthority();
|
||||
|
||||
void removeAuthorityInCache(Long clusterId, String topicName);
|
||||
|
||||
int deleteAuthorityByTopic(Long clusterId, String topicName);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.xiaojukeji.kafka.manager.dao.gateway.impl;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.AppDO;
|
||||
import com.xiaojukeji.kafka.manager.dao.gateway.AppDao;
|
||||
import com.xiaojukeji.kafka.manager.task.Constant;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
@@ -21,7 +22,7 @@ public class AppDaoImpl implements AppDao {
|
||||
/**
|
||||
* APP最近的一次更新时间, 更新之后的缓存
|
||||
*/
|
||||
private static Long APP_CACHE_LATEST_UPDATE_TIME = 0L;
|
||||
private static volatile long APP_CACHE_LATEST_UPDATE_TIME = Constant.START_TIMESTAMP;
|
||||
private static final Map<String, AppDO> APP_MAP = new ConcurrentHashMap<>();
|
||||
|
||||
@Override
|
||||
@@ -29,11 +30,6 @@ public class AppDaoImpl implements AppDao {
|
||||
return sqlSession.insert("AppDao.insert", appDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insertIgnoreGatewayDB(AppDO appDO) {
|
||||
return sqlSession.insert("AppDao.insert", appDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteByName(String appName) {
|
||||
return sqlSession.delete("AppDao.deleteByName", appName);
|
||||
@@ -66,7 +62,12 @@ public class AppDaoImpl implements AppDao {
|
||||
}
|
||||
|
||||
private void updateTopicCache() {
|
||||
Long timestamp = System.currentTimeMillis();
|
||||
long timestamp = System.currentTimeMillis();
|
||||
|
||||
if (timestamp + 1000 <= APP_CACHE_LATEST_UPDATE_TIME) {
|
||||
// 近一秒内的请求不走db
|
||||
return;
|
||||
}
|
||||
|
||||
Date afterTime = new Date(APP_CACHE_LATEST_UPDATE_TIME);
|
||||
List<AppDO> doList = sqlSession.selectList("AppDao.listAfterTime", afterTime);
|
||||
@@ -76,19 +77,22 @@ public class AppDaoImpl implements AppDao {
|
||||
/**
|
||||
* 更新APP缓存
|
||||
*/
|
||||
synchronized private void updateTopicCache(List<AppDO> doList, Long timestamp) {
|
||||
private synchronized void updateTopicCache(List<AppDO> doList, long timestamp) {
|
||||
if (doList == null || doList.isEmpty() || APP_CACHE_LATEST_UPDATE_TIME >= timestamp) {
|
||||
// 本次无数据更新, 或者本次更新过时 时, 忽略本次更新
|
||||
return;
|
||||
}
|
||||
if (APP_CACHE_LATEST_UPDATE_TIME == Constant.START_TIMESTAMP) {
|
||||
APP_MAP.clear();
|
||||
}
|
||||
|
||||
for (AppDO elem: doList) {
|
||||
APP_MAP.put(elem.getAppId(), elem);
|
||||
}
|
||||
APP_CACHE_LATEST_UPDATE_TIME = timestamp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AppDO> listNewAll() {
|
||||
return sqlSession.selectList("AppDao.listNewAll");
|
||||
public static void resetCache() {
|
||||
APP_CACHE_LATEST_UPDATE_TIME = Constant.START_TIMESTAMP;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.xiaojukeji.kafka.manager.dao.gateway.impl;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.AuthorityDO;
|
||||
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
|
||||
import com.xiaojukeji.kafka.manager.dao.gateway.AuthorityDao;
|
||||
import com.xiaojukeji.kafka.manager.task.Constant;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
@@ -23,7 +23,8 @@ public class AuthorityDaoImpl implements AuthorityDao {
|
||||
* Authority最近的一次更新时间, 更新之后的缓存
|
||||
* <AppID, <clusterId, <TopicName, AuthorityDO>>>
|
||||
*/
|
||||
private static Long AUTHORITY_CACHE_LATEST_UPDATE_TIME = 0L;
|
||||
private static volatile long AUTHORITY_CACHE_LATEST_UPDATE_TIME = Constant.START_TIMESTAMP;
|
||||
|
||||
private static final Map<String, Map<Long, Map<String, AuthorityDO>>> AUTHORITY_MAP = new ConcurrentHashMap<>();
|
||||
|
||||
@Override
|
||||
@@ -31,11 +32,6 @@ public class AuthorityDaoImpl implements AuthorityDao {
|
||||
return sqlSession.insert("AuthorityDao.replace", authorityDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int replaceIgnoreGatewayDB(AuthorityDO authorityDO) {
|
||||
return sqlSession.insert("AuthorityDao.replace", authorityDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AuthorityDO> getAuthority(Long clusterId, String topicName, String appId) {
|
||||
Map<String, Object> params = new HashMap<>(3);
|
||||
@@ -62,8 +58,8 @@ public class AuthorityDaoImpl implements AuthorityDao {
|
||||
}
|
||||
|
||||
List<AuthorityDO> authorityDOList = new ArrayList<>();
|
||||
for (Long clusterId: doMap.keySet()) {
|
||||
authorityDOList.addAll(doMap.get(clusterId).values());
|
||||
for (Map.Entry<Long, Map<String, AuthorityDO>> entry: doMap.entrySet()) {
|
||||
authorityDOList.addAll(entry.getValue().values());
|
||||
}
|
||||
return authorityDOList;
|
||||
}
|
||||
@@ -87,23 +83,6 @@ public class AuthorityDaoImpl implements AuthorityDao {
|
||||
return AUTHORITY_MAP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAuthorityInCache(Long clusterId, String topicName) {
|
||||
AUTHORITY_MAP.forEach((appId, map) -> {
|
||||
map.forEach((id, subMap) -> {
|
||||
if (id.equals(clusterId)) {
|
||||
subMap.remove(topicName);
|
||||
if (subMap.isEmpty()) {
|
||||
map.remove(id);
|
||||
}
|
||||
}
|
||||
});
|
||||
if (map.isEmpty()) {
|
||||
AUTHORITY_MAP.remove(appId);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteAuthorityByTopic(Long clusterId, String topicName) {
|
||||
Map<String, Object> params = new HashMap<>(2);
|
||||
@@ -116,6 +95,11 @@ public class AuthorityDaoImpl implements AuthorityDao {
|
||||
private void updateAuthorityCache() {
|
||||
Long timestamp = System.currentTimeMillis();
|
||||
|
||||
if (timestamp + 1000 <= AUTHORITY_CACHE_LATEST_UPDATE_TIME) {
|
||||
// 近一秒内的请求不走db
|
||||
return;
|
||||
}
|
||||
|
||||
Date afterTime = new Date(AUTHORITY_CACHE_LATEST_UPDATE_TIME);
|
||||
List<AuthorityDO> doList = sqlSession.selectList("AuthorityDao.listAfterTime", afterTime);
|
||||
updateAuthorityCache(doList, timestamp);
|
||||
@@ -124,11 +108,15 @@ public class AuthorityDaoImpl implements AuthorityDao {
|
||||
/**
|
||||
* 更新Topic缓存
|
||||
*/
|
||||
synchronized private void updateAuthorityCache(List<AuthorityDO> doList, Long timestamp) {
|
||||
private synchronized void updateAuthorityCache(List<AuthorityDO> doList, Long timestamp) {
|
||||
if (doList == null || doList.isEmpty() || AUTHORITY_CACHE_LATEST_UPDATE_TIME >= timestamp) {
|
||||
// 本次无数据更新, 或者本次更新过时 时, 忽略本次更新
|
||||
return;
|
||||
}
|
||||
if (AUTHORITY_CACHE_LATEST_UPDATE_TIME == Constant.START_TIMESTAMP) {
|
||||
AUTHORITY_MAP.clear();
|
||||
}
|
||||
|
||||
for (AuthorityDO elem: doList) {
|
||||
Map<Long, Map<String, AuthorityDO>> doMap =
|
||||
AUTHORITY_MAP.getOrDefault(elem.getAppId(), new ConcurrentHashMap<>());
|
||||
@@ -139,4 +127,8 @@ public class AuthorityDaoImpl implements AuthorityDao {
|
||||
}
|
||||
AUTHORITY_CACHE_LATEST_UPDATE_TIME = timestamp;
|
||||
}
|
||||
|
||||
public static void resetCache() {
|
||||
AUTHORITY_CACHE_LATEST_UPDATE_TIME = Constant.START_TIMESTAMP;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.xiaojukeji.kafka.manager.dao.impl;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.TopicDO;
|
||||
import com.xiaojukeji.kafka.manager.dao.TopicDao;
|
||||
import com.xiaojukeji.kafka.manager.task.Constant;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
@@ -18,7 +19,8 @@ public class TopicDaoImpl implements TopicDao {
|
||||
/**
|
||||
* Topic最近的一次更新时间, 更新之后的缓存
|
||||
*/
|
||||
private static Long TOPIC_CACHE_LATEST_UPDATE_TIME = 0L;
|
||||
private static volatile long TOPIC_CACHE_LATEST_UPDATE_TIME = Constant.START_TIMESTAMP;
|
||||
|
||||
private static final Map<Long, Map<String, TopicDO>> TOPIC_MAP = new ConcurrentHashMap<>();
|
||||
|
||||
@Autowired
|
||||
@@ -62,7 +64,7 @@ public class TopicDaoImpl implements TopicDao {
|
||||
@Override
|
||||
public List<TopicDO> getByClusterId(Long clusterId) {
|
||||
updateTopicCache();
|
||||
return new ArrayList<>(TOPIC_MAP.getOrDefault(clusterId, new ConcurrentHashMap<>(0)).values());
|
||||
return new ArrayList<>(TOPIC_MAP.getOrDefault(clusterId, Collections.emptyMap()).values());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -75,28 +77,28 @@ public class TopicDaoImpl implements TopicDao {
|
||||
updateTopicCache();
|
||||
List<TopicDO> doList = new ArrayList<>();
|
||||
for (Long clusterId: TOPIC_MAP.keySet()) {
|
||||
doList.addAll(TOPIC_MAP.getOrDefault(clusterId, new ConcurrentHashMap<>(0)).values());
|
||||
doList.addAll(TOPIC_MAP.getOrDefault(clusterId, Collections.emptyMap()).values());
|
||||
}
|
||||
return doList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TopicDO getTopic(Long clusterId, String topicName, String appId) {
|
||||
Map<String, Object> params = new HashMap<>(2);
|
||||
Map<String, Object> params = new HashMap<>(3);
|
||||
params.put("clusterId", clusterId);
|
||||
params.put("topicName", topicName);
|
||||
params.put("appId", appId);
|
||||
return sqlSession.selectOne("TopicDao.getTopic", params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TopicDO removeTopicInCache(Long clusterId, String topicName) {
|
||||
return TOPIC_MAP.getOrDefault(clusterId, new HashMap<>(0)).remove(topicName);
|
||||
}
|
||||
|
||||
private void updateTopicCache() {
|
||||
Long timestamp = System.currentTimeMillis();
|
||||
|
||||
if (timestamp + 1000 <= TOPIC_CACHE_LATEST_UPDATE_TIME) {
|
||||
// 近一秒内的请求不走db
|
||||
return;
|
||||
}
|
||||
|
||||
Date afterTime = new Date(TOPIC_CACHE_LATEST_UPDATE_TIME);
|
||||
List<TopicDO> doList = sqlSession.selectList("TopicDao.listAfterTime", afterTime);
|
||||
updateTopicCache(doList, timestamp);
|
||||
@@ -105,11 +107,15 @@ public class TopicDaoImpl implements TopicDao {
|
||||
/**
|
||||
* 更新Topic缓存
|
||||
*/
|
||||
synchronized private void updateTopicCache(List<TopicDO> doList, Long timestamp) {
|
||||
private synchronized void updateTopicCache(List<TopicDO> doList, Long timestamp) {
|
||||
if (doList == null || doList.isEmpty() || TOPIC_CACHE_LATEST_UPDATE_TIME >= timestamp) {
|
||||
// 本次无数据更新, 或者本次更新过时 时, 忽略本次更新
|
||||
return;
|
||||
}
|
||||
if (TOPIC_CACHE_LATEST_UPDATE_TIME == Constant.START_TIMESTAMP) {
|
||||
TOPIC_MAP.clear();
|
||||
}
|
||||
|
||||
for (TopicDO elem: doList) {
|
||||
Map<String, TopicDO> doMap = TOPIC_MAP.getOrDefault(elem.getClusterId(), new ConcurrentHashMap<>());
|
||||
doMap.put(elem.getTopicName(), elem);
|
||||
@@ -117,4 +123,8 @@ public class TopicDaoImpl implements TopicDao {
|
||||
}
|
||||
TOPIC_CACHE_LATEST_UPDATE_TIME = timestamp;
|
||||
}
|
||||
|
||||
public static void resetCache() {
|
||||
TOPIC_CACHE_LATEST_UPDATE_TIME = Constant.START_TIMESTAMP;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.xiaojukeji.kafka.manager.task;
|
||||
|
||||
public class Constant {
|
||||
public static final long START_TIMESTAMP = 0;
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.xiaojukeji.kafka.manager.task;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.utils.factory.DefaultThreadFactory;
|
||||
import com.xiaojukeji.kafka.manager.dao.gateway.impl.AppDaoImpl;
|
||||
import com.xiaojukeji.kafka.manager.dao.gateway.impl.AuthorityDaoImpl;
|
||||
import com.xiaojukeji.kafka.manager.dao.impl.TopicDaoImpl;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 后台任务线程
|
||||
* @author zengqiao
|
||||
* @date 21/02/02
|
||||
*/
|
||||
@Service
|
||||
public class DaoBackgroundTask {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(DaoBackgroundTask.class);
|
||||
|
||||
private static final ScheduledExecutorService SYNC_CACHE_THREAD_POOL = Executors.newSingleThreadScheduledExecutor(new DefaultThreadFactory("syncCacheTask"));
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
SYNC_CACHE_THREAD_POOL.scheduleAtFixedRate(() -> {
|
||||
LOGGER.info("class=DaoBackgroundTask||method=init||msg=sync cache start");
|
||||
|
||||
TopicDaoImpl.resetCache();
|
||||
|
||||
AppDaoImpl.resetCache();
|
||||
|
||||
AuthorityDaoImpl.resetCache();
|
||||
|
||||
LOGGER.info("class=DaoBackgroundTask||method=init||msg=sync cache finished");
|
||||
}, 1, 10, TimeUnit.MINUTES);
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@
|
||||
<result column="name" property="name" />
|
||||
<result column="value" property="value" />
|
||||
<result column="version" property="version" />
|
||||
<result column="description" property="description" />
|
||||
<result column="create_time" property="createTime" />
|
||||
<result column="modify_time" property="modifyTime" />
|
||||
</resultMap>
|
||||
@@ -27,9 +28,9 @@
|
||||
<insert id="insert" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.GatewayConfigDO">
|
||||
<![CDATA[
|
||||
INSERT INTO gateway_config
|
||||
(`type`, name, value, version)
|
||||
(`type`, name, value, version, description)
|
||||
VALUES
|
||||
(#{type}, #{name}, #{value}, #{version})
|
||||
(#{type}, #{name}, #{value}, #{version}, #{description})
|
||||
]]>
|
||||
</insert>
|
||||
|
||||
@@ -45,7 +46,8 @@
|
||||
`type`=#{type},
|
||||
`name`=#{name},
|
||||
`value`=#{value},
|
||||
`version`=#{version}
|
||||
`version`=#{version},
|
||||
`description`=#{description}
|
||||
WHERE id=#{id}
|
||||
]]>
|
||||
</update>
|
||||
|
||||
@@ -33,7 +33,7 @@ public interface AccountService {
|
||||
* @param username 用户名
|
||||
* @return
|
||||
*/
|
||||
ResultStatus deleteByName(String username);
|
||||
ResultStatus deleteByName(String username, String operator);
|
||||
|
||||
/**
|
||||
* 更新账号
|
||||
|
||||
@@ -2,13 +2,16 @@ package com.xiaojukeji.kafka.manager.account.component.sso;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.account.AccountService;
|
||||
import com.xiaojukeji.kafka.manager.account.component.AbstractSingleSignOn;
|
||||
import com.xiaojukeji.kafka.manager.common.bizenum.AccountRoleEnum;
|
||||
import com.xiaojukeji.kafka.manager.common.constant.LoginConstant;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.Result;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.dto.normal.LoginDTO;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.AccountDO;
|
||||
import com.xiaojukeji.kafka.manager.common.utils.EncryptUtil;
|
||||
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
|
||||
import com.xiaojukeji.kafka.manager.common.utils.ldap.LDAPAuthentication;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@@ -23,12 +26,50 @@ public class BaseSessionSignOn extends AbstractSingleSignOn {
|
||||
@Autowired
|
||||
private AccountService accountService;
|
||||
|
||||
@Autowired
|
||||
private LDAPAuthentication ldapAuthentication;
|
||||
|
||||
//是否开启ldap验证
|
||||
@Value(value = "${ldap.enabled}")
|
||||
private boolean ldapEnabled;
|
||||
|
||||
//ldap自动注册的默认角色。请注意:它通常来说都是低权限角色
|
||||
@Value(value = "${ldap.auth-user-registration-role}")
|
||||
private String authUserRegistrationRole;
|
||||
|
||||
//ldap自动注册是否开启
|
||||
@Value(value = "${ldap.auth-user-registration}")
|
||||
private boolean authUserRegistration;
|
||||
|
||||
@Override
|
||||
public Result<String> loginAndGetLdap(HttpServletRequest request, HttpServletResponse response, LoginDTO dto) {
|
||||
if (ValidateUtils.isBlank(dto.getUsername()) || ValidateUtils.isNull(dto.getPassword())) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Result<AccountDO> accountResult = accountService.getAccountDO(dto.getUsername());
|
||||
|
||||
//modifier limin
|
||||
//判断是否激活了LDAP验证。若激活并且数据库无此用户则自动注册
|
||||
if(ldapEnabled){
|
||||
//去LDAP验证账密
|
||||
if(!ldapAuthentication.authenricate(dto.getUsername(),dto.getPassword())){
|
||||
return null;
|
||||
}
|
||||
|
||||
if(ValidateUtils.isNull(accountResult) && authUserRegistration){
|
||||
//自动注册
|
||||
AccountDO accountDO = new AccountDO();
|
||||
accountDO.setUsername(dto.getUsername());
|
||||
accountDO.setRole(AccountRoleEnum.getUserRoleEnum(authUserRegistrationRole).getRole());
|
||||
accountDO.setPassword(EncryptUtil.md5(dto.getPassword()));
|
||||
accountService.createAccount(accountDO);
|
||||
}
|
||||
|
||||
return Result.buildSuc(dto.getUsername());
|
||||
|
||||
}
|
||||
|
||||
if (ValidateUtils.isNull(accountResult) || accountResult.failed()) {
|
||||
return new Result<>(accountResult.getCode(), accountResult.getMessage());
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ import com.xiaojukeji.kafka.manager.account.AccountService;
|
||||
import com.xiaojukeji.kafka.manager.account.common.EnterpriseStaff;
|
||||
import com.xiaojukeji.kafka.manager.account.component.AbstractEnterpriseStaffService;
|
||||
import com.xiaojukeji.kafka.manager.common.bizenum.AccountRoleEnum;
|
||||
import com.xiaojukeji.kafka.manager.common.bizenum.ModuleEnum;
|
||||
import com.xiaojukeji.kafka.manager.common.bizenum.OperateEnum;
|
||||
import com.xiaojukeji.kafka.manager.common.constant.Constant;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.Result;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.ResultStatus;
|
||||
@@ -15,6 +17,7 @@ import com.xiaojukeji.kafka.manager.common.utils.EncryptUtil;
|
||||
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
|
||||
import com.xiaojukeji.kafka.manager.dao.AccountDao;
|
||||
import com.xiaojukeji.kafka.manager.service.service.ConfigService;
|
||||
import com.xiaojukeji.kafka.manager.service.service.OperateRecordService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -48,6 +51,9 @@ public class AccountServiceImpl implements AccountService {
|
||||
@Autowired
|
||||
private AbstractEnterpriseStaffService enterpriseStaffService;
|
||||
|
||||
@Autowired
|
||||
private OperateRecordService operateRecordService;
|
||||
|
||||
/**
|
||||
* 用户组织信息
|
||||
* <username, Staff>
|
||||
@@ -82,9 +88,12 @@ public class AccountServiceImpl implements AccountService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultStatus deleteByName(String username) {
|
||||
public ResultStatus deleteByName(String username, String operator) {
|
||||
try {
|
||||
if (accountDao.deleteByName(username) > 0) {
|
||||
Map<String, String> content = new HashMap<>();
|
||||
content.put("username", username);
|
||||
operateRecordService.insert(operator, ModuleEnum.AUTHORITY, username, OperateEnum.DELETE, content);
|
||||
return ResultStatus.SUCCESS;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -18,6 +18,9 @@ public class OrderExtensionAddGatewayConfigDTO {
|
||||
@ApiModelProperty(value = "值")
|
||||
private String value;
|
||||
|
||||
@ApiModelProperty(value = "描述说明")
|
||||
private String description;
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
@@ -42,12 +45,21 @@ public class OrderExtensionAddGatewayConfigDTO {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "OrderExtensionAddGatewayConfigDTO{" +
|
||||
"type='" + type + '\'' +
|
||||
", name='" + name + '\'' +
|
||||
", value='" + value + '\'' +
|
||||
", description='" + description + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,9 @@ public class OrderExtensionModifyGatewayConfigDTO {
|
||||
@ApiModelProperty(value = "值")
|
||||
private String value;
|
||||
|
||||
@ApiModelProperty(value = "描述说明")
|
||||
private String description;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
@@ -55,6 +58,14 @@ public class OrderExtensionModifyGatewayConfigDTO {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "OrderExtensionModifyGatewayConfigDTO{" +
|
||||
@@ -62,6 +73,7 @@ public class OrderExtensionModifyGatewayConfigDTO {
|
||||
", type='" + type + '\'' +
|
||||
", name='" + name + '\'' +
|
||||
", value='" + value + '\'' +
|
||||
", description='" + description + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
|
||||
@@ -87,6 +87,6 @@ public class ApplyAppOrder extends AbstractAppOrder {
|
||||
appDO.setDescription(orderDO.getDescription());
|
||||
appDO.generateAppIdAndPassword(orderDO.getId(), configUtils.getIdc());
|
||||
appDO.setType(0);
|
||||
return appService.addApp(appDO);
|
||||
return appService.addApp(appDO, userName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,5 +68,10 @@
|
||||
<artifactId>spring-test</artifactId>
|
||||
<version>${spring-version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.minio</groupId>
|
||||
<artifactId>minio</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -4,6 +4,7 @@ import com.xiaojukeji.kafka.manager.common.entity.Result;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.ResultStatus;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.dto.normal.KafkaFileDTO;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.KafkaFileDO;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -24,7 +25,7 @@ public interface KafkaFileService {
|
||||
|
||||
KafkaFileDO getFileByFileName(String fileName);
|
||||
|
||||
Result<String> downloadKafkaConfigFile(Long fileId);
|
||||
Result<MultipartFile> downloadKafkaFile(Long fileId);
|
||||
|
||||
String getDownloadBaseUrl();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.xiaojukeji.kafka.manager.kcm.common;
|
||||
|
||||
public class Constant {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static final String TASK_TITLE_PREFIX = "Logi-Kafka";
|
||||
|
||||
/**
|
||||
* 并发度,顺序执行
|
||||
*/
|
||||
public static final Integer AGENT_TASK_BATCH = 1;
|
||||
|
||||
/**
|
||||
* 失败的容忍度为0
|
||||
*/
|
||||
public static final Integer AGENT_TASK_TOLERANCE = 0;
|
||||
}
|
||||
@@ -6,34 +6,35 @@ package com.xiaojukeji.kafka.manager.kcm.common.bizenum;
|
||||
* @date 20/4/26
|
||||
*/
|
||||
public enum ClusterTaskActionEnum {
|
||||
START(0, "start"),
|
||||
PAUSE(1, "pause"),
|
||||
IGNORE(2, "ignore"),
|
||||
CANCEL(3, "cancel"),
|
||||
ROLLBACK(4, "rollback"),
|
||||
UNKNOWN("unknown"),
|
||||
|
||||
START("start"),
|
||||
PAUSE("pause"),
|
||||
|
||||
IGNORE("ignore"),
|
||||
CANCEL("cancel"),
|
||||
|
||||
REDO("redo"),
|
||||
KILL("kill"),
|
||||
|
||||
ROLLBACK("rollback"),
|
||||
|
||||
;
|
||||
private Integer code;
|
||||
|
||||
private String message;
|
||||
private String action;
|
||||
|
||||
ClusterTaskActionEnum(Integer code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
ClusterTaskActionEnum(String action) {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
public String getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TaskActionEnum{" +
|
||||
"code=" + code +
|
||||
", message='" + message + '\'' +
|
||||
return "ClusterTaskActionEnum{" +
|
||||
"action='" + action + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.xiaojukeji.kafka.manager.kcm.common.entry.ao;
|
||||
|
||||
public class ClusterTaskLog {
|
||||
private String stdout;
|
||||
|
||||
public ClusterTaskLog(String stdout) {
|
||||
this.stdout = stdout;
|
||||
}
|
||||
|
||||
public String getStdout() {
|
||||
return stdout;
|
||||
}
|
||||
|
||||
public void setStdout(String stdout) {
|
||||
this.stdout = stdout;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AgentOperationTaskLog{" +
|
||||
"stdout='" + stdout + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user