[Feature]HA-镜像Topic管理(#899)

1、底层Kafka需要是滴滴版本的Kafka;
2、新增镜像Topic的增删改查;
3、新增镜像Topic的指标查看;
This commit is contained in:
zengqiao
2023-02-09 15:19:28 +08:00
committed by EricZeng
parent efdf624c67
commit 861faa5df5
25 changed files with 725 additions and 3 deletions

View File

@@ -0,0 +1,38 @@
package com.xiaojukeji.know.streaming.km.common.bean.dto.ha.mirror;
import com.xiaojukeji.know.streaming.km.common.bean.dto.BaseDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
* @author zengqiao
* @date 20/4/23
*/
@Data
@ApiModel(description="Topic镜像信息")
public class MirrorTopicCreateDTO extends BaseDTO {
@Min(value = 0, message = "sourceClusterPhyId不允许为空且最小值为0")
@ApiModelProperty(value = "源集群ID", example = "3")
private Long sourceClusterPhyId;
@Min(value = 0, message = "destClusterPhyId不允许为空且最小值为0")
@ApiModelProperty(value = "目标集群ID", example = "3")
private Long destClusterPhyId;
@NotBlank(message = "topicName不允许为空串")
@ApiModelProperty(value = "Topic名称", example = "mirrorTopic")
private String topicName;
@NotNull(message = "syncData不允许为空")
@ApiModelProperty(value = "同步数据", example = "true")
private Boolean syncData;
@NotNull(message = "syncConfig不允许为空")
@ApiModelProperty(value = "同步配置", example = "false")
private Boolean syncConfig;
}

View File

@@ -0,0 +1,29 @@
package com.xiaojukeji.know.streaming.km.common.bean.dto.ha.mirror;
import com.xiaojukeji.know.streaming.km.common.bean.dto.BaseDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
/**
* @author zengqiao
* @date 20/4/23
*/
@Data
@ApiModel(description="Topic镜像信息")
public class MirrorTopicDeleteDTO extends BaseDTO {
@Min(value = 0, message = "sourceClusterPhyId不允许为空且最小值为0")
@ApiModelProperty(value = "源集群ID", example = "3")
private Long sourceClusterPhyId;
@Min(value = 0, message = "destClusterPhyId不允许为空且最小值为0")
@ApiModelProperty(value = "目标集群ID", example = "3")
private Long destClusterPhyId;
@NotBlank(message = "topicName不允许为空串")
@ApiModelProperty(value = "Topic名称", example = "mirrorTopic")
private String topicName;
}

View File

@@ -0,0 +1,23 @@
package com.xiaojukeji.know.streaming.km.common.bean.entity.ha;
import com.xiaojukeji.know.streaming.km.common.bean.po.BasePO;
import com.xiaojukeji.know.streaming.km.common.enums.ha.HaResTypeEnum;
import lombok.Data;
@Data
public class HaActiveStandbyRelation extends BasePO {
private Long activeClusterPhyId;
private Long standbyClusterPhyId;
/**
* 资源名称
*/
private String resName;
/**
* 资源类型0集群1镜像Topic2主备Topic
* @see HaResTypeEnum
*/
private Integer resType;
}

View File

@@ -0,0 +1,33 @@
package com.xiaojukeji.know.streaming.km.common.bean.po.ha;
import com.baomidou.mybatisplus.annotation.TableName;
import com.xiaojukeji.know.streaming.km.common.bean.po.BasePO;
import com.xiaojukeji.know.streaming.km.common.constant.Constant;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@TableName(Constant.MYSQL_HA_TABLE_NAME_PREFIX + "active_standby_relation")
public class HaActiveStandbyRelationPO extends BasePO {
private Long activeClusterPhyId;
private Long standbyClusterPhyId;
/**
* 资源名称
*/
private String resName;
/**
* 资源类型0集群1镜像Topic2主备Topic
*/
private Integer resType;
public HaActiveStandbyRelationPO(Long activeClusterPhyId, Long standbyClusterPhyId, String resName, Integer resType) {
this.activeClusterPhyId = activeClusterPhyId;
this.standbyClusterPhyId = standbyClusterPhyId;
this.resName = resName;
this.resType = resType;
}
}

View File

@@ -32,6 +32,9 @@ public class ClusterPhyTopicsOverviewVO extends BaseTimeVO {
@ApiModelProperty(value = "副本数", example = "2")
private Integer replicaNum;
@ApiModelProperty(value = "处于镜像复制中", example = "true")
private Boolean inMirror;
@ApiModelProperty(value = "多个指标的当前值, 包括健康分/LogSize等")
private BaseMetrics latestMetrics;

View File

@@ -0,0 +1,37 @@
package com.xiaojukeji.know.streaming.km.common.bean.vo.ha.mirror;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author zengqiao
* @date 20/4/29
*/
@Data
@ApiModel(description="Topic复制信息")
public class TopicMirrorInfoVO {
@ApiModelProperty(value="源集群ID", example = "1")
private Long sourceClusterId;
@ApiModelProperty(value="源集群名称", example = "know-streaming-1")
private String sourceClusterName;
@ApiModelProperty(value="目标集群ID", example = "2")
private Long destClusterId;
@ApiModelProperty(value="目标集群名称", example = "know-streaming-2")
private String destClusterName;
@ApiModelProperty(value="Topic名称", example = "know-streaming")
private String topicName;
@ApiModelProperty(value="写入速率(bytes/s)", example = "100")
private Double bytesIn;
@ApiModelProperty(value="复制速率(bytes/s)", example = "100")
private Double replicationBytesIn;
@ApiModelProperty(value="延迟消息数", example = "100")
private Long lag;
}

View File

@@ -46,6 +46,7 @@ public class Constant {
public static final String MYSQL_TABLE_NAME_PREFIX = "ks_km_";
public static final String MYSQL_KC_TABLE_NAME_PREFIX = "ks_kc_";
public static final String MYSQL_HA_TABLE_NAME_PREFIX = "ks_ha_";
public static final String SWAGGER_API_TAG_PREFIX = "KS-KM-";

View File

@@ -77,7 +77,7 @@ public class TopicVOConverter {
return vo;
}
public static List<ClusterPhyTopicsOverviewVO> convert2ClusterPhyTopicsOverviewVOList(List<Topic> topicList, Map<String, TopicMetrics> metricsMap) {
public static List<ClusterPhyTopicsOverviewVO> convert2ClusterPhyTopicsOverviewVOList(List<Topic> topicList, Map<String, TopicMetrics> metricsMap, Set<String> haTopicNameSet) {
List<ClusterPhyTopicsOverviewVO> voList = new ArrayList<>();
for (Topic topic: topicList) {
ClusterPhyTopicsOverviewVO vo = new ClusterPhyTopicsOverviewVO();
@@ -92,6 +92,7 @@ public class TopicVOConverter {
vo.setLatestMetrics(metricsMap.getOrDefault(topic.getTopicName(), new TopicMetrics(topic.getTopicName(), topic.getClusterPhyId())));
vo.setInMirror(haTopicNameSet.contains(topic.getTopicName()));
voList.add(vo);
}

View File

@@ -0,0 +1,25 @@
package com.xiaojukeji.know.streaming.km.common.enums.ha;
import lombok.Getter;
/**
* @author zengqiao
* @date 20/7/28
*/
@Getter
public enum HaResTypeEnum {
CLUSTER(0, "Cluster"),
MIRROR_TOPIC(1, "镜像Topic"),
;
private final int code;
private final String msg;
HaResTypeEnum(int code, String msg) {
this.code = code;
this.msg = msg;
}
}