Skip to content

Commit

Permalink
[improve][broker] Fast return when AppendIndexMetadataInterceptor is …
Browse files Browse the repository at this point in the history
…matched. (#18884)

### Motivation

Optimize the method, fast return when AppendIndexMetadataInterceptor is matched.

### Modifications

1. Fast return when when AppendIndexMetadataInterceptor is matched.
  • Loading branch information
Nicklee007 authored Dec 12, 2022
1 parent bdbb118 commit 9917aac
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public long getIndex() {
for (BrokerEntryMetadataInterceptor interceptor : brokerEntryMetadataInterceptors) {
if (interceptor instanceof AppendIndexMetadataInterceptor) {
index = ((AppendIndexMetadataInterceptor) interceptor).getIndex();
break;
}
}
return index;
Expand All @@ -89,6 +90,7 @@ public void onManagedLedgerPropertiesInitialize(Map<String, String> propertiesMa
if (interceptor instanceof AppendIndexMetadataInterceptor) {
((AppendIndexMetadataInterceptor) interceptor)
.recoveryIndexGenerator(Long.parseLong(propertiesMap.get(INDEX)));
break;
}
}
}
Expand Down Expand Up @@ -117,6 +119,7 @@ public CompletableFuture<Void> onManagedLedgerLastLedgerInitialize(String name,
((AppendIndexMetadataInterceptor) interceptor)
.recoveryIndexGenerator(brokerEntryMetadata.getIndex());
}
break;
}
}
}
Expand Down Expand Up @@ -144,6 +147,7 @@ public void onUpdateManagedLedgerInfo(Map<String, String> propertiesMap) {
for (BrokerEntryMetadataInterceptor interceptor : brokerEntryMetadataInterceptors) {
if (interceptor instanceof AppendIndexMetadataInterceptor) {
propertiesMap.put(INDEX, String.valueOf(((AppendIndexMetadataInterceptor) interceptor).getIndex()));
break;
}
}
}
Expand Down

0 comments on commit 9917aac

Please sign in to comment.