dlg99 commented on PR #3214:
URL: https://github.com/apache/bookkeeper/pull/3214#issuecomment-1254003527

   > Why is releasePermit() added on line 79 of LedgerChecker.java?
   It is in the callback.
   Permits requested before bookieClient.readEntry called, and must be released 
in the callback passed there.
   
   ```java
                   final long entryToRead = curEntryId;
   
                   final EntryExistsCallback eecb = new 
EntryExistsCallback(lh.getLedgerMetadata().getWriteQuorumSize(),
                                                 new GenericCallback<Boolean>() 
{
                                                     @Override
                                                     public void 
operationComplete(int rc, Boolean result) {
                                                         releasePermit();
                                                         if (result) {
                                                             
fragments.add(lastLedgerFragment);
                                                         }
                                                         
checkFragments(fragments, cb,
                                                             
percentageOfLedgerFragmentToBeVerified);
                                                     }
                                                 });
   
                   try {
                       DistributionSchedule.WriteSet writeSet = 
lh.getDistributionSchedule().getWriteSet(entryToRead);
                       acquirePermits(writeSet.size());
                       for (int i = 0; i < writeSet.size(); i++) {
                               BookieId addr = curEnsemble.get(writeSet.get(i));
                               bookieClient.readEntry(addr, lh.getId(), 
entryToRead,
                                       eecb, null, BookieProtocol.FLAG_NONE);
                       }
                       writeSet.recycle();
                   } catch (InterruptedException e) {
                       LOG.error("InterruptedException when checking entry : 
{}", entryToRead, e);
                   }
   
   ```


-- 
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]

Reply via email to