This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/master by this push:
     new 16c9766b9 fix numLedgersReplicated metric not update (#3218)
16c9766b9 is described below

commit 16c9766b952fb3d1fb42d6a308e8525c9ffddbf8
Author: Hang Chen <[email protected]>
AuthorDate: Wed Apr 20 03:25:04 2022 +0800

    fix numLedgersReplicated metric not update (#3218)
---
 .../java/org/apache/bookkeeper/replication/ReplicationWorker.java  | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/ReplicationWorker.java
 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/ReplicationWorker.java
index f8d6402ea..721380a65 100644
--- 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/ReplicationWorker.java
+++ 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/ReplicationWorker.java
@@ -375,6 +375,7 @@ public class ReplicationWorker implements Runnable {
             }
 
             boolean foundOpenFragments = false;
+            long numFragsReplicated = 0;
             for (LedgerFragment ledgerFragment : fragments) {
                 if (!ledgerFragment.isClosed()) {
                     foundOpenFragments = true;
@@ -387,6 +388,7 @@ public class ReplicationWorker implements Runnable {
                 }
                 try {
                     admin.replicateLedgerFragment(lh, ledgerFragment, 
onReadEntryFailureCallback);
+                    numFragsReplicated++;
                 } catch (BKException.BKBookieHandleNotAvailableException e) {
                     LOG.warn("BKBookieHandleNotAvailableException while 
replicating the fragment", e);
                 } catch (BKException.BKLedgerRecoveryException e) {
@@ -395,6 +397,11 @@ public class ReplicationWorker implements Runnable {
                     LOG.warn("BKNotEnoughBookiesException while replicating 
the fragment", e);
                 }
             }
+
+            if (numFragsReplicated > 0) {
+                numLedgersReplicated.inc();
+            }
+
             if (foundOpenFragments || isLastSegmentOpenAndMissingBookies(lh)) {
                 deferLedgerLockRelease = true;
                 deferLedgerLockRelease(ledgerIdToReplicate);

Reply via email to