Interface ServiceUnitStateChannel

All Superinterfaces:
AutoCloseable, Closeable
All Known Implementing Classes:
ServiceUnitStateChannelImpl

public interface ServiceUnitStateChannel extends Closeable
Defines the ServiceUnitStateChannel interface.
  • Method Details

    • start

      void start() throws PulsarServerException
      Starts the ServiceUnitStateChannel.
      Throws:
      PulsarServerException - if it fails to start the channel.
    • started

      boolean started()
      Whether the channel started.
    • close

      void close() throws PulsarServerException
      Closes the ServiceUnitStateChannel.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      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

      boolean isChannelOwner() throws ExecutionException, InterruptedException, TimeoutException
      Checks if the current broker is the owner broker of this channel.
      Returns:
      True if the current broker is the owner. Otherwise, false.
      Throws:
      ExecutionException
      InterruptedException
      TimeoutException
    • getOwnerAsync

      CompletableFuture<Optional<String>> getOwnerAsync(String serviceUnit)
      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

      Optional<String> getAssigned(String serviceUnit)
      Asynchronously gets the assigned broker of the service unit.
      Parameters:
      serviceUnit - (e.g. bundle))
      Returns:
      assigned brokerId
    • isOwner

      boolean isOwner(String serviceUnit, String targetBrokerId)
      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

      boolean isOwner(String serviceUnit)
      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

      CompletableFuture<String> publishAssignEventAsync(String serviceUnit, String brokerId)
      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

      CompletableFuture<Void> publishUnloadEventAsync(Unload unload)
      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

      CompletableFuture<Void> publishSplitEventAsync(Split split)
      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

      void listen(StateChangeListener listener)
      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.