@Override public void deleteLedger(long lId) throws InterruptedException, BKException { checkProgrammedFail(); if (!ledgers.containsKey(lId)) { throw BKException.create(BKException.Code.NoSuchLedgerExistsException); } ledgers.remove(lId); }
@Override public LedgerHandle createLedger(int ensSize, int writeQuorumSize, int ackQuorumSize, DigestType digestType, byte[] passwd) throws BKException, InterruptedException { checkProgrammedFail(); try { long id = sequence.getAndIncrement(); log.info("Creating ledger {}", id); PulsarMockLedgerHandle lh = new PulsarMockLedgerHandle(this, id, digestType, passwd); ledgers.put(id, lh); return lh; } catch (Throwable t) { log.error("Exception:", t); return null; } }
@Override public long addEntry(byte[] data) throws InterruptedException, BKException { try { bk.checkProgrammedFail(); } catch (BKException e) { fenced = true; throw e; } if (fenced) { throw BKException.create(BKException.Code.LedgerFencedException); } lastEntry = entries.size(); entries.add(LedgerEntryImpl.create(ledgerId, lastEntry, data.length, Unpooled.wrappedBuffer(data))); return lastEntry; }