final ExecutorService executorService) throws IOException { LedgerManager lm = BookKeeperAccessor.getLedgerManager(bkc.get());
@Override protected int runCmd() throws Exception { LedgerHandle lh = getBookKeeperClient().get().openLedgerNoRecovery( getLedgerID(), BookKeeper.DigestType.CRC32, dlConf.getBKDigestPW().getBytes(UTF_8)); final CountDownLatch doneLatch = new CountDownLatch(1); final AtomicInteger resultHolder = new AtomicInteger(-1234); BookkeeperInternalCallbacks.GenericCallback<Void> recoverCb = new BookkeeperInternalCallbacks.GenericCallback<Void>() { @Override public void operationComplete(int rc, Void result) { resultHolder.set(rc); doneLatch.countDown(); } }; try { BookKeeperAccessor.forceRecoverLedger(lh, recoverCb); doneLatch.await(); if (BKException.Code.OK != resultHolder.get()) { throw BKException.create(resultHolder.get()); } } finally { lh.close(); } return 0; }
LedgerHandle lh = ((BKDistributedLogNamespace) namespace).getReaderBKC() .get().openLedgerNoRecovery(ledgerId, BookKeeper.DigestType.CRC32, confLocal.getBKDigestPW().getBytes(UTF_8)); LedgerMetadata metadata = BookKeeperAccessor.getLedgerMetadata(lh); assertEquals(DistributedLogConfiguration.BKDL_BOOKKEEPER_ENSEMBLE_SIZE_DEFAULT, metadata.getEnsembleSize()); lh.close(); lh = ((BKDistributedLogNamespace) namespace).getReaderBKC() .get().openLedgerNoRecovery(ledgerId, BookKeeper.DigestType.CRC32, confLocal.getBKDigestPW().getBytes(UTF_8)); metadata = BookKeeperAccessor.getLedgerMetadata(lh); assertEquals(DistributedLogConfiguration.BKDL_BOOKKEEPER_ENSEMBLE_SIZE_DEFAULT - 1, metadata.getEnsembleSize()); lh.close();
@Override public List<InputSplit> getSplits(JobContext jobContext) throws IOException, InterruptedException { List<LogSegmentMetadata> segments = dlm.getLogSegments(); List<InputSplit> inputSplits = Lists.newArrayListWithCapacity(segments.size()); BookKeeper bk = namespace.getReaderBKC().get(); LedgerManager lm = BookKeeperAccessor.getLedgerManager(bk); final AtomicInteger rcHolder = new AtomicInteger(0); final AtomicReference<LedgerMetadata> metadataHolder = new AtomicReference<LedgerMetadata>(null); for (LogSegmentMetadata segment : segments) { final CountDownLatch latch = new CountDownLatch(1); lm.readLedgerMetadata(segment.getLedgerId(), new BookkeeperInternalCallbacks.GenericCallback<LedgerMetadata>() { @Override public void operationComplete(int rc, LedgerMetadata ledgerMetadata) { metadataHolder.set(ledgerMetadata); rcHolder.set(rc); latch.countDown(); } }); latch.await(); if (BKException.Code.OK != rcHolder.get()) { throw new IOException("Faild to get log segment metadata for " + segment + " : " + BKException.getMessage(rcHolder.get())); } inputSplits.add(new LogSegmentSplit(segment, metadataHolder.get())); } return inputSplits; }
@Override protected int runCmd() throws Exception { LedgerHandle lh = getBookKeeperClient().get().openLedgerNoRecovery( getLedgerID(), BookKeeper.DigestType.CRC32, dlConf.getBKDigestPW().getBytes(UTF_8)); final CountDownLatch doneLatch = new CountDownLatch(1); final AtomicInteger resultHolder = new AtomicInteger(-1234); BookkeeperInternalCallbacks.GenericCallback<Void> recoverCb = new BookkeeperInternalCallbacks.GenericCallback<Void>() { @Override public void operationComplete(int rc, Void result) { resultHolder.set(rc); doneLatch.countDown(); } }; try { BookKeeperAccessor.forceRecoverLedger(lh, recoverCb); doneLatch.await(); if (BKException.Code.OK != resultHolder.get()) { throw BKException.create(resultHolder.get()); } } finally { lh.close(); } return 0; }
final AtomicLong numLedgers = new AtomicLong(0); LedgerManager lm = BookKeeperAccessor.getLedgerManager(bkc.get());
final ExecutorService executorService) throws IOException { LedgerManager lm = BookKeeperAccessor.getLedgerManager(bkc.get());
final AtomicLong numLedgers = new AtomicLong(0); LedgerManager lm = BookKeeperAccessor.getLedgerManager(bkc.get());