Class SubscriptionAggregator<LISTENER_TYPE extends BasicTableDataListener>
java.lang.Object
io.deephaven.engine.table.impl.locations.impl.SubscriptionAggregator<LISTENER_TYPE>
- Type Parameters:
LISTENER_TYPE
- A bound on the type of listener supported by this aggregator's subscriptions
- Direct Known Subclasses:
AbstractTableLocation
,AbstractTableLocationProvider
public abstract class SubscriptionAggregator<LISTENER_TYPE extends BasicTableDataListener>
extends Object
Implement optional subscription support suitable for multiple TableDataService components.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Refresh and activate update pushing from the implementing class.final <T> void
activationFailed
(T token, @NotNull TableDataException exception) Deliver an exception triggered while activating or maintaining the underlying data source.final <T> void
activationSuccessful
(T token) Notify the implementation that activation has completed.boolean
Check if this subscription aggregator still has any valid subscribers - useful if there may have been no notifications delivered for some time, as a test to determine whether work should be done to maintain the underlying subscription.protected void
Deactivate pushed updates from the implementing class.protected abstract void
deliverInitialSnapshot
(LISTENER_TYPE listener) Prompt listeners to record current state, under the subscriptions lock.protected <T> boolean
matchSubscriptionToken
(T token) Verify that a notification pertains to a currently-active subscription.protected void
Method to override in order to observe successful activation.final void
subscribe
(LISTENER_TYPE listener) final boolean
final void
unsubscribe
(LISTENER_TYPE listener)
-
Field Details
-
subscriptions
-
-
Method Details
-
supportsSubscriptions
public final boolean supportsSubscriptions() -
subscribe
-
deliverInitialSnapshot
Prompt listeners to record current state, under the subscriptions lock.- Parameters:
listener
- The listener to notify
-
postActivationHook
protected void postActivationHook()Method to override in order to observe successful activation. -
unsubscribe
-
checkHasSubscribers
public boolean checkHasSubscribers()Check if this subscription aggregator still has any valid subscribers - useful if there may have been no notifications delivered for some time, as a test to determine whether work should be done to maintain the underlying subscription.- Returns:
- true if there are valid subscribers, else false
-
activateUnderlyingDataSource
protected void activateUnderlyingDataSource()Refresh and activate update pushing from the implementing class.
If the implementation will deliver notifications in a different thread than the one that calls this method, then this method must be asynchronous - that is, it must not block pending delivery of results. This requirement holds even if that other thread has nothing to do with the initial activation request!
Listeners should guard against duplicate notifications, especially if the implementation delivers synchronous notifications.
The implementation should call activationSuccessful() when done activating and delivering initial run results, unless activationFailed() was called instead.
Must be called under the subscription lock.
-
activationSuccessful
public final <T> void activationSuccessful(@Nullable T token) Notify the implementation that activation has completed. This may be invoked upon "re-activation" of an existing subscription, in which case it is effectively a no-op. This is public because it is called externally by services implementing subscriptions.- Parameters:
token
- A subscription-related object that the subclass can use to match a notification
-
activationFailed
public final <T> void activationFailed(@Nullable T token, @NotNull @NotNull TableDataException exception) Deliver an exception triggered while activating or maintaining the underlying data source. The underlying data source is implicitly deactivated. This is public because it is called externally by services implementing subscriptions.- Parameters:
token
- A subscription-related object that the subclass can use to match a notificationexception
- The exception
-
deactivateUnderlyingDataSource
protected void deactivateUnderlyingDataSource()Deactivate pushed updates from the implementing class. Must be called under the subscription lock. -
matchSubscriptionToken
protected <T> boolean matchSubscriptionToken(T token) Verify that a notification pertains to a currently-active subscription. Must be called under the subscription lock.- Parameters:
token
- A subscription-related object that the subclass can use to match a notification- Returns:
- True iff notification delivery should proceed
-