@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
@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);
/** * 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); } }); }
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;