Interface BrokerRegistry
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
BrokerRegistryImpl
Responsible for registering the current Broker lookup info to
the distributed store (e.g. Zookeeper) for broker discovery.
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(BiConsumer<String, org.apache.pulsar.metadata.api.NotificationType> listener) Add listener to listen the broker register change.voidclose()Close the broker registry.Get the map of brokerId->brokerLookupData.Async get available brokers.Get the current broker ID.booleanReturn the broker has been registered.booleanReturn the broker registry is started.lookupAsync(String broker) Get the broker lookup data.Register local broker to metadata store.voidstart()Start broker registry.voidUnregister the broker.
-
Method Details
-
start
Start broker registry.- Throws:
PulsarServerException
-
isStarted
boolean isStarted()Return the broker registry is started. -
isRegistered
boolean isRegistered()Return the broker has been registered. -
registerAsync
CompletableFuture<Void> registerAsync()Register local broker to metadata store. -
unregister
void unregister() throws org.apache.pulsar.metadata.api.MetadataStoreExceptionUnregister the broker. Same asModularLoadManager.disableBroker()- Throws:
org.apache.pulsar.metadata.api.MetadataStoreException
-
getBrokerId
String getBrokerId()Get the current broker ID.- Returns:
- The service url without the protocol prefix, 'http://'. e.g. broker-xyz:port
-
getAvailableBrokersAsync
CompletableFuture<List<String>> getAvailableBrokersAsync()Async get available brokers.- Returns:
- The brokers service url list.
-
lookupAsync
Get the broker lookup data.- Parameters:
broker- The service url without the protocol prefix, 'http://'. e.g. broker-xyz:port
-
getAvailableBrokerLookupDataAsync
CompletableFuture<Map<String,BrokerLookupData>> getAvailableBrokerLookupDataAsync()Get the map of brokerId->brokerLookupData.- Returns:
- Map of broker lookup data.
-
addListener
Add listener to listen the broker register change.- Parameters:
listener- Key is broker IdgetBrokerId()Value is notification type.
-
close
Close the broker registry.- Specified by:
closein interfaceAutoCloseable- Throws:
PulsarServerException- if it fails to close the broker registry.
-