@Override public void operationComplete(Void result, Stat stat) { log.info("[{}] Updated cursor {} with ledger id {} md-position={} rd-position={}", ledger.getName(), name, lh.getId(), markDeletePosition, readPosition); final LedgerHandle oldLedger = cursorLedger; cursorLedger = lh; cursorLedgerStat = stat; // At this point the position had already been safely markdeleted callback.operationComplete(); asyncDeleteLedger(oldLedger); }
private ManagedLedgerFactoryImpl(ZooKeeper zkc, ClientConfiguration bkClientConfiguration, ManagedLedgerFactoryConfig config) throws Exception { this(new BookKeeper(bkClientConfiguration, zkc), true /* isBookkeeperManaged */, zkc, config); }
public ManagedLedgerOfflineBacklog(DigestType digestType, byte[] password, String brokerName, boolean accurate) { this.digestType = BookKeeper.DigestType.fromApiDigestType(digestType); this.password = password; this.accurate = accurate; this.brokerName = brokerName; }
public long getCursorLedgerLastEntry() { LedgerHandle lh = cursorLedger; return lh != null ? lh.getLastAddConfirmed() : -1; }
public long getCursorLedger() { LedgerHandle lh = cursorLedger; return lh != null ? lh.getId() : -1; }
@Override public void asyncAddEntry(byte[] data, int offset, int length, AsyncCallback.AddCallback callback, Object ctx) { lh.asyncAddEntry(data, offset, length, callback, ctx); }
@Override public void deleteLedger(long lId) throws InterruptedException, BKException { checkProgrammedFail(); if (!ledgers.containsKey(lId)) { throw BKException.create(BKException.Code.NoSuchLedgerExistsException); } ledgers.remove(lId); }
static public SortedMap<Long, ArrayList<BookieSocketAddress>> bookiesForLedger(final LedgerHandle lh) { return lh.getLedgerMetadata().getEnsembles(); }
@Override public void asyncClose(AsyncCallback.CloseCallback callback, Object ctx) { lh.asyncClose(callback, ctx); }
static int getExceptionCode(Throwable t) { if (t instanceof BKException) { return ((BKException) t).getCode(); } else if (t.getCause() != null) { return getExceptionCode(t.getCause()); } else { return BKException.Code.UnexpectedConditionException; } }
public static LedgerMetadata getLedgerMetadata(LedgerHandle lh) { return lh.getLedgerMetadata(); } }
@Override public ClientConfiguration getConf() { return super.getConf(); }
public ZooKeeper getZkHandle() { return super.getZkHandle(); }
@Override public LedgerHandle createLedger(DigestType digestType, byte passwd[]) throws BKException, InterruptedException { return createLedger(3, 2, digestType, passwd); }
/** * Force a read to zookeeper to get list of bookies. * * @throws InterruptedException * @throws KeeperException */ public void readBookiesBlocking() throws InterruptedException, BKException { bookieWatcher.initialBlockingBookieRead(); } }
public void failNow(int rc) { failAfter(0, rc); }
@Override public CompletableFuture<Long> tryReadLastAddConfirmedAsync() { return readLastAddConfirmedAsync(); }
@Override public void close() throws InterruptedException, BKException { shutdown(); }
public ClientConfiguration getConf() { return super.getConf(); }
@Override public LedgerHandle createLedger(int ensSize, int qSize, DigestType digestType, byte passwd[]) throws BKException, InterruptedException { return createLedger(ensSize, qSize, qSize, digestType, passwd); }