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()
.
-
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
ConstructorsModifierConstructorDescriptionprotected
AbstractTableLocationProvider
(boolean supportsSubscriptions, TableUpdateMode updateMode, TableUpdateMode locationUpdateMode) Construct a standalone provider.protected
AbstractTableLocationProvider
(@NotNull TableKey tableKey, boolean supportsSubscriptions, TableUpdateMode updateMode, TableUpdateMode locationUpdateMode) Construct a provider as part of a service. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
beginTransaction
(@NotNull Object token) Internal method to begin an atomic transaction of location adds and removes.protected 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.protected void
endTransaction
(@NotNull Object token) Internal method to end an atomic transaction of location adds and removes.final TableLocationProvider
Ensure that this location provider is initialized.final ImmutableTableKey
getKey()
Get theTableKey
associated with this provider.@NotNull TableUpdateMode
Get the locationupdate guarantees
of this provider describing how individual locations will add or remove rows.@Nullable TableLocation
getTableLocationIfPresent
(@NotNull TableLocationKey tableLocationKey) Get theTableLocation
associated with the given key if it exists.void
getTableLocationKeys
(Consumer<LiveSupplier<ImmutableTableLocationKey>> consumer, Predicate<ImmutableTableLocationKey> filter) Get this provider's currently known location keys.@NotNull TableUpdateMode
Get theupdate guarantees
of this provider describing how this provider will add or remove table locations.protected final void
handleTableLocationKeyAdded
(@NotNull TableLocationKey locationKey) Deliver a possibly-new key.protected final void
handleTableLocationKeyAdded
(@NotNull TableLocationKey locationKey, @Nullable Object transactionToken) Deliver a possibly-new key, optionally as part of a transaction.protected void
handleTableLocationKeyRemoved
(@NotNull TableLocationKey locationKey, @Nullable Object transactionToken) Handle a removal, optionally as part of a transaction.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 byhandleTableLocationKeyAdded(TableLocationKey, Object)
, 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, getTableLocationKeys, getTableLocationKeys, refresh, subscribe, supportsSubscriptions, unsubscribe
-
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 providersupportsSubscriptions
- Whether this provider should support subscriptionsupdateMode
- What updates to the set of locations are allowedlocationUpdateMode
- 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 subscriptionsupdateMode
- What updates to the set of locations are allowedlocationUpdateMode
- What updates to the location rows are allowed
-
-
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
-
beginTransaction
Internal method to begin an atomic transaction of location adds and removes.- Parameters:
token
- A token to identify the transaction
-
endTransaction
Internal method to end an atomic transaction of location adds and removes.- Parameters:
token
- A token to identify the transaction
-
handleTableLocationKeyAdded
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 keytransactionToken
- 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 thatlocationKey
was removed if necessary. SeeremoveTableLocationKey(TableLocationKey)
for additional discussions of semantics.- Parameters:
locationKey
- the TableLocation that was removedtransactionToken
- The token identifying the transaction (or null if not part of a transaction)
-
visitLocationKey
Called after a table location has been visited byhandleTableLocationKeyAdded(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
- 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
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 associatedLiveSupplier
is retained by the caller.- Specified by:
getTableLocationKeys
in interfaceTableLocationProvider
- Parameters:
consumer
- A consumer to receive the location keysfilter
- A filter to apply to the location keys before the consumer is called
-
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.- 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 theTableLocation
associated with the given key if it exists. Callers should ensure that they retain theLiveSupplier
returned byTableLocationProvider.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 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.
-
getUpdateMode
Description copied from interface:TableLocationProvider
Get theupdate guarantees
of this provider describing how this provider will add or remove table locations.- Specified by:
getUpdateMode
in interfaceTableLocationProvider
-
getLocationUpdateMode
Description copied from interface:TableLocationProvider
Get the locationupdate guarantees
of this provider describing how individual locations will add or remove rows.- Specified by:
getLocationUpdateMode
in interfaceTableLocationProvider
-