315157973 commented on code in PR #15425:
URL: https://github.com/apache/pulsar/pull/15425#discussion_r866560902
##########
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java:
##########
@@ -2532,10 +2532,45 @@ void internalFlushPendingMarkDeletes() {
void createNewMetadataLedger(final VoidCallback callback) {
ledger.mbean.startCursorLedgerCreateOp();
+ doCreateNewMetadataLedger().thenAccept(newLedgerHandle -> {
+ if (newLedgerHandle == null) {
+ return;
+ }
+ MarkDeleteEntry mdEntry = lastMarkDeleteEntry;
+ // Created the ledger, now write the last position content
+ persistPositionToLedger(newLedgerHandle, mdEntry, new
VoidCallback() {
+ @Override
+ public void operationComplete() {
+ if (log.isDebugEnabled()) {
+ log.debug("[{}] Persisted position {} for cursor {}",
ledger.getName(),
+ mdEntry.newPosition, name);
+ }
+ switchToNewLedger(newLedgerHandle, callback);
+ }
+
+ @Override
+ public void operationFailed(ManagedLedgerException exception) {
+ log.warn("[{}] Failed to persist position {} for cursor
{}", ledger.getName(),
+ mdEntry.newPosition, name);
+
+ deleteLedgerAsync(newLedgerHandle);
+ callback.operationFailed(exception);
+ }
+ });
+ }).whenComplete((result, e) -> {
+ ledger.mbean.endCursorLedgerCreateOp();
+ if (e != null) {
+ callback.operationFailed(createManagedLedgerException(e));
+ }
+ });
+ }
+ private CompletableFuture<LedgerHandle> doCreateNewMetadataLedger() {
+ CompletableFuture<LedgerHandle> future = new CompletableFuture<>();
ledger.asyncCreateLedger(bookkeeper, config, digestType, (rc, lh, ctx)
-> {
if (ledger.checkAndCompleteLedgerOpTask(rc, lh, ctx)) {
+ future.complete(null);
Review Comment:
The previous logic was that if the judgment here is true, this directly
returns. I need to know whether the value is true. Therefore, null is returned.
If the value is null, the metadata does not need to be persisted.
Or, do you have any advice
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]