Skip to content

Commit

Permalink
[ISSUE apache#4577] Implement FilterEngine for EventMesh Filters
Browse files Browse the repository at this point in the history
  • Loading branch information
xwm1992 committed Nov 24, 2023
1 parent e6fc846 commit 7d0c500
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -288,21 +288,24 @@ public Map<String, String> getMetaData(String key, boolean fuzzyEnabled) {
Map<String, String> result = new HashMap<>();
Map<String, String> tmpMap;
do {
tmpMap = getResultFromNacos(pageNo, pageSize, key, group);
tmpMap = getResultFromNacos(pageNo, pageSize, key, group, fuzzyEnabled);
result.putAll(tmpMap);
} while (!(tmpMap.size() < pageSize));
return result;
}

private Map<String, String> getResultFromNacos(int pageNo, int pageSize, String key, String group) {
private Map<String, String> getResultFromNacos(int pageNo, int pageSize, String key, String group, boolean fuzzyEnabled) {
Map<String, String> result = new HashMap<>();
try (CloseableHttpClient httpclient = HttpClients.createDefault()) {
URI uri = new URIBuilder("http://" + serverAddr + "/nacos/v1/cs/configs")
URIBuilder uriBuilder = new URIBuilder("http://" + serverAddr + "/nacos/v1/cs/configs")
.setParameter("dataId", key)
.setParameter("group", group)
.setParameter("pageNo", String.valueOf(pageNo))
.setParameter("pageSize", String.valueOf(pageSize))
.build();
.setParameter("pageSize", String.valueOf(pageSize));
if (fuzzyEnabled) {
uriBuilder.setParameter("search", "blur");
}
URI uri = uriBuilder.build();
HttpGet httpGet = new HttpGet(uri);
try (CloseableHttpResponse closeableHttpResponse = httpclient.execute(httpGet)){
if (closeableHttpResponse.getStatusLine().getStatusCode() == 200) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ private void updateFilterPatternMap(String key, String value) {
if (filterJsonNodeArray != null) {
for (JsonNode filterJsonNode : filterJsonNodeArray) {
String topic = filterJsonNode.get("topic").asText();
String filterCondition = filterJsonNode.get("condition").asText();
String filterCondition = filterJsonNode.get("condition").toString();
Pattern filterPattern = PatternBuilder.build(filterCondition);
filterPatternMap.put(group + "-" + topic, filterPattern);
}
Expand Down

0 comments on commit 7d0c500

Please sign in to comment.