From 9ac6cd5c79e094fdcd8f99564e1ce879e2f876ac Mon Sep 17 00:00:00 2001 From: Chia-Ping Tsai Date: Sat, 13 May 2023 21:23:28 +0800 Subject: [PATCH] [METRICS] rewrite ClusterMetrics.PartitionMetric by java 17 record --- .../common/metrics/broker/ClusterMetrics.java | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/common/src/main/java/org/astraea/common/metrics/broker/ClusterMetrics.java b/common/src/main/java/org/astraea/common/metrics/broker/ClusterMetrics.java index 1292b24901..0e1983aca9 100644 --- a/common/src/main/java/org/astraea/common/metrics/broker/ClusterMetrics.java +++ b/common/src/main/java/org/astraea/common/metrics/broker/ClusterMetrics.java @@ -76,23 +76,11 @@ public static ClusterMetrics.Partition ofAlias(String alias) { } public List fetch(MBeanClient client) { - return client.beans(ALL.get(this)).stream() - .map(PartitionMetric::new) - .collect(Collectors.toUnmodifiableList()); + return client.beans(ALL.get(this)).stream().map(PartitionMetric::new).toList(); } } - public static class PartitionMetric implements HasGauge { - private final BeanObject beanObject; - - public PartitionMetric(BeanObject beanObject) { - this.beanObject = beanObject; - } - - @Override - public BeanObject beanObject() { - return beanObject; - } + public record PartitionMetric(BeanObject beanObject) implements HasGauge { public TopicPartition topicPartition() { return partitionIndex().orElseThrow();