heesung-sn commented on code in PR #19851:
URL: https://github.com/apache/pulsar/pull/19851#discussion_r1144258938
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/NamespaceService.java:
##########
@@ -1445,23 +1451,44 @@ public PulsarClientImpl
getNamespaceClient(ClusterDataImpl cluster) {
});
}
- public Optional<NamespaceEphemeralData> getOwner(NamespaceBundle bundle)
throws Exception {
- // if there is no znode for the service unit, it is not owned by any
broker
- return
getOwnerAsync(bundle).get(pulsar.getConfiguration().getMetadataStoreOperationTimeoutSeconds(),
SECONDS);
- }
-
public CompletableFuture<Optional<NamespaceEphemeralData>>
getOwnerAsync(NamespaceBundle bundle) {
+ if (ExtensibleLoadManagerImpl.isLoadManagerExtensionEnabled(config)) {
+ ExtensibleLoadManagerImpl extensibleLoadManager =
ExtensibleLoadManagerImpl.get(loadManager.get());
+ return
extensibleLoadManager.getOwnershipWithLookupDataAsync(bundle)
+ .thenCompose(lookupData -> {
+ if (lookupData.isPresent()) {
+ return CompletableFuture.completedFuture(
+
Optional.of(lookupData.get().toNamespaceEphemeralData()));
+ } else {
+ return
CompletableFuture.completedFuture(Optional.empty());
+ }
+ });
+ }
return ownershipCache.getOwnerAsync(bundle);
}
+ public boolean checkOwnershipPresent(NamespaceBundle bundle) throws
Exception {
+ return checkOwnershipPresentAsync(bundle).get(pulsar.getConfiguration()
+ .getMetadataStoreOperationTimeoutSeconds(), SECONDS);
+ }
+
+ public CompletableFuture<Boolean>
checkOwnershipPresentAsync(NamespaceBundle bundle) {
+ if (ExtensibleLoadManagerImpl.isLoadManagerExtensionEnabled(config)) {
+ ExtensibleLoadManagerImpl extensibleLoadManager =
ExtensibleLoadManagerImpl.get(loadManager.get());
+ return extensibleLoadManager.getOwnershipAsync(Optional.empty(),
bundle)
Review Comment:
I think we can remove `Optional<ServiceUnitId> topic` and pass just
`bundleUnit` only to getOwnershipAsync, like the one below. Let the leader own
all system namespace topics, and we don't auto-unload system topics.
```
private CompletableFuture<Optional<String>> getOwnershipAsync(ServiceUnitId
bundleUnit) {
final String bundle = bundleUnit.toString();
CompletableFuture<Optional<String>> owner;
if (isSystemNamespace(bundleUnit.toString())) {
owner = serviceUnitStateChannel.getChannelOwnerAsync();
} else {
owner = serviceUnitStateChannel.getOwnerAsync(bundle);
}
return owner;
```
--
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]