horizonzy commented on code in PR #4058:
URL: https://github.com/apache/bookkeeper/pull/4058#discussion_r1305689839
##########
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:
I think this metric doesn't need to be highly real-time. We just need to
give users an approximate value and indicate whether it has changed. If
real-time values are required, we can retrieve the current data of
under-replicated ledgers using the BookKeeper shell.
--
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]