/** * Whether a ledger is closed or not. * * @param ledgerDesc * ledger descriptor. * @return true if a ledger is closed, otherwise false. * @throws BKException */ public boolean isLedgerHandleClosed(LedgerDescriptor ledgerDesc) throws BKException { RefCountedLedgerHandle refhandle = getLedgerHandle(ledgerDesc); if (null == refhandle) { LOG.error("Accessing ledger {} without opening.", ledgerDesc); throw BKException.create(BKException.Code.UnexpectedConditionException); } return refhandle.handle.isClosed(); }
LedgerHandle lh = getLedgerHandle(writer); LedgerHandle readLh = openLedgerNoRecovery(lh); assertTrue("Ledger " + lh.getId() + " should be closed", readLh.isClosed()); assertEquals("There should be two entries in ledger " + lh.getId(), 1L, readLh.getLastAddConfirmed());
assertTrue("Ledger " + lh.getId() + " should not be closed", readLh.isClosed()); assertEquals("Only one entry is written for ledger " + lh.getId(), 0L, lh.getLastAddPushed());
assertTrue("Ledger " + lh.getId() + " should not be closed", readLh.isClosed()); assertEquals("There should be no entries in ledger " + lh.getId(), LedgerHandle.INVALID_ENTRY_ID, readLh.getLastAddConfirmed());
assertTrue("Ledger " + lh.getId() + " should be closed", readLh.isClosed()); assertEquals("There should be no entries in ledger " + lh.getId(), LedgerHandle.INVALID_ENTRY_ID, readLh.getLastAddConfirmed());
assertFalse("Ledger " + lh.getId() + " should not be closed", readLh.isClosed()); assertEquals("There should be no entries in ledger " + lh.getId(), LedgerHandle.INVALID_ENTRY_ID, readLh.getLastAddConfirmed());
@Override public String toString() { return String.format("%s, Length = %d, Closed = %s", this.metadata, this.ledger.getLength(), this.ledger.isClosed()); } }
private boolean isLedgerClosed() { return getLh().isClosed(); }
/** * Write Processor main loop. This method is not thread safe and should only be invoked as part of the Write Processor. */ private void processWritesSync() { if (this.closed.get()) { // BookKeeperLog is closed. No point in trying anything else. return; } if (getWriteLedger().ledger.isClosed()) { // Current ledger is closed. Execute the rollover processor to safely create a new ledger. This will reinvoke // the write processor upon finish, so the writes can be reattempted. this.rolloverProcessor.runAsync(); } else if (!processPendingWrites() && !this.closed.get()) { // We were not able to complete execution of all writes. Try again. this.writeProcessor.runAsync(); } }
long lastEntry = lh.getLastAddConfirmed(); if (!lh.isClosed() && lastEntry < curEntryId) { lastEntry = curEntryId;