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
ConstructorsModifierConstructorDescriptionprotectedAbstractTableLocationProvider(boolean supportsSubscriptions, TableUpdateMode updateMode, TableUpdateMode locationUpdateMode) Construct a standalone provider.protectedAbstractTableLocationProvider(@NotNull TableKey tableKey, boolean supportsSubscriptions, TableUpdateMode updateMode, TableUpdateMode locationUpdateMode) Construct a provider as part of a service. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidbeginTransaction(@NotNull Object token) Internal method to begin an atomic transaction of location adds and removes.protected final voidPrompt listeners to record current state, under the subscriptions lock.protected voidInitialization method for subclasses to override, in case simply callingTableLocationProvider.refresh()is inappropriate.protected voidendTransaction(@NotNull Object token) Internal method to end an atomic transaction of location adds and removes.final TableLocationProviderEnsure that this location provider is initialized.final ImmutableTableKeygetKey()Get theTableKeyassociated with this provider.@NotNull TableUpdateModeGet the locationupdate guaranteesof this provider describing how individual locations will add or remove rows.@Nullable TableLocationgetTableLocationIfPresent(@NotNull TableLocationKey tableLocationKey) Get theTableLocationassociated with the given key if it exists.voidgetTableLocationKeys(Consumer<LiveSupplier<ImmutableTableLocationKey>> consumer, Predicate<ImmutableTableLocationKey> filter) Get this provider's currently known location keys.@NotNull TableUpdateModeGet theupdate guaranteesof this provider describing how this provider will add or remove table locations.protected final voidhandleTableLocationKeyAdded(@NotNull TableLocationKey locationKey) Deliver a possibly-new key.protected final voidhandleTableLocationKeyAdded(@NotNull TableLocationKey locationKey, @Nullable Object transactionToken) Deliver a possibly-new key, optionally as part of a transaction.protected voidhandleTableLocationKeyRemoved(@NotNull TableLocationKey locationKey, @Nullable Object transactionToken) Handle a removal, optionally as part of a transaction.final booleanhasTableLocationKey(@NotNull TableLocationKey tableLocationKey) Check if this provider knows the supplied location key.protected final booleanInternal method for subclasses to call to determine if they need to callensureInitialized(), if doing so might entail extra work (e.g.protected abstract @NotNull TableLocationmakeTableLocation(@NotNull TableLocationKey locationKey) Make a new implementation-appropriate TableLocation from the supplied key.voidremoveTableLocationKey(@NotNull TableLocationKey locationKey) Remove aTableLocationKeyand its correspondingTableLocation(if it was created).protected final voidInternal method for subclasses to call when they consider themselves to have been initialized.final StringtoString()protected voidvisitLocationKey(@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, unsubscribeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface io.deephaven.util.type.NamedImplementation
getImplementationNameMethods 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:TableLocationProviderGet theTableKeyassociated with this provider.- Specified by:
getKeyin interfaceTableLocationProvider- Returns:
- The associated
TableKey
-
deliverInitialSnapshot
Description copied from class:SubscriptionAggregatorPrompt listeners to record current state, under the subscriptions lock.- Specified by:
deliverInitialSnapshotin 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 thatlocationKeywas 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- TheTableLocationKeythat 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:TableLocationProviderEnsure 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:
ensureInitializedin 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:TableLocationProviderGet 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 associatedLiveSupplieris retained by the caller.- Specified by:
getTableLocationKeysin 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:TableLocationProviderCheck if this provider knows the supplied location key.- Specified by:
hasTableLocationKeyin 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:TableLocationProviderGet theTableLocationassociated with the given key if it exists. Callers should ensure that they retain theLiveSupplierreturned 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:
getTableLocationIfPresentin interfaceTableLocationProvider- Parameters:
tableLocationKey- ATableLocationKeyspecifying the location to get.- Returns:
- The
TableLocationmatching the given key if present, else null.
-
removeTableLocationKey
Remove aTableLocationKeyand its correspondingTableLocation(if it was created). All subscribers to this TableLocationProvider will benotified. If the TableLocation was created, all of its subscribers will additionally benotifiedthat 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- TheTableLocationKeyto 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:TableLocationProviderGet theupdate guaranteesof this provider describing how this provider will add or remove table locations.- Specified by:
getUpdateModein interfaceTableLocationProvider
-
getLocationUpdateMode
Description copied from interface:TableLocationProviderGet the locationupdate guaranteesof this provider describing how individual locations will add or remove rows.- Specified by:
getLocationUpdateModein interfaceTableLocationProvider
-