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:
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 handleTableLocationKey(TableLocationKey).

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)
      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
    • AbstractTableLocationProvider

      protected AbstractTableLocationProvider(boolean supportsSubscriptions)
      Construct a standalone provider.
      Parameters:
      supportsSubscriptions - Whether this provider should support subscriptions
  • 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
    • handleTableLocationKey

      protected final void handleTableLocationKey(@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.
    • visitLocationKey

      protected void visitLocationKey(@NotNull @NotNull TableLocationKey locationKey)
      Called after a table location has been visited by handleTableLocationKey(TableLocationKey), 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

      @NotNull public final @NotNull Collection<ImmutableTableLocationKey> getTableLocationKeys()
      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.
      Specified by:
      getTableLocationKeys in interface TableLocationProvider
      Returns:
      A collection of keys for locations available from this provider
    • 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 for
      Returns:
      Whether the key is known to this provider
    • getTableLocationIfPresent

      @Nullable public @Nullable TableLocation getTableLocationIfPresent(@NotNull @NotNull TableLocationKey tableLocationKey)
      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.
    • handleTableLocationKeyRemoved

      protected void handleTableLocationKeyRemoved(@NotNull @NotNull ImmutableTableLocationKey locationKey)
      Notify subscribers that locationKey was removed.
      Parameters:
      locationKey - the TableLocation that was removed