From cc484d56805b8387f0660809ae7e3117a8fd1c46 Mon Sep 17 00:00:00 2001 From: dinglei Date: Sun, 28 Jul 2024 17:12:59 +0800 Subject: [PATCH] [ISSUE #8454] Active brokers number should be initailized to 1 in broker heartbeat manager. (#8453) * active brokers should be 1 on computing if absent * active brokers number should be initailized to 1 in broker heartbeat manager. --- .../impl/heartbeat/DefaultBrokerHeartbeatManager.java | 2 +- .../controller/impl/heartbeat/RaftBrokerHeartBeatManager.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/controller/src/main/java/org/apache/rocketmq/controller/impl/heartbeat/DefaultBrokerHeartbeatManager.java b/controller/src/main/java/org/apache/rocketmq/controller/impl/heartbeat/DefaultBrokerHeartbeatManager.java index 5ec298a383e..05d742fb7b0 100644 --- a/controller/src/main/java/org/apache/rocketmq/controller/impl/heartbeat/DefaultBrokerHeartbeatManager.java +++ b/controller/src/main/java/org/apache/rocketmq/controller/impl/heartbeat/DefaultBrokerHeartbeatManager.java @@ -184,7 +184,7 @@ public Map> getActiveBrokersNum() { .forEach(id -> { map.computeIfAbsent(id.getClusterName(), k -> new HashMap<>()); map.get(id.getClusterName()).compute(id.getBrokerName(), (broker, num) -> - num == null ? 0 : num + 1 + num == null ? 1 : num + 1 ); }); return map; diff --git a/controller/src/main/java/org/apache/rocketmq/controller/impl/heartbeat/RaftBrokerHeartBeatManager.java b/controller/src/main/java/org/apache/rocketmq/controller/impl/heartbeat/RaftBrokerHeartBeatManager.java index 99f7b34d4a4..d981ff430c9 100644 --- a/controller/src/main/java/org/apache/rocketmq/controller/impl/heartbeat/RaftBrokerHeartBeatManager.java +++ b/controller/src/main/java/org/apache/rocketmq/controller/impl/heartbeat/RaftBrokerHeartBeatManager.java @@ -263,7 +263,7 @@ public Map> getActiveBrokersNum() { .forEach(id -> { map.computeIfAbsent(id.getClusterName(), k -> new HashMap<>()); map.get(id.getClusterName()).compute(id.getBrokerName(), (broker, num) -> - num == null ? 0 : num + 1 + num == null ? 1 : num + 1 ); }); return map;