mirror of
https://github.com/didi/KnowStreaming.git
synced 2025-12-24 11:52:08 +08:00
Merge pull request #364 from Huyueeer/devConfig
平台配置EXPIRED_TOPIC_CONFIG新增正则过滤Topic
This commit is contained in:
@@ -136,7 +136,8 @@ EXPIRED_TOPIC_CONFIG
|
|||||||
配置Value:
|
配置Value:
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"minExpiredDay": 30, #过期时间大于此值才显示
|
"minExpiredDay": 30, #过期时间大于此值才显示,
|
||||||
|
"filterRegex": ".*XXX\\s+", #忽略符合此正则规则的Topic
|
||||||
"ignoreClusterIdList": [ # 忽略的集群
|
"ignoreClusterIdList": [ # 忽略的集群
|
||||||
50
|
50
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ import java.util.List;
|
|||||||
public class TopicExpiredConfig {
|
public class TopicExpiredConfig {
|
||||||
private Integer minExpiredDay = 30;
|
private Integer minExpiredDay = 30;
|
||||||
|
|
||||||
|
private String filterRegex = "";
|
||||||
|
|
||||||
private List<Long> ignoreClusterIdList = new ArrayList<>();
|
private List<Long> ignoreClusterIdList = new ArrayList<>();
|
||||||
|
|
||||||
public Integer getMinExpiredDay() {
|
public Integer getMinExpiredDay() {
|
||||||
@@ -28,10 +30,19 @@ public class TopicExpiredConfig {
|
|||||||
this.ignoreClusterIdList = ignoreClusterIdList;
|
this.ignoreClusterIdList = ignoreClusterIdList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getFilterRegex() {
|
||||||
|
return filterRegex;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFilterRegex(String filterRegex) {
|
||||||
|
this.filterRegex = filterRegex;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "TopicExpiredConfig{" +
|
return "TopicExpiredConfig{" +
|
||||||
"minExpiredDay=" + minExpiredDay +
|
"minExpiredDay=" + minExpiredDay +
|
||||||
|
", filterRegex='" + filterRegex + '\'' +
|
||||||
", ignoreClusterIdList=" + ignoreClusterIdList +
|
", ignoreClusterIdList=" + ignoreClusterIdList +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author zengqiao
|
* @author zengqiao
|
||||||
@@ -240,9 +241,11 @@ public class ExpertServiceImpl implements ExpertService {
|
|||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//获取满足条件的过期Topic
|
||||||
List<TopicExpiredDO> filteredExpiredTopicList = new ArrayList<>();
|
List<TopicExpiredDO> filteredExpiredTopicList = new ArrayList<>();
|
||||||
for (TopicExpiredDO elem: expiredTopicList) {
|
for (TopicExpiredDO elem: expiredTopicList) {
|
||||||
if (config.getIgnoreClusterIdList().contains(elem.getClusterId())) {
|
//判定是否为忽略Cluster或者判定是否为忽略Topic名,使用正则来过滤理论上不属于过期的Topic
|
||||||
|
if (config.getIgnoreClusterIdList().contains(elem.getClusterId()) || Pattern.matches(config.getFilterRegex(), elem.getTopicName())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
filteredExpiredTopicList.add(elem);
|
filteredExpiredTopicList.add(elem);
|
||||||
|
|||||||
Reference in New Issue
Block a user