hangc0276 commented on code in PR #4058:
URL: https://github.com/apache/bookkeeper/pull/4058#discussion_r1306857375


##########
bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/Auditor.java:
##########
@@ -558,14 +556,26 @@ private void scheduleReplicasCheckTask() {
         executor.scheduleAtFixedRate(auditorReplicasCheckTask, initialDelay, 
interval, TimeUnit.SECONDS);
     }
 
-    private class UnderReplicatedLedgersChangedCb implements 
GenericCallback<Void> {
-        @Override
-        public void operationComplete(int rc, Void result) {
+    private void scheduleReplicateStatTask() {
+        long interval = conf.getAuditorUnderReplicasStatInterval();
+        if (interval <= 0) {
+            LOG.info("Under Replicas Stats disabled");
+            return;
+        }
+        auditorStatExecutor = Executors.newSingleThreadScheduledExecutor(
+                new ThreadFactory() {
+                    @Override
+                    public Thread newThread(Runnable r) {
+                        Thread t = new Thread(r, "AuditorStat-" + 
bookieIdentifier);
+                        t.setDaemon(true);
+                        return t;
+                    }
+                });
+        auditorStatExecutor.scheduleAtFixedRate(() -> {
             Iterator<UnderreplicatedLedger> underreplicatedLedgersInfo = 
ledgerUnderreplicationManager
                     .listLedgersToRereplicate(null);
             
auditorStats.getUnderReplicatedLedgersGuageValue().set(Iterators.size(underreplicatedLedgersInfo));

Review Comment:
   If it is better to use `bin/bookkeeper shell` to get the count of 
under-replicated ledgers directly?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to