mirror of
https://github.com/didi/KnowStreaming.git
synced 2026-01-03 11:28:12 +08:00
add v2.2.0 feature & fix
This commit is contained in:
@@ -9,6 +9,8 @@ public class LogicalCluster {
|
||||
|
||||
private String logicalClusterName;
|
||||
|
||||
private String logicalClusterIdentification;
|
||||
|
||||
private Integer mode;
|
||||
|
||||
private Integer topicNum;
|
||||
@@ -41,6 +43,14 @@ public class LogicalCluster {
|
||||
this.logicalClusterName = logicalClusterName;
|
||||
}
|
||||
|
||||
public String getLogicalClusterIdentification() {
|
||||
return logicalClusterIdentification;
|
||||
}
|
||||
|
||||
public void setLogicalClusterIdentification(String logicalClusterIdentification) {
|
||||
this.logicalClusterIdentification = logicalClusterIdentification;
|
||||
}
|
||||
|
||||
public Integer getMode() {
|
||||
return mode;
|
||||
}
|
||||
@@ -81,6 +91,14 @@ public class LogicalCluster {
|
||||
this.bootstrapServers = bootstrapServers;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Long getGmtCreate() {
|
||||
return gmtCreate;
|
||||
}
|
||||
@@ -97,19 +115,12 @@ public class LogicalCluster {
|
||||
this.gmtModify = gmtModify;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "LogicalCluster{" +
|
||||
"logicalClusterId=" + logicalClusterId +
|
||||
", logicalClusterName='" + logicalClusterName + '\'' +
|
||||
", logicalClusterIdentification='" + logicalClusterIdentification + '\'' +
|
||||
", mode=" + mode +
|
||||
", topicNum=" + topicNum +
|
||||
", clusterVersion='" + clusterVersion + '\'' +
|
||||
|
||||
@@ -27,9 +27,12 @@ public class ClusterDTO {
|
||||
@ApiModelProperty(value="数据中心")
|
||||
private String idc;
|
||||
|
||||
@ApiModelProperty(value="安全配置参数")
|
||||
@ApiModelProperty(value="Kafka安全配置")
|
||||
private String securityProperties;
|
||||
|
||||
@ApiModelProperty(value="Jmx配置")
|
||||
private String jmxProperties;
|
||||
|
||||
public Long getClusterId() {
|
||||
return clusterId;
|
||||
}
|
||||
@@ -78,6 +81,14 @@ public class ClusterDTO {
|
||||
this.securityProperties = securityProperties;
|
||||
}
|
||||
|
||||
public String getJmxProperties() {
|
||||
return jmxProperties;
|
||||
}
|
||||
|
||||
public void setJmxProperties(String jmxProperties) {
|
||||
this.jmxProperties = jmxProperties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ClusterDTO{" +
|
||||
@@ -87,6 +98,7 @@ public class ClusterDTO {
|
||||
", bootstrapServers='" + bootstrapServers + '\'' +
|
||||
", idc='" + idc + '\'' +
|
||||
", securityProperties='" + securityProperties + '\'' +
|
||||
", jmxProperties='" + jmxProperties + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,9 @@ public class LogicalClusterDTO {
|
||||
@ApiModelProperty(value = "名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "集群标识, 用于告警的上报")
|
||||
private String identification;
|
||||
|
||||
@ApiModelProperty(value = "集群模式")
|
||||
private Integer mode;
|
||||
|
||||
@@ -52,6 +55,14 @@ public class LogicalClusterDTO {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getIdentification() {
|
||||
return identification;
|
||||
}
|
||||
|
||||
public void setIdentification(String identification) {
|
||||
this.identification = identification;
|
||||
}
|
||||
|
||||
public Integer getMode() {
|
||||
return mode;
|
||||
}
|
||||
@@ -97,6 +108,7 @@ public class LogicalClusterDTO {
|
||||
return "LogicalClusterDTO{" +
|
||||
"id=" + id +
|
||||
", name='" + name + '\'' +
|
||||
", identification='" + identification + '\'' +
|
||||
", mode=" + mode +
|
||||
", clusterId=" + clusterId +
|
||||
", regionIdList=" + regionIdList +
|
||||
@@ -117,6 +129,7 @@ public class LogicalClusterDTO {
|
||||
}
|
||||
appId = ValidateUtils.isNull(appId)? "": appId;
|
||||
description = ValidateUtils.isNull(description)? "": description;
|
||||
identification = ValidateUtils.isNull(identification)? name: identification;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,8 @@ public class ClusterDO implements Comparable<ClusterDO> {
|
||||
|
||||
private String securityProperties;
|
||||
|
||||
private String jmxProperties;
|
||||
|
||||
private Integer status;
|
||||
|
||||
private Date gmtCreate;
|
||||
@@ -31,30 +33,6 @@ public class ClusterDO implements Comparable<ClusterDO> {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public Date getGmtCreate() {
|
||||
return gmtCreate;
|
||||
}
|
||||
|
||||
public void setGmtCreate(Date gmtCreate) {
|
||||
this.gmtCreate = gmtCreate;
|
||||
}
|
||||
|
||||
public Date getGmtModify() {
|
||||
return gmtModify;
|
||||
}
|
||||
|
||||
public void setGmtModify(Date gmtModify) {
|
||||
this.gmtModify = gmtModify;
|
||||
}
|
||||
|
||||
public String getClusterName() {
|
||||
return clusterName;
|
||||
}
|
||||
@@ -87,6 +65,38 @@ public class ClusterDO implements Comparable<ClusterDO> {
|
||||
this.securityProperties = securityProperties;
|
||||
}
|
||||
|
||||
public String getJmxProperties() {
|
||||
return jmxProperties;
|
||||
}
|
||||
|
||||
public void setJmxProperties(String jmxProperties) {
|
||||
this.jmxProperties = jmxProperties;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public Date getGmtCreate() {
|
||||
return gmtCreate;
|
||||
}
|
||||
|
||||
public void setGmtCreate(Date gmtCreate) {
|
||||
this.gmtCreate = gmtCreate;
|
||||
}
|
||||
|
||||
public Date getGmtModify() {
|
||||
return gmtModify;
|
||||
}
|
||||
|
||||
public void setGmtModify(Date gmtModify) {
|
||||
this.gmtModify = gmtModify;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ClusterDO{" +
|
||||
@@ -95,6 +105,7 @@ public class ClusterDO implements Comparable<ClusterDO> {
|
||||
", zookeeper='" + zookeeper + '\'' +
|
||||
", bootstrapServers='" + bootstrapServers + '\'' +
|
||||
", securityProperties='" + securityProperties + '\'' +
|
||||
", jmxProperties='" + jmxProperties + '\'' +
|
||||
", status=" + status +
|
||||
", gmtCreate=" + gmtCreate +
|
||||
", gmtModify=" + gmtModify +
|
||||
|
||||
@@ -11,6 +11,8 @@ public class LogicalClusterDO {
|
||||
|
||||
private String name;
|
||||
|
||||
private String identification;
|
||||
|
||||
private Integer mode;
|
||||
|
||||
private String appId;
|
||||
@@ -41,6 +43,14 @@ public class LogicalClusterDO {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getIdentification() {
|
||||
return identification;
|
||||
}
|
||||
|
||||
public void setIdentification(String identification) {
|
||||
this.identification = identification;
|
||||
}
|
||||
|
||||
public Integer getMode() {
|
||||
return mode;
|
||||
}
|
||||
@@ -102,6 +112,7 @@ public class LogicalClusterDO {
|
||||
return "LogicalClusterDO{" +
|
||||
"id=" + id +
|
||||
", name='" + name + '\'' +
|
||||
", identification='" + identification + '\'' +
|
||||
", mode=" + mode +
|
||||
", appId='" + appId + '\'' +
|
||||
", clusterId=" + clusterId +
|
||||
|
||||
@@ -15,6 +15,9 @@ public class LogicClusterVO {
|
||||
@ApiModelProperty(value="逻辑集群名称")
|
||||
private String clusterName;
|
||||
|
||||
@ApiModelProperty(value="逻辑标识")
|
||||
private String clusterIdentification;
|
||||
|
||||
@ApiModelProperty(value="逻辑集群类型, 0:共享集群, 1:独享集群, 2:独立集群")
|
||||
private Integer mode;
|
||||
|
||||
@@ -24,9 +27,6 @@ public class LogicClusterVO {
|
||||
@ApiModelProperty(value="集群版本")
|
||||
private String clusterVersion;
|
||||
|
||||
@ApiModelProperty(value="物理集群ID")
|
||||
private Long physicalClusterId;
|
||||
|
||||
@ApiModelProperty(value="集群服务地址")
|
||||
private String bootstrapServers;
|
||||
|
||||
@@ -55,6 +55,22 @@ public class LogicClusterVO {
|
||||
this.clusterName = clusterName;
|
||||
}
|
||||
|
||||
public String getClusterIdentification() {
|
||||
return clusterIdentification;
|
||||
}
|
||||
|
||||
public void setClusterIdentification(String clusterIdentification) {
|
||||
this.clusterIdentification = clusterIdentification;
|
||||
}
|
||||
|
||||
public Integer getMode() {
|
||||
return mode;
|
||||
}
|
||||
|
||||
public void setMode(Integer mode) {
|
||||
this.mode = mode;
|
||||
}
|
||||
|
||||
public Integer getTopicNum() {
|
||||
return topicNum;
|
||||
}
|
||||
@@ -71,14 +87,6 @@ public class LogicClusterVO {
|
||||
this.clusterVersion = clusterVersion;
|
||||
}
|
||||
|
||||
public Long getPhysicalClusterId() {
|
||||
return physicalClusterId;
|
||||
}
|
||||
|
||||
public void setPhysicalClusterId(Long physicalClusterId) {
|
||||
this.physicalClusterId = physicalClusterId;
|
||||
}
|
||||
|
||||
public String getBootstrapServers() {
|
||||
return bootstrapServers;
|
||||
}
|
||||
@@ -87,6 +95,14 @@ public class LogicClusterVO {
|
||||
this.bootstrapServers = bootstrapServers;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Long getGmtCreate() {
|
||||
return gmtCreate;
|
||||
}
|
||||
@@ -103,32 +119,15 @@ public class LogicClusterVO {
|
||||
this.gmtModify = gmtModify;
|
||||
}
|
||||
|
||||
public Integer getMode() {
|
||||
return mode;
|
||||
}
|
||||
|
||||
public void setMode(Integer mode) {
|
||||
this.mode = mode;
|
||||
}
|
||||
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "LogicClusterVO{" +
|
||||
"clusterId=" + clusterId +
|
||||
", clusterName='" + clusterName + '\'' +
|
||||
", clusterIdentification='" + clusterIdentification + '\'' +
|
||||
", mode=" + mode +
|
||||
", topicNum=" + topicNum +
|
||||
", clusterVersion='" + clusterVersion + '\'' +
|
||||
", physicalClusterId=" + physicalClusterId +
|
||||
", bootstrapServers='" + bootstrapServers + '\'' +
|
||||
", description='" + description + '\'' +
|
||||
", gmtCreate=" + gmtCreate +
|
||||
|
||||
@@ -32,9 +32,12 @@ public class ClusterBaseVO {
|
||||
@ApiModelProperty(value="集群类型")
|
||||
private Integer mode;
|
||||
|
||||
@ApiModelProperty(value="安全配置参数")
|
||||
@ApiModelProperty(value="Kafka安全配置")
|
||||
private String securityProperties;
|
||||
|
||||
@ApiModelProperty(value="Jmx配置")
|
||||
private String jmxProperties;
|
||||
|
||||
@ApiModelProperty(value="1:监控中, 0:暂停监控")
|
||||
private Integer status;
|
||||
|
||||
@@ -108,6 +111,14 @@ public class ClusterBaseVO {
|
||||
this.securityProperties = securityProperties;
|
||||
}
|
||||
|
||||
public String getJmxProperties() {
|
||||
return jmxProperties;
|
||||
}
|
||||
|
||||
public void setJmxProperties(String jmxProperties) {
|
||||
this.jmxProperties = jmxProperties;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
@@ -141,8 +152,9 @@ public class ClusterBaseVO {
|
||||
", bootstrapServers='" + bootstrapServers + '\'' +
|
||||
", kafkaVersion='" + kafkaVersion + '\'' +
|
||||
", idc='" + idc + '\'' +
|
||||
", mode='" + mode + '\'' +
|
||||
", mode=" + mode +
|
||||
", securityProperties='" + securityProperties + '\'' +
|
||||
", jmxProperties='" + jmxProperties + '\'' +
|
||||
", status=" + status +
|
||||
", gmtCreate=" + gmtCreate +
|
||||
", gmtModify=" + gmtModify +
|
||||
|
||||
@@ -18,6 +18,9 @@ public class LogicalClusterVO {
|
||||
@ApiModelProperty(value = "逻辑集群名称")
|
||||
private String logicalClusterName;
|
||||
|
||||
@ApiModelProperty(value = "逻辑集群标识")
|
||||
private String logicalClusterIdentification;
|
||||
|
||||
@ApiModelProperty(value = "物理集群ID")
|
||||
private Long physicalClusterId;
|
||||
|
||||
@@ -55,6 +58,14 @@ public class LogicalClusterVO {
|
||||
this.logicalClusterName = logicalClusterName;
|
||||
}
|
||||
|
||||
public String getLogicalClusterIdentification() {
|
||||
return logicalClusterIdentification;
|
||||
}
|
||||
|
||||
public void setLogicalClusterIdentification(String logicalClusterIdentification) {
|
||||
this.logicalClusterIdentification = logicalClusterIdentification;
|
||||
}
|
||||
|
||||
public Long getPhysicalClusterId() {
|
||||
return physicalClusterId;
|
||||
}
|
||||
@@ -116,6 +127,7 @@ public class LogicalClusterVO {
|
||||
return "LogicalClusterVO{" +
|
||||
"logicalClusterId=" + logicalClusterId +
|
||||
", logicalClusterName='" + logicalClusterName + '\'' +
|
||||
", logicalClusterIdentification='" + logicalClusterIdentification + '\'' +
|
||||
", physicalClusterId=" + physicalClusterId +
|
||||
", regionIdList=" + regionIdList +
|
||||
", mode=" + mode +
|
||||
|
||||
@@ -53,6 +53,13 @@ public class JsonUtils {
|
||||
return JSON.toJSONString(obj);
|
||||
}
|
||||
|
||||
public static <T> T stringToObj(String src, Class<T> clazz) {
|
||||
if (ValidateUtils.isBlank(src)) {
|
||||
return null;
|
||||
}
|
||||
return JSON.parseObject(src, clazz);
|
||||
}
|
||||
|
||||
public static List<TopicConnectionDO> parseTopicConnections(Long clusterId, JSONObject jsonObject, long postTime) {
|
||||
List<TopicConnectionDO> connectionDOList = new ArrayList<>();
|
||||
for (String clientType: jsonObject.keySet()) {
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.xiaojukeji.kafka.manager.common.utils.jmx;
|
||||
|
||||
public class JmxConfig {
|
||||
/**
|
||||
* 单台最大连接数
|
||||
*/
|
||||
private Integer maxConn;
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 开启SSL
|
||||
*/
|
||||
private Boolean openSSL;
|
||||
|
||||
public Integer getMaxConn() {
|
||||
return maxConn;
|
||||
}
|
||||
|
||||
public void setMaxConn(Integer maxConn) {
|
||||
this.maxConn = maxConn;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public Boolean isOpenSSL() {
|
||||
return openSSL;
|
||||
}
|
||||
|
||||
public void setOpenSSL(Boolean openSSL) {
|
||||
this.openSSL = openSSL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "JmxConfig{" +
|
||||
"maxConn=" + maxConn +
|
||||
", username='" + username + '\'' +
|
||||
", password='" + password + '\'' +
|
||||
", openSSL=" + openSSL +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.xiaojukeji.kafka.manager.common.utils.jmx;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -7,8 +8,14 @@ import javax.management.*;
|
||||
import javax.management.remote.JMXConnector;
|
||||
import javax.management.remote.JMXConnectorFactory;
|
||||
import javax.management.remote.JMXServiceURL;
|
||||
import javax.management.remote.rmi.RMIConnectorServer;
|
||||
import javax.naming.Context;
|
||||
import javax.rmi.ssl.SslRMIClientSocketFactory;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
@@ -28,13 +35,19 @@ public class JmxConnectorWrap {
|
||||
|
||||
private AtomicInteger atomicInteger;
|
||||
|
||||
public JmxConnectorWrap(String host, int port, int maxConn) {
|
||||
private JmxConfig jmxConfig;
|
||||
|
||||
public JmxConnectorWrap(String host, int port, JmxConfig jmxConfig) {
|
||||
this.host = host;
|
||||
this.port = port;
|
||||
if (maxConn <= 0) {
|
||||
maxConn = 1;
|
||||
this.jmxConfig = jmxConfig;
|
||||
if (ValidateUtils.isNull(this.jmxConfig)) {
|
||||
this.jmxConfig = new JmxConfig();
|
||||
}
|
||||
this.atomicInteger = new AtomicInteger(maxConn);
|
||||
if (ValidateUtils.isNullOrLessThanZero(this.jmxConfig.getMaxConn())) {
|
||||
this.jmxConfig.setMaxConn(1);
|
||||
}
|
||||
this.atomicInteger = new AtomicInteger(this.jmxConfig.getMaxConn());
|
||||
}
|
||||
|
||||
public boolean checkJmxConnectionAndInitIfNeed() {
|
||||
@@ -64,8 +77,18 @@ public class JmxConnectorWrap {
|
||||
}
|
||||
String jmxUrl = String.format("service:jmx:rmi:///jndi/rmi://%s:%d/jmxrmi", host, port);
|
||||
try {
|
||||
JMXServiceURL url = new JMXServiceURL(jmxUrl);
|
||||
jmxConnector = JMXConnectorFactory.connect(url, null);
|
||||
Map<String, Object> environment = new HashMap<String, Object>();
|
||||
if (!ValidateUtils.isBlank(this.jmxConfig.getUsername()) && !ValidateUtils.isBlank(this.jmxConfig.getPassword())) {
|
||||
environment.put(javax.management.remote.JMXConnector.CREDENTIALS, Arrays.asList(this.jmxConfig.getUsername(), this.jmxConfig.getPassword()));
|
||||
}
|
||||
if (jmxConfig.isOpenSSL() != null && this.jmxConfig.isOpenSSL()) {
|
||||
environment.put(Context.SECURITY_PROTOCOL, "ssl");
|
||||
SslRMIClientSocketFactory clientSocketFactory = new SslRMIClientSocketFactory();
|
||||
environment.put(RMIConnectorServer.RMI_CLIENT_SOCKET_FACTORY_ATTRIBUTE, clientSocketFactory);
|
||||
environment.put("com.sun.jndi.rmi.factory.socket", clientSocketFactory);
|
||||
}
|
||||
|
||||
jmxConnector = JMXConnectorFactory.connect(new JMXServiceURL(jmxUrl), environment);
|
||||
LOGGER.info("JMX connect success, host:{} port:{}.", host, port);
|
||||
return true;
|
||||
} catch (MalformedURLException e) {
|
||||
|
||||
Reference in New Issue
Block a user