throw new IOException(
"Cannot find metadata for an in-progress ledger with first txId "
+ firstTxId);
}
EditLogLedgerMetadata inProgressMeta = inProgressMetaAndVersion.getEntry();
if (currentInProgressLedger != null) {
long inProgressLedgerId = currentInProgressLedger.getId();
if (inProgressMeta.getLedgerId() == inProgressLedgerId) {
// If the segment is already // If the segment is currently
// in-progress, then finalize the ledger (this ensures every entry
// in the ledger committed to the BookKeeper quorum)
try {
currentInProgressLedger.close();
} catch (BKException e) {
bkException("Unexpected BookKeeper error closing ledger id " +
inProgressLedgerId, e);
} catch (InterruptedException e) {
interruptedException("Interrupted closing ledger id " +
inProgressLedgerId, e);
}
currentInProgressPath = null;
currentInProgressLedger = null;
} else { // We can not finalize a ledger that is not in-progress
throw new IOException("Current in-progress ledger has ledger id (" +
inProgressLedgerId + ") different from expected ledger id " +
inProgressMeta.getLedgerId());
}
}
// Set lastTxId in the metadata and persist it to ZooKeeper
EditLogLedgerMetadata finalizedMeta =
inProgressMeta.finalizeWithLastTxId(lastTxId);
String finalizedPath =
metadataManager.fullyQualifiedPathForLedger(finalizedMeta);
if (LOG.isDebugEnabled()) {
LOG.debug("Attempting to finalize metadata " + finalizedMeta +