jvrao commented on a change in pull request #1683: Enhance Auditor
URL: https://github.com/apache/bookkeeper/pull/1683#discussion_r219397459
 
 

 ##########
 File path: 
bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/Auditor.java
 ##########
 @@ -345,21 +348,73 @@ public void start() {
                 return;
             }
 
+            try {
+                watchBookieChanges();
+                knownBookies = getAvailableBookies();
+            } catch (BKException bke) {
+                LOG.error("Couldn't get bookie list, so exiting", bke);
+                submitShutdownTask();
+            }
+
+            try {
+                this.ledgerUnderreplicationManager
+                        .notifyLostBookieRecoveryDelayChanged(new 
LostBookieRecoveryDelayChangedCb());
+            } catch (UnavailableException ue) {
+                LOG.error("Exception while registering for 
LostBookieRecoveryDelay change notification, so exiting",
+                        ue);
+                submitShutdownTask();
+            }
+
+            long bookieCheckInterval = 
conf.getAuditorPeriodicBookieCheckInterval();
+            if (bookieCheckInterval == 0) {
+                LOG.info("Auditor periodic bookie checking disabled, running 
once check now anyhow");
+                executor.submit(bookieCheck);
+            } else {
+                LOG.info("Auditor periodic bookie checking enabled"
+                         + " 'auditorPeriodicBookieCheckInterval' {} seconds", 
bookieCheckInterval);
+                executor.scheduleAtFixedRate(bookieCheck, 0, 
bookieCheckInterval, TimeUnit.SECONDS);
+            }
+            
             long interval = conf.getAuditorPeriodicCheckInterval();
 
             if (interval > 0) {
-                LOG.info("Auditor periodic ledger checking enabled"
-                         + " 'auditorPeriodicCheckInterval' {} seconds", 
interval);
+                LOG.info("Auditor periodic ledger checking enabled" + " 
'auditorPeriodicCheckInterval' {} seconds",
+                        interval);
+
+                long checkAllLedgersLastExecutedCTime = -1;
+                long durationSinceLastExecutionInSecs = 0;
+                long initialDelay = 0;
+                try {
+                    checkAllLedgersLastExecutedCTime = 
ledgerUnderreplicationManager.getCheckAllLedgersCTime();
+                } catch (UnavailableException ue) {
+                    LOG.error("Got UnavailableException while trying to get 
checkAllLedgersCTime", ue);
+                }
+                if (checkAllLedgersLastExecutedCTime == -1) {
+                    durationSinceLastExecutionInSecs = -1;
+                    initialDelay = 0;
+                } else {
+                    durationSinceLastExecutionInSecs = 
(System.currentTimeMillis() - checkAllLedgersLastExecutedCTime)
+                            / 1000;
+                    initialDelay = durationSinceLastExecutionInSecs > interval 
? 0
+                            : (interval - durationSinceLastExecutionInSecs);
+                }
+                LOG.info(
+                        "checkAllLedgers scheduling info.  
checkAllLedgersLastExecutedCTime: {} "
+                                + "durationSinceLastExecutionInSecs: {} 
initialDelay: {} interval: {}",
+                        checkAllLedgersLastExecutedCTime, 
durationSinceLastExecutionInSecs, initialDelay, interval);
+
                 executor.scheduleAtFixedRate(new Runnable() {
                         public void run() {
                             try {
                                 if 
(!ledgerUnderreplicationManager.isLedgerReplicationEnabled()) {
-                                    LOG.info("Ledger replication disabled, 
skipping");
+                                    LOG.info("Ledger replication disabled, 
skipping checkAllLedgers");
                                     return;
                                 }
 
                                 Stopwatch stopwatch = 
Stopwatch.createStarted();
+                                LOG.info("Starting checkAllLedgers");
                                 checkAllLedgers();
+                                LOG.info("Completed checkAllLedgers");
 
 Review comment:
   Since you added log info; add more info if possible. At least the time it 
took and maybe how many ledgers it checked??

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to