/** * Inititates the ledger open operation without recovery. */ public void initiateWithoutRecovery() { this.doRecovery = false; initiate(); }
@Override public void safeOperationComplete(int rc, Void result) { if (rc == BKException.Code.OK) { openComplete(BKException.Code.OK, lh); } else if (rc == BKException.Code.UnauthorizedAccessException) { openComplete(BKException.Code.UnauthorizedAccessException, null); } else { openComplete(bk.getReturnRc(BKException.Code.LedgerRecoveryException), null); } } @Override
/** * 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 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(); } } }
/** * Inititates the ledger open operation. */ public void initiate() { startTime = MathUtils.nowInNano(); /** * Asynchronously read the ledger metadata node. */ bk.getLedgerManager().readLedgerMetadata(ledgerId) .whenComplete((metadata, exception) -> { if (exception != null) { openComplete(BKException.getExceptionCode(exception), null); } else { openWithMetadata(metadata); } }); }
return; new LedgerOpenOp(BookKeeper.this, clientStats, lId, digestType, passwd, cb, ctx).initiate(); } finally { closeLock.readLock().unlock();
return; new LedgerOpenOp(BookKeeper.this, clientStats, lId, digestType, passwd, cb, ctx).initiateWithoutRecovery(); } 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); }
@Override public void readLastConfirmedComplete(int rc, long lastConfirmed, Object ctx) { if (rc != BKException.Code.OK) { openComplete(bk.getReturnRc(BKException.Code.ReadException), null); } else { lh.lastAddConfirmed = lh.lastAddPushed = lastConfirmed; openComplete(BKException.Code.OK, lh); } } }, null);
if (!Arrays.equals(passwd, metadata.getPassword())) { LOG.error("Provided passwd does not match that in metadata"); openComplete(BKException.Code.UnauthorizedAccessException, null); return; openComplete(BKException.Code.DigestMatchException, null); return; } catch (GeneralSecurityException e) { LOG.error("Security exception while opening ledger: " + ledgerId, e); openComplete(BKException.Code.DigestNotInitializedException, null); return; } catch (NumberFormatException e) { LOG.error("Incorrectly entered parameter throttle: " + bk.getConf().getThrottleValue(), e); openComplete(BKException.Code.IncorrectParameterException, null); return; openComplete(BKException.Code.OK, lh); return;