public LedgerReader(BookKeeper bkc) { clientCtx = bkc.getClientCtx(); }
/** * Open a ledger as an administrator. This means that no digest password * checks are done. Otherwise, the call is identical to BookKeeper#asyncOpenLedger * * @param lId * ledger identifier * @param cb * Callback which will receive a LedgerHandle object * @param ctx * optional context object, to be passwd to the callback (can be null) * * @see BookKeeper#asyncOpenLedger */ public void asyncOpenLedger(final long lId, final OpenCallback cb, final Object ctx) { new LedgerOpenOp(bkc, bkc.getClientCtx().getClientStats(), lId, cb, ctx).initiate(); }
/** * Open a ledger as an administrator without recovering the ledger. This means * that no digest password checks are done. Otherwise, the call is identical * to BookKeeper#asyncOpenLedgerNoRecovery * * @param lId * ledger identifier * @param cb * Callback which will receive a LedgerHandle object * @param ctx * optional context object, to be passwd to the callback (can be null) * * @see BookKeeper#asyncOpenLedgerNoRecovery */ public void asyncOpenLedgerNoRecovery(final long lId, final OpenCallback cb, final Object ctx) { new LedgerOpenOp(bkc, bkc.getClientCtx().getClientStats(), lId, cb, ctx).initiateWithoutRecovery(); }
private void delete(Long ledgerId, AsyncCallback.DeleteCallback cb) { if (!validate()) { cb.deleteComplete(BKException.Code.IncorrectParameterException, null); return; } LedgerDeleteOp op = new LedgerDeleteOp(bk, bk.getClientCtx().getClientStats(), ledgerId, cb, null); ReentrantReadWriteLock closeLock = bk.getCloseLock(); closeLock.readLock().lock(); try { if (bk.isClosed()) { cb.deleteComplete(BKException.Code.ClientClosedException, null); return; } op.initiate(); } finally { closeLock.readLock().unlock(); } } }
/** * Open a ledger as an administrator. This means that no digest password * checks are done. Otherwise, the call is identical to * BookKeeper#openLedger * * @param lId * - ledger identifier * @see BookKeeper#openLedger */ public LedgerHandle openLedger(final long lId) throws InterruptedException, BKException { CompletableFuture<LedgerHandle> future = new CompletableFuture<>(); SyncOpenCallback result = new SyncOpenCallback(future); new LedgerOpenOp(bkc, bkc.getClientCtx().getClientStats(), lId, result, null).initiate(); return SyncCallbackUtils.waitForResult(future); }
/** * Open a ledger as an administrator without recovering the ledger. This * means that no digest password checks are done. Otherwise, the call is * identical to BookKeeper#openLedgerNoRecovery * * @param lId * ledger identifier * @see BookKeeper#openLedgerNoRecovery */ @SuppressWarnings("unchecked") public LedgerHandle openLedgerNoRecovery(final long lId) throws InterruptedException, BKException { CompletableFuture<LedgerHandle> future = new CompletableFuture<>(); SyncOpenCallback result = new SyncOpenCallback(future); new LedgerOpenOp(bkc, bkc.getClientCtx().getClientStats(), lId, result, null) .initiateWithoutRecovery(); return SyncCallbackUtils.waitForResult(future); }
private void create(CreateCallback cb) { if (!validate()) { cb.createComplete(BKException.Code.IncorrectParameterException, null, null); return; } LedgerCreateOp op = new LedgerCreateOp(bk, builderEnsembleSize, builderWriteQuorumSize, builderAckQuorumSize, DigestType.fromApiDigestType(builderDigestType), builderPassword, cb, null, builderCustomMetadata, builderWriteFlags, bk.getClientCtx().getClientStats()); ReentrantReadWriteLock closeLock = bk.getCloseLock(); closeLock.readLock().lock(); try { if (bk.isClosed()) { cb.createComplete(BKException.Code.ClientClosedException, null, null); return; } op.initiate(); } finally { closeLock.readLock().unlock(); } } }
private void create(CreateCallback cb) { if (!validate()) { cb.createComplete(BKException.Code.IncorrectParameterException, null, null); return; } LedgerCreateOp op = new LedgerCreateOp(parent.bk, parent.builderEnsembleSize, parent.builderWriteQuorumSize, parent.builderAckQuorumSize, DigestType.fromApiDigestType(parent.builderDigestType), parent.builderPassword, cb, null, parent.builderCustomMetadata, parent.builderWriteFlags, parent.bk.getClientCtx().getClientStats()); ReentrantReadWriteLock closeLock = parent.bk.getCloseLock(); closeLock.readLock().lock(); try { if (parent.bk.isClosed()) { cb.createComplete(BKException.Code.ClientClosedException, null, null); return; } op.initiateAdv(builderLedgerId == null ? -1L : builderLedgerId); } finally { closeLock.readLock().unlock(); } } }
private void open(OpenCallback cb) { final int validateRc = validate(); if (Code.OK != validateRc) { cb.openComplete(validateRc, null, null); return; } LedgerOpenOp op = new LedgerOpenOp(bk, bk.getClientCtx().getClientStats(), ledgerId, fromApiDigestType(digestType), password, cb, null); ReentrantReadWriteLock closeLock = bk.getCloseLock(); closeLock.readLock().lock(); try { if (bk.isClosed()) { cb.openComplete(BKException.Code.ClientClosedException, null, null); return; } if (recovery) { op.initiate(); } else { op.initiateWithoutRecovery(); } } finally { closeLock.readLock().unlock(); } } }
try { if (adv) { lh = new LedgerHandleAdv(bk.getClientCtx(), ledgerId, writtenMetadata, digestType, passwd, writeFlags); } else { lh = new LedgerHandle(bk.getClientCtx(), ledgerId, writtenMetadata, digestType, passwd, writeFlags);
lh = new ReadOnlyLedgerHandle(bk.getClientCtx(), ledgerId, versionedMetadata, digestType, passwd, !doRecovery); } catch (GeneralSecurityException e) {