mirror of
https://github.com/didi/KnowStreaming.git
synced 2025-12-24 20:22:12 +08:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ec7f801929 | ||
|
|
0f8aca382e | ||
|
|
0270f77eaa | ||
|
|
dcba71ada4 | ||
|
|
6080f76a9c | ||
|
|
5efd424172 |
2
build.sh
2
build.sh
@@ -4,7 +4,7 @@ cd $workspace
|
|||||||
|
|
||||||
## constant
|
## constant
|
||||||
OUTPUT_DIR=./output
|
OUTPUT_DIR=./output
|
||||||
KM_VERSION=2.2.0
|
KM_VERSION=2.3.0
|
||||||
APP_NAME=kafka-manager
|
APP_NAME=kafka-manager
|
||||||
APP_DIR=${APP_NAME}-${KM_VERSION}
|
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 '配置类型',
|
`type` varchar(128) NOT NULL DEFAULT '' COMMENT '配置类型',
|
||||||
`name` varchar(128) NOT NULL DEFAULT '' COMMENT '配置名称',
|
`name` varchar(128) NOT NULL DEFAULT '' COMMENT '配置名称',
|
||||||
`value` text 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 '创建时间',
|
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||||
`modify_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
|
`modify_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
|
|||||||
@@ -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;
|
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<T> result = new Result<T>();
|
||||||
result.setCode(ResultStatus.GATEWAY_INVALID_REQUEST.getCode());
|
result.setCode(ResultStatus.GATEWAY_INVALID_REQUEST.getCode());
|
||||||
result.setMessage(message);
|
result.setMessage(message);
|
||||||
@@ -105,6 +105,14 @@ public class Result<T> implements Serializable {
|
|||||||
return result;
|
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) {
|
public static Result buildFrom(ResultStatus resultStatus) {
|
||||||
Result result = new Result();
|
Result result = new Result();
|
||||||
result.setCode(resultStatus.getCode());
|
result.setCode(resultStatus.getCode());
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ public enum ResultStatus {
|
|||||||
|
|
||||||
SUCCESS(Constant.SUCCESS, "success"),
|
SUCCESS(Constant.SUCCESS, "success"),
|
||||||
|
|
||||||
|
FAIL(1, "操作失败"),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 操作错误[1000, 2000)
|
* 操作错误[1000, 2000)
|
||||||
* ------------------------------------------------------------------------------------------
|
* ------------------------------------------------------------------------------------------
|
||||||
@@ -91,6 +93,8 @@ public enum ResultStatus {
|
|||||||
|
|
||||||
ZOOKEEPER_CONNECT_FAILED(8020, "zookeeper connect failed"),
|
ZOOKEEPER_CONNECT_FAILED(8020, "zookeeper connect failed"),
|
||||||
ZOOKEEPER_READ_FAILED(8021, "zookeeper read failed"),
|
ZOOKEEPER_READ_FAILED(8021, "zookeeper read failed"),
|
||||||
|
ZOOKEEPER_WRITE_FAILED(8022, "zookeeper write failed"),
|
||||||
|
ZOOKEEPER_DELETE_FAILED(8023, "zookeeper delete failed"),
|
||||||
|
|
||||||
// 调用集群任务里面的agent失败
|
// 调用集群任务里面的agent失败
|
||||||
CALL_CLUSTER_TASK_AGENT_FAILED(8030, " call cluster task agent failed"),
|
CALL_CLUSTER_TASK_AGENT_FAILED(8030, " call cluster task agent failed"),
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ public class ClusterDetailDTO {
|
|||||||
|
|
||||||
private String securityProperties;
|
private String securityProperties;
|
||||||
|
|
||||||
|
private String jmxProperties;
|
||||||
|
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
private Date gmtCreate;
|
private Date gmtCreate;
|
||||||
@@ -103,6 +105,14 @@ public class ClusterDetailDTO {
|
|||||||
this.securityProperties = securityProperties;
|
this.securityProperties = securityProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getJmxProperties() {
|
||||||
|
return jmxProperties;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setJmxProperties(String jmxProperties) {
|
||||||
|
this.jmxProperties = jmxProperties;
|
||||||
|
}
|
||||||
|
|
||||||
public Integer getStatus() {
|
public Integer getStatus() {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
@@ -176,8 +186,9 @@ public class ClusterDetailDTO {
|
|||||||
", bootstrapServers='" + bootstrapServers + '\'' +
|
", bootstrapServers='" + bootstrapServers + '\'' +
|
||||||
", kafkaVersion='" + kafkaVersion + '\'' +
|
", kafkaVersion='" + kafkaVersion + '\'' +
|
||||||
", idc='" + idc + '\'' +
|
", idc='" + idc + '\'' +
|
||||||
", mode='" + mode + '\'' +
|
", mode=" + mode +
|
||||||
", securityProperties='" + securityProperties + '\'' +
|
", securityProperties='" + securityProperties + '\'' +
|
||||||
|
", jmxProperties='" + jmxProperties + '\'' +
|
||||||
", status=" + status +
|
", status=" + status +
|
||||||
", gmtCreate=" + gmtCreate +
|
", gmtCreate=" + gmtCreate +
|
||||||
", gmtModify=" + gmtModify +
|
", 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)
|
if (ValidateUtils.isNull(clusterName)
|
||||||
|| ValidateUtils.isNull(zookeeper)
|
|| ValidateUtils.isNull(zookeeper)
|
||||||
|| ValidateUtils.isNull(idc)
|
|| ValidateUtils.isNull(idc)
|
||||||
|| ValidateUtils.isNull(bootstrapServers)
|
|| ValidateUtils.isNull(bootstrapServers)) {
|
||||||
) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ public class GatewayConfigDO {
|
|||||||
|
|
||||||
private Long version;
|
private Long version;
|
||||||
|
|
||||||
|
private String description;
|
||||||
|
|
||||||
private Date createTime;
|
private Date createTime;
|
||||||
|
|
||||||
private Date modifyTime;
|
private Date modifyTime;
|
||||||
@@ -61,6 +63,14 @@ public class GatewayConfigDO {
|
|||||||
this.version = version;
|
this.version = version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
public Date getCreateTime() {
|
public Date getCreateTime() {
|
||||||
return createTime;
|
return createTime;
|
||||||
}
|
}
|
||||||
@@ -85,6 +95,7 @@ public class GatewayConfigDO {
|
|||||||
", name='" + name + '\'' +
|
", name='" + name + '\'' +
|
||||||
", value='" + value + '\'' +
|
", value='" + value + '\'' +
|
||||||
", version=" + version +
|
", version=" + version +
|
||||||
|
", description='" + description + '\'' +
|
||||||
", createTime=" + createTime +
|
", createTime=" + createTime +
|
||||||
", modifyTime=" + modifyTime +
|
", modifyTime=" + modifyTime +
|
||||||
'}';
|
'}';
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ public class ExpiredTopicVO {
|
|||||||
@ApiModelProperty(value = "负责人")
|
@ApiModelProperty(value = "负责人")
|
||||||
private String principals;
|
private String principals;
|
||||||
|
|
||||||
@ApiModelProperty(value = "状态, -1:可下线, 0:过期待通知, 1+:已通知待反馈")
|
@ApiModelProperty(value = "状态, -1:已通知可下线, 0:过期待通知, 1+:已通知待反馈")
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
public Long getClusterId() {
|
public Long getClusterId() {
|
||||||
|
|||||||
@@ -26,6 +26,9 @@ public class GatewayConfigVO {
|
|||||||
@ApiModelProperty(value="版本")
|
@ApiModelProperty(value="版本")
|
||||||
private Long version;
|
private Long version;
|
||||||
|
|
||||||
|
@ApiModelProperty(value="描述说明")
|
||||||
|
private String description;
|
||||||
|
|
||||||
@ApiModelProperty(value="创建时间")
|
@ApiModelProperty(value="创建时间")
|
||||||
private Date createTime;
|
private Date createTime;
|
||||||
|
|
||||||
@@ -72,6 +75,14 @@ public class GatewayConfigVO {
|
|||||||
this.version = version;
|
this.version = version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
public Date getCreateTime() {
|
public Date getCreateTime() {
|
||||||
return createTime;
|
return createTime;
|
||||||
}
|
}
|
||||||
@@ -96,6 +107,7 @@ public class GatewayConfigVO {
|
|||||||
", name='" + name + '\'' +
|
", name='" + name + '\'' +
|
||||||
", value='" + value + '\'' +
|
", value='" + value + '\'' +
|
||||||
", version=" + version +
|
", version=" + version +
|
||||||
|
", description='" + description + '\'' +
|
||||||
", createTime=" + createTime +
|
", createTime=" + createTime +
|
||||||
", modifyTime=" + modifyTime +
|
", modifyTime=" + modifyTime +
|
||||||
'}';
|
'}';
|
||||||
|
|||||||
@@ -60,6 +60,13 @@ public class JsonUtils {
|
|||||||
return JSON.parseObject(src, clazz);
|
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) {
|
public static List<TopicConnectionDO> parseTopicConnections(Long clusterId, JSONObject jsonObject, long postTime) {
|
||||||
List<TopicConnectionDO> connectionDOList = new ArrayList<>();
|
List<TopicConnectionDO> connectionDOList = new ArrayList<>();
|
||||||
for (String clientType: jsonObject.keySet()) {
|
for (String clientType: jsonObject.keySet()) {
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ public class JmxConnectorWrap {
|
|||||||
try {
|
try {
|
||||||
Map<String, Object> environment = new HashMap<String, Object>();
|
Map<String, Object> environment = new HashMap<String, Object>();
|
||||||
if (!ValidateUtils.isBlank(this.jmxConfig.getUsername()) && !ValidateUtils.isBlank(this.jmxConfig.getPassword())) {
|
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()) {
|
if (jmxConfig.isOpenSSL() != null && this.jmxConfig.isOpenSSL()) {
|
||||||
environment.put(Context.SECURITY_PROTOCOL, "ssl");
|
environment.put(Context.SECURITY_PROTOCOL, "ssl");
|
||||||
|
|||||||
@@ -33,7 +33,9 @@ public class ZkPathUtil {
|
|||||||
|
|
||||||
private static final String D_METRICS_CONFIG_ROOT_NODE = CONFIG_ROOT_NODE + ZOOKEEPER_SEPARATOR + "KafkaExMetrics";
|
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) {
|
public static String getBrokerIdNodePath(Integer brokerId) {
|
||||||
return BROKER_IDS_ROOT + ZOOKEEPER_SEPARATOR + String.valueOf(brokerId);
|
return BROKER_IDS_ROOT + ZOOKEEPER_SEPARATOR + String.valueOf(brokerId);
|
||||||
@@ -111,6 +113,10 @@ public class ZkPathUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String getKafkaExtraMetricsPath(Integer brokerId) {
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,6 +94,9 @@ import 'antd/es/divider/style';
|
|||||||
import Upload from 'antd/es/upload';
|
import Upload from 'antd/es/upload';
|
||||||
import 'antd/es/upload/style';
|
import 'antd/es/upload/style';
|
||||||
|
|
||||||
|
import Transfer from 'antd/es/transfer';
|
||||||
|
import 'antd/es/transfer/style';
|
||||||
|
|
||||||
import TimePicker from 'antd/es/time-picker';
|
import TimePicker from 'antd/es/time-picker';
|
||||||
import 'antd/es/time-picker/style';
|
import 'antd/es/time-picker/style';
|
||||||
|
|
||||||
@@ -142,5 +145,6 @@ export {
|
|||||||
TimePicker,
|
TimePicker,
|
||||||
RangePickerValue,
|
RangePickerValue,
|
||||||
Badge,
|
Badge,
|
||||||
Popover
|
Popover,
|
||||||
|
Transfer
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
.editor{
|
.editor{
|
||||||
height: 100%;
|
height: 100%;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: -14%;
|
left: -12%;
|
||||||
width: 120%;
|
width: 120%;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,24 +21,12 @@ class Monacoeditor extends React.Component<IEditorProps> {
|
|||||||
public state = {
|
public state = {
|
||||||
placeholder: '',
|
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() {
|
public async componentDidMount() {
|
||||||
const { value, onChange } = this.props;
|
const { value, onChange } = this.props;
|
||||||
const format: any = await format2json(value);
|
const format: any = await format2json(value);
|
||||||
this.editor = monaco.editor.create(this.ref, {
|
this.editor = monaco.editor.create(this.ref, {
|
||||||
value: format.result,
|
value: format.result || value,
|
||||||
language: 'json',
|
language: 'json',
|
||||||
lineNumbers: 'off',
|
lineNumbers: 'off',
|
||||||
scrollBeyondLastLine: false,
|
scrollBeyondLastLine: false,
|
||||||
@@ -48,7 +36,7 @@ class Monacoeditor extends React.Component<IEditorProps> {
|
|||||||
minimap: {
|
minimap: {
|
||||||
enabled: false,
|
enabled: false,
|
||||||
},
|
},
|
||||||
// automaticLayout: true, // 自动布局
|
automaticLayout: true, // 自动布局
|
||||||
glyphMargin: true, // 字形边缘 {},[]
|
glyphMargin: true, // 字形边缘 {},[]
|
||||||
// useTabStops: false,
|
// useTabStops: false,
|
||||||
// formatOnPaste: true,
|
// formatOnPaste: true,
|
||||||
|
|||||||
@@ -130,6 +130,8 @@ class XForm extends React.Component<IXFormProps> {
|
|||||||
this.renderFormItem(formItem),
|
this.renderFormItem(formItem),
|
||||||
)}
|
)}
|
||||||
{formItem.renderExtraElement ? formItem.renderExtraElement() : null}
|
{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>
|
</Form.Item>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ export const timeMonthStr = 'YYYY/MM';
|
|||||||
// tslint:disable-next-line:max-line-length
|
// tslint:disable-next-line:max-line-length
|
||||||
|
|
||||||
export const indexUrl ={
|
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
|
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">
|
<div className="k-row">
|
||||||
<ul className="k-tab">
|
<ul className="k-tab">
|
||||||
<li>{this.props.tab}</li>
|
<li>{this.props.tab}</li>
|
||||||
{this.renderSearch()}
|
{this.renderSearch('', '请输入消费组名称')}
|
||||||
</ul>
|
</ul>
|
||||||
<Table
|
<Table
|
||||||
columns={this.columns}
|
columns={this.columns}
|
||||||
|
|||||||
@@ -2,7 +2,8 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
|
|
||||||
import { SearchAndFilterContainer } from 'container/search-filter';
|
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 { observer } from 'mobx-react';
|
||||||
import { pagination } from 'constants/table';
|
import { pagination } from 'constants/table';
|
||||||
import Url from 'lib/url-parser';
|
import Url from 'lib/url-parser';
|
||||||
@@ -16,8 +17,12 @@ import { timeFormat } from 'constants/strategy';
|
|||||||
export class ClusterController extends SearchAndFilterContainer {
|
export class ClusterController extends SearchAndFilterContainer {
|
||||||
public clusterId: number;
|
public clusterId: number;
|
||||||
|
|
||||||
public state = {
|
public state: any = {
|
||||||
searchKey: '',
|
searchKey: '',
|
||||||
|
searchCandidateKey: '',
|
||||||
|
isCandidateModel: false,
|
||||||
|
mockData: [],
|
||||||
|
targetKeys: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
constructor(props: any) {
|
constructor(props: any) {
|
||||||
@@ -37,6 +42,94 @@ export class ClusterController extends SearchAndFilterContainer {
|
|||||||
return data;
|
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() {
|
public renderController() {
|
||||||
|
|
||||||
const columns = [
|
const columns = [
|
||||||
@@ -58,12 +151,6 @@ export class ClusterController extends SearchAndFilterContainer {
|
|||||||
key: 'host',
|
key: 'host',
|
||||||
dataIndex: 'host',
|
dataIndex: 'host',
|
||||||
width: '30%',
|
width: '30%',
|
||||||
// render: (r: string, t: IController) => {
|
|
||||||
// return (
|
|
||||||
// <a href={`${this.urlPrefix}/admin/broker-detail?clusterId=${this.clusterId}&brokerId=${t.brokerId}`}>{r}
|
|
||||||
// </a>
|
|
||||||
// );
|
|
||||||
// },
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '变更时间',
|
title: '变更时间',
|
||||||
@@ -87,16 +174,104 @@ export class ClusterController extends SearchAndFilterContainer {
|
|||||||
|
|
||||||
public componentDidMount() {
|
public componentDidMount() {
|
||||||
admin.getControllerHistory(this.clusterId);
|
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() {
|
public render() {
|
||||||
return (
|
return (
|
||||||
<div className="k-row">
|
<div className="k-row">
|
||||||
<ul className="k-tab">
|
<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>
|
<li>{this.props.tab}</li>
|
||||||
{this.renderSearch('', '请输入Host')}
|
{this.renderSearch('', '请输入Host')}
|
||||||
</ul>
|
</ul>
|
||||||
{this.renderController()}
|
{this.renderController()}
|
||||||
|
{this.renderAddCandidateController()}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,3 +95,9 @@
|
|||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.asd{
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-around;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
@@ -46,7 +46,7 @@ export class ClusterDetail extends React.Component {
|
|||||||
<ClusterOverview basicInfo={content} />
|
<ClusterOverview basicInfo={content} />
|
||||||
</TabPane>
|
</TabPane>
|
||||||
<TabPane tab="Topic信息" key="2">
|
<TabPane tab="Topic信息" key="2">
|
||||||
<ClusterTopic tab={'Topic信息'}/>
|
<ClusterTopic tab={'Topic信息'} />
|
||||||
</TabPane>
|
</TabPane>
|
||||||
<TabPane tab="Broker信息" key="3">
|
<TabPane tab="Broker信息" key="3">
|
||||||
<ClusterBroker tab={'Broker信息'} basicInfo={content} />
|
<ClusterBroker tab={'Broker信息'} basicInfo={content} />
|
||||||
@@ -60,11 +60,11 @@ export class ClusterDetail extends React.Component {
|
|||||||
<TabPane tab="逻辑集群信息" key="6">
|
<TabPane tab="逻辑集群信息" key="6">
|
||||||
<LogicalCluster tab={'逻辑集群信息'} basicInfo={content} />
|
<LogicalCluster tab={'逻辑集群信息'} basicInfo={content} />
|
||||||
</TabPane>
|
</TabPane>
|
||||||
<TabPane tab="Controller变更历史" key="7">
|
<TabPane tab="Controller信息" key="7">
|
||||||
<ClusterController tab={'Controller变更历史'} />
|
<ClusterController tab={'Controller变更历史'} />
|
||||||
</TabPane>
|
</TabPane>
|
||||||
<TabPane tab="限流信息" key="8">
|
<TabPane tab="限流信息" key="8">
|
||||||
<CurrentLimiting tab={'限流信息'}/>
|
<CurrentLimiting tab={'限流信息'} />
|
||||||
</TabPane>
|
</TabPane>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import { urlPrefix } from 'constants/left-menu';
|
|||||||
import { indexUrl } from 'constants/strategy'
|
import { indexUrl } from 'constants/strategy'
|
||||||
import { region } from 'store';
|
import { region } from 'store';
|
||||||
import './index.less';
|
import './index.less';
|
||||||
|
import Monacoeditor from 'component/editor/monacoEditor';
|
||||||
import { getAdminClusterColumns } from '../config';
|
import { getAdminClusterColumns } from '../config';
|
||||||
|
|
||||||
const { confirm } = Modal;
|
const { confirm } = Modal;
|
||||||
@@ -132,6 +133,25 @@ export class ClusterList extends SearchAndFilterContainer {
|
|||||||
"security.protocol": "SASL_PLAINTEXT",
|
"security.protocol": "SASL_PLAINTEXT",
|
||||||
"sasl.mechanism": "PLAIN",
|
"sasl.mechanism": "PLAIN",
|
||||||
"sasl.jaas.config": "org.apache.kafka.common.security.plain.PlainLoginModule required username=\\"xxxxxx\\" password=\\"xxxxxx\\";"
|
"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,
|
rows: 8,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import * as React from 'react';
|
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 { users } from 'store/users';
|
||||||
import { version } from 'store/version';
|
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 { Popconfirm, Tooltip } from 'component/antd';
|
||||||
import { admin } from 'store/admin';
|
import { admin } from 'store/admin';
|
||||||
import { cellStyle } from 'constants/table';
|
import { cellStyle } from 'constants/table';
|
||||||
@@ -27,6 +27,7 @@ export const getUserColumns = () => {
|
|||||||
return (
|
return (
|
||||||
<span className="table-operation">
|
<span className="table-operation">
|
||||||
<a onClick={() => showApplyModal(record)}>编辑</a>
|
<a onClick={() => showApplyModal(record)}>编辑</a>
|
||||||
|
<a onClick={() => showApplyModalModifyPassword(record)}>修改密码</a>
|
||||||
<Popconfirm
|
<Popconfirm
|
||||||
title="确定删除?"
|
title="确定删除?"
|
||||||
onConfirm={() => users.deleteUser(record.username)}
|
onConfirm={() => users.deleteUser(record.username)}
|
||||||
@@ -184,6 +185,87 @@ export const getConfigureColumns = () => {
|
|||||||
return columns;
|
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) => {
|
const renderClusterHref = (value: number | string, item: IMetaData, key: number) => {
|
||||||
return ( // 0 暂停监控--不可点击 1 监控中---可正常点击
|
return ( // 0 暂停监控--不可点击 1 监控中---可正常点击
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -3,11 +3,11 @@ import { SearchAndFilterContainer } from 'container/search-filter';
|
|||||||
import { Table, Button, Spin } from 'component/antd';
|
import { Table, Button, Spin } from 'component/antd';
|
||||||
import { admin } from 'store/admin';
|
import { admin } from 'store/admin';
|
||||||
import { observer } from 'mobx-react';
|
import { observer } from 'mobx-react';
|
||||||
import { IConfigure } from 'types/base-type';
|
import { IConfigure, IConfigGateway } from 'types/base-type';
|
||||||
import { users } from 'store/users';
|
import { users } from 'store/users';
|
||||||
import { pagination } from 'constants/table';
|
import { pagination } from 'constants/table';
|
||||||
import { getConfigureColumns } from './config';
|
import { getConfigureColumns, getConfigColumns } from './config';
|
||||||
import { showConfigureModal } from 'container/modal/admin';
|
import { showConfigureModal, showConfigGatewayModal } from 'container/modal/admin';
|
||||||
|
|
||||||
@observer
|
@observer
|
||||||
export class ConfigureManagement extends SearchAndFilterContainer {
|
export class ConfigureManagement extends SearchAndFilterContainer {
|
||||||
@@ -17,8 +17,13 @@ export class ConfigureManagement extends SearchAndFilterContainer {
|
|||||||
};
|
};
|
||||||
|
|
||||||
public componentDidMount() {
|
public componentDidMount() {
|
||||||
|
if (this.props.isShow) {
|
||||||
|
admin.getGatewayList();
|
||||||
|
admin.getGatewayType();
|
||||||
|
} else {
|
||||||
admin.getConfigure();
|
admin.getConfigure();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public getData<T extends IConfigure>(origin: T[]) {
|
public getData<T extends IConfigure>(origin: T[]) {
|
||||||
let data: T[] = origin;
|
let data: T[] = origin;
|
||||||
@@ -34,15 +39,34 @@ export class ConfigureManagement extends SearchAndFilterContainer {
|
|||||||
return data;
|
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() {
|
public renderTable() {
|
||||||
return (
|
return (
|
||||||
<Spin spinning={users.loading}>
|
<Spin spinning={users.loading}>
|
||||||
<Table
|
{this.props.isShow ? <Table
|
||||||
|
rowKey="key"
|
||||||
|
columns={getConfigColumns()}
|
||||||
|
dataSource={this.getGatewayData(admin.configGatewayList)}
|
||||||
|
pagination={pagination}
|
||||||
|
/> : <Table
|
||||||
rowKey="key"
|
rowKey="key"
|
||||||
columns={getConfigureColumns()}
|
columns={getConfigureColumns()}
|
||||||
dataSource={this.getData(admin.configureList)}
|
dataSource={this.getData(admin.configureList)}
|
||||||
pagination={pagination}
|
pagination={pagination}
|
||||||
/>
|
/>}
|
||||||
</Spin>
|
</Spin>
|
||||||
|
|
||||||
);
|
);
|
||||||
@@ -53,7 +77,7 @@ export class ConfigureManagement extends SearchAndFilterContainer {
|
|||||||
<ul>
|
<ul>
|
||||||
{this.renderSearch('', '请输入配置键、值或描述')}
|
{this.renderSearch('', '请输入配置键、值或描述')}
|
||||||
<li className="right-btn-1">
|
<li className="right-btn-1">
|
||||||
<Button type="primary" onClick={() => showConfigureModal()}>增加配置</Button>
|
<Button type="primary" onClick={() => this.props.isShow ? showConfigGatewayModal() : showConfigureModal()}>增加配置</Button>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { curveKeys, CURVE_KEY_MAP, PERIOD_RADIO_MAP, PERIOD_RADIO } from './conf
|
|||||||
import moment = require('moment');
|
import moment = require('moment');
|
||||||
import { observer } from 'mobx-react';
|
import { observer } from 'mobx-react';
|
||||||
import { timeStampStr } from 'constants/strategy';
|
import { timeStampStr } from 'constants/strategy';
|
||||||
|
import { adminMonitor } from 'store/admin-monitor';
|
||||||
|
|
||||||
@observer
|
@observer
|
||||||
export class DataCurveFilter extends React.Component {
|
export class DataCurveFilter extends React.Component {
|
||||||
@@ -21,6 +22,7 @@ export class DataCurveFilter extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public refreshAll = () => {
|
public refreshAll = () => {
|
||||||
|
adminMonitor.setRequestId(null);
|
||||||
Object.keys(curveKeys).forEach((c: curveKeys) => {
|
Object.keys(curveKeys).forEach((c: curveKeys) => {
|
||||||
const { typeInfo, curveInfo: option } = CURVE_KEY_MAP.get(c);
|
const { typeInfo, curveInfo: option } = CURVE_KEY_MAP.get(c);
|
||||||
const { parser } = typeInfo;
|
const { parser } = typeInfo;
|
||||||
|
|||||||
@@ -20,8 +20,11 @@ export class PlatformManagement extends React.Component {
|
|||||||
<TabPane tab="用户管理" key="2">
|
<TabPane tab="用户管理" key="2">
|
||||||
<UserManagement />
|
<UserManagement />
|
||||||
</TabPane>
|
</TabPane>
|
||||||
<TabPane tab="配置管理" key="3">
|
<TabPane tab="平台配置" key="3">
|
||||||
<ConfigureManagement />
|
<ConfigureManagement isShow={false} />
|
||||||
|
</TabPane>
|
||||||
|
<TabPane tab="网关配置" key="4">
|
||||||
|
<ConfigureManagement isShow={true} />
|
||||||
</TabPane>
|
</TabPane>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ export class UserManagement extends SearchAndFilterContainer {
|
|||||||
searchKey = (searchKey + '').trim().toLowerCase();
|
searchKey = (searchKey + '').trim().toLowerCase();
|
||||||
|
|
||||||
data = searchKey ? origin.filter((item: IUser) =>
|
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;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { alarm } from 'store/alarm';
|
import { alarm } from 'store/alarm';
|
||||||
import { IMonitorGroups } from 'types/base-type';
|
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';
|
import { VirtualScrollSelect } from '../../../component/virtual-scroll-select';
|
||||||
|
|
||||||
interface IAlarmSelectProps {
|
interface IAlarmSelectProps {
|
||||||
@@ -36,6 +36,10 @@ export class AlarmSelect extends React.Component<IAlarmSelectProps> {
|
|||||||
onChange && onChange(params);
|
onChange && onChange(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public componentWillUnmount() {
|
||||||
|
deleteValueFromLocalStorage('monitorGroups');
|
||||||
|
}
|
||||||
|
|
||||||
public render() {
|
public render() {
|
||||||
const { value, isDisabled } = this.props;
|
const { value, isDisabled } = this.props;
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import { pagination } from 'constants/table';
|
|||||||
import { urlPrefix } from 'constants/left-menu';
|
import { urlPrefix } from 'constants/left-menu';
|
||||||
import { alarm } from 'store/alarm';
|
import { alarm } from 'store/alarm';
|
||||||
import 'styles/table-filter.less';
|
import 'styles/table-filter.less';
|
||||||
|
import { Link } from 'react-router-dom';
|
||||||
|
|
||||||
@observer
|
@observer
|
||||||
export class AlarmList extends SearchAndFilterContainer {
|
export class AlarmList extends SearchAndFilterContainer {
|
||||||
@@ -55,9 +56,7 @@ export class AlarmList extends SearchAndFilterContainer {
|
|||||||
{this.renderSearch('名称:', '请输入告警规则或者操作人')}
|
{this.renderSearch('名称:', '请输入告警规则或者操作人')}
|
||||||
<li className="right-btn-1">
|
<li className="right-btn-1">
|
||||||
<Button type="primary">
|
<Button type="primary">
|
||||||
<a href={`${urlPrefix}/alarm/add`}>
|
<Link to={`/alarm/add`}>新增规则</Link>
|
||||||
新增规则
|
|
||||||
</a>
|
|
||||||
</Button>
|
</Button>
|
||||||
</li>
|
</li>
|
||||||
</>
|
</>
|
||||||
@@ -68,6 +67,9 @@ export class AlarmList extends SearchAndFilterContainer {
|
|||||||
if (!alarm.monitorStrategies.length) {
|
if (!alarm.monitorStrategies.length) {
|
||||||
alarm.getMonitorStrategies();
|
alarm.getMonitorStrategies();
|
||||||
}
|
}
|
||||||
|
if (!app.data.length) {
|
||||||
|
app.getAppList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public render() {
|
public render() {
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ export class MyCluster extends SearchAndFilterContainer {
|
|||||||
],
|
],
|
||||||
formData: {},
|
formData: {},
|
||||||
visible: true,
|
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: '确认',
|
okText: '确认',
|
||||||
onSubmit: (value: any) => {
|
onSubmit: (value: any) => {
|
||||||
value.idc = region.currentRegion;
|
value.idc = region.currentRegion;
|
||||||
|
|||||||
@@ -117,12 +117,12 @@ class DataMigrationFormTable extends React.Component<IFormTableProps> {
|
|||||||
key: 'maxThrottle',
|
key: 'maxThrottle',
|
||||||
editable: true,
|
editable: true,
|
||||||
}, {
|
}, {
|
||||||
title: '迁移保存时间(h)',
|
title: '迁移后Topic保存时间(h)',
|
||||||
dataIndex: 'reassignRetentionTime',
|
dataIndex: 'reassignRetentionTime',
|
||||||
key: 'reassignRetentionTime',
|
key: 'reassignRetentionTime',
|
||||||
editable: true,
|
editable: true,
|
||||||
}, {
|
}, {
|
||||||
title: '原本保存时间(h)',
|
title: '原Topic保存时间(h)',
|
||||||
dataIndex: 'retentionTime',
|
dataIndex: 'retentionTime',
|
||||||
key: 'retentionTime', // originalRetentionTime
|
key: 'retentionTime', // originalRetentionTime
|
||||||
width: '132px',
|
width: '132px',
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ export const showEditClusterTopic = (item: IClusterTopics) => {
|
|||||||
attrs: {
|
attrs: {
|
||||||
placeholder: '请输入保存时间',
|
placeholder: '请输入保存时间',
|
||||||
suffix: '小时',
|
suffix: '小时',
|
||||||
|
prompttype:'修改保存时间,预计一分钟左右生效!'
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -158,26 +158,26 @@ export const createMigrationTasks = () => {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'originalRetentionTime',
|
key: 'originalRetentionTime',
|
||||||
label: '原本保存时间',
|
label: '原Topic保存时间',
|
||||||
rules: [{
|
rules: [{
|
||||||
required: true,
|
required: true,
|
||||||
message: '请输入原本保存时间',
|
message: '请输入原Topic保存时间',
|
||||||
}],
|
}],
|
||||||
attrs: {
|
attrs: {
|
||||||
disabled: true,
|
disabled: true,
|
||||||
placeholder: '请输入原本保存时间',
|
placeholder: '请输入原Topic保存时间',
|
||||||
suffix: '小时',
|
suffix: '小时',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'reassignRetentionTime',
|
key: 'reassignRetentionTime',
|
||||||
label: '迁移保存时间',
|
label: '迁移后Topic保存时间',
|
||||||
rules: [{
|
rules: [{
|
||||||
required: true,
|
required: true,
|
||||||
message: '请输入迁移保存时间',
|
message: '请输入迁移后Topic保存时间',
|
||||||
}],
|
}],
|
||||||
attrs: {
|
attrs: {
|
||||||
placeholder: '请输入迁移保存时间',
|
placeholder: '请输入迁移后Topic保存时间',
|
||||||
suffix: '小时',
|
suffix: '小时',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -24,26 +24,111 @@ export const showApplyModal = (record?: IUser) => {
|
|||||||
value: +item,
|
value: +item,
|
||||||
})),
|
})),
|
||||||
rules: [{ required: true, message: '请选择角色' }],
|
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 || {},
|
formData: record || {},
|
||||||
visible: true,
|
visible: true,
|
||||||
title: record ? '修改用户' : '新增用户',
|
title: record ? '修改用户' : '新增用户',
|
||||||
onSubmit: (value: IUser) => {
|
onSubmit: (value: IUser) => {
|
||||||
if (record) {
|
if (record) {
|
||||||
return users.modfiyUser(value).then(() => {
|
return users.modfiyUser(value)
|
||||||
message.success('操作成功');
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
return users.addUser(value).then(() => {
|
return users.addUser(value).then(() => {
|
||||||
message.success('操作成功');
|
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);
|
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 * as React from 'react';
|
||||||
import { notification } from 'component/antd';
|
import { notification, Select } from 'component/antd';
|
||||||
import { IUploadFile, IConfigure } from 'types/base-type';
|
import { IUploadFile, IConfigure, IConfigGateway } from 'types/base-type';
|
||||||
import { version } from 'store/version';
|
import { version } from 'store/version';
|
||||||
import { admin } from 'store/admin';
|
import { admin } from 'store/admin';
|
||||||
import { wrapper } from 'store';
|
import { wrapper } from 'store';
|
||||||
@@ -157,8 +157,8 @@ export const showModifyModal = (record: IUploadFile) => {
|
|||||||
|
|
||||||
export const showConfigureModal = async (record?: IConfigure) => {
|
export const showConfigureModal = async (record?: IConfigure) => {
|
||||||
if (record) {
|
if (record) {
|
||||||
const result:any = await format2json(record.configValue);
|
const result: any = await format2json(record.configValue);
|
||||||
record.configValue = result.result;
|
record.configValue = result.result || record.configValue;
|
||||||
}
|
}
|
||||||
const xFormModal = {
|
const xFormModal = {
|
||||||
formMap: [
|
formMap: [
|
||||||
@@ -193,10 +193,69 @@ export const showConfigureModal = async (record?: IConfigure) => {
|
|||||||
return admin.editConfigure(value).then(data => {
|
return admin.editConfigure(value).then(data => {
|
||||||
notification.success({ message: '编辑配置成功' });
|
notification.success({ message: '编辑配置成功' });
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
return admin.addNewConfigure(value).then(data => {
|
return admin.addNewConfigure(value).then(data => {
|
||||||
notification.success({ message: '新建配置成功' });
|
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: '新建配置成功' });
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
wrapper.open(xFormModal);
|
wrapper.open(xFormModal);
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ export const showEditModal = (record?: IAppItem, from?: string, isDisabled?: boo
|
|||||||
],
|
],
|
||||||
formData: record,
|
formData: record,
|
||||||
visible: true,
|
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>,
|
// customRenderElement: isDisabled ? '' : record ? '' : <span className="tips">集群资源充足时,预计1分钟自动审批通过</span>,
|
||||||
isWaitting: true,
|
isWaitting: true,
|
||||||
onSubmit: (value: IAppItem) => {
|
onSubmit: (value: IAppItem) => {
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ export const migrationModal = (renderData: IRenderData[]) => {
|
|||||||
visible: true,
|
visible: true,
|
||||||
width: 1000,
|
width: 1000,
|
||||||
title: '新建迁移任务',
|
title: '新建迁移任务',
|
||||||
customRenderElement: <WrappedDataMigrationFormTable data={renderData}/>,
|
customRenderElement: <WrappedDataMigrationFormTable data={renderData} />,
|
||||||
nofooter: true,
|
nofooter: true,
|
||||||
noform: true,
|
noform: true,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -75,8 +75,8 @@ export const showApprovalModal = (info: IOrderInfo, status: number, from?: strin
|
|||||||
// }],
|
// }],
|
||||||
rules: [{
|
rules: [{
|
||||||
required: true,
|
required: true,
|
||||||
message: '请输入大于12小于999的整数',
|
message: '请输入大于0小于10000的整数',
|
||||||
pattern: /^([1-9]{1}[0-9]{2})$|^([2-9]{1}[0-9]{1})$|^(1[2-9]{1})$/,
|
pattern: /^\+?[1-9]\d{0,3}(\.\d*)?$/,
|
||||||
}],
|
}],
|
||||||
}, {
|
}, {
|
||||||
key: 'species',
|
key: 'species',
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ export const applyTopic = () => {
|
|||||||
],
|
],
|
||||||
formData: {},
|
formData: {},
|
||||||
visible: true,
|
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: '确认',
|
okText: '确认',
|
||||||
// customRenderElement: <span className="tips">集群资源充足时,预计1分钟自动审批通过</span>,
|
// customRenderElement: <span className="tips">集群资源充足时,预计1分钟自动审批通过</span>,
|
||||||
isWaitting: true,
|
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;
|
const value = this.state[keyName] as string;
|
||||||
return (
|
return (
|
||||||
<li className="render-box">
|
<li className="render-box">
|
||||||
|
|||||||
@@ -101,7 +101,9 @@ export class ConnectInformation extends SearchAndFilterContainer {
|
|||||||
<>
|
<>
|
||||||
<div className="k-row" >
|
<div className="k-row" >
|
||||||
<ul className="k-tab">
|
<ul className="k-tab">
|
||||||
<li>连接信息</li>
|
<li>
|
||||||
|
连接信息 <span style={{ color: '#a7a8a9', fontSize: '12px', padding: '0 15px' }}>展示近20分钟的连接信息</span>
|
||||||
|
</li>
|
||||||
{this.renderSearch('', '请输入连接信息', 'searchKey')}
|
{this.renderSearch('', '请输入连接信息', 'searchKey')}
|
||||||
</ul>
|
</ul>
|
||||||
{this.renderConnectionInfo(this.getData(topic.connectionInfo))}
|
{this.renderConnectionInfo(this.getData(topic.connectionInfo))}
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ export class GroupID extends SearchAndFilterContainer {
|
|||||||
|
|
||||||
public renderConsumerDetails() {
|
public renderConsumerDetails() {
|
||||||
const consumerGroup = this.consumerGroup;
|
const consumerGroup = this.consumerGroup;
|
||||||
const columns = [{
|
const columns: any = [{
|
||||||
title: 'Partition ID',
|
title: 'Partition ID',
|
||||||
dataIndex: 'partitionId',
|
dataIndex: 'partitionId',
|
||||||
key: 'partitionId',
|
key: 'partitionId',
|
||||||
@@ -179,7 +179,8 @@ export class GroupID extends SearchAndFilterContainer {
|
|||||||
<>
|
<>
|
||||||
<div className="details-box">
|
<div className="details-box">
|
||||||
<b>{consumerGroup}</b>
|
<b>{consumerGroup}</b>
|
||||||
<div>
|
<div style={{ display: 'flex' }}>
|
||||||
|
{this.renderSearch('', '请输入Consumer ID')}
|
||||||
<Button onClick={this.backToPage}>返回</Button>
|
<Button onClick={this.backToPage}>返回</Button>
|
||||||
<Button onClick={this.updateDetailsStatus}>刷新</Button>
|
<Button onClick={this.updateDetailsStatus}>刷新</Button>
|
||||||
<Button onClick={() => this.showResetOffset()}>重置Offset</Button>
|
<Button onClick={() => this.showResetOffset()}>重置Offset</Button>
|
||||||
@@ -187,7 +188,7 @@ export class GroupID extends SearchAndFilterContainer {
|
|||||||
</div>
|
</div>
|
||||||
<Table
|
<Table
|
||||||
columns={columns}
|
columns={columns}
|
||||||
dataSource={topic.consumeDetails}
|
dataSource={this.getDetailData(topic.consumeDetails)}
|
||||||
rowKey="key"
|
rowKey="key"
|
||||||
pagination={pagination}
|
pagination={pagination}
|
||||||
/>
|
/>
|
||||||
@@ -214,7 +215,12 @@ export class GroupID extends SearchAndFilterContainer {
|
|||||||
dataIndex: 'location',
|
dataIndex: 'location',
|
||||||
key: 'location',
|
key: 'location',
|
||||||
width: '34%',
|
width: '34%',
|
||||||
},
|
}, {
|
||||||
|
title: '状态',
|
||||||
|
dataIndex: 'state',
|
||||||
|
key: 'state',
|
||||||
|
width: '34%',
|
||||||
|
}
|
||||||
];
|
];
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -236,7 +242,17 @@ export class GroupID extends SearchAndFilterContainer {
|
|||||||
|
|
||||||
data = searchKey ? origin.filter((item: IConsumerGroups) =>
|
data = searchKey ? origin.filter((item: IConsumerGroups) =>
|
||||||
(item.consumerGroup !== undefined && item.consumerGroup !== null) && item.consumerGroup.toLowerCase().includes(searchKey as string),
|
(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;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -72,9 +72,9 @@ class ResetOffset extends React.Component<any> {
|
|||||||
const { typeValue, offsetValue } = this.state;
|
const { typeValue, offsetValue } = this.state;
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Alert message="重置之前一定要关闭消费客户端!!!" type="warning" showIcon={true} />
|
<Alert message="重置消费偏移前,请先关闭客户端,否则会重置失败 !!!" type="warning" showIcon={true} />
|
||||||
<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} className="mb-30" /> */}
|
||||||
<div className="o-container">
|
<div className="o-container">
|
||||||
<Form labelAlign="left" onSubmit={this.handleSubmit} >
|
<Form labelAlign="left" onSubmit={this.handleSubmit} >
|
||||||
<Radio.Group onChange={this.onChangeType} value={typeValue}>
|
<Radio.Group onChange={this.onChangeType} value={typeValue}>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import fetch, { formFetch } from './fetch';
|
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 { IRequestParams } from 'types/alarm';
|
||||||
import { apiCache } from 'lib/api-cache';
|
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 = () => {
|
export const getDataCenter = () => {
|
||||||
return fetch(`/normal/configs/idc`);
|
return fetch(`/normal/configs/idc`);
|
||||||
};
|
};
|
||||||
@@ -530,6 +558,23 @@ export const getControllerHistory = (clusterId: number) => {
|
|||||||
return fetch(`/rd/clusters/${clusterId}/controller-history`);
|
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
|
* 运维管控 broker
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -248,8 +248,8 @@ export const getClusterMetricOption = (type: IOptionType, record: IClusterMetric
|
|||||||
const unitSeries = item.data[item.seriesName] !== null ? Number(item.data[item.seriesName]) : null;
|
const unitSeries = item.data[item.seriesName] !== null ? Number(item.data[item.seriesName]) : null;
|
||||||
// tslint:disable-next-line:max-line-length
|
// 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>';
|
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')
|
if ((item.data.produceThrottled && item.seriesName === 'appIdBytesInPerSec')
|
||||||
|| (item.data.consumeThrottled && item.seriesName === 'appIdBytesOutPerSec') ) {
|
|| (item.data.consumeThrottled && item.seriesName === 'appIdBytesOutPerSec')) {
|
||||||
return result += item.seriesName + ': ' + unitSeries + '(被限流)' + '<br>';
|
return result += item.seriesName + ': ' + unitSeries + '(被限流)' + '<br>';
|
||||||
}
|
}
|
||||||
return result += item.seriesName + ': ' + unitSeries + '<br>';
|
return result += item.seriesName + ': ' + unitSeries + '<br>';
|
||||||
|
|||||||
@@ -3,6 +3,11 @@ import { observable, action } from 'mobx';
|
|||||||
import { getBrokersMetricsHistory } from 'lib/api';
|
import { getBrokersMetricsHistory } from 'lib/api';
|
||||||
import { IClusterMetrics } from 'types/base-type';
|
import { IClusterMetrics } from 'types/base-type';
|
||||||
|
|
||||||
|
const STATUS = {
|
||||||
|
PENDING: 'pending',
|
||||||
|
REJECT: 'reject',
|
||||||
|
FULLFILLED: 'fullfilled'
|
||||||
|
}
|
||||||
class AdminMonitor {
|
class AdminMonitor {
|
||||||
@observable
|
@observable
|
||||||
public currentClusterId = null as number;
|
public currentClusterId = null as number;
|
||||||
@@ -33,33 +38,42 @@ class AdminMonitor {
|
|||||||
@action.bound
|
@action.bound
|
||||||
public setBrokersChartsData(data: IClusterMetrics[]) {
|
public setBrokersChartsData(data: IClusterMetrics[]) {
|
||||||
this.brokersMetricsHistory = data;
|
this.brokersMetricsHistory = data;
|
||||||
|
this.setRequestId(STATUS.FULLFILLED);
|
||||||
|
Promise.all(this.taskQueue).then(() => {
|
||||||
this.setRequestId(null);
|
this.setRequestId(null);
|
||||||
|
this.taskQueue = [];
|
||||||
|
})
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
public taskQueue = [] as any[];
|
||||||
|
|
||||||
public getBrokersMetricsList = async (startTime: string, endTime: string) => {
|
public getBrokersMetricsList = async (startTime: string, endTime: string) => {
|
||||||
if (this.requestId && this.requestId !== 'error') {
|
if (this.requestId) {
|
||||||
return new Promise((res, rej) => {
|
//逐条定时查询任务状态
|
||||||
window.setTimeout(() => {
|
const p = new Promise((res, rej) => {
|
||||||
if (this.requestId === 'error') {
|
const timer = window.setInterval(() => {
|
||||||
rej();
|
if (this.requestId === STATUS.REJECT) {
|
||||||
} else {
|
rej(this.brokersMetricsHistory);
|
||||||
|
window.clearInterval(timer);
|
||||||
|
} else if (this.requestId === STATUS.FULLFILLED) {
|
||||||
res(this.brokersMetricsHistory);
|
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)
|
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) => {
|
public getBrokersChartsData = async (startTime: string, endTime: string, reload?: boolean) => {
|
||||||
if (this.brokersMetricsHistory && !reload) {
|
if (this.brokersMetricsHistory && !reload) {
|
||||||
return new Promise(res => res(this.brokersMetricsHistory));
|
return new Promise(res => res(this.brokersMetricsHistory));
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.getBrokersMetricsList(startTime, endTime);
|
return this.getBrokersMetricsList(startTime, endTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { observable, action } from 'mobx';
|
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 {
|
import {
|
||||||
deleteCluster,
|
deleteCluster,
|
||||||
getBasicInfo,
|
getBasicInfo,
|
||||||
@@ -12,7 +12,12 @@ import {
|
|||||||
getConfigure,
|
getConfigure,
|
||||||
addNewConfigure,
|
addNewConfigure,
|
||||||
editConfigure,
|
editConfigure,
|
||||||
|
addNewConfigGateway,
|
||||||
deleteConfigure,
|
deleteConfigure,
|
||||||
|
getGatewayList,
|
||||||
|
getGatewayType,
|
||||||
|
editConfigGateway,
|
||||||
|
deleteConfigGateway,
|
||||||
getDataCenter,
|
getDataCenter,
|
||||||
getClusterBroker,
|
getClusterBroker,
|
||||||
getClusterConsumer,
|
getClusterConsumer,
|
||||||
@@ -49,6 +54,9 @@ import {
|
|||||||
getStaffSummary,
|
getStaffSummary,
|
||||||
getBillStaffSummary,
|
getBillStaffSummary,
|
||||||
getBillStaffDetail,
|
getBillStaffDetail,
|
||||||
|
getCandidateController,
|
||||||
|
addCandidateController,
|
||||||
|
deleteCandidateCancel
|
||||||
} from 'lib/api';
|
} from 'lib/api';
|
||||||
import { getControlMetricOption, getClusterMetricOption } from 'lib/line-charts-config';
|
import { getControlMetricOption, getClusterMetricOption } from 'lib/line-charts-config';
|
||||||
|
|
||||||
@@ -59,6 +67,7 @@ import { transBToMB } from 'lib/utils';
|
|||||||
|
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import { timestore } from './time';
|
import { timestore } from './time';
|
||||||
|
import { message } from 'component/antd';
|
||||||
|
|
||||||
class Admin {
|
class Admin {
|
||||||
@observable
|
@observable
|
||||||
@@ -97,6 +106,12 @@ class Admin {
|
|||||||
@observable
|
@observable
|
||||||
public configureList: IConfigure[] = [];
|
public configureList: IConfigure[] = [];
|
||||||
|
|
||||||
|
@observable
|
||||||
|
public configGatewayList: IConfigGateway[] = [];
|
||||||
|
|
||||||
|
@observable
|
||||||
|
public gatewayType: [];
|
||||||
|
|
||||||
@observable
|
@observable
|
||||||
public dataCenterList: string[] = [];
|
public dataCenterList: string[] = [];
|
||||||
|
|
||||||
@@ -142,6 +157,12 @@ class Admin {
|
|||||||
@observable
|
@observable
|
||||||
public controllerHistory: IController[] = [];
|
public controllerHistory: IController[] = [];
|
||||||
|
|
||||||
|
@observable
|
||||||
|
public controllerCandidate: IController[] = [];
|
||||||
|
|
||||||
|
@observable
|
||||||
|
public filtercontrollerCandidate: string = '';
|
||||||
|
|
||||||
@observable
|
@observable
|
||||||
public brokersPartitions: IBrokersPartitions[] = [];
|
public brokersPartitions: IBrokersPartitions[] = [];
|
||||||
|
|
||||||
@@ -152,7 +173,7 @@ class Admin {
|
|||||||
public brokersAnalysisTopic: IAnalysisTopicVO[] = [];
|
public brokersAnalysisTopic: IAnalysisTopicVO[] = [];
|
||||||
|
|
||||||
@observable
|
@observable
|
||||||
public brokersMetadata: IBrokersMetadata[] = [];
|
public brokersMetadata: IBrokersMetadata[] | any = [];
|
||||||
|
|
||||||
@observable
|
@observable
|
||||||
public brokersRegions: IBrokersRegions[] = [];
|
public brokersRegions: IBrokersRegions[] = [];
|
||||||
@@ -206,10 +227,10 @@ class Admin {
|
|||||||
public kafkaRoles: IKafkaRoles[];
|
public kafkaRoles: IKafkaRoles[];
|
||||||
|
|
||||||
@observable
|
@observable
|
||||||
public controlType: IOptionType = 'byteIn/byteOut' ;
|
public controlType: IOptionType = 'byteIn/byteOut';
|
||||||
|
|
||||||
@observable
|
@observable
|
||||||
public type: IOptionType = 'byteIn/byteOut' ;
|
public type: IOptionType = 'byteIn/byteOut';
|
||||||
|
|
||||||
@observable
|
@observable
|
||||||
public currentClusterId = null as number;
|
public currentClusterId = null as number;
|
||||||
@@ -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
|
@action.bound
|
||||||
public setDataCenter(data: string[]) {
|
public setDataCenter(data: string[]) {
|
||||||
this.dataCenterList = data || [];
|
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
|
@action.bound
|
||||||
public setBrokersBasicInfo(data: IBrokersBasicInfo) {
|
public setBrokersBasicInfo(data: IBrokersBasicInfo) {
|
||||||
this.brokersBasicInfo = data;
|
this.brokersBasicInfo = data;
|
||||||
@@ -356,10 +402,10 @@ class Admin {
|
|||||||
this.replicaStatus = data.brokerReplicaStatusList.slice(1);
|
this.replicaStatus = data.brokerReplicaStatusList.slice(1);
|
||||||
|
|
||||||
this.bytesInStatus.forEach((item, index) => {
|
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.replicaStatus.forEach((item, index) => {
|
||||||
this.copyValueList.push({name: copyValueMap[index], value: item});
|
this.copyValueList.push({ name: copyValueMap[index], value: item });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -415,8 +461,8 @@ class Admin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@action.bound
|
@action.bound
|
||||||
public setBrokersMetadata(data: IBrokersMetadata[]) {
|
public setBrokersMetadata(data: IBrokersMetadata[]|any) {
|
||||||
this.brokersMetadata = data ? data.map((item, index) => {
|
this.brokersMetadata = data ? data.map((item:any, index:any) => {
|
||||||
item.key = index;
|
item.key = index;
|
||||||
return {
|
return {
|
||||||
...item,
|
...item,
|
||||||
@@ -568,7 +614,7 @@ class Admin {
|
|||||||
return deleteCluster(clusterId).then(() => this.getMetaData(true));
|
return deleteCluster(clusterId).then(() => this.getMetaData(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
public getPeakFlowChartData(value: ILabelValue[], map: string []) {
|
public getPeakFlowChartData(value: ILabelValue[], map: string[]) {
|
||||||
return getPieChartOption(value, map);
|
return getPieChartOption(value, map);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -627,6 +673,30 @@ class Admin {
|
|||||||
deleteConfigure(configKey).then(() => this.getConfigure());
|
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() {
|
public getDataCenter() {
|
||||||
getDataCenter().then(this.setDataCenter);
|
getDataCenter().then(this.setDataCenter);
|
||||||
}
|
}
|
||||||
@@ -643,6 +713,20 @@ class Admin {
|
|||||||
return getControllerHistory(clusterId).then(this.setControllerHistory);
|
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) {
|
public getBrokersBasicInfo(clusterId: number, brokerId: number) {
|
||||||
return getBrokersBasicInfo(clusterId, brokerId).then(this.setBrokersBasicInfo);
|
return getBrokersBasicInfo(clusterId, brokerId).then(this.setBrokersBasicInfo);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -181,6 +181,7 @@ class Alarm {
|
|||||||
public modifyMonitorStrategy(params: IRequestParams) {
|
public modifyMonitorStrategy(params: IRequestParams) {
|
||||||
return modifyMonitorStrategy(params).then(() => {
|
return modifyMonitorStrategy(params).then(() => {
|
||||||
message.success('操作成功');
|
message.success('操作成功');
|
||||||
|
window.location.href = `${urlPrefix}/alarm`;
|
||||||
}).finally(() => this.setLoading(false));
|
}).finally(() => this.setLoading(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,9 @@ export class Users {
|
|||||||
@observable
|
@observable
|
||||||
public staff: IStaff[] = [];
|
public staff: IStaff[] = [];
|
||||||
|
|
||||||
|
@observable
|
||||||
|
public newPassWord: any = null;
|
||||||
|
|
||||||
@action.bound
|
@action.bound
|
||||||
public setAccount(data: IUser) {
|
public setAccount(data: IUser) {
|
||||||
setCookie([{ key: 'role', value: `${data.role}`, time: 1 }]);
|
setCookie([{ key: 'role', value: `${data.role}`, time: 1 }]);
|
||||||
@@ -42,6 +45,11 @@ export class Users {
|
|||||||
this.loading = value;
|
this.loading = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@action.bound
|
||||||
|
public setNewPassWord(value: boolean) {
|
||||||
|
this.newPassWord = value;
|
||||||
|
}
|
||||||
|
|
||||||
public getAccount() {
|
public getAccount() {
|
||||||
getAccount().then(this.setAccount);
|
getAccount().then(this.setAccount);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -190,6 +190,7 @@ export interface IUser {
|
|||||||
chineseName?: string;
|
chineseName?: string;
|
||||||
department?: string;
|
department?: string;
|
||||||
key?: number;
|
key?: number;
|
||||||
|
confirmPassword?:string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IOffset {
|
export interface IOffset {
|
||||||
@@ -486,6 +487,17 @@ export interface IConfigure {
|
|||||||
key?: number;
|
key?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface IConfigGateway {
|
||||||
|
id: number;
|
||||||
|
key?: number;
|
||||||
|
modifyTime: number;
|
||||||
|
name: string;
|
||||||
|
value: string;
|
||||||
|
version: string;
|
||||||
|
type: string;
|
||||||
|
description: string;
|
||||||
|
}
|
||||||
|
|
||||||
export interface IEepand {
|
export interface IEepand {
|
||||||
brokerIdList: number[];
|
brokerIdList: number[];
|
||||||
clusterId: number;
|
clusterId: number;
|
||||||
@@ -650,8 +662,10 @@ export interface IBrokerData {
|
|||||||
export interface IController {
|
export interface IController {
|
||||||
brokerId: number;
|
brokerId: number;
|
||||||
host: string;
|
host: string;
|
||||||
timestamp: number;
|
timestamp?: number;
|
||||||
version: number;
|
version?: number;
|
||||||
|
startTime?: number;
|
||||||
|
status?: number;
|
||||||
key?: 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.common.zookeeper.ZkConfigImpl;
|
||||||
import com.xiaojukeji.kafka.manager.dao.ControllerDao;
|
import com.xiaojukeji.kafka.manager.dao.ControllerDao;
|
||||||
import com.xiaojukeji.kafka.manager.common.utils.jmx.JmxConnectorWrap;
|
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.service.JmxService;
|
||||||
import com.xiaojukeji.kafka.manager.service.utils.ConfigUtils;
|
|
||||||
import com.xiaojukeji.kafka.manager.service.zookeeper.*;
|
import com.xiaojukeji.kafka.manager.service.zookeeper.*;
|
||||||
import com.xiaojukeji.kafka.manager.service.service.ClusterService;
|
import com.xiaojukeji.kafka.manager.service.service.ClusterService;
|
||||||
import com.xiaojukeji.kafka.manager.common.zookeeper.ZkPathUtil;
|
import com.xiaojukeji.kafka.manager.common.zookeeper.ZkPathUtil;
|
||||||
@@ -49,15 +46,6 @@ public class PhysicalClusterMetadataManager {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ClusterService clusterService;
|
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, ClusterDO> CLUSTER_MAP = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
private final static Map<Long, ControllerData> CONTROLLER_DATA_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);
|
zkConfig.watchChildren(ZkPathUtil.BROKER_IDS_ROOT, brokerListener);
|
||||||
|
|
||||||
//增加Topic监控
|
//增加Topic监控
|
||||||
TopicStateListener topicListener = new TopicStateListener(clusterDO.getId(), zkConfig, topicDao, authorityDao);
|
TopicStateListener topicListener = new TopicStateListener(clusterDO.getId(), zkConfig);
|
||||||
topicListener.init();
|
topicListener.init();
|
||||||
zkConfig.watchChildren(ZkPathUtil.BROKER_TOPICS_ROOT, topicListener);
|
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.ResultStatus;
|
||||||
import com.xiaojukeji.kafka.manager.common.entity.ao.ClusterDetailDTO;
|
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.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.vo.normal.cluster.ClusterNameDTO;
|
||||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.ClusterDO;
|
import com.xiaojukeji.kafka.manager.common.entity.pojo.ClusterDO;
|
||||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.ClusterMetricsDO;
|
import com.xiaojukeji.kafka.manager.common.entity.pojo.ClusterMetricsDO;
|
||||||
@@ -51,4 +52,20 @@ public interface ClusterService {
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
Result<List<ControllerPreferredCandidate>> getControllerPreferredCandidates(Long clusterId);
|
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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,4 +26,20 @@ public interface ZookeeperService {
|
|||||||
* @return 操作结果
|
* @return 操作结果
|
||||||
*/
|
*/
|
||||||
Result<List<Integer>> getControllerPreferredCandidates(Long clusterId);
|
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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -221,13 +221,24 @@ public class GatewayConfigServiceImpl implements GatewayConfigService {
|
|||||||
if (ValidateUtils.isNull(oldGatewayConfigDO)) {
|
if (ValidateUtils.isNull(oldGatewayConfigDO)) {
|
||||||
return Result.buildFrom(ResultStatus.RESOURCE_NOT_EXIST);
|
return Result.buildFrom(ResultStatus.RESOURCE_NOT_EXIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!oldGatewayConfigDO.getName().equals(newGatewayConfigDO.getName())
|
if (!oldGatewayConfigDO.getName().equals(newGatewayConfigDO.getName())
|
||||||
|| !oldGatewayConfigDO.getType().equals(newGatewayConfigDO.getType())
|
|| !oldGatewayConfigDO.getType().equals(newGatewayConfigDO.getType())
|
||||||
|| ValidateUtils.isBlank(newGatewayConfigDO.getValue())) {
|
|| ValidateUtils.isBlank(newGatewayConfigDO.getValue())) {
|
||||||
return Result.buildFrom(ResultStatus.PARAM_ILLEGAL);
|
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.buildSuc();
|
||||||
}
|
}
|
||||||
return Result.buildFrom(ResultStatus.MYSQL_ERROR);
|
return Result.buildFrom(ResultStatus.MYSQL_ERROR);
|
||||||
|
|||||||
@@ -111,12 +111,13 @@ public class ClusterServiceImpl implements ClusterService {
|
|||||||
// 不允许修改zk地址
|
// 不允许修改zk地址
|
||||||
return ResultStatus.CHANGE_ZOOKEEPER_FORBIDDEN;
|
return ResultStatus.CHANGE_ZOOKEEPER_FORBIDDEN;
|
||||||
}
|
}
|
||||||
clusterDO.setStatus(originClusterDO.getStatus());
|
|
||||||
Map<String, String> content = new HashMap<>();
|
Map<String, String> content = new HashMap<>();
|
||||||
content.put("cluster id", clusterDO.getId().toString());
|
content.put("cluster id", clusterDO.getId().toString());
|
||||||
content.put("security properties", clusterDO.getSecurityProperties());
|
content.put("security properties", clusterDO.getSecurityProperties());
|
||||||
content.put("jmx properties", clusterDO.getJmxProperties());
|
content.put("jmx properties", clusterDO.getJmxProperties());
|
||||||
operateRecordService.insert(operator, ModuleEnum.CLUSTER, clusterDO.getClusterName(), OperateEnum.EDIT, content);
|
operateRecordService.insert(operator, ModuleEnum.CLUSTER, clusterDO.getClusterName(), OperateEnum.EDIT, content);
|
||||||
|
|
||||||
|
clusterDO.setStatus(originClusterDO.getStatus());
|
||||||
return updateById(clusterDO);
|
return updateById(clusterDO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,7 +215,7 @@ public class ClusterServiceImpl implements ClusterService {
|
|||||||
if (zk != null) {
|
if (zk != null) {
|
||||||
zk.close();
|
zk.close();
|
||||||
}
|
}
|
||||||
} catch (Throwable t) {
|
} catch (Exception e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -275,7 +276,7 @@ public class ClusterServiceImpl implements ClusterService {
|
|||||||
try {
|
try {
|
||||||
Map<String, String> content = new HashMap<>();
|
Map<String, String> content = new HashMap<>();
|
||||||
content.put("cluster id", clusterId.toString());
|
content.put("cluster id", clusterId.toString());
|
||||||
operateRecordService.insert(operator, ModuleEnum.CLUSTER, getClusterName(clusterId).getPhysicalClusterName(), OperateEnum.DELETE, content);
|
operateRecordService.insert(operator, ModuleEnum.CLUSTER, String.valueOf(clusterId), OperateEnum.DELETE, content);
|
||||||
if (clusterDao.deleteById(clusterId) <= 0) {
|
if (clusterDao.deleteById(clusterId) <= 0) {
|
||||||
LOGGER.error("delete cluster failed, clusterId:{}.", clusterId);
|
LOGGER.error("delete cluster failed, clusterId:{}.", clusterId);
|
||||||
return ResultStatus.MYSQL_ERROR;
|
return ResultStatus.MYSQL_ERROR;
|
||||||
@@ -289,8 +290,9 @@ public class ClusterServiceImpl implements ClusterService {
|
|||||||
|
|
||||||
private ClusterDetailDTO getClusterDetailDTO(ClusterDO clusterDO, Boolean needDetail) {
|
private ClusterDetailDTO getClusterDetailDTO(ClusterDO clusterDO, Boolean needDetail) {
|
||||||
if (ValidateUtils.isNull(clusterDO)) {
|
if (ValidateUtils.isNull(clusterDO)) {
|
||||||
return null;
|
return new ClusterDetailDTO();
|
||||||
}
|
}
|
||||||
|
|
||||||
ClusterDetailDTO dto = new ClusterDetailDTO();
|
ClusterDetailDTO dto = new ClusterDetailDTO();
|
||||||
dto.setClusterId(clusterDO.getId());
|
dto.setClusterId(clusterDO.getId());
|
||||||
dto.setClusterName(clusterDO.getClusterName());
|
dto.setClusterName(clusterDO.getClusterName());
|
||||||
@@ -299,6 +301,7 @@ public class ClusterServiceImpl implements ClusterService {
|
|||||||
dto.setKafkaVersion(physicalClusterMetadataManager.getKafkaVersionFromCache(clusterDO.getId()));
|
dto.setKafkaVersion(physicalClusterMetadataManager.getKafkaVersionFromCache(clusterDO.getId()));
|
||||||
dto.setIdc(configUtils.getIdc());
|
dto.setIdc(configUtils.getIdc());
|
||||||
dto.setSecurityProperties(clusterDO.getSecurityProperties());
|
dto.setSecurityProperties(clusterDO.getSecurityProperties());
|
||||||
|
dto.setJmxProperties(clusterDO.getJmxProperties());
|
||||||
dto.setStatus(clusterDO.getStatus());
|
dto.setStatus(clusterDO.getStatus());
|
||||||
dto.setGmtCreate(clusterDO.getGmtCreate());
|
dto.setGmtCreate(clusterDO.getGmtCreate());
|
||||||
dto.setGmtModify(clusterDO.getGmtModify());
|
dto.setGmtModify(clusterDO.getGmtModify());
|
||||||
@@ -337,4 +340,39 @@ public class ClusterServiceImpl implements ClusterService {
|
|||||||
}
|
}
|
||||||
return Result.buildSuc(controllerPreferredCandidateList);
|
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());
|
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()) {
|
while (it.hasNext()) {
|
||||||
List<AdminClient.ConsumerSummary> consumerSummaryList = JavaConversions.asJavaList(it.next());
|
List<AdminClient.ConsumerSummary> consumerSummaryList = JavaConversions.asJavaList(it.next());
|
||||||
for (AdminClient.ConsumerSummary consumerSummary: consumerSummaryList) {
|
for (AdminClient.ConsumerSummary consumerSummary: consumerSummaryList) {
|
||||||
|
|||||||
@@ -70,4 +70,58 @@ public class ZookeeperServiceImpl implements ZookeeperService {
|
|||||||
}
|
}
|
||||||
return Result.buildFrom(ResultStatus.ZOOKEEPER_READ_FAILED);
|
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(
|
AdminUtils.assignReplicasToBrokers(
|
||||||
convert2BrokerMetadataSeq(brokerIdList),
|
convert2BrokerMetadataSeq(brokerIdList),
|
||||||
partitionNum,
|
partitionNum,
|
||||||
@@ -177,7 +177,7 @@ public class TopicCommands {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
Map<TopicAndPartition, scala.collection.Seq<Object>> existingAssignJavaMap =
|
Map<TopicAndPartition, Seq<Object>> existingAssignJavaMap =
|
||||||
JavaConversions.asJavaMap(existingAssignScalaMap);
|
JavaConversions.asJavaMap(existingAssignScalaMap);
|
||||||
// 新增分区的分配策略和旧的分配策略合并
|
// 新增分区的分配策略和旧的分配策略合并
|
||||||
Map<Object, Seq<Object>> targetMap = new HashMap<>();
|
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.StateChangeListener;
|
||||||
import com.xiaojukeji.kafka.manager.common.zookeeper.ZkConfigImpl;
|
import com.xiaojukeji.kafka.manager.common.zookeeper.ZkConfigImpl;
|
||||||
import com.xiaojukeji.kafka.manager.common.zookeeper.ZkPathUtil;
|
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.PhysicalClusterMetadataManager;
|
||||||
import com.xiaojukeji.kafka.manager.service.cache.ThreadPool;
|
import com.xiaojukeji.kafka.manager.service.cache.ThreadPool;
|
||||||
import org.apache.zookeeper.data.Stat;
|
import org.apache.zookeeper.data.Stat;
|
||||||
@@ -24,28 +22,17 @@ import java.util.concurrent.*;
|
|||||||
* @date 20/5/14
|
* @date 20/5/14
|
||||||
*/
|
*/
|
||||||
public class TopicStateListener implements StateChangeListener {
|
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 Long clusterId;
|
||||||
|
|
||||||
private ZkConfigImpl zkConfig;
|
private ZkConfigImpl zkConfig;
|
||||||
|
|
||||||
private TopicDao topicDao;
|
|
||||||
|
|
||||||
private AuthorityDao authorityDao;
|
|
||||||
|
|
||||||
public TopicStateListener(Long clusterId, ZkConfigImpl zkConfig) {
|
public TopicStateListener(Long clusterId, ZkConfigImpl zkConfig) {
|
||||||
this.clusterId = clusterId;
|
this.clusterId = clusterId;
|
||||||
this.zkConfig = zkConfig;
|
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
|
@Override
|
||||||
public void init() {
|
public void init() {
|
||||||
try {
|
try {
|
||||||
@@ -53,7 +40,7 @@ public class TopicStateListener implements StateChangeListener {
|
|||||||
FutureTask[] taskList = new FutureTask[topicNameList.size()];
|
FutureTask[] taskList = new FutureTask[topicNameList.size()];
|
||||||
for (int i = 0; i < topicNameList.size(); i++) {
|
for (int i = 0; i < topicNameList.size(); i++) {
|
||||||
String topicName = topicNameList.get(i);
|
String topicName = topicNameList.get(i);
|
||||||
taskList[i] = new FutureTask(new Callable() {
|
taskList[i] = new FutureTask(new Callable<Object>() {
|
||||||
@Override
|
@Override
|
||||||
public Object call() throws Exception {
|
public Object call() throws Exception {
|
||||||
processTopicAdded(topicName);
|
processTopicAdded(topicName);
|
||||||
@@ -65,7 +52,6 @@ public class TopicStateListener implements StateChangeListener {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("init topics metadata failed, clusterId:{}.", clusterId, e);
|
LOGGER.error("init topics metadata failed, clusterId:{}.", clusterId, e);
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -92,8 +78,6 @@ public class TopicStateListener implements StateChangeListener {
|
|||||||
private void processTopicDelete(String topicName) {
|
private void processTopicDelete(String topicName) {
|
||||||
LOGGER.warn("delete topic, clusterId:{} topicName:{}.", clusterId, topicName);
|
LOGGER.warn("delete topic, clusterId:{} topicName:{}.", clusterId, topicName);
|
||||||
PhysicalClusterMetadataManager.removeTopicMetadata(clusterId, topicName);
|
PhysicalClusterMetadataManager.removeTopicMetadata(clusterId, topicName);
|
||||||
topicDao.removeTopicInCache(clusterId, topicName);
|
|
||||||
authorityDao.removeAuthorityInCache(clusterId, topicName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processTopicAdded(String topicName) {
|
private void processTopicAdded(String topicName) {
|
||||||
|
|||||||
@@ -22,6 +22,4 @@ public interface TopicDao {
|
|||||||
List<TopicDO> listAll();
|
List<TopicDO> listAll();
|
||||||
|
|
||||||
TopicDO getTopic(Long clusterId, String topicName, String appId);
|
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 insert(AppDO appDO);
|
||||||
|
|
||||||
int insertIgnoreGatewayDB(AppDO appDO);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除appId
|
* 删除appId
|
||||||
* @param appName App名称
|
* @param appName App名称
|
||||||
@@ -60,6 +58,4 @@ public interface AppDao {
|
|||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
int updateById(AppDO appDO);
|
int updateById(AppDO appDO);
|
||||||
|
|
||||||
List<AppDO> listNewAll();
|
|
||||||
}
|
}
|
||||||
@@ -15,8 +15,6 @@ public interface AuthorityDao {
|
|||||||
*/
|
*/
|
||||||
int insert(AuthorityDO authorityDO);
|
int insert(AuthorityDO authorityDO);
|
||||||
|
|
||||||
int replaceIgnoreGatewayDB(AuthorityDO authorityDO);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取权限
|
* 获取权限
|
||||||
* @param clusterId 集群id
|
* @param clusterId 集群id
|
||||||
@@ -38,7 +36,5 @@ public interface AuthorityDao {
|
|||||||
|
|
||||||
Map<String, Map<Long, Map<String, AuthorityDO>>> getAllAuthority();
|
Map<String, Map<Long, Map<String, AuthorityDO>>> getAllAuthority();
|
||||||
|
|
||||||
void removeAuthorityInCache(Long clusterId, String topicName);
|
|
||||||
|
|
||||||
int deleteAuthorityByTopic(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.common.entity.pojo.gateway.AppDO;
|
||||||
import com.xiaojukeji.kafka.manager.dao.gateway.AppDao;
|
import com.xiaojukeji.kafka.manager.dao.gateway.AppDao;
|
||||||
|
import com.xiaojukeji.kafka.manager.task.Constant;
|
||||||
import org.mybatis.spring.SqlSessionTemplate;
|
import org.mybatis.spring.SqlSessionTemplate;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
@@ -21,7 +22,7 @@ public class AppDaoImpl implements AppDao {
|
|||||||
/**
|
/**
|
||||||
* APP最近的一次更新时间, 更新之后的缓存
|
* 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<>();
|
private static final Map<String, AppDO> APP_MAP = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -29,11 +30,6 @@ public class AppDaoImpl implements AppDao {
|
|||||||
return sqlSession.insert("AppDao.insert", appDO);
|
return sqlSession.insert("AppDao.insert", appDO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int insertIgnoreGatewayDB(AppDO appDO) {
|
|
||||||
return sqlSession.insert("AppDao.insert", appDO);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int deleteByName(String appName) {
|
public int deleteByName(String appName) {
|
||||||
return sqlSession.delete("AppDao.deleteByName", appName);
|
return sqlSession.delete("AppDao.deleteByName", appName);
|
||||||
@@ -66,7 +62,12 @@ public class AppDaoImpl implements AppDao {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateTopicCache() {
|
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);
|
Date afterTime = new Date(APP_CACHE_LATEST_UPDATE_TIME);
|
||||||
List<AppDO> doList = sqlSession.selectList("AppDao.listAfterTime", afterTime);
|
List<AppDO> doList = sqlSession.selectList("AppDao.listAfterTime", afterTime);
|
||||||
@@ -76,19 +77,22 @@ public class AppDaoImpl implements AppDao {
|
|||||||
/**
|
/**
|
||||||
* 更新APP缓存
|
* 更新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) {
|
if (doList == null || doList.isEmpty() || APP_CACHE_LATEST_UPDATE_TIME >= timestamp) {
|
||||||
// 本次无数据更新, 或者本次更新过时 时, 忽略本次更新
|
// 本次无数据更新, 或者本次更新过时 时, 忽略本次更新
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (APP_CACHE_LATEST_UPDATE_TIME == Constant.START_TIMESTAMP) {
|
||||||
|
APP_MAP.clear();
|
||||||
|
}
|
||||||
|
|
||||||
for (AppDO elem: doList) {
|
for (AppDO elem: doList) {
|
||||||
APP_MAP.put(elem.getAppId(), elem);
|
APP_MAP.put(elem.getAppId(), elem);
|
||||||
}
|
}
|
||||||
APP_CACHE_LATEST_UPDATE_TIME = timestamp;
|
APP_CACHE_LATEST_UPDATE_TIME = timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public static void resetCache() {
|
||||||
public List<AppDO> listNewAll() {
|
APP_CACHE_LATEST_UPDATE_TIME = Constant.START_TIMESTAMP;
|
||||||
return sqlSession.selectList("AppDao.listNewAll");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package com.xiaojukeji.kafka.manager.dao.gateway.impl;
|
package com.xiaojukeji.kafka.manager.dao.gateway.impl;
|
||||||
|
|
||||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.AuthorityDO;
|
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.dao.gateway.AuthorityDao;
|
||||||
|
import com.xiaojukeji.kafka.manager.task.Constant;
|
||||||
import org.mybatis.spring.SqlSessionTemplate;
|
import org.mybatis.spring.SqlSessionTemplate;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
@@ -23,7 +23,8 @@ public class AuthorityDaoImpl implements AuthorityDao {
|
|||||||
* Authority最近的一次更新时间, 更新之后的缓存
|
* Authority最近的一次更新时间, 更新之后的缓存
|
||||||
* <AppID, <clusterId, <TopicName, AuthorityDO>>>
|
* <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<>();
|
private static final Map<String, Map<Long, Map<String, AuthorityDO>>> AUTHORITY_MAP = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -31,11 +32,6 @@ public class AuthorityDaoImpl implements AuthorityDao {
|
|||||||
return sqlSession.insert("AuthorityDao.replace", authorityDO);
|
return sqlSession.insert("AuthorityDao.replace", authorityDO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int replaceIgnoreGatewayDB(AuthorityDO authorityDO) {
|
|
||||||
return sqlSession.insert("AuthorityDao.replace", authorityDO);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<AuthorityDO> getAuthority(Long clusterId, String topicName, String appId) {
|
public List<AuthorityDO> getAuthority(Long clusterId, String topicName, String appId) {
|
||||||
Map<String, Object> params = new HashMap<>(3);
|
Map<String, Object> params = new HashMap<>(3);
|
||||||
@@ -62,8 +58,8 @@ public class AuthorityDaoImpl implements AuthorityDao {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<AuthorityDO> authorityDOList = new ArrayList<>();
|
List<AuthorityDO> authorityDOList = new ArrayList<>();
|
||||||
for (Long clusterId: doMap.keySet()) {
|
for (Map.Entry<Long, Map<String, AuthorityDO>> entry: doMap.entrySet()) {
|
||||||
authorityDOList.addAll(doMap.get(clusterId).values());
|
authorityDOList.addAll(entry.getValue().values());
|
||||||
}
|
}
|
||||||
return authorityDOList;
|
return authorityDOList;
|
||||||
}
|
}
|
||||||
@@ -87,23 +83,6 @@ public class AuthorityDaoImpl implements AuthorityDao {
|
|||||||
return AUTHORITY_MAP;
|
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
|
@Override
|
||||||
public int deleteAuthorityByTopic(Long clusterId, String topicName) {
|
public int deleteAuthorityByTopic(Long clusterId, String topicName) {
|
||||||
Map<String, Object> params = new HashMap<>(2);
|
Map<String, Object> params = new HashMap<>(2);
|
||||||
@@ -116,6 +95,11 @@ public class AuthorityDaoImpl implements AuthorityDao {
|
|||||||
private void updateAuthorityCache() {
|
private void updateAuthorityCache() {
|
||||||
Long timestamp = System.currentTimeMillis();
|
Long timestamp = System.currentTimeMillis();
|
||||||
|
|
||||||
|
if (timestamp + 1000 <= AUTHORITY_CACHE_LATEST_UPDATE_TIME) {
|
||||||
|
// 近一秒内的请求不走db
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Date afterTime = new Date(AUTHORITY_CACHE_LATEST_UPDATE_TIME);
|
Date afterTime = new Date(AUTHORITY_CACHE_LATEST_UPDATE_TIME);
|
||||||
List<AuthorityDO> doList = sqlSession.selectList("AuthorityDao.listAfterTime", afterTime);
|
List<AuthorityDO> doList = sqlSession.selectList("AuthorityDao.listAfterTime", afterTime);
|
||||||
updateAuthorityCache(doList, timestamp);
|
updateAuthorityCache(doList, timestamp);
|
||||||
@@ -124,11 +108,15 @@ public class AuthorityDaoImpl implements AuthorityDao {
|
|||||||
/**
|
/**
|
||||||
* 更新Topic缓存
|
* 更新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) {
|
if (doList == null || doList.isEmpty() || AUTHORITY_CACHE_LATEST_UPDATE_TIME >= timestamp) {
|
||||||
// 本次无数据更新, 或者本次更新过时 时, 忽略本次更新
|
// 本次无数据更新, 或者本次更新过时 时, 忽略本次更新
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (AUTHORITY_CACHE_LATEST_UPDATE_TIME == Constant.START_TIMESTAMP) {
|
||||||
|
AUTHORITY_MAP.clear();
|
||||||
|
}
|
||||||
|
|
||||||
for (AuthorityDO elem: doList) {
|
for (AuthorityDO elem: doList) {
|
||||||
Map<Long, Map<String, AuthorityDO>> doMap =
|
Map<Long, Map<String, AuthorityDO>> doMap =
|
||||||
AUTHORITY_MAP.getOrDefault(elem.getAppId(), new ConcurrentHashMap<>());
|
AUTHORITY_MAP.getOrDefault(elem.getAppId(), new ConcurrentHashMap<>());
|
||||||
@@ -139,4 +127,8 @@ public class AuthorityDaoImpl implements AuthorityDao {
|
|||||||
}
|
}
|
||||||
AUTHORITY_CACHE_LATEST_UPDATE_TIME = timestamp;
|
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.common.entity.pojo.TopicDO;
|
||||||
import com.xiaojukeji.kafka.manager.dao.TopicDao;
|
import com.xiaojukeji.kafka.manager.dao.TopicDao;
|
||||||
|
import com.xiaojukeji.kafka.manager.task.Constant;
|
||||||
import org.mybatis.spring.SqlSessionTemplate;
|
import org.mybatis.spring.SqlSessionTemplate;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
@@ -18,7 +19,8 @@ public class TopicDaoImpl implements TopicDao {
|
|||||||
/**
|
/**
|
||||||
* Topic最近的一次更新时间, 更新之后的缓存
|
* 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<>();
|
private static final Map<Long, Map<String, TopicDO>> TOPIC_MAP = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -62,7 +64,7 @@ public class TopicDaoImpl implements TopicDao {
|
|||||||
@Override
|
@Override
|
||||||
public List<TopicDO> getByClusterId(Long clusterId) {
|
public List<TopicDO> getByClusterId(Long clusterId) {
|
||||||
updateTopicCache();
|
updateTopicCache();
|
||||||
return new ArrayList<>(TOPIC_MAP.getOrDefault(clusterId, new ConcurrentHashMap<>(0)).values());
|
return new ArrayList<>(TOPIC_MAP.getOrDefault(clusterId, Collections.emptyMap()).values());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -75,28 +77,28 @@ public class TopicDaoImpl implements TopicDao {
|
|||||||
updateTopicCache();
|
updateTopicCache();
|
||||||
List<TopicDO> doList = new ArrayList<>();
|
List<TopicDO> doList = new ArrayList<>();
|
||||||
for (Long clusterId: TOPIC_MAP.keySet()) {
|
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;
|
return doList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TopicDO getTopic(Long clusterId, String topicName, String appId) {
|
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("clusterId", clusterId);
|
||||||
params.put("topicName", topicName);
|
params.put("topicName", topicName);
|
||||||
params.put("appId", appId);
|
params.put("appId", appId);
|
||||||
return sqlSession.selectOne("TopicDao.getTopic", params);
|
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() {
|
private void updateTopicCache() {
|
||||||
Long timestamp = System.currentTimeMillis();
|
Long timestamp = System.currentTimeMillis();
|
||||||
|
|
||||||
|
if (timestamp + 1000 <= TOPIC_CACHE_LATEST_UPDATE_TIME) {
|
||||||
|
// 近一秒内的请求不走db
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Date afterTime = new Date(TOPIC_CACHE_LATEST_UPDATE_TIME);
|
Date afterTime = new Date(TOPIC_CACHE_LATEST_UPDATE_TIME);
|
||||||
List<TopicDO> doList = sqlSession.selectList("TopicDao.listAfterTime", afterTime);
|
List<TopicDO> doList = sqlSession.selectList("TopicDao.listAfterTime", afterTime);
|
||||||
updateTopicCache(doList, timestamp);
|
updateTopicCache(doList, timestamp);
|
||||||
@@ -105,11 +107,15 @@ public class TopicDaoImpl implements TopicDao {
|
|||||||
/**
|
/**
|
||||||
* 更新Topic缓存
|
* 更新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) {
|
if (doList == null || doList.isEmpty() || TOPIC_CACHE_LATEST_UPDATE_TIME >= timestamp) {
|
||||||
// 本次无数据更新, 或者本次更新过时 时, 忽略本次更新
|
// 本次无数据更新, 或者本次更新过时 时, 忽略本次更新
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (TOPIC_CACHE_LATEST_UPDATE_TIME == Constant.START_TIMESTAMP) {
|
||||||
|
TOPIC_MAP.clear();
|
||||||
|
}
|
||||||
|
|
||||||
for (TopicDO elem: doList) {
|
for (TopicDO elem: doList) {
|
||||||
Map<String, TopicDO> doMap = TOPIC_MAP.getOrDefault(elem.getClusterId(), new ConcurrentHashMap<>());
|
Map<String, TopicDO> doMap = TOPIC_MAP.getOrDefault(elem.getClusterId(), new ConcurrentHashMap<>());
|
||||||
doMap.put(elem.getTopicName(), elem);
|
doMap.put(elem.getTopicName(), elem);
|
||||||
@@ -117,4 +123,8 @@ public class TopicDaoImpl implements TopicDao {
|
|||||||
}
|
}
|
||||||
TOPIC_CACHE_LATEST_UPDATE_TIME = timestamp;
|
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="name" property="name" />
|
||||||
<result column="value" property="value" />
|
<result column="value" property="value" />
|
||||||
<result column="version" property="version" />
|
<result column="version" property="version" />
|
||||||
|
<result column="description" property="description" />
|
||||||
<result column="create_time" property="createTime" />
|
<result column="create_time" property="createTime" />
|
||||||
<result column="modify_time" property="modifyTime" />
|
<result column="modify_time" property="modifyTime" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
@@ -27,9 +28,9 @@
|
|||||||
<insert id="insert" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.GatewayConfigDO">
|
<insert id="insert" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.GatewayConfigDO">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
INSERT INTO gateway_config
|
INSERT INTO gateway_config
|
||||||
(`type`, name, value, version)
|
(`type`, name, value, version, description)
|
||||||
VALUES
|
VALUES
|
||||||
(#{type}, #{name}, #{value}, #{version})
|
(#{type}, #{name}, #{value}, #{version}, #{description})
|
||||||
]]>
|
]]>
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
@@ -45,7 +46,8 @@
|
|||||||
`type`=#{type},
|
`type`=#{type},
|
||||||
`name`=#{name},
|
`name`=#{name},
|
||||||
`value`=#{value},
|
`value`=#{value},
|
||||||
`version`=#{version}
|
`version`=#{version},
|
||||||
|
`description`=#{description}
|
||||||
WHERE id=#{id}
|
WHERE id=#{id}
|
||||||
]]>
|
]]>
|
||||||
</update>
|
</update>
|
||||||
|
|||||||
@@ -18,6 +18,9 @@ public class OrderExtensionAddGatewayConfigDTO {
|
|||||||
@ApiModelProperty(value = "值")
|
@ApiModelProperty(value = "值")
|
||||||
private String value;
|
private String value;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "描述说明")
|
||||||
|
private String description;
|
||||||
|
|
||||||
public String getType() {
|
public String getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
@@ -42,12 +45,21 @@ public class OrderExtensionAddGatewayConfigDTO {
|
|||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "OrderExtensionAddGatewayConfigDTO{" +
|
return "OrderExtensionAddGatewayConfigDTO{" +
|
||||||
"type='" + type + '\'' +
|
"type='" + type + '\'' +
|
||||||
", name='" + name + '\'' +
|
", name='" + name + '\'' +
|
||||||
", value='" + value + '\'' +
|
", value='" + value + '\'' +
|
||||||
|
", description='" + description + '\'' +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,9 @@ public class OrderExtensionModifyGatewayConfigDTO {
|
|||||||
@ApiModelProperty(value = "值")
|
@ApiModelProperty(value = "值")
|
||||||
private String value;
|
private String value;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "描述说明")
|
||||||
|
private String description;
|
||||||
|
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
@@ -55,6 +58,14 @@ public class OrderExtensionModifyGatewayConfigDTO {
|
|||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "OrderExtensionModifyGatewayConfigDTO{" +
|
return "OrderExtensionModifyGatewayConfigDTO{" +
|
||||||
@@ -62,6 +73,7 @@ public class OrderExtensionModifyGatewayConfigDTO {
|
|||||||
", type='" + type + '\'' +
|
", type='" + type + '\'' +
|
||||||
", name='" + name + '\'' +
|
", name='" + name + '\'' +
|
||||||
", value='" + value + '\'' +
|
", value='" + value + '\'' +
|
||||||
|
", description='" + description + '\'' +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
* @date 20/4/26
|
||||||
*/
|
*/
|
||||||
public enum ClusterTaskActionEnum {
|
public enum ClusterTaskActionEnum {
|
||||||
START(0, "start"),
|
UNKNOWN("unknown"),
|
||||||
PAUSE(1, "pause"),
|
|
||||||
IGNORE(2, "ignore"),
|
START("start"),
|
||||||
CANCEL(3, "cancel"),
|
PAUSE("pause"),
|
||||||
ROLLBACK(4, "rollback"),
|
|
||||||
|
IGNORE("ignore"),
|
||||||
|
CANCEL("cancel"),
|
||||||
|
|
||||||
|
REDO("redo"),
|
||||||
|
KILL("kill"),
|
||||||
|
|
||||||
|
ROLLBACK("rollback"),
|
||||||
|
|
||||||
;
|
;
|
||||||
private Integer code;
|
|
||||||
|
|
||||||
private String message;
|
private String action;
|
||||||
|
|
||||||
ClusterTaskActionEnum(Integer code, String message) {
|
ClusterTaskActionEnum(String action) {
|
||||||
this.code = code;
|
this.action = action;
|
||||||
this.message = message;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getCode() {
|
public String getAction() {
|
||||||
return code;
|
return action;
|
||||||
}
|
|
||||||
|
|
||||||
public String getMessage() {
|
|
||||||
return message;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "TaskActionEnum{" +
|
return "ClusterTaskActionEnum{" +
|
||||||
"code=" + code +
|
"action='" + action + '\'' +
|
||||||
", message='" + message + '\'' +
|
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.xiaojukeji.kafka.manager.kcm.common.entry.ao;
|
package com.xiaojukeji.kafka.manager.kcm.common.entry.ao;
|
||||||
|
|
||||||
|
import com.xiaojukeji.kafka.manager.common.entity.Result;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -119,7 +121,7 @@ public class CreationTaskData {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "CreationTaskDTO{" +
|
return "CreationTaskData{" +
|
||||||
"uuid='" + uuid + '\'' +
|
"uuid='" + uuid + '\'' +
|
||||||
", clusterId=" + clusterId +
|
", clusterId=" + clusterId +
|
||||||
", hostList=" + hostList +
|
", hostList=" + hostList +
|
||||||
|
|||||||
@@ -1,9 +1,18 @@
|
|||||||
package com.xiaojukeji.kafka.manager.kcm.component.agent;
|
package com.xiaojukeji.kafka.manager.kcm.component.agent;
|
||||||
|
|
||||||
|
import com.xiaojukeji.kafka.manager.common.entity.Result;
|
||||||
|
import com.xiaojukeji.kafka.manager.kcm.common.bizenum.ClusterTaskActionEnum;
|
||||||
import com.xiaojukeji.kafka.manager.kcm.common.bizenum.ClusterTaskStateEnum;
|
import com.xiaojukeji.kafka.manager.kcm.common.bizenum.ClusterTaskStateEnum;
|
||||||
import com.xiaojukeji.kafka.manager.kcm.common.bizenum.ClusterTaskSubStateEnum;
|
import com.xiaojukeji.kafka.manager.kcm.common.bizenum.ClusterTaskSubStateEnum;
|
||||||
|
import com.xiaojukeji.kafka.manager.kcm.common.entry.ao.ClusterTaskLog;
|
||||||
import com.xiaojukeji.kafka.manager.kcm.common.entry.ao.CreationTaskData;
|
import com.xiaojukeji.kafka.manager.kcm.common.entry.ao.CreationTaskData;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
@@ -13,33 +22,79 @@ import java.util.Map;
|
|||||||
* @date 20/4/26
|
* @date 20/4/26
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractAgent {
|
public abstract class AbstractAgent {
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractAgent.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建任务
|
* 创建任务
|
||||||
|
* @param creationTaskData 创建任务参数
|
||||||
|
* @return 任务ID
|
||||||
*/
|
*/
|
||||||
public abstract Long createTask(CreationTaskData dto);
|
public abstract Result<Long> createTask(CreationTaskData creationTaskData);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 任务动作
|
* 执行任务
|
||||||
|
* @param taskId 任务ID
|
||||||
|
* @param actionEnum 执行动作
|
||||||
|
* @return true:触发成功, false:触发失败
|
||||||
*/
|
*/
|
||||||
public abstract Boolean actionTask(Long taskId, String action);
|
public abstract boolean actionTask(Long taskId, ClusterTaskActionEnum actionEnum);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 任务动作
|
* 执行任务
|
||||||
|
* @param taskId 任务ID
|
||||||
|
* @param actionEnum 执行动作
|
||||||
|
* @param hostname 具体主机
|
||||||
|
* @return true:触发成功, false:触发失败
|
||||||
*/
|
*/
|
||||||
public abstract Boolean actionHostTask(Long taskId, String action, String hostname);
|
public abstract boolean actionHostTask(Long taskId, ClusterTaskActionEnum actionEnum, String hostname);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取任务状态
|
* 获取任务运行的状态[阻塞, 执行中, 完成等]
|
||||||
|
* @param taskId 任务ID
|
||||||
|
* @return 任务状态
|
||||||
*/
|
*/
|
||||||
public abstract ClusterTaskStateEnum getTaskState(Long agentTaskId);
|
public abstract Result<ClusterTaskStateEnum> getTaskExecuteState(Long taskId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取任务结果
|
* 获取任务结果
|
||||||
|
* @param taskId 任务ID
|
||||||
|
* @return 任务结果
|
||||||
*/
|
*/
|
||||||
public abstract Map<String, ClusterTaskSubStateEnum> getTaskResult(Long taskId);
|
public abstract Result<Map<String, ClusterTaskSubStateEnum>> getTaskResult(Long taskId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取任务日志
|
* 获取任务执行日志
|
||||||
|
* @param taskId 任务ID
|
||||||
|
* @param hostname 具体主机
|
||||||
|
* @return 机器运行日志
|
||||||
*/
|
*/
|
||||||
public abstract String getTaskLog(Long agentTaskId, String hostname);
|
public abstract Result<ClusterTaskLog> getTaskLog(Long taskId, String hostname);
|
||||||
|
|
||||||
|
protected static String readScriptInJarFile(String fileName) {
|
||||||
|
InputStream inputStream = AbstractAgent.class.getClassLoader().getResourceAsStream(fileName);
|
||||||
|
if (inputStream == null) {
|
||||||
|
LOGGER.error("class=AbstractAgent||method=readScriptInJarFile||fileName={}||msg=read script failed", fileName);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
|
||||||
|
String line = null;
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
while ((line = bufferedReader.readLine()) != null) {
|
||||||
|
sb.append(line).append("\n");
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOGGER.error("class=AbstractAgent||method=readScriptInJarFile||fileName={}||errMsg={}||msg=read script failed", fileName, e.getMessage());
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
inputStream.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
LOGGER.error("class=AbstractAgent||method=readScriptInJarFile||fileName={}||errMsg={}||msg=close reading script failed", fileName, e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,11 @@
|
|||||||
package com.xiaojukeji.kafka.manager.kcm.component.agent.n9e;
|
package com.xiaojukeji.kafka.manager.kcm.component.agent.n9e;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.xiaojukeji.kafka.manager.common.bizenum.KafkaFileEnum;
|
import com.xiaojukeji.kafka.manager.common.bizenum.KafkaFileEnum;
|
||||||
|
import com.xiaojukeji.kafka.manager.common.entity.Result;
|
||||||
|
import com.xiaojukeji.kafka.manager.kcm.common.Constant;
|
||||||
|
import com.xiaojukeji.kafka.manager.kcm.common.bizenum.ClusterTaskActionEnum;
|
||||||
import com.xiaojukeji.kafka.manager.kcm.common.bizenum.ClusterTaskTypeEnum;
|
import com.xiaojukeji.kafka.manager.kcm.common.bizenum.ClusterTaskTypeEnum;
|
||||||
|
import com.xiaojukeji.kafka.manager.kcm.common.entry.ao.ClusterTaskLog;
|
||||||
import com.xiaojukeji.kafka.manager.kcm.common.entry.ao.CreationTaskData;
|
import com.xiaojukeji.kafka.manager.kcm.common.entry.ao.CreationTaskData;
|
||||||
import com.xiaojukeji.kafka.manager.common.utils.HttpUtils;
|
import com.xiaojukeji.kafka.manager.common.utils.HttpUtils;
|
||||||
import com.xiaojukeji.kafka.manager.common.utils.JsonUtils;
|
import com.xiaojukeji.kafka.manager.common.utils.JsonUtils;
|
||||||
@@ -11,20 +14,17 @@ import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
|
|||||||
import com.xiaojukeji.kafka.manager.kcm.common.bizenum.ClusterTaskStateEnum;
|
import com.xiaojukeji.kafka.manager.kcm.common.bizenum.ClusterTaskStateEnum;
|
||||||
import com.xiaojukeji.kafka.manager.kcm.common.bizenum.ClusterTaskSubStateEnum;
|
import com.xiaojukeji.kafka.manager.kcm.common.bizenum.ClusterTaskSubStateEnum;
|
||||||
import com.xiaojukeji.kafka.manager.kcm.component.agent.AbstractAgent;
|
import com.xiaojukeji.kafka.manager.kcm.component.agent.AbstractAgent;
|
||||||
|
import com.xiaojukeji.kafka.manager.kcm.component.agent.n9e.entry.N9eCreationTask;
|
||||||
import com.xiaojukeji.kafka.manager.kcm.component.agent.n9e.entry.N9eResult;
|
import com.xiaojukeji.kafka.manager.kcm.component.agent.n9e.entry.N9eResult;
|
||||||
import com.xiaojukeji.kafka.manager.kcm.component.agent.n9e.entry.N9eTaskResultDTO;
|
import com.xiaojukeji.kafka.manager.kcm.component.agent.n9e.entry.N9eTaskResult;
|
||||||
import com.xiaojukeji.kafka.manager.kcm.component.agent.n9e.entry.N9eTaskStatusEnum;
|
import com.xiaojukeji.kafka.manager.kcm.component.agent.n9e.entry.N9eTaskStdoutLog;
|
||||||
import com.xiaojukeji.kafka.manager.kcm.component.agent.n9e.entry.N9eTaskStdoutDTO;
|
import com.xiaojukeji.kafka.manager.kcm.component.agent.n9e.entry.bizenum.N9eTaskStatusEnum;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -54,16 +54,6 @@ public class N9e extends AbstractAgent {
|
|||||||
|
|
||||||
private String script;
|
private String script;
|
||||||
|
|
||||||
/**
|
|
||||||
* 并发度,顺序执行
|
|
||||||
*/
|
|
||||||
private static final Integer BATCH = 1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 失败的容忍度为0
|
|
||||||
*/
|
|
||||||
private static final Integer TOLERANCE = 0;
|
|
||||||
|
|
||||||
private static final String CREATE_TASK_URI = "/api/job-ce/tasks";
|
private static final String CREATE_TASK_URI = "/api/job-ce/tasks";
|
||||||
|
|
||||||
private static final String ACTION_TASK_URI = "/api/job-ce/task/{taskId}/action";
|
private static final String ACTION_TASK_URI = "/api/job-ce/task/{taskId}/action";
|
||||||
@@ -82,143 +72,134 @@ public class N9e extends AbstractAgent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long createTask(CreationTaskData creationTaskData) {
|
public Result<Long> createTask(CreationTaskData creationTaskData) {
|
||||||
Map<String, Object> param = buildCreateTaskParam(creationTaskData);
|
String content = JsonUtils.toJSONString(buildCreateTaskParam(creationTaskData));
|
||||||
|
|
||||||
String response = null;
|
String response = null;
|
||||||
try {
|
try {
|
||||||
response = HttpUtils.postForString(
|
response = HttpUtils.postForString(baseUrl + CREATE_TASK_URI, content, buildHeader());
|
||||||
baseUrl + CREATE_TASK_URI,
|
N9eResult nr = JsonUtils.stringToObj(response, N9eResult.class);
|
||||||
JsonUtils.toJSONString(param),
|
if (!ValidateUtils.isBlank(nr.getErr())) {
|
||||||
buildHeader()
|
LOGGER.error("class=N9e||method=createTask||param={}||response={}||msg=call create task failed", content, response);
|
||||||
);
|
return Result.buildFailure(nr.getErr());
|
||||||
N9eResult zr = JSON.parseObject(response, N9eResult.class);
|
|
||||||
if (!ValidateUtils.isBlank(zr.getErr())) {
|
|
||||||
LOGGER.warn("class=N9e||method=createTask||param={}||errMsg={}||msg=call create task fail", JsonUtils.toJSONString(param),zr.getErr());
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
return Long.valueOf(zr.getDat().toString());
|
return Result.buildSuc(Long.valueOf(nr.getDat().toString()));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("create task failed, req:{}.", creationTaskData, e);
|
LOGGER.error("class=N9e||method=createTask||param={}||response={}||errMsg={}||msg=call create task failed", content, response, e.getMessage());
|
||||||
}
|
}
|
||||||
return null;
|
return Result.buildFailure("create n9e task failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean actionTask(Long taskId, String action) {
|
public boolean actionTask(Long taskId, ClusterTaskActionEnum actionEnum) {
|
||||||
Map<String, Object> param = new HashMap<>(1);
|
Map<String, Object> param = new HashMap<>(1);
|
||||||
param.put("action", action);
|
param.put("action", actionEnum.getAction());
|
||||||
|
|
||||||
String response = null;
|
String response = null;
|
||||||
try {
|
try {
|
||||||
response = HttpUtils.putForString(
|
response = HttpUtils.putForString(baseUrl + ACTION_TASK_URI.replace("{taskId}", String.valueOf(taskId)), JsonUtils.toJSONString(param), buildHeader());
|
||||||
baseUrl + ACTION_TASK_URI.replace("{taskId}", taskId.toString()),
|
N9eResult nr = JsonUtils.stringToObj(response, N9eResult.class);
|
||||||
JSON.toJSONString(param),
|
if (ValidateUtils.isBlank(nr.getErr())) {
|
||||||
buildHeader()
|
|
||||||
);
|
|
||||||
N9eResult zr = JSON.parseObject(response, N9eResult.class);
|
|
||||||
if (ValidateUtils.isBlank(zr.getErr())) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
LOGGER.warn("class=N9e||method=actionTask||param={}||errMsg={}||msg=call action task fail", JSON.toJSONString(param),zr.getErr());
|
|
||||||
|
LOGGER.error("class=N9e||method=actionTask||param={}||response={}||msg=call action task fail", JsonUtils.toJSONString(param), response);
|
||||||
return false;
|
return false;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("action task failed, taskId:{}, action:{}.", taskId, action, e);
|
LOGGER.error("class=N9e||method=actionTask||param={}||response={}||errMsg={}||msg=call action task fail", JsonUtils.toJSONString(param), response, e.getMessage());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean actionHostTask(Long taskId, String action, String hostname) {
|
public boolean actionHostTask(Long taskId, ClusterTaskActionEnum actionEnum, String hostname) {
|
||||||
Map<String, Object> param = new HashMap<>(2);
|
Map<String, Object> params = new HashMap<>(2);
|
||||||
param.put("action", action);
|
params.put("action", actionEnum.getAction());
|
||||||
param.put("hostname", hostname);
|
params.put("hostname", hostname);
|
||||||
|
|
||||||
String response = null;
|
String response = null;
|
||||||
try {
|
try {
|
||||||
response = HttpUtils.putForString(
|
response = HttpUtils.putForString(baseUrl + ACTION_HOST_TASK_URI.replace("{taskId}", String.valueOf(taskId)), JsonUtils.toJSONString(params), buildHeader());
|
||||||
baseUrl + ACTION_HOST_TASK_URI.replace("{taskId}", taskId.toString()),
|
N9eResult nr = JsonUtils.stringToObj(response, N9eResult.class);
|
||||||
JSON.toJSONString(param),
|
if (ValidateUtils.isBlank(nr.getErr())) {
|
||||||
buildHeader()
|
|
||||||
);
|
|
||||||
N9eResult zr = JSON.parseObject(response, N9eResult.class);
|
|
||||||
if (ValidateUtils.isBlank(zr.getErr())) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
LOGGER.warn("class=N9e||method=actionHostTask||param={}||errMsg={}||msg=call action host task fail", JSON.toJSONString(param),zr.getErr());
|
|
||||||
|
LOGGER.error("class=N9e||method=actionHostTask||params={}||response={}||msg=call action host task fail", JsonUtils.toJSONString(params), response);
|
||||||
return false;
|
return false;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("action task failed, taskId:{} action:{} hostname:{}.", taskId, action, hostname, e);
|
LOGGER.error("class=N9e||method=actionHostTask||params={}||response={}||errMsg={}||msg=call action host task fail", JsonUtils.toJSONString(params), response, e.getMessage());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ClusterTaskStateEnum getTaskState(Long agentTaskId) {
|
public Result<ClusterTaskStateEnum> getTaskExecuteState(Long taskId) {
|
||||||
String response = null;
|
String response = null;
|
||||||
try {
|
try {
|
||||||
// 获取任务的state
|
// 获取任务的state
|
||||||
response = HttpUtils.get(
|
response = HttpUtils.get(baseUrl + TASK_STATE_URI.replace("{taskId}", String.valueOf(taskId)), null);
|
||||||
baseUrl + TASK_STATE_URI.replace("{taskId}", agentTaskId.toString()), null
|
N9eResult nr = JsonUtils.stringToObj(response, N9eResult.class);
|
||||||
);
|
if (!ValidateUtils.isBlank(nr.getErr())) {
|
||||||
N9eResult n9eResult = JSON.parseObject(response, N9eResult.class);
|
return Result.buildFailure(nr.getErr());
|
||||||
if (!ValidateUtils.isBlank(n9eResult.getErr())) {
|
|
||||||
LOGGER.error("get response result failed, agentTaskId:{} response:{}.", agentTaskId, response);
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
String state = JSON.parseObject(JSON.toJSONString(n9eResult.getDat()), String.class);
|
|
||||||
|
String state = JsonUtils.stringToObj(JsonUtils.toJSONString(nr.getDat()), String.class);
|
||||||
|
|
||||||
N9eTaskStatusEnum n9eTaskStatusEnum = N9eTaskStatusEnum.getByMessage(state);
|
N9eTaskStatusEnum n9eTaskStatusEnum = N9eTaskStatusEnum.getByMessage(state);
|
||||||
if (ValidateUtils.isNull(n9eTaskStatusEnum)) {
|
if (ValidateUtils.isNull(n9eTaskStatusEnum)) {
|
||||||
LOGGER.error("get task status failed, agentTaskId:{} state:{}.", agentTaskId, state);
|
LOGGER.error("class=N9e||method=getTaskExecuteState||taskId={}||response={}||msg=get task state failed", taskId, response);
|
||||||
return null;
|
return Result.buildFailure("unknown state, state:" + state);
|
||||||
}
|
}
|
||||||
return n9eTaskStatusEnum.getStatus();
|
return Result.buildSuc(n9eTaskStatusEnum.getStatus());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("get task status failed, agentTaskId:{} response:{}.", agentTaskId, response, e);
|
LOGGER.error("class=N9e||method=getTaskExecuteState||taskId={}||response={}||errMsg={}||msg=get task state failed", taskId, response, e.getMessage());
|
||||||
}
|
}
|
||||||
return null;
|
return Result.buildFailure("get task state failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, ClusterTaskSubStateEnum> getTaskResult(Long agentTaskId) {
|
public Result<Map<String, ClusterTaskSubStateEnum>> getTaskResult(Long taskId) {
|
||||||
String response = null;
|
String response = null;
|
||||||
try {
|
try {
|
||||||
// 获取子任务的state
|
// 获取子任务的state
|
||||||
response = HttpUtils.get(baseUrl + TASK_SUB_STATE_URI.replace("{taskId}", agentTaskId.toString()), null);
|
response = HttpUtils.get(baseUrl + TASK_SUB_STATE_URI.replace("{taskId}", String.valueOf(taskId)), null);
|
||||||
N9eResult n9eResult = JSON.parseObject(response, N9eResult.class);
|
N9eResult nr = JsonUtils.stringToObj(response, N9eResult.class);
|
||||||
|
if (!ValidateUtils.isBlank(nr.getErr())) {
|
||||||
N9eTaskResultDTO n9eTaskResultDTO =
|
LOGGER.error("class=N9e||method=getTaskResult||taskId={}||response={}||msg=get task result failed", taskId, response);
|
||||||
JSON.parseObject(JSON.toJSONString(n9eResult.getDat()), N9eTaskResultDTO.class);
|
return Result.buildFailure(nr.getErr());
|
||||||
return n9eTaskResultDTO.convert2HostnameStatusMap();
|
|
||||||
} catch (Exception e) {
|
|
||||||
LOGGER.error("get task result failed, agentTaskId:{} response:{}.", agentTaskId, response, e);
|
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
|
return Result.buildSuc(JsonUtils.stringToObj(JsonUtils.toJSONString(nr.getDat()), N9eTaskResult.class).convert2HostnameStatusMap());
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOGGER.error("class=N9e||method=getTaskResult||taskId={}||response={}||errMsg={}||msg=get task result failed", taskId, response, e.getMessage());
|
||||||
|
}
|
||||||
|
return Result.buildFailure("get task result failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTaskLog(Long agentTaskId, String hostname) {
|
public Result<ClusterTaskLog> getTaskLog(Long taskId, String hostname) {
|
||||||
String response = null;
|
|
||||||
try {
|
|
||||||
Map<String, String> params = new HashMap<>(1);
|
Map<String, String> params = new HashMap<>(1);
|
||||||
params.put("hostname", hostname);
|
params.put("hostname", hostname);
|
||||||
|
|
||||||
response = HttpUtils.get(baseUrl + TASK_STD_LOG_URI.replace("{taskId}", agentTaskId.toString()), params);
|
String response = null;
|
||||||
N9eResult n9eResult = JSON.parseObject(response, N9eResult.class);
|
try {
|
||||||
if (!ValidateUtils.isBlank(n9eResult.getErr())) {
|
response = HttpUtils.get(baseUrl + TASK_STD_LOG_URI.replace("{taskId}", String.valueOf(taskId)), params);
|
||||||
LOGGER.error("get task log failed, agentTaskId:{} response:{}.", agentTaskId, response);
|
N9eResult nr = JsonUtils.stringToObj(response, N9eResult.class);
|
||||||
return null;
|
if (!ValidateUtils.isBlank(nr.getErr())) {
|
||||||
|
LOGGER.error("class=N9e||method=getTaskLog||taskId={}||response={}||msg=get task log failed", taskId, response);
|
||||||
|
return Result.buildFailure(nr.getErr());
|
||||||
}
|
}
|
||||||
List<N9eTaskStdoutDTO> dtoList =
|
|
||||||
JSON.parseArray(JSON.toJSONString(n9eResult.getDat()), N9eTaskStdoutDTO.class);
|
List<N9eTaskStdoutLog> dtoList = JsonUtils.stringToArrObj(JsonUtils.toJSONString(nr.getDat()), N9eTaskStdoutLog.class);
|
||||||
if (ValidateUtils.isEmptyList(dtoList)) {
|
if (ValidateUtils.isEmptyList(dtoList)) {
|
||||||
return "";
|
return Result.buildSuc(new ClusterTaskLog(""));
|
||||||
}
|
}
|
||||||
return dtoList.get(0).getStdout();
|
return Result.buildSuc(new ClusterTaskLog(dtoList.get(0).getStdout()));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("get task log failed, agentTaskId:{}.", agentTaskId, e);
|
LOGGER.error("class=N9e||method=getTaskLog||taskId={}||response={}||errMsg={}||msg=get task log failed", taskId, response, e.getMessage());
|
||||||
}
|
}
|
||||||
return null;
|
return Result.buildFailure("get task log failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, String> buildHeader() {
|
private Map<String, String> buildHeader() {
|
||||||
@@ -228,7 +209,7 @@ public class N9e extends AbstractAgent {
|
|||||||
return headers;
|
return headers;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, Object> buildCreateTaskParam(CreationTaskData creationTaskData) {
|
private N9eCreationTask buildCreateTaskParam(CreationTaskData creationTaskData) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append(creationTaskData.getUuid()).append(",,");
|
sb.append(creationTaskData.getUuid()).append(",,");
|
||||||
sb.append(creationTaskData.getClusterId()).append(",,");
|
sb.append(creationTaskData.getClusterId()).append(",,");
|
||||||
@@ -240,46 +221,17 @@ public class N9e extends AbstractAgent {
|
|||||||
sb.append(creationTaskData.getServerPropertiesMd5()).append(",,");
|
sb.append(creationTaskData.getServerPropertiesMd5()).append(",,");
|
||||||
sb.append(creationTaskData.getServerPropertiesUrl());
|
sb.append(creationTaskData.getServerPropertiesUrl());
|
||||||
|
|
||||||
Map<String, Object> params = new HashMap<>(10);
|
N9eCreationTask n9eCreationTask = new N9eCreationTask();
|
||||||
params.put("title", String.format("集群ID=%d-升级部署", creationTaskData.getClusterId()));
|
n9eCreationTask.setTitle(Constant.TASK_TITLE_PREFIX + "-集群ID:" + creationTaskData.getClusterId());
|
||||||
params.put("batch", BATCH);
|
n9eCreationTask.setBatch(Constant.AGENT_TASK_BATCH);
|
||||||
params.put("tolerance", TOLERANCE);
|
n9eCreationTask.setTolerance(Constant.AGENT_TASK_TOLERANCE);
|
||||||
params.put("timeout", timeout);
|
n9eCreationTask.setTimeout(this.timeout);
|
||||||
params.put("pause", ListUtils.strList2String(creationTaskData.getPauseList()));
|
n9eCreationTask.setPause(ListUtils.strList2String(creationTaskData.getPauseList()));
|
||||||
params.put("script", this.script);
|
n9eCreationTask.setScript(this.script);
|
||||||
params.put("args", sb.toString());
|
n9eCreationTask.setArgs(sb.toString());
|
||||||
params.put("account", account);
|
n9eCreationTask.setAccount(this.account);
|
||||||
params.put("action", "pause");
|
n9eCreationTask.setAction(ClusterTaskActionEnum.PAUSE.getAction());
|
||||||
params.put("hosts", creationTaskData.getHostList());
|
n9eCreationTask.setHosts(creationTaskData.getHostList());
|
||||||
return params;
|
return n9eCreationTask;
|
||||||
}
|
|
||||||
|
|
||||||
private static String readScriptInJarFile(String fileName) {
|
|
||||||
InputStream inputStream = N9e.class.getClassLoader().getResourceAsStream(fileName);
|
|
||||||
if (inputStream == null) {
|
|
||||||
LOGGER.error("read kcm script failed, filename:{}", fileName);
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
|
|
||||||
String line = null;
|
|
||||||
StringBuilder stringBuilder = new StringBuilder("");
|
|
||||||
|
|
||||||
while ((line = bufferedReader.readLine()) != null) {
|
|
||||||
stringBuilder.append(line);
|
|
||||||
stringBuilder.append("\n");
|
|
||||||
}
|
|
||||||
return stringBuilder.toString();
|
|
||||||
} catch (IOException e) {
|
|
||||||
LOGGER.error("read kcm script failed, filename:{}", fileName, e);
|
|
||||||
return "";
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
inputStream.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
LOGGER.error("close reading kcm script failed, filename:{}", fileName, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,151 @@
|
|||||||
|
package com.xiaojukeji.kafka.manager.kcm.component.agent.n9e.entry;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class N9eCreationTask {
|
||||||
|
/**
|
||||||
|
* 任务标题
|
||||||
|
*/
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 并发度, =2则表示两台并发执行
|
||||||
|
*/
|
||||||
|
private Integer batch;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 错误容忍度, 达到容忍度之上时, 任务会被暂停并不可以继续执行
|
||||||
|
*/
|
||||||
|
private Integer tolerance;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单台任务的超时时间(秒)
|
||||||
|
*/
|
||||||
|
private Integer timeout;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 暂停点, 格式: host1,host2,host3
|
||||||
|
*/
|
||||||
|
private String pause;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 任务执行对应的脚本
|
||||||
|
*/
|
||||||
|
private String script;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 任务参数
|
||||||
|
*/
|
||||||
|
private String args;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 使用的账号
|
||||||
|
*/
|
||||||
|
private String account;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 动作
|
||||||
|
*/
|
||||||
|
private String action;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 操作的主机列表
|
||||||
|
*/
|
||||||
|
private List<String> hosts;
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getBatch() {
|
||||||
|
return batch;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBatch(Integer batch) {
|
||||||
|
this.batch = batch;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getTolerance() {
|
||||||
|
return tolerance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTolerance(Integer tolerance) {
|
||||||
|
this.tolerance = tolerance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getTimeout() {
|
||||||
|
return timeout;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTimeout(Integer timeout) {
|
||||||
|
this.timeout = timeout;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPause() {
|
||||||
|
return pause;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPause(String pause) {
|
||||||
|
this.pause = pause;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getScript() {
|
||||||
|
return script;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setScript(String script) {
|
||||||
|
this.script = script;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getArgs() {
|
||||||
|
return args;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setArgs(String args) {
|
||||||
|
this.args = args;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAccount() {
|
||||||
|
return account;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAccount(String account) {
|
||||||
|
this.account = account;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAction() {
|
||||||
|
return action;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAction(String action) {
|
||||||
|
this.action = action;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getHosts() {
|
||||||
|
return hosts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHosts(List<String> hosts) {
|
||||||
|
this.hosts = hosts;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "N9eCreationTask{" +
|
||||||
|
"title='" + title + '\'' +
|
||||||
|
", batch=" + batch +
|
||||||
|
", tolerance=" + tolerance +
|
||||||
|
", timeout=" + timeout +
|
||||||
|
", pause='" + pause + '\'' +
|
||||||
|
", script='" + script + '\'' +
|
||||||
|
", args='" + args + '\'' +
|
||||||
|
", account='" + account + '\'' +
|
||||||
|
", action='" + action + '\'' +
|
||||||
|
", hosts=" + hosts +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,7 +12,7 @@ import java.util.Map;
|
|||||||
* @author zengqiao
|
* @author zengqiao
|
||||||
* @date 20/9/7
|
* @date 20/9/7
|
||||||
*/
|
*/
|
||||||
public class N9eTaskResultDTO {
|
public class N9eTaskResult {
|
||||||
private List<String> waiting;
|
private List<String> waiting;
|
||||||
|
|
||||||
private List<String> running;
|
private List<String> running;
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package com.xiaojukeji.kafka.manager.kcm.component.agent.n9e.entry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author zengqiao
|
||||||
|
* @date 20/9/7
|
||||||
|
*/
|
||||||
|
public class N9eTaskStdoutLog {
|
||||||
|
private String host;
|
||||||
|
|
||||||
|
private String stdout;
|
||||||
|
|
||||||
|
public String getHost() {
|
||||||
|
return host;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHost(String host) {
|
||||||
|
this.host = host;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStdout() {
|
||||||
|
return stdout;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStdout(String stdout) {
|
||||||
|
this.stdout = stdout;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "N9eTaskStdoutDTO{" +
|
||||||
|
"host='" + host + '\'' +
|
||||||
|
", stdout='" + stdout + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
package com.xiaojukeji.kafka.manager.kcm.component.agent.n9e.entry.bizenum;
|
||||||
|
|
||||||
|
import com.xiaojukeji.kafka.manager.kcm.common.bizenum.ClusterTaskStateEnum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author zengqiao
|
||||||
|
* @date 20/9/3
|
||||||
|
*/
|
||||||
|
public enum N9eTaskStatusEnum {
|
||||||
|
DONE(0, "done", ClusterTaskStateEnum.FINISHED),
|
||||||
|
PAUSE(1, "pause", ClusterTaskStateEnum.BLOCKED),
|
||||||
|
START(2, "start", ClusterTaskStateEnum.RUNNING),
|
||||||
|
;
|
||||||
|
|
||||||
|
private Integer code;
|
||||||
|
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
private ClusterTaskStateEnum status;
|
||||||
|
|
||||||
|
N9eTaskStatusEnum(Integer code, String message, ClusterTaskStateEnum status) {
|
||||||
|
this.code = code;
|
||||||
|
this.message = message;
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCode(Integer code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessage(String message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClusterTaskStateEnum getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(ClusterTaskStateEnum status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static N9eTaskStatusEnum getByMessage(String message) {
|
||||||
|
for (N9eTaskStatusEnum elem: N9eTaskStatusEnum.values()) {
|
||||||
|
if (elem.message.equals(message)) {
|
||||||
|
return elem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -95,8 +95,11 @@ public class S3Service extends AbstractStorageService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDownloadBaseUrl() {
|
public String getDownloadBaseUrl() {
|
||||||
|
if (this.endpoint.startsWith("http://")) {
|
||||||
return this.endpoint + "/" + this.bucket;
|
return this.endpoint + "/" + this.bucket;
|
||||||
}
|
}
|
||||||
|
return "http://" + this.endpoint + "/" + this.bucket;
|
||||||
|
}
|
||||||
|
|
||||||
private boolean createBucketIfNotExist() {
|
private boolean createBucketIfNotExist() {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import com.xiaojukeji.kafka.manager.kcm.ClusterTaskService;
|
|||||||
import com.xiaojukeji.kafka.manager.kcm.common.Converters;
|
import com.xiaojukeji.kafka.manager.kcm.common.Converters;
|
||||||
import com.xiaojukeji.kafka.manager.kcm.common.bizenum.ClusterTaskActionEnum;
|
import com.xiaojukeji.kafka.manager.kcm.common.bizenum.ClusterTaskActionEnum;
|
||||||
import com.xiaojukeji.kafka.manager.kcm.common.entry.ClusterTaskConstant;
|
import com.xiaojukeji.kafka.manager.kcm.common.entry.ClusterTaskConstant;
|
||||||
|
import com.xiaojukeji.kafka.manager.kcm.common.entry.ao.ClusterTaskLog;
|
||||||
import com.xiaojukeji.kafka.manager.kcm.common.entry.ao.ClusterTaskSubStatus;
|
import com.xiaojukeji.kafka.manager.kcm.common.entry.ao.ClusterTaskSubStatus;
|
||||||
import com.xiaojukeji.kafka.manager.kcm.common.bizenum.ClusterTaskStateEnum;
|
import com.xiaojukeji.kafka.manager.kcm.common.bizenum.ClusterTaskStateEnum;
|
||||||
import com.xiaojukeji.kafka.manager.kcm.common.bizenum.ClusterTaskSubStateEnum;
|
import com.xiaojukeji.kafka.manager.kcm.common.bizenum.ClusterTaskSubStateEnum;
|
||||||
@@ -34,7 +35,7 @@ import java.util.*;
|
|||||||
*/
|
*/
|
||||||
@Service("clusterTaskService")
|
@Service("clusterTaskService")
|
||||||
public class ClusterTaskServiceImpl implements ClusterTaskService {
|
public class ClusterTaskServiceImpl implements ClusterTaskService {
|
||||||
private final static Logger LOGGER = LoggerFactory.getLogger(ClusterTaskServiceImpl.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(ClusterTaskServiceImpl.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private AbstractAgent abstractAgent;
|
private AbstractAgent abstractAgent;
|
||||||
@@ -63,13 +64,13 @@ public class ClusterTaskServiceImpl implements ClusterTaskService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 创建任务
|
// 创建任务
|
||||||
Long agentTaskId = abstractAgent.createTask(dtoResult.getData());
|
Result<Long> createResult = abstractAgent.createTask(dtoResult.getData());
|
||||||
if (ValidateUtils.isNull(agentTaskId)) {
|
if (ValidateUtils.isNull(createResult) || createResult.failed()) {
|
||||||
return Result.buildFrom(ResultStatus.CALL_CLUSTER_TASK_AGENT_FAILED);
|
return Result.buildFrom(ResultStatus.CALL_CLUSTER_TASK_AGENT_FAILED);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (clusterTaskDao.insert(Converters.convert2ClusterTaskDO(agentTaskId, dtoResult.getData(), operator)) > 0) {
|
if (clusterTaskDao.insert(Converters.convert2ClusterTaskDO(createResult.getData(), dtoResult.getData(), operator)) > 0) {
|
||||||
return Result.buildFrom(ResultStatus.SUCCESS);
|
return Result.buildFrom(ResultStatus.SUCCESS);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -87,45 +88,44 @@ public class ClusterTaskServiceImpl implements ClusterTaskService {
|
|||||||
Long agentTaskId = getActiveAgentTaskId(clusterTaskDO);
|
Long agentTaskId = getActiveAgentTaskId(clusterTaskDO);
|
||||||
Boolean rollback = inRollback(clusterTaskDO);
|
Boolean rollback = inRollback(clusterTaskDO);
|
||||||
|
|
||||||
ClusterTaskStateEnum stateEnum = abstractAgent.getTaskState(agentTaskId);
|
Result<ClusterTaskStateEnum> stateEnumResult = abstractAgent.getTaskExecuteState(agentTaskId);
|
||||||
if (ClusterTaskActionEnum.START.getMessage().equals(action)
|
if (ValidateUtils.isNull(stateEnumResult) || stateEnumResult.failed()) {
|
||||||
&& ClusterTaskStateEnum.BLOCKED.equals(stateEnum)) {
|
return ResultStatus.CALL_CLUSTER_TASK_AGENT_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ClusterTaskActionEnum.START.getAction().equals(action) && ClusterTaskStateEnum.BLOCKED.equals(stateEnumResult.getData())) {
|
||||||
// 暂停状态, 可以执行开始
|
// 暂停状态, 可以执行开始
|
||||||
return actionTaskExceptRollbackAction(agentTaskId, action, "");
|
return actionTaskExceptRollbackAction(agentTaskId, ClusterTaskActionEnum.START, "");
|
||||||
}
|
}
|
||||||
if (ClusterTaskActionEnum.PAUSE.getMessage().equals(action)
|
if (ClusterTaskActionEnum.PAUSE.getAction().equals(action) && ClusterTaskStateEnum.RUNNING.equals(stateEnumResult.getData())) {
|
||||||
&& ClusterTaskStateEnum.RUNNING.equals(stateEnum)) {
|
|
||||||
// 运行状态, 可以执行暂停
|
// 运行状态, 可以执行暂停
|
||||||
return actionTaskExceptRollbackAction(agentTaskId, action, "");
|
return actionTaskExceptRollbackAction(agentTaskId, ClusterTaskActionEnum.PAUSE, "");
|
||||||
}
|
}
|
||||||
if (ClusterTaskActionEnum.IGNORE.getMessage().equals(action)
|
if (ClusterTaskActionEnum.IGNORE.getAction().equals(action)) {
|
||||||
|| ClusterTaskActionEnum.CANCEL.getMessage().equals(action)) {
|
|
||||||
// 忽略 & 取消随时都可以操作
|
// 忽略 & 取消随时都可以操作
|
||||||
return actionTaskExceptRollbackAction(agentTaskId, action, hostname);
|
return actionTaskExceptRollbackAction(agentTaskId, ClusterTaskActionEnum.IGNORE, hostname);
|
||||||
}
|
}
|
||||||
if ((!ClusterTaskStateEnum.FINISHED.equals(stateEnum) || !rollback)
|
if (ClusterTaskActionEnum.CANCEL.getAction().equals(action)) {
|
||||||
&& ClusterTaskActionEnum.ROLLBACK.getMessage().equals(action)) {
|
// 忽略 & 取消随时都可以操作
|
||||||
|
return actionTaskExceptRollbackAction(agentTaskId, ClusterTaskActionEnum.CANCEL, hostname);
|
||||||
|
}
|
||||||
|
if ((!ClusterTaskStateEnum.FINISHED.equals(stateEnumResult.getData()) || !rollback)
|
||||||
|
&& ClusterTaskActionEnum.ROLLBACK.getAction().equals(action)) {
|
||||||
// 暂未操作完时可以回滚, 回滚所有操作过的机器到上一个版本
|
// 暂未操作完时可以回滚, 回滚所有操作过的机器到上一个版本
|
||||||
return actionTaskRollback(clusterTaskDO);
|
return actionTaskRollback(clusterTaskDO);
|
||||||
}
|
}
|
||||||
return ResultStatus.OPERATION_FAILED;
|
return ResultStatus.OPERATION_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ResultStatus actionTaskExceptRollbackAction(Long agentId, String action, String hostname) {
|
private ResultStatus actionTaskExceptRollbackAction(Long agentId, ClusterTaskActionEnum actionEnum, String hostname) {
|
||||||
if (!ValidateUtils.isBlank(hostname)) {
|
if (!ValidateUtils.isBlank(hostname)) {
|
||||||
return actionHostTaskExceptRollbackAction(agentId, action, hostname);
|
return actionHostTaskExceptRollbackAction(agentId, actionEnum, hostname);
|
||||||
}
|
}
|
||||||
if (abstractAgent.actionTask(agentId, action)) {
|
return abstractAgent.actionTask(agentId, actionEnum)? ResultStatus.SUCCESS: ResultStatus.OPERATION_FAILED;
|
||||||
return ResultStatus.SUCCESS;
|
|
||||||
}
|
|
||||||
return ResultStatus.OPERATION_FAILED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ResultStatus actionHostTaskExceptRollbackAction(Long agentId, String action, String hostname) {
|
private ResultStatus actionHostTaskExceptRollbackAction(Long agentId, ClusterTaskActionEnum actionEnum, String hostname) {
|
||||||
if (abstractAgent.actionHostTask(agentId, action, hostname)) {
|
return abstractAgent.actionHostTask(agentId, actionEnum, hostname)? ResultStatus.SUCCESS: ResultStatus.OPERATION_FAILED;
|
||||||
return ResultStatus.SUCCESS;
|
|
||||||
}
|
|
||||||
return ResultStatus.OPERATION_FAILED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ResultStatus actionTaskRollback(ClusterTaskDO clusterTaskDO) {
|
private ResultStatus actionTaskRollback(ClusterTaskDO clusterTaskDO) {
|
||||||
@@ -133,9 +133,9 @@ public class ClusterTaskServiceImpl implements ClusterTaskService {
|
|||||||
return ResultStatus.OPERATION_FORBIDDEN;
|
return ResultStatus.OPERATION_FORBIDDEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, ClusterTaskSubStateEnum> subStatusEnumMap =
|
Result<Map<String, ClusterTaskSubStateEnum>> subStatusEnumMapResult =
|
||||||
abstractAgent.getTaskResult(clusterTaskDO.getAgentTaskId());
|
abstractAgent.getTaskResult(clusterTaskDO.getAgentTaskId());
|
||||||
if (ValidateUtils.isNull(subStatusEnumMap)) {
|
if (ValidateUtils.isNull(subStatusEnumMapResult) || subStatusEnumMapResult.failed()) {
|
||||||
return ResultStatus.CALL_CLUSTER_TASK_AGENT_FAILED;
|
return ResultStatus.CALL_CLUSTER_TASK_AGENT_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,7 +143,7 @@ public class ClusterTaskServiceImpl implements ClusterTaskService {
|
|||||||
List<String> rollbackHostList = new ArrayList<>();
|
List<String> rollbackHostList = new ArrayList<>();
|
||||||
List<String> rollbackPauseHostList = new ArrayList<>();
|
List<String> rollbackPauseHostList = new ArrayList<>();
|
||||||
for (String host: ListUtils.string2StrList(clusterTaskDO.getHostList())) {
|
for (String host: ListUtils.string2StrList(clusterTaskDO.getHostList())) {
|
||||||
ClusterTaskSubStateEnum subStateEnum = subStatusEnumMap.get(host);
|
ClusterTaskSubStateEnum subStateEnum = subStatusEnumMapResult.getData().get(host);
|
||||||
if (ValidateUtils.isNull(subStateEnum)) {
|
if (ValidateUtils.isNull(subStateEnum)) {
|
||||||
// 机器对应的任务查询失败
|
// 机器对应的任务查询失败
|
||||||
return ResultStatus.OPERATION_FAILED;
|
return ResultStatus.OPERATION_FAILED;
|
||||||
@@ -166,17 +166,17 @@ public class ClusterTaskServiceImpl implements ClusterTaskService {
|
|||||||
clusterTaskDO.setRollbackPauseHostList(ListUtils.strList2String(rollbackPauseHostList));
|
clusterTaskDO.setRollbackPauseHostList(ListUtils.strList2String(rollbackPauseHostList));
|
||||||
|
|
||||||
// 创建任务
|
// 创建任务
|
||||||
Long agentTaskId = abstractAgent.createTask(Converters.convert2CreationTaskData(clusterTaskDO));
|
Result<Long> createResult = abstractAgent.createTask(Converters.convert2CreationTaskData(clusterTaskDO));
|
||||||
if (ValidateUtils.isNull(agentTaskId)) {
|
if (ValidateUtils.isNull(createResult) || createResult.failed()) {
|
||||||
return ResultStatus.CALL_CLUSTER_TASK_AGENT_FAILED;
|
return ResultStatus.CALL_CLUSTER_TASK_AGENT_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
clusterTaskDO.setAgentRollbackTaskId(agentTaskId);
|
clusterTaskDO.setAgentRollbackTaskId(createResult.getData());
|
||||||
if (clusterTaskDao.updateRollback(clusterTaskDO) <= 0) {
|
if (clusterTaskDao.updateRollback(clusterTaskDO) <= 0) {
|
||||||
return ResultStatus.MYSQL_ERROR;
|
return ResultStatus.MYSQL_ERROR;
|
||||||
}
|
}
|
||||||
abstractAgent.actionTask(clusterTaskDO.getAgentTaskId(), ClusterTaskActionEnum.CANCEL.getMessage());
|
abstractAgent.actionTask(clusterTaskDO.getAgentTaskId(), ClusterTaskActionEnum.CANCEL);
|
||||||
return ResultStatus.SUCCESS;
|
return ResultStatus.SUCCESS;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("create cluster task failed, clusterTaskDO:{}.", clusterTaskDO, e);
|
LOGGER.error("create cluster task failed, clusterTaskDO:{}.", clusterTaskDO, e);
|
||||||
@@ -191,11 +191,11 @@ public class ClusterTaskServiceImpl implements ClusterTaskService {
|
|||||||
return Result.buildFrom(ResultStatus.TASK_NOT_EXIST);
|
return Result.buildFrom(ResultStatus.TASK_NOT_EXIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
String stdoutLog = abstractAgent.getTaskLog(getActiveAgentTaskId(clusterTaskDO, hostname), hostname);
|
Result<ClusterTaskLog> stdoutLogResult = abstractAgent.getTaskLog(getActiveAgentTaskId(clusterTaskDO, hostname), hostname);
|
||||||
if (ValidateUtils.isNull(stdoutLog)) {
|
if (ValidateUtils.isNull(stdoutLogResult) || stdoutLogResult.failed()) {
|
||||||
return Result.buildFrom(ResultStatus.CALL_CLUSTER_TASK_AGENT_FAILED);
|
return Result.buildFrom(ResultStatus.CALL_CLUSTER_TASK_AGENT_FAILED);
|
||||||
}
|
}
|
||||||
return new Result<>(stdoutLog);
|
return new Result<>(stdoutLogResult.getData().getStdout());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -205,24 +205,33 @@ public class ClusterTaskServiceImpl implements ClusterTaskService {
|
|||||||
return Result.buildFrom(ResultStatus.TASK_NOT_EXIST);
|
return Result.buildFrom(ResultStatus.TASK_NOT_EXIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Result<ClusterTaskStateEnum> statusEnumResult = abstractAgent.getTaskExecuteState(getActiveAgentTaskId(clusterTaskDO));
|
||||||
|
if (ValidateUtils.isNull(statusEnumResult) || statusEnumResult.failed()) {
|
||||||
|
return new Result<>(statusEnumResult.getCode(), statusEnumResult.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
return new Result<>(new ClusterTaskStatus(
|
return new Result<>(new ClusterTaskStatus(
|
||||||
clusterTaskDO.getId(),
|
clusterTaskDO.getId(),
|
||||||
clusterTaskDO.getClusterId(),
|
clusterTaskDO.getClusterId(),
|
||||||
inRollback(clusterTaskDO),
|
inRollback(clusterTaskDO),
|
||||||
abstractAgent.getTaskState(getActiveAgentTaskId(clusterTaskDO)),
|
statusEnumResult.getData(),
|
||||||
getTaskSubStatus(clusterTaskDO)
|
getTaskSubStatus(clusterTaskDO)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ClusterTaskStateEnum getTaskState(Long agentTaskId) {
|
public ClusterTaskStateEnum getTaskState(Long agentTaskId) {
|
||||||
return abstractAgent.getTaskState(agentTaskId);
|
Result<ClusterTaskStateEnum> statusEnumResult = abstractAgent.getTaskExecuteState(agentTaskId);
|
||||||
|
if (ValidateUtils.isNull(statusEnumResult) || statusEnumResult.failed()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return statusEnumResult.getData();
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<ClusterTaskSubStatus> getTaskSubStatus(ClusterTaskDO clusterTaskDO) {
|
private List<ClusterTaskSubStatus> getTaskSubStatus(ClusterTaskDO clusterTaskDO) {
|
||||||
Map<String, ClusterTaskSubStateEnum> statusMap = this.getClusterTaskSubState(clusterTaskDO);
|
Map<String, ClusterTaskSubStateEnum> statusMap = this.getClusterTaskSubState(clusterTaskDO);
|
||||||
if (ValidateUtils.isNull(statusMap)) {
|
if (ValidateUtils.isNull(statusMap)) {
|
||||||
return null;
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
List<String> pauseList = ListUtils.string2StrList(clusterTaskDO.getPauseHostList());
|
List<String> pauseList = ListUtils.string2StrList(clusterTaskDO.getPauseHostList());
|
||||||
|
|
||||||
@@ -242,20 +251,22 @@ public class ClusterTaskServiceImpl implements ClusterTaskService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, ClusterTaskSubStateEnum> getClusterTaskSubState(ClusterTaskDO clusterTaskDO) {
|
private Map<String, ClusterTaskSubStateEnum> getClusterTaskSubState(ClusterTaskDO clusterTaskDO) {
|
||||||
Map<String, ClusterTaskSubStateEnum> statusMap = abstractAgent.getTaskResult(clusterTaskDO.getAgentTaskId());
|
Result<Map<String, ClusterTaskSubStateEnum>> statusMapResult = abstractAgent.getTaskResult(clusterTaskDO.getAgentTaskId());
|
||||||
if (ValidateUtils.isNull(statusMap)) {
|
if (ValidateUtils.isNull(statusMapResult) || statusMapResult.failed()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Map<String, ClusterTaskSubStateEnum> statusMap = statusMapResult.getData();
|
||||||
if (!inRollback(clusterTaskDO)) {
|
if (!inRollback(clusterTaskDO)) {
|
||||||
return statusMap;
|
return statusMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, ClusterTaskSubStateEnum> rollbackStatusMap =
|
Result<Map<String, ClusterTaskSubStateEnum>> rollbackStatusMapResult =
|
||||||
abstractAgent.getTaskResult(clusterTaskDO.getAgentRollbackTaskId());
|
abstractAgent.getTaskResult(clusterTaskDO.getAgentRollbackTaskId());
|
||||||
if (ValidateUtils.isNull(rollbackStatusMap)) {
|
if (ValidateUtils.isNull(rollbackStatusMapResult) || rollbackStatusMapResult.failed()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
statusMap.putAll(rollbackStatusMap);
|
|
||||||
|
statusMap.putAll(rollbackStatusMapResult.getData());
|
||||||
return statusMap;
|
return statusMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -276,7 +287,7 @@ public class ClusterTaskServiceImpl implements ClusterTaskService {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("get all cluster task failed.");
|
LOGGER.error("get all cluster task failed.");
|
||||||
}
|
}
|
||||||
return null;
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -302,9 +313,6 @@ public class ClusterTaskServiceImpl implements ClusterTaskService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean inRollback(ClusterTaskDO clusterTaskDO) {
|
private boolean inRollback(ClusterTaskDO clusterTaskDO) {
|
||||||
if (ClusterTaskConstant.INVALID_AGENT_TASK_ID.equals(clusterTaskDO.getAgentRollbackTaskId())) {
|
return !ClusterTaskConstant.INVALID_AGENT_TASK_ID.equals(clusterTaskDO.getAgentRollbackTaskId());
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,12 +4,12 @@ import com.xiaojukeji.kafka.manager.common.bizenum.KafkaFileEnum;
|
|||||||
import com.xiaojukeji.kafka.manager.common.entity.Result;
|
import com.xiaojukeji.kafka.manager.common.entity.Result;
|
||||||
import com.xiaojukeji.kafka.manager.common.entity.ResultStatus;
|
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.dto.normal.KafkaFileDTO;
|
||||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.KafkaFileDO;
|
|
||||||
import com.xiaojukeji.kafka.manager.common.utils.CopyUtils;
|
import com.xiaojukeji.kafka.manager.common.utils.CopyUtils;
|
||||||
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
|
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
|
||||||
import com.xiaojukeji.kafka.manager.dao.KafkaFileDao;
|
import com.xiaojukeji.kafka.manager.dao.KafkaFileDao;
|
||||||
import com.xiaojukeji.kafka.manager.kcm.KafkaFileService;
|
import com.xiaojukeji.kafka.manager.common.entity.pojo.KafkaFileDO;
|
||||||
import com.xiaojukeji.kafka.manager.kcm.component.storage.AbstractStorageService;
|
import com.xiaojukeji.kafka.manager.kcm.component.storage.AbstractStorageService;
|
||||||
|
import com.xiaojukeji.kafka.manager.kcm.KafkaFileService;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public class GatewayHeartbeatController {
|
|||||||
doList = JsonUtils.parseTopicConnections(clusterId, jsonObject, System.currentTimeMillis());
|
doList = JsonUtils.parseTopicConnections(clusterId, jsonObject, System.currentTimeMillis());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("class=GatewayHeartbeatController||method=receiveTopicConnections||clusterId={}||brokerId={}||msg=parse data failed||exception={}", clusterId, brokerId, e.getMessage());
|
LOGGER.error("class=GatewayHeartbeatController||method=receiveTopicConnections||clusterId={}||brokerId={}||msg=parse data failed||exception={}", clusterId, brokerId, e.getMessage());
|
||||||
return Result.buildFailure("fail");
|
return Result.buildGatewayFailure("fail");
|
||||||
}
|
}
|
||||||
|
|
||||||
topicConnectionService.batchAdd(doList);
|
topicConnectionService.batchAdd(doList);
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ import java.util.Map;
|
|||||||
@RestController
|
@RestController
|
||||||
@RequestMapping(ApiPrefix.GATEWAY_API_V1_PREFIX)
|
@RequestMapping(ApiPrefix.GATEWAY_API_V1_PREFIX)
|
||||||
public class GatewayServiceDiscoveryController {
|
public class GatewayServiceDiscoveryController {
|
||||||
|
|
||||||
private final static Logger LOGGER = LoggerFactory.getLogger(GatewayHeartbeatController.class);
|
private final static Logger LOGGER = LoggerFactory.getLogger(GatewayHeartbeatController.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -65,7 +64,7 @@ public class GatewayServiceDiscoveryController {
|
|||||||
KafkaBootstrapServerConfig config =
|
KafkaBootstrapServerConfig config =
|
||||||
gatewayConfigService.getKafkaBootstrapServersConfig(Long.MIN_VALUE);
|
gatewayConfigService.getKafkaBootstrapServersConfig(Long.MIN_VALUE);
|
||||||
if (ValidateUtils.isNull(config) || ValidateUtils.isNull(config.getClusterIdBootstrapServersMap())) {
|
if (ValidateUtils.isNull(config) || ValidateUtils.isNull(config.getClusterIdBootstrapServersMap())) {
|
||||||
return Result.buildFailure("call init kafka bootstrap servers failed");
|
return Result.buildGatewayFailure("call init kafka bootstrap servers failed");
|
||||||
}
|
}
|
||||||
if (ValidateUtils.isEmptyMap(config.getClusterIdBootstrapServersMap())) {
|
if (ValidateUtils.isEmptyMap(config.getClusterIdBootstrapServersMap())) {
|
||||||
return Result.buildSuc();
|
return Result.buildSuc();
|
||||||
@@ -81,7 +80,7 @@ public class GatewayServiceDiscoveryController {
|
|||||||
KafkaBootstrapServerConfig config =
|
KafkaBootstrapServerConfig config =
|
||||||
gatewayConfigService.getKafkaBootstrapServersConfig(versionNumber);
|
gatewayConfigService.getKafkaBootstrapServersConfig(versionNumber);
|
||||||
if (ValidateUtils.isNull(config) || ValidateUtils.isNull(config.getClusterIdBootstrapServersMap())) {
|
if (ValidateUtils.isNull(config) || ValidateUtils.isNull(config.getClusterIdBootstrapServersMap())) {
|
||||||
return Result.buildFailure("call update kafka bootstrap servers failed");
|
return Result.buildGatewayFailure("call update kafka bootstrap servers failed");
|
||||||
}
|
}
|
||||||
if (ValidateUtils.isEmptyMap(config.getClusterIdBootstrapServersMap())) {
|
if (ValidateUtils.isEmptyMap(config.getClusterIdBootstrapServersMap())) {
|
||||||
return Result.buildSuc();
|
return Result.buildSuc();
|
||||||
@@ -99,7 +98,7 @@ public class GatewayServiceDiscoveryController {
|
|||||||
public Result<String> getMaxRequestNum(@RequestParam("versionNumber") long versionNumber) {
|
public Result<String> getMaxRequestNum(@RequestParam("versionNumber") long versionNumber) {
|
||||||
RequestQueueConfig config = gatewayConfigService.getRequestQueueConfig(versionNumber);
|
RequestQueueConfig config = gatewayConfigService.getRequestQueueConfig(versionNumber);
|
||||||
if (ValidateUtils.isNull(config)) {
|
if (ValidateUtils.isNull(config)) {
|
||||||
return Result.buildFailure("call get request queue size config failed");
|
return Result.buildGatewayFailure("call get request queue size config failed");
|
||||||
}
|
}
|
||||||
if (ValidateUtils.isNull(config.getMaxRequestQueueSize())) {
|
if (ValidateUtils.isNull(config.getMaxRequestQueueSize())) {
|
||||||
return Result.buildSuc();
|
return Result.buildSuc();
|
||||||
@@ -119,7 +118,7 @@ public class GatewayServiceDiscoveryController {
|
|||||||
public Result<String> getAppIdRate(@RequestParam("versionNumber") long versionNumber) {
|
public Result<String> getAppIdRate(@RequestParam("versionNumber") long versionNumber) {
|
||||||
AppRateConfig config = gatewayConfigService.getAppRateConfig(versionNumber);
|
AppRateConfig config = gatewayConfigService.getAppRateConfig(versionNumber);
|
||||||
if (ValidateUtils.isNull(config)) {
|
if (ValidateUtils.isNull(config)) {
|
||||||
return Result.buildFailure("call get app rate config failed");
|
return Result.buildGatewayFailure("call get app rate config failed");
|
||||||
}
|
}
|
||||||
if (ValidateUtils.isNull(config.getAppRateLimit())) {
|
if (ValidateUtils.isNull(config.getAppRateLimit())) {
|
||||||
return Result.buildSuc();
|
return Result.buildSuc();
|
||||||
@@ -139,7 +138,7 @@ public class GatewayServiceDiscoveryController {
|
|||||||
public Result getIpRate(@RequestParam("versionNumber") long versionNumber) {
|
public Result getIpRate(@RequestParam("versionNumber") long versionNumber) {
|
||||||
IpRateConfig config = gatewayConfigService.getIpRateConfig(versionNumber);
|
IpRateConfig config = gatewayConfigService.getIpRateConfig(versionNumber);
|
||||||
if (ValidateUtils.isNull(config)) {
|
if (ValidateUtils.isNull(config)) {
|
||||||
return Result.buildFailure("call get ip rate config failed");
|
return Result.buildGatewayFailure("call get ip rate config failed");
|
||||||
}
|
}
|
||||||
if (ValidateUtils.isNull(config.getIpRateLimit())) {
|
if (ValidateUtils.isNull(config.getIpRateLimit())) {
|
||||||
return Result.buildSuc();
|
return Result.buildSuc();
|
||||||
@@ -160,7 +159,7 @@ public class GatewayServiceDiscoveryController {
|
|||||||
SpRateConfig config =
|
SpRateConfig config =
|
||||||
gatewayConfigService.getSpRateConfig(versionNumber);
|
gatewayConfigService.getSpRateConfig(versionNumber);
|
||||||
if (ValidateUtils.isNull(config) || ValidateUtils.isNull(config.getSpRateMap())) {
|
if (ValidateUtils.isNull(config) || ValidateUtils.isNull(config.getSpRateMap())) {
|
||||||
return Result.buildFailure("call update kafka bootstrap servers failed");
|
return Result.buildGatewayFailure("call update kafka bootstrap servers failed");
|
||||||
}
|
}
|
||||||
if (ValidateUtils.isEmptyMap(config.getSpRateMap())) {
|
if (ValidateUtils.isEmptyMap(config.getSpRateMap())) {
|
||||||
return Result.buildSuc();
|
return Result.buildSuc();
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.xiaojukeji.kafka.manager.web.api.versionone.op;
|
|||||||
|
|
||||||
import com.xiaojukeji.kafka.manager.common.entity.Result;
|
import com.xiaojukeji.kafka.manager.common.entity.Result;
|
||||||
import com.xiaojukeji.kafka.manager.common.entity.ResultStatus;
|
import com.xiaojukeji.kafka.manager.common.entity.ResultStatus;
|
||||||
|
import com.xiaojukeji.kafka.manager.common.entity.dto.op.ControllerPreferredCandidateDTO;
|
||||||
import com.xiaojukeji.kafka.manager.common.entity.dto.rd.ClusterDTO;
|
import com.xiaojukeji.kafka.manager.common.entity.dto.rd.ClusterDTO;
|
||||||
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
|
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
|
||||||
import com.xiaojukeji.kafka.manager.service.service.ClusterService;
|
import com.xiaojukeji.kafka.manager.service.service.ClusterService;
|
||||||
@@ -13,6 +14,7 @@ import io.swagger.annotations.ApiOperation;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author zengqiao
|
* @author zengqiao
|
||||||
* @date 20/4/23
|
* @date 20/4/23
|
||||||
@@ -25,48 +27,56 @@ public class OpClusterController {
|
|||||||
private ClusterService clusterService;
|
private ClusterService clusterService;
|
||||||
|
|
||||||
@ApiOperation(value = "接入集群")
|
@ApiOperation(value = "接入集群")
|
||||||
@RequestMapping(value = "clusters", method = RequestMethod.POST)
|
@PostMapping(value = "clusters")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Result addNew(@RequestBody ClusterDTO dto) {
|
public Result addNew(@RequestBody ClusterDTO dto) {
|
||||||
if (ValidateUtils.isNull(dto) || !dto.legal()) {
|
if (ValidateUtils.isNull(dto) || !dto.legal()) {
|
||||||
return Result.buildFrom(ResultStatus.PARAM_ILLEGAL);
|
return Result.buildFrom(ResultStatus.PARAM_ILLEGAL);
|
||||||
}
|
}
|
||||||
return Result.buildFrom(
|
return Result.buildFrom(
|
||||||
clusterService.addNew(
|
clusterService.addNew(ClusterModelConverter.convert2ClusterDO(dto), SpringTool.getUserName())
|
||||||
ClusterModelConverter.convert2ClusterDO(dto),
|
|
||||||
SpringTool.getUserName()
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "删除集群")
|
@ApiOperation(value = "删除集群")
|
||||||
@RequestMapping(value = "clusters", method = RequestMethod.DELETE)
|
@DeleteMapping(value = "clusters")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Result delete(@RequestParam(value = "clusterId") Long clusterId) {
|
public Result delete(@RequestParam(value = "clusterId") Long clusterId) {
|
||||||
return Result.buildFrom(clusterService.deleteById(clusterId, SpringTool.getUserName()));
|
return Result.buildFrom(clusterService.deleteById(clusterId, SpringTool.getUserName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "修改集群信息")
|
@ApiOperation(value = "修改集群信息")
|
||||||
@RequestMapping(value = "clusters", method = RequestMethod.PUT)
|
@PutMapping(value = "clusters")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Result modify(@RequestBody ClusterDTO reqObj) {
|
public Result modify(@RequestBody ClusterDTO reqObj) {
|
||||||
if (ValidateUtils.isNull(reqObj) || !reqObj.legal() || ValidateUtils.isNull(reqObj.getClusterId())) {
|
if (ValidateUtils.isNull(reqObj) || !reqObj.legal() || ValidateUtils.isNull(reqObj.getClusterId())) {
|
||||||
return Result.buildFrom(ResultStatus.PARAM_ILLEGAL);
|
return Result.buildFrom(ResultStatus.PARAM_ILLEGAL);
|
||||||
}
|
}
|
||||||
ResultStatus rs = clusterService.updateById(
|
return Result.buildFrom(
|
||||||
ClusterModelConverter.convert2ClusterDO(reqObj),
|
clusterService.updateById(ClusterModelConverter.convert2ClusterDO(reqObj), SpringTool.getUserName())
|
||||||
SpringTool.getUserName()
|
|
||||||
);
|
);
|
||||||
return Result.buildFrom(rs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "开启|关闭集群监控")
|
@ApiOperation(value = "开启|关闭集群监控")
|
||||||
@RequestMapping(value = "clusters/{clusterId}/monitor", method = RequestMethod.PUT)
|
@PutMapping(value = "clusters/{clusterId}/monitor")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Result modifyStatus(@PathVariable Long clusterId,
|
public Result modifyStatus(@PathVariable Long clusterId, @RequestParam("status") Integer status) {
|
||||||
@RequestParam("status") Integer status) {
|
|
||||||
return Result.buildFrom(
|
return Result.buildFrom(
|
||||||
clusterService.modifyStatus(clusterId, status, SpringTool.getUserName())
|
clusterService.modifyStatus(clusterId, status, SpringTool.getUserName())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "增加Controller优先候选的Broker", notes = "滴滴内部引擎特性")
|
||||||
|
@PostMapping(value = "cluster-controller/preferred-candidates")
|
||||||
|
@ResponseBody
|
||||||
|
public Result addControllerPreferredCandidates(@RequestBody ControllerPreferredCandidateDTO dto) {
|
||||||
|
return clusterService.addControllerPreferredCandidates(dto.getClusterId(), dto.getBrokerIdList());
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "删除Controller优先候选的Broker", notes = "滴滴内部引擎特性")
|
||||||
|
@DeleteMapping(value = "cluster-controller/preferred-candidates")
|
||||||
|
@ResponseBody
|
||||||
|
public Result deleteControllerPreferredCandidates(@RequestBody ControllerPreferredCandidateDTO dto) {
|
||||||
|
return clusterService.deleteControllerPreferredCandidates(dto.getClusterId(), dto.getBrokerIdList());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -3,8 +3,11 @@ package com.xiaojukeji.kafka.manager.web.api.versionone.op;
|
|||||||
import com.xiaojukeji.kafka.manager.bpm.common.entry.apply.gateway.OrderExtensionAddGatewayConfigDTO;
|
import com.xiaojukeji.kafka.manager.bpm.common.entry.apply.gateway.OrderExtensionAddGatewayConfigDTO;
|
||||||
import com.xiaojukeji.kafka.manager.bpm.common.entry.apply.gateway.OrderExtensionDeleteGatewayConfigDTO;
|
import com.xiaojukeji.kafka.manager.bpm.common.entry.apply.gateway.OrderExtensionDeleteGatewayConfigDTO;
|
||||||
import com.xiaojukeji.kafka.manager.bpm.common.entry.apply.gateway.OrderExtensionModifyGatewayConfigDTO;
|
import com.xiaojukeji.kafka.manager.bpm.common.entry.apply.gateway.OrderExtensionModifyGatewayConfigDTO;
|
||||||
|
import com.xiaojukeji.kafka.manager.common.bizenum.gateway.GatewayConfigKeyEnum;
|
||||||
|
import com.xiaojukeji.kafka.manager.common.constant.ApiPrefix;
|
||||||
import com.xiaojukeji.kafka.manager.common.entity.Result;
|
import com.xiaojukeji.kafka.manager.common.entity.Result;
|
||||||
import com.xiaojukeji.kafka.manager.common.entity.ResultStatus;
|
import com.xiaojukeji.kafka.manager.common.entity.ResultStatus;
|
||||||
|
import com.xiaojukeji.kafka.manager.common.utils.JsonUtils;
|
||||||
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
|
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
|
||||||
import com.xiaojukeji.kafka.manager.service.service.gateway.GatewayConfigService;
|
import com.xiaojukeji.kafka.manager.service.service.gateway.GatewayConfigService;
|
||||||
import com.xiaojukeji.kafka.manager.web.converters.GatewayModelConverter;
|
import com.xiaojukeji.kafka.manager.web.converters.GatewayModelConverter;
|
||||||
@@ -16,12 +19,20 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
|
|
||||||
@Api(tags = "OP-Gateway配置相关接口(REST)")
|
@Api(tags = "OP-Gateway配置相关接口(REST)")
|
||||||
@RestController
|
@RestController
|
||||||
|
@RequestMapping(ApiPrefix.API_V1_OP_PREFIX)
|
||||||
public class OpGatewayConfigController {
|
public class OpGatewayConfigController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private GatewayConfigService gatewayConfigService;
|
private GatewayConfigService gatewayConfigService;
|
||||||
|
|
||||||
|
@ApiOperation(value = "Gateway配置类型", notes = "")
|
||||||
|
@GetMapping(value = "gateway-configs/type-enums")
|
||||||
|
@ResponseBody
|
||||||
|
public Result getClusterModesEnum() {
|
||||||
|
return new Result<>(JsonUtils.toJson(GatewayConfigKeyEnum.class));
|
||||||
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "创建Gateway配置", notes = "")
|
@ApiOperation(value = "创建Gateway配置", notes = "")
|
||||||
@RequestMapping(value = "gateway-configs", method = RequestMethod.POST)
|
@PostMapping(value = "gateway-configs")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Result createGatewayConfig(@RequestBody OrderExtensionAddGatewayConfigDTO dto) {
|
public Result createGatewayConfig(@RequestBody OrderExtensionAddGatewayConfigDTO dto) {
|
||||||
if (ValidateUtils.isNull(dto) || !dto.legal()) {
|
if (ValidateUtils.isNull(dto) || !dto.legal()) {
|
||||||
@@ -31,7 +42,7 @@ public class OpGatewayConfigController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "修改Gateway配置", notes = "")
|
@ApiOperation(value = "修改Gateway配置", notes = "")
|
||||||
@RequestMapping(value = "gateway-configs", method = RequestMethod.PUT)
|
@PutMapping(value = "gateway-configs")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Result modifyGatewayConfig(@RequestBody OrderExtensionModifyGatewayConfigDTO dto) {
|
public Result modifyGatewayConfig(@RequestBody OrderExtensionModifyGatewayConfigDTO dto) {
|
||||||
if (ValidateUtils.isNull(dto) || !dto.legal()) {
|
if (ValidateUtils.isNull(dto) || !dto.legal()) {
|
||||||
@@ -41,7 +52,7 @@ public class OpGatewayConfigController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "删除Gateway配置", notes = "")
|
@ApiOperation(value = "删除Gateway配置", notes = "")
|
||||||
@RequestMapping(value = "gateway-configs", method = RequestMethod.DELETE)
|
@DeleteMapping(value = "gateway-configs")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Result deleteGatewayConfig(@RequestBody OrderExtensionDeleteGatewayConfigDTO dto) {
|
public Result deleteGatewayConfig(@RequestBody OrderExtensionDeleteGatewayConfigDTO dto) {
|
||||||
if (ValidateUtils.isNull(dto) || !dto.legal()) {
|
if (ValidateUtils.isNull(dto) || !dto.legal()) {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.xiaojukeji.kafka.manager.web.api.versionone.rd;
|
package com.xiaojukeji.kafka.manager.web.api.versionone.rd;
|
||||||
|
|
||||||
|
import com.xiaojukeji.kafka.manager.common.constant.ApiPrefix;
|
||||||
import com.xiaojukeji.kafka.manager.common.entity.Result;
|
import com.xiaojukeji.kafka.manager.common.entity.Result;
|
||||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.GatewayConfigDO;
|
import com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.GatewayConfigDO;
|
||||||
import com.xiaojukeji.kafka.manager.common.entity.vo.rd.GatewayConfigVO;
|
import com.xiaojukeji.kafka.manager.common.entity.vo.rd.GatewayConfigVO;
|
||||||
@@ -15,12 +16,13 @@ import java.util.List;
|
|||||||
|
|
||||||
@Api(tags = "RD-Gateway配置相关接口(REST)")
|
@Api(tags = "RD-Gateway配置相关接口(REST)")
|
||||||
@RestController
|
@RestController
|
||||||
|
@RequestMapping(ApiPrefix.API_V1_RD_PREFIX)
|
||||||
public class RdGatewayConfigController {
|
public class RdGatewayConfigController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private GatewayConfigService gatewayConfigService;
|
private GatewayConfigService gatewayConfigService;
|
||||||
|
|
||||||
@ApiOperation(value = "Gateway相关配置信息", notes = "")
|
@ApiOperation(value = "Gateway相关配置信息", notes = "")
|
||||||
@RequestMapping(value = "gateway-configs", method = RequestMethod.GET)
|
@GetMapping(value = "gateway-configs")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Result<List<GatewayConfigVO>> getGatewayConfigs() {
|
public Result<List<GatewayConfigVO>> getGatewayConfigs() {
|
||||||
List<GatewayConfigDO> doList = gatewayConfigService.list();
|
List<GatewayConfigDO> doList = gatewayConfigService.list();
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
package com.xiaojukeji.kafka.manager.web.api.versionone.rd;
|
package com.xiaojukeji.kafka.manager.web.api.versionone.rd;
|
||||||
|
|
||||||
import com.xiaojukeji.kafka.manager.common.bizenum.KafkaFileEnum;
|
import com.xiaojukeji.kafka.manager.common.bizenum.KafkaFileEnum;
|
||||||
import com.xiaojukeji.kafka.manager.common.constant.ApiPrefix;
|
|
||||||
import com.xiaojukeji.kafka.manager.common.entity.Result;
|
import com.xiaojukeji.kafka.manager.common.entity.Result;
|
||||||
import com.xiaojukeji.kafka.manager.common.entity.dto.normal.KafkaFileDTO;
|
import com.xiaojukeji.kafka.manager.common.entity.dto.normal.KafkaFileDTO;
|
||||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.KafkaFileDO;
|
|
||||||
import com.xiaojukeji.kafka.manager.common.entity.vo.rd.KafkaFileVO;
|
import com.xiaojukeji.kafka.manager.common.entity.vo.rd.KafkaFileVO;
|
||||||
|
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
|
||||||
|
import com.xiaojukeji.kafka.manager.kcm.component.storage.common.StorageEnum;
|
||||||
|
import com.xiaojukeji.kafka.manager.common.entity.pojo.KafkaFileDO;
|
||||||
|
import com.xiaojukeji.kafka.manager.service.service.ClusterService;
|
||||||
|
import com.xiaojukeji.kafka.manager.kcm.KafkaFileService;
|
||||||
import com.xiaojukeji.kafka.manager.common.utils.JsonUtils;
|
import com.xiaojukeji.kafka.manager.common.utils.JsonUtils;
|
||||||
import com.xiaojukeji.kafka.manager.common.utils.SpringTool;
|
import com.xiaojukeji.kafka.manager.common.utils.SpringTool;
|
||||||
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
|
import com.xiaojukeji.kafka.manager.common.constant.ApiPrefix;
|
||||||
import com.xiaojukeji.kafka.manager.kcm.KafkaFileService;
|
|
||||||
import com.xiaojukeji.kafka.manager.kcm.component.storage.common.StorageEnum;
|
|
||||||
import com.xiaojukeji.kafka.manager.service.service.ClusterService;
|
|
||||||
import com.xiaojukeji.kafka.manager.web.converters.KafkaFileConverter;
|
import com.xiaojukeji.kafka.manager.web.converters.KafkaFileConverter;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
|||||||
@@ -24,14 +24,13 @@ import java.util.List;
|
|||||||
@RestController
|
@RestController
|
||||||
@RequestMapping(ApiPrefix.API_V1_RD_PREFIX)
|
@RequestMapping(ApiPrefix.API_V1_RD_PREFIX)
|
||||||
public class RdOperateRecordController {
|
public class RdOperateRecordController {
|
||||||
|
|
||||||
private static final int MAX_RECORD_COUNT = 200;
|
private static final int MAX_RECORD_COUNT = 200;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private OperateRecordService operateRecordService;
|
private OperateRecordService operateRecordService;
|
||||||
|
|
||||||
@ApiOperation(value = "查询操作记录", notes = "")
|
@ApiOperation(value = "查询操作记录", notes = "")
|
||||||
@RequestMapping(value = "operate-record", method = RequestMethod.POST)
|
@PostMapping(value = "operate-record")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Result<List<OperateRecordVO>> geOperateRecords(@RequestBody OperateRecordDTO dto) {
|
public Result<List<OperateRecordVO>> geOperateRecords(@RequestBody OperateRecordDTO dto) {
|
||||||
if (ValidateUtils.isNull(dto) || !dto.legal()) {
|
if (ValidateUtils.isNull(dto) || !dto.legal()) {
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ public class GatewayModelConverter {
|
|||||||
vo.setName(configDO.getName());
|
vo.setName(configDO.getName());
|
||||||
vo.setValue(configDO.getValue());
|
vo.setValue(configDO.getValue());
|
||||||
vo.setVersion(configDO.getVersion());
|
vo.setVersion(configDO.getVersion());
|
||||||
|
vo.setDescription(configDO.getDescription());
|
||||||
vo.setCreateTime(configDO.getCreateTime());
|
vo.setCreateTime(configDO.getCreateTime());
|
||||||
vo.setModifyTime(configDO.getModifyTime());
|
vo.setModifyTime(configDO.getModifyTime());
|
||||||
voList.add(vo);
|
voList.add(vo);
|
||||||
@@ -76,18 +77,20 @@ public class GatewayModelConverter {
|
|||||||
|
|
||||||
public static GatewayConfigDO convert2GatewayConfigDO(OrderExtensionAddGatewayConfigDTO configDTO) {
|
public static GatewayConfigDO convert2GatewayConfigDO(OrderExtensionAddGatewayConfigDTO configDTO) {
|
||||||
GatewayConfigDO configDO = new GatewayConfigDO();
|
GatewayConfigDO configDO = new GatewayConfigDO();
|
||||||
configDO.setType(configDO.getType());
|
configDO.setType(configDTO.getType());
|
||||||
configDO.setName(configDO.getName());
|
configDO.setName(configDTO.getName());
|
||||||
configDO.setValue(configDO.getValue());
|
configDO.setValue(configDTO.getValue());
|
||||||
|
configDO.setDescription(ValidateUtils.isNull(configDTO.getDescription())? "": configDTO.getDescription());
|
||||||
return configDO;
|
return configDO;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GatewayConfigDO convert2GatewayConfigDO(OrderExtensionModifyGatewayConfigDTO configDTO) {
|
public static GatewayConfigDO convert2GatewayConfigDO(OrderExtensionModifyGatewayConfigDTO configDTO) {
|
||||||
GatewayConfigDO configDO = new GatewayConfigDO();
|
GatewayConfigDO configDO = new GatewayConfigDO();
|
||||||
configDO.setId(configDO.getId());
|
configDO.setId(configDTO.getId());
|
||||||
configDO.setType(configDO.getType());
|
configDO.setType(configDTO.getType());
|
||||||
configDO.setName(configDO.getName());
|
configDO.setName(configDTO.getName());
|
||||||
configDO.setValue(configDO.getValue());
|
configDO.setValue(configDTO.getValue());
|
||||||
|
configDO.setDescription(ValidateUtils.isNull(configDTO.getDescription())? "": configDTO.getDescription());
|
||||||
return configDO;
|
return configDO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -119,7 +119,7 @@ public class WebMetricsInterceptor {
|
|||||||
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||||
String uri = attributes.getRequest().getRequestURI();
|
String uri = attributes.getRequest().getRequestURI();
|
||||||
if (uri.contains(ApiPrefix.GATEWAY_API_V1_PREFIX)) {
|
if (uri.contains(ApiPrefix.GATEWAY_API_V1_PREFIX)) {
|
||||||
return Result.buildFailure("api limited");
|
return Result.buildGatewayFailure("api limited");
|
||||||
}
|
}
|
||||||
return new Result<>(ResultStatus.OPERATION_FORBIDDEN);
|
return new Result<>(ResultStatus.OPERATION_FORBIDDEN);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ logging:
|
|||||||
custom:
|
custom:
|
||||||
idc: cn
|
idc: cn
|
||||||
jmx:
|
jmx:
|
||||||
max-conn: 10
|
max-conn: 10 # 2.3版本配置不在这个地方生效
|
||||||
store-metrics-task:
|
store-metrics-task:
|
||||||
community:
|
community:
|
||||||
broker-metrics-enabled: true
|
broker-metrics-enabled: true
|
||||||
@@ -53,7 +53,7 @@ account:
|
|||||||
kcm:
|
kcm:
|
||||||
enabled: false
|
enabled: false
|
||||||
s3:
|
s3:
|
||||||
endpoint: 127.0.0.1
|
endpoint: s3.didiyunapi.com
|
||||||
access-key: 1234567890
|
access-key: 1234567890
|
||||||
secret-key: 0987654321
|
secret-key: 0987654321
|
||||||
bucket: logi-kafka
|
bucket: logi-kafka
|
||||||
|
|||||||
2
pom.xml
2
pom.xml
@@ -16,7 +16,7 @@
|
|||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<kafka-manager.revision>2.2.0-SNAPSHOT</kafka-manager.revision>
|
<kafka-manager.revision>2.3.0-SNAPSHOT</kafka-manager.revision>
|
||||||
<swagger2.version>2.7.0</swagger2.version>
|
<swagger2.version>2.7.0</swagger2.version>
|
||||||
<swagger.version>1.5.13</swagger.version>
|
<swagger.version>1.5.13</swagger.version>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user