You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@bookkeeper.apache.org by GitBox <gi...@apache.org> on 2018/12/19 11:47:14 UTC

[GitHub] sijie closed pull request #1888: Bring back statslogger to BookKeeper client in ReplicationWorker process.

sijie closed pull request #1888: Bring back statslogger to BookKeeper client in ReplicationWorker process.
URL: https://github.com/apache/bookkeeper/pull/1888
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/AbstractConfiguration.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/AbstractConfiguration.java
index 7f00d09adb..f12200fcaf 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/AbstractConfiguration.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/AbstractConfiguration.java
@@ -153,6 +153,9 @@
     // enforce minimum number of racks per write quorum
     public static final String ENFORCE_MIN_NUM_RACKS_PER_WRITE_QUORUM = "enforceMinNumRacksPerWriteQuorum";
 
+    // option to limit stats logging
+    public static final String LIMIT_STATS_LOGGING = "limitStatsLogging";
+
     protected AbstractConfiguration() {
         super();
         if (READ_SYSTEM_PROPERTIES) {
@@ -875,6 +878,29 @@ public T setPreserveMdcForTaskExecution(boolean enabled) {
         setProperty(PRESERVE_MDC_FOR_TASK_EXECUTION, enabled);
         return getThis();
     }
+
+    /**
+     * Return the flag indicating whether to limit stats logging.
+     *
+     * @return
+     *      the boolean flag indicating whether to limit stats logging
+     */
+    public boolean getLimitStatsLogging() {
+        return getBoolean(LIMIT_STATS_LOGGING, false);
+    }
+
+    /**
+     * Sets flag to limit the stats logging.
+     *
+     * @param limitStatsLogging
+     *          flag to limit the stats logging.
+     * @return configuration.
+     */
+    public T setLimitStatsLogging(boolean limitStatsLogging) {
+        setProperty(LIMIT_STATS_LOGGING, limitStatsLogging);
+        return getThis();
+    }
+
     /**
      * Trickery to allow inheritance with fluent style.
      */
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieClientImpl.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieClientImpl.java
index 50dd85fd83..18f48a2ab8 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieClientImpl.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieClientImpl.java
@@ -171,8 +171,12 @@ public long getNumPendingRequests(BookieSocketAddress address, long ledgerId) {
     @Override
     public PerChannelBookieClient create(BookieSocketAddress address, PerChannelBookieClientPool pcbcPool,
             SecurityHandlerFactory shFactory) throws SecurityException {
-        return new PerChannelBookieClient(conf, executor, eventLoopGroup, address, statsLogger,
-                                          authProviderFactory, registry, pcbcPool, shFactory);
+        StatsLogger statsLoggerForPCBC = statsLogger;
+        if (conf.getLimitStatsLogging()) {
+            statsLoggerForPCBC = NullStatsLogger.INSTANCE;
+        }
+        return new PerChannelBookieClient(conf, executor, eventLoopGroup, address, statsLoggerForPCBC,
+                authProviderFactory, registry, pcbcPool, shFactory);
     }
 
     public PerChannelBookieClientPool lookupClient(BookieSocketAddress addr) {
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/Auditor.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/Auditor.java
index 89883b0528..870cea3bde 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/Auditor.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/Auditor.java
@@ -71,6 +71,7 @@
 import org.apache.bookkeeper.replication.ReplicationException.CompatibilityException;
 import org.apache.bookkeeper.replication.ReplicationException.UnavailableException;
 import org.apache.bookkeeper.stats.Counter;
+import org.apache.bookkeeper.stats.NullStatsLogger;
 import org.apache.bookkeeper.stats.OpStatsLogger;
 import org.apache.bookkeeper.stats.StatsLogger;
 import org.apache.bookkeeper.stats.annotations.StatsDoc;
@@ -161,12 +162,16 @@
     )
     private final Counter numDelayedBookieAuditsCancelled;
 
-    static BookKeeper createBookKeeperClient(ServerConfiguration conf)
+    static BookKeeper createBookKeeperClient(ServerConfiguration conf) throws InterruptedException, IOException {
+        return createBookKeeperClient(conf, NullStatsLogger.INSTANCE);
+    }
+
+    static BookKeeper createBookKeeperClient(ServerConfiguration conf, StatsLogger statsLogger)
             throws InterruptedException, IOException {
         ClientConfiguration clientConfiguration = new ClientConfiguration(conf);
         clientConfiguration.setClientRole(ClientConfiguration.CLIENT_ROLE_SYSTEM);
         try {
-            return BookKeeper.forConfig(clientConfiguration).build();
+            return BookKeeper.forConfig(clientConfiguration).statsLogger(statsLogger).build();
         } catch (BKException e) {
             throw new IOException("Failed to create bookkeeper client", e);
         }
diff --git a/site/_data/config/bk_server.yaml b/site/_data/config/bk_server.yaml
index b60bfbf993..a7115985df 100644
--- a/site/_data/config/bk_server.yaml
+++ b/site/_data/config/bk_server.yaml
@@ -538,6 +538,9 @@ groups:
         - Twitter Ostrich   : org.apache.bookkeeper.stats.twitter.ostrich.OstrichProvider
         - Twitter Science   : org.apache.bookkeeper.stats.twitter.science.TwitterStatsProvider
     default: org.apache.bookkeeper.stats.prometheus.PrometheusMetricsProvider
+  - param: limitStatsLogging
+    description: option to limit stats logging
+    default: 'false'
 
 - name: Prometheus Metrics Provider Settings
   params:


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services