Class AbstractTableLocationProvider

java.lang.Object
io.deephaven.engine.table.impl.locations.impl.SubscriptionAggregator<TableLocationProvider.Listener>
io.deephaven.engine.table.impl.locations.impl.AbstractTableLocationProvider
All Implemented Interfaces:
TableLocationProvider, NamedImplementation
Direct Known Subclasses:
IcebergTableLocationProviderBase, PollingTableLocationProvider

public abstract class AbstractTableLocationProvider extends SubscriptionAggregator<TableLocationProvider.Listener> implements TableLocationProvider
Partial TableLocationProvider implementation for standalone use or as part of a TableDataService.

Presents an interface similar to TableLocationProvider.Listener for subclasses to use when communicating with the parent; see handleTableLocationKeyAdded(TableLocationKey, Object).

Note that subclasses are responsible for determining when it's appropriate to call setInitialized() and/or override doInitialization().

  • Constructor Details

    • AbstractTableLocationProvider

      protected AbstractTableLocationProvider(@NotNull @NotNull TableKey tableKey, boolean supportsSubscriptions, TableUpdateMode updateMode, TableUpdateMode locationUpdateMode)
      Construct a provider as part of a service.
      Parameters:
      tableKey - A key that will be used by this provider
      supportsSubscriptions - Whether this provider should support subscriptions
      updateMode - What updates to the set of locations are allowed
      locationUpdateMode - What updates to the location rows are allowed
    • AbstractTableLocationProvider

      protected AbstractTableLocationProvider(boolean supportsSubscriptions, TableUpdateMode updateMode, TableUpdateMode locationUpdateMode)
      Construct a standalone provider.
      Parameters:
      supportsSubscriptions - Whether this provider should support subscriptions
      updateMode - What updates to the set of locations are allowed
      locationUpdateMode - What updates to the location rows are allowed
  • Method Details

    • toString

      public final String toString()
      Overrides:
      toString in class Object
    • getKey

      public final ImmutableTableKey getKey()
      Description copied from interface: TableLocationProvider
      Get the TableKey associated with this provider.
      Specified by:
      getKey in interface TableLocationProvider
      Returns:
      The associated TableKey
    • deliverInitialSnapshot

      protected final void deliverInitialSnapshot(@NotNull TableLocationProvider.Listener listener)
      Description copied from class: SubscriptionAggregator
      Prompt listeners to record current state, under the subscriptions lock.
      Specified by:
      deliverInitialSnapshot in class SubscriptionAggregator<TableLocationProvider.Listener>
      Parameters:
      listener - The listener to notify
    • beginTransaction

      protected void beginTransaction(@NotNull @NotNull Object token)
      Internal method to begin an atomic transaction of location adds and removes.
      Parameters:
      token - A token to identify the transaction
    • endTransaction

      protected void endTransaction(@NotNull @NotNull Object token)
      Internal method to end an atomic transaction of location adds and removes.
      Parameters:
      token - A token to identify the transaction
    • handleTableLocationKeyAdded

      protected final void handleTableLocationKeyAdded(@NotNull @NotNull TableLocationKey locationKey)
      Deliver a possibly-new key.
      Parameters:
      locationKey - The new key
      ApiNote:
      This method is intended to be used by subclasses or by tightly-coupled discovery tools.
    • handleTableLocationKeyAdded

      protected final void handleTableLocationKeyAdded(@NotNull @NotNull TableLocationKey locationKey, @Nullable @Nullable Object transactionToken)
      Deliver a possibly-new key, optionally as part of a transaction.
      Parameters:
      locationKey - The new key
      transactionToken - The token identifying the transaction (or null if not part of a transaction)
      ApiNote:
      This method is intended to be used by subclasses or by tightly-coupled discovery tools.
    • handleTableLocationKeyRemoved

      protected void handleTableLocationKeyRemoved(@NotNull @NotNull TableLocationKey locationKey, @Nullable @Nullable Object transactionToken)
      Handle a removal, optionally as part of a transaction. Notify subscribers that locationKey was removed if necessary. See removeTableLocationKey(TableLocationKey) for additional discussions of semantics.
      Parameters:
      locationKey - the TableLocation that was removed
      transactionToken - The token identifying the transaction (or null if not part of a transaction)
    • visitLocationKey

      protected void visitLocationKey(@NotNull @NotNull TableLocationKey locationKey)
      Called after a table location has been visited by handleTableLocationKeyAdded(TableLocationKey, Object), but before notifications have been delivered to any subscriptions, if applicable. The default implementation does nothing, and may be overridden to implement additional features.
      Parameters:
      locationKey - The TableLocationKey that was visited.
    • makeTableLocation

      @NotNull protected abstract @NotNull TableLocation makeTableLocation(@NotNull @NotNull TableLocationKey locationKey)
      Make a new implementation-appropriate TableLocation from the supplied key.
      Parameters:
      locationKey - The table location key
      Returns:
      The new TableLocation
    • ensureInitialized

      public final TableLocationProvider ensureInitialized()
      Description copied from interface: TableLocationProvider
      Ensure that this location provider is initialized. Mainly useful in cases where it cannot be otherwise guaranteed that TableLocationProvider.refresh() or TableLocationProvider.subscribe(Listener) has been called prior to calls to the various table location fetch methods.
      Specified by:
      ensureInitialized in interface TableLocationProvider
      Returns:
      this, to allow method chaining.
    • isInitialized

      protected final boolean isInitialized()
      Internal method for subclasses to call to determine if they need to call ensureInitialized(), if doing so might entail extra work (e.g. enqueueing an asynchronous job).
      Returns:
      Whether setInitialized() has been called
    • setInitialized

      protected final void setInitialized()
      Internal method for subclasses to call when they consider themselves to have been initialized.
    • doInitialization

      protected void doInitialization()
      Initialization method for subclasses to override, in case simply calling TableLocationProvider.refresh() is inappropriate. This is *not* guaranteed to be called only once. It should internally call setInitialized() upon successful initialization.
    • getTableLocationKeys

      public void getTableLocationKeys(Consumer<LiveSupplier<ImmutableTableLocationKey>> consumer, Predicate<ImmutableTableLocationKey> filter)
      Description copied from interface: TableLocationProvider
      Get this provider's currently known location keys. The locations specified by the keys returned may have null size - that is, they may not "exist" for application purposes. TableLocationProvider.getTableLocation(TableLocationKey) is guaranteed to succeed for all results as long as the associated LiveSupplier is retained by the caller.
      Specified by:
      getTableLocationKeys in interface TableLocationProvider
      Parameters:
      consumer - A consumer to receive the location keys
      filter - A filter to apply to the location keys before the consumer is called
    • hasTableLocationKey

      public final boolean hasTableLocationKey(@NotNull @NotNull TableLocationKey tableLocationKey)
      Description copied from interface: TableLocationProvider
      Check if this provider knows the supplied location key.
      Specified by:
      hasTableLocationKey in interface TableLocationProvider
      Parameters:
      tableLocationKey - The key to test.
      Returns:
      Whether the key is known to this provider.
    • getTableLocationIfPresent

      @Nullable public @Nullable TableLocation getTableLocationIfPresent(@NotNull @NotNull TableLocationKey tableLocationKey)
      Description copied from interface: TableLocationProvider
      Get the TableLocation associated with the given key if it exists. Callers should ensure that they retain the LiveSupplier returned by TableLocationProvider.getTableLocationKeys(Consumer, Predicate) for the key they are interested in, as the location may be removed if the supplier is no longer live.
      Specified by:
      getTableLocationIfPresent in interface TableLocationProvider
      Parameters:
      tableLocationKey - A TableLocationKey specifying the location to get.
      Returns:
      The TableLocation matching the given key if present, else null.
    • removeTableLocationKey

      public void removeTableLocationKey(@NotNull @NotNull TableLocationKey locationKey)
      Remove a TableLocationKey and its corresponding TableLocation (if it was created). All subscribers to this TableLocationProvider will be notified. If the TableLocation was created, all of its subscribers will additionally be notified that it no longer exists. This TableLocationProvider will continue to update other locations and will no longer provide or request information about the removed location.

      In practice, there are three downstream patterns in use.

      1. Intermediate TableLocationProviders, which will simply pass the removal on
      2. SourceTables, which will propagate a failure notification to all downstream listeners, and become failed.
      3. SourcePartitionedTables, which will notify their downstream consumers of the removed constituent.
      Parameters:
      locationKey - The TableLocationKey to remove
      ApiNote:
      Use with caution! Implementations that call this method must provide certain guarantees: Reads should only succeed against removed locations if they will return complete, correct, consistent data. Otherwise, they should fail with a meaningful error message.
    • getUpdateMode

      @NotNull public @NotNull TableUpdateMode getUpdateMode()
      Description copied from interface: TableLocationProvider
      Get the update guarantees of this provider describing how this provider will add or remove table locations.
      Specified by:
      getUpdateMode in interface TableLocationProvider
    • getLocationUpdateMode

      @NotNull public @NotNull TableUpdateMode getLocationUpdateMode()
      Description copied from interface: TableLocationProvider
      Get the location update guarantees of this provider describing how individual locations will add or remove rows.
      Specified by:
      getLocationUpdateMode in interface TableLocationProvider