Class ServiceUnitStateMetadataStoreTableViewImpl

java.lang.Object
org.apache.pulsar.broker.loadbalance.extensions.channel.ServiceUnitStateMetadataStoreTableViewImpl
All Implemented Interfaces:
Closeable, AutoCloseable, ServiceUnitStateTableView

public class ServiceUnitStateMetadataStoreTableViewImpl extends Object
  • Field Details

  • Constructor Details

    • ServiceUnitStateMetadataStoreTableViewImpl

      public ServiceUnitStateMetadataStoreTableViewImpl()
  • Method Details

    • start

      public void start(PulsarService pulsar, BiConsumer<String,ServiceUnitStateData> tailItemListener, BiConsumer<String,ServiceUnitStateData> existingItemListener) throws org.apache.pulsar.metadata.api.MetadataStoreException
      Description copied from interface: ServiceUnitStateTableView
      Starts the tableview. It initially populates its local table view by scanning existing items in the remote store, and it starts listening to service unit ownership changes from the remote store.
      Parameters:
      pulsar - pulsar service reference
      tailItemListener - listener to listen tail(newly updated) items
      existingItemListener - listener to listen existing items
      Throws:
      org.apache.pulsar.metadata.api.MetadataStoreException
    • resolveConflict

      protected boolean resolveConflict(ServiceUnitStateData prev, ServiceUnitStateData cur)
    • validateServiceUnitPath

      protected boolean validateServiceUnitPath(String path)
    • close

      public void close() throws IOException
      Description copied from interface: ServiceUnitStateTableView
      Closes the tableview.
      Throws:
      IOException - if it fails to close the tableview.
    • get

      public ServiceUnitStateData get(String key)
      Description copied from interface: ServiceUnitStateTableView
      Gets one item from the local tableview.
      Parameters:
      key - the key to get
      Returns:
      value if exists. Otherwise, null.
    • put

      public CompletableFuture<Void> put(String key, @NonNull @NonNull ServiceUnitStateData value)
      Description copied from interface: ServiceUnitStateTableView
      Tries to put the item in the persistent store. If it completes, all peer tableviews (including the local one) will be notified and be eventually consistent with this put value. It ignores put operation if the input value conflicts with the existing one in the persistent store.
      Parameters:
      key - the key to put
      value - the value to put
      Returns:
      a future to track the completion of the operation
    • flush

      public void flush(long waitDurationInMillis)
      Description copied from interface: ServiceUnitStateTableView
      Tries to flush any batched or buffered updates.
      Parameters:
      waitDurationInMillis - time to wait until complete.
    • delete

      public CompletableFuture<Void> delete(String key)
      Description copied from interface: ServiceUnitStateTableView
      Tries to delete the item from the persistent store. All peer tableviews (including the local one) will be notified and be eventually consistent with this deletion. It ignores delete operation if the key is not present in the persistent store.
      Parameters:
      key - the key to delete
      Returns:
      a future to track the completion of the operation
    • entrySet

      Description copied from interface: ServiceUnitStateTableView
      Returns the entry set of the items in the local tableview.
      Returns:
      entry set
    • init

      protected void init(PulsarService pulsar) throws org.apache.pulsar.metadata.api.MetadataStoreException
      Throws:
      org.apache.pulsar.metadata.api.MetadataStoreException
    • ownedServiceUnits

      public Set<NamespaceBundle> ownedServiceUnits()
      Description copied from interface: ServiceUnitStateTableView
      Returns service units (namespace bundles) owned by this broker.
      Specified by:
      ownedServiceUnits in interface ServiceUnitStateTableView
      Returns:
      a set of owned service units (namespace bundles)
    • updateOwnedServiceUnits

      protected void updateOwnedServiceUnits(String key, ServiceUnitStateData val)