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 2019/07/02 21:45:33 UTC

[GitHub] [bookkeeper] eolivelli commented on a change in pull request #2120: Implementation of new scrutiny - replicas check (Part-1)

eolivelli commented on a change in pull request #2120: Implementation of new scrutiny - replicas check (Part-1)
URL: https://github.com/apache/bookkeeper/pull/2120#discussion_r299695394
 
 

 ##########
 File path: bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/Auditor.java
 ##########
 @@ -1072,6 +1214,366 @@ public void processResult(int rc, String s, Object obj) {
         }
     }
 
+    private static class MissingEntriesInfo {
+        private final long ledgerId;
+        private final Entry<Long, ? extends List<BookieSocketAddress>> segmentInfo;
+        private final BookieSocketAddress bookieMissingEntries;
+        private final List<Long> unavailableEntriesList;
+
+        private MissingEntriesInfo(long ledgerId, Entry<Long, ? extends List<BookieSocketAddress>> segmentInfo,
+                BookieSocketAddress bookieMissingEntries, List<Long> unavailableEntriesList) {
+            this.ledgerId = ledgerId;
+            this.segmentInfo = segmentInfo;
+            this.bookieMissingEntries = bookieMissingEntries;
+            this.unavailableEntriesList = unavailableEntriesList;
+        }
+
+        public long getLedgerId() {
+            return ledgerId;
+        }
+
+        public Entry<Long, ? extends List<BookieSocketAddress>> getSegmentInfo() {
+            return segmentInfo;
+        }
+
+        public BookieSocketAddress getBookieMissingEntries() {
+            return bookieMissingEntries;
+        }
+
+        public List<Long> getUnavailableEntriesList() {
+            return unavailableEntriesList;
+        }
+    }
+
+    private class ReadLedgerMetadataCallbackForReplicasCheck
+            implements BiConsumer<Versioned<LedgerMetadata>, Throwable> {
+        final long ledgerInRange;
+        final MultiCallback mcbForThisLedgerRange;
+        final ConcurrentHashMap<Long, List<MissingEntriesInfo>> ledgersWithMissingEntries;
+        final ConcurrentHashMap<Long, List<MissingEntriesInfo>> ledgersWithUnavailableBookies;
+
+        ReadLedgerMetadataCallbackForReplicasCheck(long ledgerInRange, MultiCallback mcbForThisLedgerRange,
+                ConcurrentHashMap<Long, List<MissingEntriesInfo>> ledgersWithMissingEntries,
+                ConcurrentHashMap<Long, List<MissingEntriesInfo>> ledgersWithUnavailableBookies) {
+            this.ledgerInRange = ledgerInRange;
+            this.mcbForThisLedgerRange = mcbForThisLedgerRange;
+            this.ledgersWithMissingEntries = ledgersWithMissingEntries;
+            this.ledgersWithUnavailableBookies = ledgersWithUnavailableBookies;
+        }
+
+        @Override
+        public void accept(Versioned<LedgerMetadata> metadataVer, Throwable exception) {
+            if (exception != null) {
+                if (BKException
+                        .getExceptionCode(exception) == BKException.Code.NoSuchLedgerExistsOnMetadataServerException) {
+                    LOG.debug("Ignoring replicas check of already deleted ledger {}", ledgerInRange);
+                    mcbForThisLedgerRange.processResult(BKException.Code.OK, null, null);
+                    return;
+                } else {
+                    LOG.warn("Unable to read the ledger: {} information", ledgerInRange, exception);
+                    mcbForThisLedgerRange.processResult(BKException.getExceptionCode(exception), null, null);
+                    return;
+                }
+            }
+
+            LedgerMetadata metadata = metadataVer.getValue();
+            if (!metadata.isClosed()) {
+                LOG.debug("Ledger: {} is not yet closed, so skipping the replicas check analysis for now",
+                        ledgerInRange);
+                mcbForThisLedgerRange.processResult(BKException.Code.OK, null, null);
+                return;
+            }
+
+            if (metadata.getLastEntryId() == -1) {
 
 Review comment:
   Nit: is there any available constant for  '-1'? 

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services