codelipenghui commented on a change in pull request #7111:
URL: https://github.com/apache/pulsar/pull/7111#discussion_r435663378
##########
File path:
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java
##########
@@ -1391,6 +1392,38 @@ synchronized void ledgerClosed(final LedgerHandle lh) {
}
}
+ synchronized void createLedgerAfterClosed() {
+ STATE_UPDATER.set(this, State.CreatingLedger);
+ this.lastLedgerCreationInitiationTimestamp = System.nanoTime();
+ mbean.startDataLedgerCreateOp();
+ asyncCreateLedger(bookKeeper, config, digestType, this,
Collections.emptyMap());
+ }
+
+ @Override
+ public void rollCurrentLedgerIfFull() {
+ log.info("[{}] Start checking if current ledger is full", name);
+ if (currentLedgerEntries > 0 && currentLedgerIsFull()) {
+ STATE_UPDATER.set(this, State.ClosingLedger);
+ currentLedger.asyncClose(new AsyncCallback.CloseCallback() {
+ @Override
+ public void closeComplete(int rc, LedgerHandle lh, Object o) {
+ checkArgument(currentLedger.getId() == lh.getId(),
"ledgerId %s doesn't match with acked ledgerId %s",
+ currentLedger.getId(),
+ lh.getId());
+
+ if (rc == BKException.Code.OK) {
+ log.debug("Successfuly closed ledger {}", lh.getId());
+ } else {
+ log.warn("Error when closing ledger {}. Status={}",
lh.getId(), BKException.getMessage(rc));
+ }
+
+ ledgerClosed(lh);
+ createLedgerAfterClosed();
Review comment:
Ok, I think we can change the current logic. If the current ledger is
closed, we can delete it. I'm not sure is there any problems with this change.
@merlimat Could you please help check this?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]