[improve][broker] Fast return when AppendIndexMetadataInterceptor is matched.
### Motivation
Optimize the method, fast return when AppendIndexMetadataInterceptor is matched.
### Modifications
1. Fast return when when AppendIndexMetadataInterceptor is matched.
@@ -64,6 +64,7 @@ public class ManagedLedgerInterceptorImpl implements ManagedLedgerInterceptor {
for (BrokerEntryMetadataInterceptor interceptor : brokerEntryMetadataInterceptors) {
if (interceptor instanceof AppendIndexMetadataInterceptor) {
index = ((AppendIndexMetadataInterceptor) interceptor).getIndex();
+ break;
}
}
return index;
@@ -89,6 +90,7 @@ public class ManagedLedgerInterceptorImpl implements ManagedLedgerInterceptor {
if (interceptor instanceof AppendIndexMetadataInterceptor) {
((AppendIndexMetadataInterceptor) interceptor)
.recoveryIndexGenerator(Long.parseLong(propertiesMap.get(INDEX)));
+ break;
}
}
}
@@ -117,6 +119,7 @@ public class ManagedLedgerInterceptorImpl implements ManagedLedgerInterceptor {
((AppendIndexMetadataInterceptor) interceptor)
.recoveryIndexGenerator(brokerEntryMetadata.getIndex());
}
+ break;
}
}
}
@@ -144,6 +147,7 @@ public class ManagedLedgerInterceptorImpl implements ManagedLedgerInterceptor {
for (BrokerEntryMetadataInterceptor interceptor : brokerEntryMetadataInterceptors) {
if (interceptor instanceof AppendIndexMetadataInterceptor) {
propertiesMap.put(INDEX, String.valueOf(((AppendIndexMetadataInterceptor) interceptor).getIndex()));
+ break;
}
}
}
