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()
.
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.deephaven.engine.table.impl.locations.TableLocationProvider
TableLocationProvider.Listener
-
Field Summary
Fields inherited from class io.deephaven.engine.table.impl.locations.impl.SubscriptionAggregator
subscriptions
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractTableLocationProvider
(boolean supportsSubscriptions) Construct a standalone provider.protected
AbstractTableLocationProvider
(@NotNull TableKey tableKey, boolean supportsSubscriptions) Construct a provider as part of a service. -
Method Summary
Modifier and TypeMethodDescriptionprotected final void
Prompt listeners to record current state, under the subscriptions lock.protected void
Initialization method for subclasses to override, in case simply callingTableLocationProvider.refresh()
is inappropriate.final TableLocationProvider
Ensure that this location provider is initialized.final ImmutableTableKey
getKey()
Get theTableKey
associated with this provider.@Nullable TableLocation
getTableLocationIfPresent
(@NotNull TableLocationKey tableLocationKey) final @NotNull Collection<ImmutableTableLocationKey>
Get this provider's currently known location keys.protected final void
handleTableLocationKey
(@NotNull TableLocationKey locationKey) Deliver a possibly-new key.protected void
handleTableLocationKeyRemoved
(@NotNull ImmutableTableLocationKey locationKey) Notify subscribers thatlocationKey
was removed.final boolean
hasTableLocationKey
(@NotNull TableLocationKey tableLocationKey) Check if this provider knows the supplied location key.protected final boolean
Internal method for subclasses to call to determine if they need to callensureInitialized()
, if doing so might entail extra work (e.g.protected abstract @NotNull TableLocation
makeTableLocation
(@NotNull TableLocationKey locationKey) Make a new implementation-appropriate TableLocation from the supplied key.void
removeTableLocationKey
(@NotNull TableLocationKey locationKey) Remove aTableLocationKey
and its correspondingTableLocation
(if it was created).protected final void
Internal method for subclasses to call when they consider themselves to have been initialized.final String
toString()
protected void
visitLocationKey
(@NotNull TableLocationKey locationKey) Called after a table location has been visited byhandleTableLocationKey(TableLocationKey)
, but before notifications have been delivered to any subscriptions, if applicable.Methods inherited from class io.deephaven.engine.table.impl.locations.impl.SubscriptionAggregator
activateUnderlyingDataSource, activationFailed, activationSuccessful, checkHasSubscribers, deactivateUnderlyingDataSource, matchSubscriptionToken, postActivationHook, subscribe, supportsSubscriptions, unsubscribe
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface io.deephaven.util.type.NamedImplementation
getImplementationName
Methods inherited from interface io.deephaven.engine.table.impl.locations.TableLocationProvider
getName, getTableLocation, refresh, subscribe, supportsSubscriptions, unsubscribe
-
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 providersupportsSubscriptions
- 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
-
getKey
Description copied from interface:TableLocationProvider
Get theTableKey
associated with this provider.- Specified by:
getKey
in interfaceTableLocationProvider
- Returns:
- The associated
TableKey
-
deliverInitialSnapshot
Description copied from class:SubscriptionAggregator
Prompt listeners to record current state, under the subscriptions lock.- Specified by:
deliverInitialSnapshot
in classSubscriptionAggregator<TableLocationProvider.Listener>
- Parameters:
listener
- The listener to notify
-
handleTableLocationKey
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
Called after a table location has been visited byhandleTableLocationKey(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
- TheTableLocationKey
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
Description copied from interface:TableLocationProvider
Ensure that this location provider is initialized. Mainly useful in cases where it cannot be otherwise guaranteed thatTableLocationProvider.refresh()
orTableLocationProvider.subscribe(Listener)
has been called prior to calls to the various table location fetch methods.- Specified by:
ensureInitialized
in interfaceTableLocationProvider
- Returns:
- this, to allow method chaining
-
isInitialized
protected final boolean isInitialized()Internal method for subclasses to call to determine if they need to callensureInitialized()
, 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 callingTableLocationProvider.refresh()
is inappropriate. This is *not* guaranteed to be called only once. It should internally callsetInitialized()
upon successful initialization. -
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 interfaceTableLocationProvider
- Returns:
- A collection of keys for locations available from this provider
-
hasTableLocationKey
Description copied from interface:TableLocationProvider
Check if this provider knows the supplied location key.- Specified by:
hasTableLocationKey
in interfaceTableLocationProvider
- 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 interfaceTableLocationProvider
- Parameters:
tableLocationKey
- ATableLocationKey
specifying the location to get- Returns:
- The
TableLocation
matching the given key if present, else null
-
removeTableLocationKey
Remove aTableLocationKey
and its correspondingTableLocation
(if it was created). All subscribers to this TableLocationProvider will benotified
. If the TableLocation was created, all of its subscribers will additionally benotified
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.
- Intermediate TableLocationProviders, which will simply pass the removal on
SourceTables
, which will propagate a failure notification to all downstream listeners, and becomefailed
.SourcePartitionedTables
, which will notify their downstream consumers of the removed constituent.
- Parameters:
locationKey
- TheTableLocationKey
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 thatlocationKey
was removed.- Parameters:
locationKey
- the TableLocation that was removed
-