pulsar-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From si...@apache.org
Subject [pulsar] branch master updated: Add configs for broker stats update frequency (#3047)
Date Sun, 25 Nov 2018 19:42:40 GMT
This is an automated email from the ASF dual-hosted git repository.

sijie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git


The following commit(s) were added to refs/heads/master by this push:
     new 1b421ed  Add configs for broker stats update frequency (#3047)
1b421ed is described below

commit 1b421ed3854fcb2682ecddc295c7ba6859c3947f
Author: Ali Ahmed <alahmed.se@gmail.com>
AuthorDate: Sun Nov 25 11:42:36 2018 -0800

    Add configs for broker stats update frequency (#3047)
    
    This allows to configure the initial delay and update frequency for broker stats. This
is useful for dev and test clusters.
    
    Fixes #687
---
 .../org/apache/pulsar/broker/ServiceConfiguration.java | 18 ++++++++++++++++++
 .../apache/pulsar/broker/service/BrokerService.java    |  9 ++++++---
 2 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfiguration.java
b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfiguration.java
index 2a7b16e..9eba00e 100644
--- a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfiguration.java
+++ b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfiguration.java
@@ -510,6 +510,8 @@ public class ServiceConfiguration implements PulsarConfiguration {
     /**** --- Broker Web Stats --- ****/
     // If true, export publisher stats when returning topics stats from the admin rest api
     private boolean exposePublisherStats = true;
+    private int statsUpdateFrequencyInSecs = 60;
+    private int statsUpdateInitailDelayInSecs = 60;
 
     /**** --- Ledger Offloading --- ****/
     /****
@@ -1761,6 +1763,22 @@ public class ServiceConfiguration implements PulsarConfiguration {
         return isRunningStandalone;
     }
 
+    public int getStatsUpdateFrequencyInSecs() {
+        return statsUpdateFrequencyInSecs;
+    }
+
+    public void setStatsUpdateFrequencyInSecs(int statsUpdateFrequencyInSecs) {
+        this.statsUpdateFrequencyInSecs = statsUpdateFrequencyInSecs;
+    }
+
+    public int getStatsUpdateInitialDelayInSecs() {
+        return statsUpdateInitailDelayInSecs;
+    }
+
+    public void setStatsUpdateInitailDelayInSecs(int statsUpdateInitailDelayInSecs) {
+        this.statsUpdateInitailDelayInSecs = statsUpdateInitailDelayInSecs;
+    }
+
     public void setRunningStandalone(boolean isRunningStandalone) {
         this.isRunningStandalone = isRunningStandalone;
     }
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java
b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java
index 01644a6..725ee93 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java
@@ -311,7 +311,9 @@ public class BrokerService implements Closeable, ZooKeeperCacheListener<Policies
         }
 
         // start other housekeeping functions
-        this.startStatsUpdater();
+        this.startStatsUpdater(
+                serviceConfig.getStatsUpdateInitialDelayInSecs(),
+                serviceConfig.getStatsUpdateFrequencyInSecs());
         this.startInactivityMonitor();
         this.startMessageExpiryMonitor();
         this.startCompactionMonitor();
@@ -321,8 +323,9 @@ public class BrokerService implements Closeable, ZooKeeperCacheListener<Policies
         ClientCnxnAspect.registerExecutor(pulsar.getExecutor());
     }
 
-    void startStatsUpdater() {
-        statsUpdater.scheduleAtFixedRate(safeRun(this::updateRates), 60, 60, TimeUnit.SECONDS);
+    void startStatsUpdater(int statsUpdateInitailDelayInSecs, int statsUpdateFrequencyInSecs)
{
+        statsUpdater.scheduleAtFixedRate(safeRun(this::updateRates),
+                statsUpdateInitailDelayInSecs, statsUpdateFrequencyInSecs, TimeUnit.SECONDS);
 
         // Ensure the broker starts up with initial stats
         updateRates();


Mime
View raw message