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/01/27 09:39:15 UTC

[GitHub] eolivelli commented on a change in pull request #1902: Metadata checker validating EnsemblePlacementpolicy

eolivelli commented on a change in pull request #1902: Metadata checker validating EnsemblePlacementpolicy
URL: https://github.com/apache/bookkeeper/pull/1902#discussion_r251227886
 
 

 ##########
 File path: bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/Auditor.java
 ##########
 @@ -803,8 +885,72 @@ void checkAllLedgers() throws BKException, IOException, InterruptedException, Ke
                 LOG.error("Got exception while trying to set checkAllLedgersCTime", ue);
             }
         } finally {
-            admin.close();
-            client.close();
+            localAdmin.close();
+            localClient.close();
+        }
+    }
+
+    void metadataCheck() throws BKAuditException {
+        final CountDownLatch metadataCheckLatch = new CountDownLatch(1);
+        Processor<Long> ledgerProcessor = new Processor<Long>() {
+            @Override
+            public void process(Long ledgerId, AsyncCallback.VoidCallback iterCallback) {
+                ledgerManager.readLedgerMetadata(ledgerId).whenComplete((metadataVer, exception) -> {
+                    if (exception == null) {
+                        LedgerMetadata metadata = metadataVer.getValue();
+                        int writeQuorumSize = metadata.getWriteQuorumSize();
+                        int ackQuorumSize = metadata.getAckQuorumSize();
+                        if (metadata.isClosed()) {
+                            for (Map.Entry<Long, ? extends List<BookieSocketAddress>> ensemble : metadata
+                                    .getAllEnsembles().entrySet()) {
+                                long startEntryIdOfSegment = ensemble.getKey();
+                                List<BookieSocketAddress> ensembleOfSegment = ensemble.getValue();
+                                boolean segmentAdheringToPlacementPolicy = admin.isEnsembleAdheringToPlacementPolicy(
+                                        ensembleOfSegment, writeQuorumSize, ackQuorumSize);
+                                if (!segmentAdheringToPlacementPolicy) {
+                                    metadataCheckEnsembleNotAdheringToPlacementPolicy.inc();
+                                    LOG.warn(
+                                            "For ledger: {}, Segment starting at entry: {}, with ensemble: {} having "
+                                                    + "writeQuorumSize: {} and ackQuorumSize: {} is not adhering to "
+                                                    + "EnsemblePlacementPolicy",
+                                            ledgerId, startEntryIdOfSegment, ensembleOfSegment, writeQuorumSize,
+                                            ackQuorumSize);
+                                }
+                            }
+                        } else {
+                            LOG.debug("Ledger: {} is not yet closed, so skipping the metadata check analysis for now",
+                                    ledgerId);
+                        }
+                        iterCallback.processResult(BKException.Code.OK, null, null);
+                    } else if (BKException
+                            .getExceptionCode(exception) == BKException.Code.NoSuchLedgerExistsException) {
+                        LOG.debug("Ignoring replication of already deleted ledger {}", ledgerId);
+                        iterCallback.processResult(BKException.Code.OK, null, null);
+                    } else {
+                        LOG.warn("Unable to read the ledger: {} information", ledgerId);
+                        iterCallback.processResult(BKException.getExceptionCode(exception), null, null);
+                    }
+                });
+            }
+        };
+        // Reading the result after processing all the ledgers
+        final List<Integer> resultCode = new ArrayList<Integer>(1);
+        ledgerManager.asyncProcessLedgers(ledgerProcessor, new AsyncCallback.VoidCallback() {
+
+            @Override
+            public void processResult(int rc, String s, Object obj) {
+                resultCode.add(rc);
+                metadataCheckLatch.countDown();
+            }
+        }, null, BKException.Code.OK, BKException.Code.ReadException);
+        try {
+            metadataCheckLatch.await();
 
 Review comment:
   This series of comments seems not addressed

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services