@Override public void closeComplete(int rc, LedgerHandle lh, Object ctx) { if (rc != BKException.Code.OK) { LOG.warn("Close failed: {}", BKException.codeLogger(rc)); } // noop } }
@Override public void recoverComplete(int rc, Object ctx) { LOG.info("Recover bookie operation completed with rc: {}", BKException.codeLogger(rc)); SyncObject syncObj = (SyncObject) ctx; synchronized (syncObj) { syncObj.rc = rc; syncObj.value = true; syncObj.notify(); } } }, sync);
@Override public void getBookieInfoComplete(int rc, BookieInfo bInfo, Object ctx) { BookieSocketAddress b = (BookieSocketAddress) ctx; if (rc != BKException.Code.OK) { if (LOG.isErrorEnabled()) { LOG.error("Reading bookie info from bookie {} failed due to {}", b, BKException.codeLogger(rc)); } } else { if (LOG.isDebugEnabled()) { LOG.debug("Free disk space on bookie {} is {}.", b, bInfo.getFreeDiskSpace()); } map.put(b, bInfo); } if (totalCompleted.incrementAndGet() == totalSent.get()) { latch.countDown(); } } }, b);
@Override public void addComplete(int rc, LedgerHandle lh, long entryId, Object ctx) { if (rc != BKException.Code.OK) { LOG.error("Failure {} while writing entry: {} while recovering ledger: {}", BKException.codeLogger(rc), entryId + 1, lh.ledgerId); submitCallback(rc); return; } long numAdd = writeCount.incrementAndGet(); if (readDone && readCount.get() == numAdd) { submitCallback(rc); } }
void processReadInfoComplete(int rc, BookieInfo bInfo, Object ctx) { synchronized (BookieInfoReader.this) { BookieSocketAddress b = (BookieSocketAddress) ctx; if (rc != BKException.Code.OK) { if (LOG.isErrorEnabled()) { LOG.error("Reading bookie info from bookie {} failed due to {}", b, BKException.codeLogger(rc)); } // We reread bookies missing from the map each time, so remove to ensure // we get to it on the next scan bookieInfoMap.clearInfo(b); errorCnt++; } else { if (LOG.isDebugEnabled()) { LOG.debug("Bookie Info for bookie {} is {}", b, bInfo); } bookieInfoMap.gotInfo(b, bInfo); } completedCnt++; if (totalSent == completedCnt) { onExit(); } } } @Override
public void recoverBookieData(final long lid, final Set<BookieSocketAddress> bookiesSrc, boolean dryrun, boolean skipOpenLedgers) throws InterruptedException, BKException { SyncObject sync = new SyncObject(); // Call the async method to recover bookie data. asyncRecoverBookieData(lid, bookiesSrc, dryrun, skipOpenLedgers, (rc, ctx) -> { LOG.info("Recover bookie for {} completed with rc : {}", lid, BKException.codeLogger(rc)); SyncObject syncObject = (SyncObject) ctx; synchronized (syncObject) { syncObject.rc = rc; syncObject.value = true; syncObject.notify(); } }, sync); // Wait for the async method to complete. synchronized (sync) { while (!sync.value) { sync.wait(); } } if (sync.rc != BKException.Code.OK) { throw BKException.create(sync.rc); } }
void handleUnrecoverableErrorDuringAdd(int rc) { if (getLedgerMetadata().getState() == LedgerMetadata.State.IN_RECOVERY) { // we should not close ledger if ledger is recovery mode // otherwise we may lose entry. errorOutPendingAdds(rc); return; } LOG.error("Closing ledger {} due to {}", ledgerId, BKException.codeLogger(rc)); asyncCloseInternal(NoopCloseCallback.instance, null, rc); }