From 5d43e7d111ab2461c94fc62c1021cf7aee9d0219 Mon Sep 17 00:00:00 2001 From: qianye <37405937+qianye1001@users.noreply.github.com> Date: Wed, 4 Sep 2024 17:14:45 +0800 Subject: [PATCH] [ISSUE #8609] Add the BrokerConfig updateNameServerAddrPeriod (#8626) --- .../apache/rocketmq/broker/BrokerController.java | 2 +- .../org/apache/rocketmq/common/BrokerConfig.java | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java b/broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java index 145a9522306..22ac7fedf1c 100644 --- a/broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java +++ b/broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java @@ -747,7 +747,7 @@ public void run() { LOG.error("Failed to update nameServer address list", e); } } - }, 1000 * 10, 1000 * 60 * 2, TimeUnit.MILLISECONDS); + }, 1000 * 10, this.brokerConfig.getUpdateNameServerAddrPeriod(), TimeUnit.MILLISECONDS); } else if (this.brokerConfig.isFetchNamesrvAddrByAddressServer()) { this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() { diff --git a/common/src/main/java/org/apache/rocketmq/common/BrokerConfig.java b/common/src/main/java/org/apache/rocketmq/common/BrokerConfig.java index 10bf7f76e86..26afe593a25 100644 --- a/common/src/main/java/org/apache/rocketmq/common/BrokerConfig.java +++ b/common/src/main/java/org/apache/rocketmq/common/BrokerConfig.java @@ -185,6 +185,11 @@ public class BrokerConfig extends BrokerIdentity { */ private int registerNameServerPeriod = 1000 * 30; + /** + * This configurable item defines interval of update name server address. Default: 120 * 1000 milliseconds + */ + private int updateNameServerAddrPeriod = 1000 * 120; + /** * the interval to send heartbeat to name server for liveness detection. */ @@ -1837,4 +1842,12 @@ public boolean isSkipWhenCKRePutReachMaxTimes() { public void setSkipWhenCKRePutReachMaxTimes(boolean skipWhenCKRePutReachMaxTimes) { this.skipWhenCKRePutReachMaxTimes = skipWhenCKRePutReachMaxTimes; } + + public int getUpdateNameServerAddrPeriod() { + return updateNameServerAddrPeriod; + } + + public void setUpdateNameServerAddrPeriod(int updateNameServerAddrPeriod) { + this.updateNameServerAddrPeriod = updateNameServerAddrPeriod; + } }