Interface ServiceUnitStateChannel
- All Superinterfaces:
AutoCloseable,Closeable
- All Known Implementing Classes:
ServiceUnitStateChannelImpl
Defines the ServiceUnitStateChannel interface.
-
Method Summary
Modifier and TypeMethodDescriptionvoidCancels the ownership monitor.voidCleans(gives up) any service unit ownerships from this broker.voidclose()Closes the ServiceUnitStateChannel.getAssigned(String serviceUnit) Asynchronously gets the assigned broker of the service unit.Asynchronously gets the current owner broker of this channel.List<org.apache.pulsar.common.stats.Metrics>Generates the metrics to monitor.Asynchronously returns service units owned by this broker.getOwnerAsync(String serviceUnit) Asynchronously gets the current owner broker of the service unit.Asynchronously returns service unit ownership entry set.booleanChecks if the current broker is the owner broker of this channel.Asynchronously checks if the current broker is the owner broker of this channel.booleanChecks if the current broker is the owner of the service unit.booleanChecks if the target broker is the owner of the service unit.voidlisten(StateChangeListener listener) Adds a state change listener.publishAssignEventAsync(String serviceUnit, String brokerId) Asynchronously publishes the service unit assignment event to this channel.publishSplitEventAsync(Split split) Asynchronously publishes the bundle split event to this channel.publishUnloadEventAsync(Unload unload) Asynchronously publishes the service unit unload event to this channel.voidSchedules ownership monitor to periodically check and correct invalid ownership states.voidstart()Starts the ServiceUnitStateChannel.booleanstarted()Whether the channel started.
-
Method Details
-
start
Starts the ServiceUnitStateChannel.- Throws:
PulsarServerException- if it fails to start the channel.
-
started
boolean started()Whether the channel started. -
close
Closes the ServiceUnitStateChannel.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
PulsarServerException- if it fails to close the channel.
-
getChannelOwnerAsync
CompletableFuture<Optional<String>> getChannelOwnerAsync()Asynchronously gets the current owner broker of this channel.- Returns:
- a future of owner brokerId to track the completion of the operation
-
isChannelOwnerAsync
CompletableFuture<Boolean> isChannelOwnerAsync()Asynchronously checks if the current broker is the owner broker of this channel.- Returns:
- a future of check result to track the completion of the operation
-
isChannelOwner
Checks if the current broker is the owner broker of this channel.- Returns:
- True if the current broker is the owner. Otherwise, false.
- Throws:
ExecutionExceptionInterruptedExceptionTimeoutException
-
getOwnerAsync
Asynchronously gets the current owner broker of the service unit.- Parameters:
serviceUnit- (e.g. bundle)- Returns:
- a future of owner brokerId to track the completion of the operation
-
getAssigned
Asynchronously gets the assigned broker of the service unit.- Parameters:
serviceUnit- (e.g. bundle))- Returns:
- assigned brokerId
-
isOwner
Checks if the target broker is the owner of the service unit.- Parameters:
serviceUnit- (e.g. bundle)targetBrokerId-- Returns:
- true if the target brokerId is the owner brokerId. false if unknown.
-
isOwner
Checks if the current broker is the owner of the service unit.- Parameters:
serviceUnit- (e.g. bundle))- Returns:
- true if the current broker is the owner. false if unknown.
-
publishAssignEventAsync
Asynchronously publishes the service unit assignment event to this channel.- Parameters:
serviceUnit- (e.g bundle)brokerId- the assigned brokerId- Returns:
- a future of owner brokerId to track the completion of the operation
-
publishUnloadEventAsync
Asynchronously publishes the service unit unload event to this channel.- Parameters:
unload- (unload specification object)- Returns:
- a future to track the completion of the operation
-
publishSplitEventAsync
Asynchronously publishes the bundle split event to this channel.- Parameters:
split- (split specification object)- Returns:
- a future to track the completion of the operation
-
getMetrics
List<org.apache.pulsar.common.stats.Metrics> getMetrics()Generates the metrics to monitor.- Returns:
- a list of the metrics
-
listen
Adds a state change listener.- Parameters:
listener- State change listener.
-
getOwnershipEntrySet
Set<Map.Entry<String,ServiceUnitStateData>> getOwnershipEntrySet()Asynchronously returns service unit ownership entry set.- Returns:
- a set of service unit ownership entries to track the completion of the operation
-
getOwnedServiceUnits
Set<NamespaceBundle> getOwnedServiceUnits()Asynchronously returns service units owned by this broker.- Returns:
- a set of owned service units to track the completion of the operation
-
scheduleOwnershipMonitor
void scheduleOwnershipMonitor()Schedules ownership monitor to periodically check and correct invalid ownership states. -
cancelOwnershipMonitor
void cancelOwnershipMonitor()Cancels the ownership monitor. -
cleanOwnerships
void cleanOwnerships()Cleans(gives up) any service unit ownerships from this broker.
-