XiaoYou201 commented on code in PR #10156: URL: https://github.com/apache/inlong/pull/10156#discussion_r1595078185
########## inlong-sort/sort-flink/base/src/main/java/org/apache/inlong/sort/base/metric/MetricOption.java: ########## @@ -57,62 +58,38 @@ public class MetricOption implements Serializable { private List<Integer> inlongAuditKeys; private MetricOption( - String inlongLabels, + Map<String, String> labels, @Nullable String inlongAudit, RegisteredMetric registeredMetric, long initRecords, long initBytes, Long initDirtyRecords, Long initDirtyBytes, Long readPhase, - String inlongAuditKeys) { - Preconditions.checkArgument(!StringUtils.isNullOrWhitespaceOnly(inlongLabels), - "Inlong labels must be set for register metric."); - + List<Integer> inlongAuditKeys, + Set<String> ipPortSet) { this.initRecords = initRecords; this.initBytes = initBytes; this.initDirtyRecords = initDirtyRecords; this.initDirtyBytes = initDirtyBytes; this.readPhase = readPhase; - this.labels = new LinkedHashMap<>(); - String[] inLongLabelArray = inlongLabels.split(DELIMITER); - Preconditions.checkArgument(Stream.of(inLongLabelArray).allMatch(label -> label.contains("=")), - "InLong metric label format must be xxx=xxx"); - Stream.of(inLongLabelArray).forEach(label -> { - String key = label.substring(0, label.indexOf('=')); - String value = label.substring(label.indexOf('=') + 1); - labels.put(key, value); - }); - + this.labels = labels; this.ipPorts = inlongAudit; - - if (ipPorts != null) { - - Preconditions.checkArgument(labels.containsKey(GROUP_ID) && labels.containsKey(STREAM_ID), - "groupId and streamId must be set when enable inlong audit collect."); - - if (inlongAuditKeys == null) { - LOG.warn("should set inlongAuditKeys when enable inlong audit collect, " - + "fallback to use id {} as audit key", AUDIT_SORT_INPUT); - inlongAuditKeys = AUDIT_SORT_INPUT; - } - - this.inlongAuditKeys = AuditUtils.extractAuditKeys(inlongAuditKeys); - this.ipPortList = AuditUtils.extractAuditIpPorts(ipPorts); - - } - - if (registeredMetric != null) { - this.registeredMetric = registeredMetric; - } + this.inlongAuditKeys = inlongAuditKeys; + this.ipPortSet = ipPortSet; + this.registeredMetric = registeredMetric; } public Map<String, String> getLabels() { return labels; } - public HashSet<String> getIpPortList() { - return ipPortList; + public Set<String> getIpPortSet() { Review Comment: This method was originally provided for the Audit module, but the Audit module uses HashSet, and this method returns Set, so a getIpPortSetAsHashSet method was added to be compatible with Audit.  ########## inlong-sort/sort-flink/base/src/main/java/org/apache/inlong/sort/base/metric/MetricOption.java: ########## @@ -57,62 +58,38 @@ public class MetricOption implements Serializable { private List<Integer> inlongAuditKeys; private MetricOption( - String inlongLabels, + Map<String, String> labels, @Nullable String inlongAudit, RegisteredMetric registeredMetric, long initRecords, long initBytes, Long initDirtyRecords, Long initDirtyBytes, Long readPhase, - String inlongAuditKeys) { - Preconditions.checkArgument(!StringUtils.isNullOrWhitespaceOnly(inlongLabels), - "Inlong labels must be set for register metric."); - + List<Integer> inlongAuditKeys, + Set<String> ipPortSet) { this.initRecords = initRecords; this.initBytes = initBytes; this.initDirtyRecords = initDirtyRecords; this.initDirtyBytes = initDirtyBytes; this.readPhase = readPhase; - this.labels = new LinkedHashMap<>(); - String[] inLongLabelArray = inlongLabels.split(DELIMITER); - Preconditions.checkArgument(Stream.of(inLongLabelArray).allMatch(label -> label.contains("=")), - "InLong metric label format must be xxx=xxx"); - Stream.of(inLongLabelArray).forEach(label -> { - String key = label.substring(0, label.indexOf('=')); - String value = label.substring(label.indexOf('=') + 1); - labels.put(key, value); - }); - + this.labels = labels; this.ipPorts = inlongAudit; - - if (ipPorts != null) { - - Preconditions.checkArgument(labels.containsKey(GROUP_ID) && labels.containsKey(STREAM_ID), - "groupId and streamId must be set when enable inlong audit collect."); - - if (inlongAuditKeys == null) { - LOG.warn("should set inlongAuditKeys when enable inlong audit collect, " - + "fallback to use id {} as audit key", AUDIT_SORT_INPUT); - inlongAuditKeys = AUDIT_SORT_INPUT; - } - - this.inlongAuditKeys = AuditUtils.extractAuditKeys(inlongAuditKeys); - this.ipPortList = AuditUtils.extractAuditIpPorts(ipPorts); - - } - - if (registeredMetric != null) { - this.registeredMetric = registeredMetric; - } + this.inlongAuditKeys = inlongAuditKeys; + this.ipPortSet = ipPortSet; + this.registeredMetric = registeredMetric; } public Map<String, String> getLabels() { return labels; } - public HashSet<String> getIpPortList() { - return ipPortList; + public Set<String> getIpPortSet() { + return ipPortSet; + } + + public HashSet<String> getIpPortSetAsHashSet() { Review Comment: This method was originally provided for the Audit module, but the Audit module uses HashSet, and this method returns Set, so a getIpPortSetAsHashSet method was added to be compatible with Audit.  -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@inlong.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org