mirror of
https://github.com/didi/KnowStreaming.git
synced 2025-12-24 11:52:08 +08:00
Jmx连接的主机IP支持可选择
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
package com.xiaojukeji.know.streaming.km.common.bean.entity.broker;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.TypeReference;
|
||||
import com.xiaojukeji.know.streaming.km.common.bean.entity.common.IpPortData;
|
||||
import com.xiaojukeji.know.streaming.km.common.bean.po.broker.BrokerPO;
|
||||
import com.xiaojukeji.know.streaming.km.common.utils.ConvertUtil;
|
||||
import com.xiaojukeji.know.streaming.km.common.zookeeper.znode.brokers.BrokerMetadata;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
@@ -7,6 +12,7 @@ import lombok.NoArgsConstructor;
|
||||
import org.apache.kafka.common.Node;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author didi
|
||||
@@ -55,6 +61,11 @@ public class Broker implements Serializable {
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 监听信息
|
||||
*/
|
||||
private Map<String, IpPortData> endpointMap;
|
||||
|
||||
public static Broker buildFrom(Long clusterPhyId, Node node, Long startTimestamp) {
|
||||
Broker metadata = new Broker();
|
||||
metadata.setClusterPhyId(clusterPhyId);
|
||||
@@ -78,9 +89,31 @@ public class Broker implements Serializable {
|
||||
metadata.setStartTimestamp(brokerMetadata.getTimestamp());
|
||||
metadata.setRack(brokerMetadata.getRack());
|
||||
metadata.setStatus(1);
|
||||
metadata.setEndpointMap(brokerMetadata.getEndpointMap());
|
||||
return metadata;
|
||||
}
|
||||
|
||||
public static Broker buildFrom(BrokerPO brokerPO) {
|
||||
Broker broker = ConvertUtil.obj2Obj(brokerPO, Broker.class);
|
||||
String endpointMapStr = brokerPO.getEndpointMap();
|
||||
if (broker == null || endpointMapStr == null || endpointMapStr.equals("")) {
|
||||
return broker;
|
||||
}
|
||||
|
||||
// 填充endpoint信息
|
||||
Map<String, IpPortData> endpointMap = ConvertUtil.str2ObjByJson(endpointMapStr, new TypeReference<Map<String, IpPortData>>(){});
|
||||
broker.setEndpointMap(endpointMap);
|
||||
return broker;
|
||||
}
|
||||
|
||||
public String getJmxHost(String endPoint) {
|
||||
if (endPoint == null || endpointMap == null) {
|
||||
return host;
|
||||
}
|
||||
IpPortData ip = endpointMap.get(endPoint);
|
||||
return ip == null ? ip.getIp() : host;
|
||||
}
|
||||
|
||||
public boolean alive() {
|
||||
return status != null && status > 0;
|
||||
}
|
||||
|
||||
@@ -27,6 +27,9 @@ public class JmxConfig implements Serializable {
|
||||
|
||||
@ApiModelProperty(value="SSL情况下的token", example = "KsKmCCY19")
|
||||
private String token;
|
||||
|
||||
@ApiModelProperty(value="使用哪个endpoint网络", example = "EXTERNAL")
|
||||
private String useWhichEndpoint;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -42,4 +42,9 @@ public class BrokerPO extends BasePO {
|
||||
* Broker状态
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 监听信息
|
||||
*/
|
||||
private String endpointMap;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user