Class RemoteTableDataService.TableLocationProviderImpl
- All Implemented Interfaces:
com.fishlib.base.log.LogOutputAppendable
,RequestResultHandler
,TableKey
,TableLocationProvider
,NamedImplementation
- Enclosing class:
- RemoteTableDataService
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.illumon.iris.db.v2.locations.TableKey
TableKey.KeyedObjectKeyImpl<VALUE_TYPE>, TableKey.SelfKeyedObjectKeyImpl<VALUE_TYPE extends TableKey>
Nested classes/interfaces inherited from interface com.illumon.iris.db.v2.locations.TableLocationProvider
TableLocationProvider.Listener, TableLocationProvider.NullTableLocationProvider
-
Field Summary
Fields inherited from class com.illumon.iris.db.v2.locations.SubscriptionAggregator
subscriptions
Fields inherited from interface com.illumon.iris.db.v2.locations.protocol.RequestResultHandler
NULL
Fields inherited from interface com.illumon.iris.db.v2.locations.TableLocationProvider
globalMark
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
Refresh and activate update pushing from the implementing class.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.Get a name for the implementing class.getName()
allow TableLocationProvider instances to have names.protected TableLocation
makeTableLocation
(TableLocationKey locationKey) Make a new implementation-appropriate TableLocation from the supplied key.protected <T> boolean
matchSubscriptionToken
(T token) Verify that a notification pertains to a currently-active subscription.void
onComplete
(TableDataRequest request) Invoked when the request completed successfully.void
onRejection
(TableDataRequest request, String rejectionMessage, TableDataProtocol.RequestRejectionType requestRejectionType) Invoked when the specified request was rejected.void
onTableLocationKeyAdded
(TableLocationKey locationKey) Invoked in response to atable locations request
for each discoveredTableLocationKey
.void
onTableLocationKeyRemoved
(TableLocationKey locationKey) Invoked when the upstream provider has removed, or detected a removed location.void
Invoked in response to alocation refresh request
.void
onTimeout
(TableDataRequest request) Invoked when the specified request timed out before a response was received.protected void
Method to override in order to observe successful activation.void
refresh()
Initialize or refresh state information about the list of existing locations.void
Initialize or refresh state information about the list of existing locations.void
refreshAndRescan
(Consumer<TableLocationKey> locationKeyObserver) Initialize or refresh state information about the list of existing locations.Optional toString path with more implementation detail.Methods inherited from class com.illumon.iris.db.v2.locations.AbstractTableLocationProvider
deliverInitialSnapshot, doInitialization, ensureInitialized, getLog, getNamespace, getTableKey, getTableLocationIfPresent, getTableLocations, getTableName, getTableType, handleTableLocationKey, handleTableLocationKey, handleTableLocationKeyRemoved, isInitialized, mark, maybeReloadLocation, removeTableLocationKey, removeUnvisited, setInitialized, toString
Methods inherited from class com.illumon.iris.db.v2.locations.SubscriptionAggregator
activationFailed, activationSuccessful, subscribe, supportsSubscriptions, unsubscribe
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.illumon.iris.db.v2.locations.TableKey
append, asTableIdentifier, toStringHelper, toStringSimple, writeTo
Methods inherited from interface com.illumon.iris.db.v2.locations.TableLocationProvider
getTableLocation, getTableLocation, subscribe, supportsSubscriptions, traverse, unsubscribe
-
Method Details
-
getImplementationName
Description copied from interface:NamedImplementation
Get a name for the implementing class. Useful for abstract classes that implement
LogOutputAppendable
or overridetoString
.The default implementation is correct, but not suitable for high-frequency usage.
- Specified by:
getImplementationName
in interfaceNamedImplementation
- Returns:
- A name for the implementing class
-
activateUnderlyingDataSource
protected void activateUnderlyingDataSource()Description copied from class:SubscriptionAggregator
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 refresh results, unless activationFailed() was called instead.
Must be called under the subscription lock.
- Overrides:
activateUnderlyingDataSource
in classSubscriptionAggregator<TableLocationProvider.Listener>
-
deactivateUnderlyingDataSource
protected void deactivateUnderlyingDataSource()Description copied from class:SubscriptionAggregator
Deactivate pushed updates from the implementing class. Must be called under the subscription lock.- Overrides:
deactivateUnderlyingDataSource
in classSubscriptionAggregator<TableLocationProvider.Listener>
-
matchSubscriptionToken
protected <T> boolean matchSubscriptionToken(T token) Description copied from class:SubscriptionAggregator
Verify that a notification pertains to a currently-active subscription. Must be called under the subscription lock.- Overrides:
matchSubscriptionToken
in classSubscriptionAggregator<TableLocationProvider.Listener>
- Parameters:
token
- A subscription-related object that the subclass can use to match a notification- Returns:
- True iff notification delivery should proceed
-
postActivationHook
protected void postActivationHook()Description copied from class:SubscriptionAggregator
Method to override in order to observe successful activation.- Overrides:
postActivationHook
in classSubscriptionAggregator<TableLocationProvider.Listener>
-
refresh
public void refresh()Description copied from interface:TableLocationProvider
Initialize or refresh state information about the list of existing locations.- Specified by:
refresh
in interfaceTableLocationProvider
-
refreshAndRescan
public void refreshAndRescan()Description copied from interface:TableLocationProvider
Initialize or refresh state information about the list of existing locations. If applicable, perform extra work to ensure any cached information is up to date.- Specified by:
refreshAndRescan
in interfaceTableLocationProvider
- Overrides:
refreshAndRescan
in classAbstractTableLocationProvider
-
refreshAndRescan
Description copied from interface:TableLocationProvider
Initialize or refresh state information about the list of existing locations. If applicable, perform extra work to ensure any cached information is up to date.- Specified by:
refreshAndRescan
in interfaceTableLocationProvider
- Parameters:
locationKeyObserver
- call this TableLocationKey consumer with each location encountered (instead of the default)
-
makeTableLocation
Description copied from class:AbstractTableLocationProvider
Make a new implementation-appropriate TableLocation from the supplied key.- Specified by:
makeTableLocation
in classAbstractTableLocationProvider
- Parameters:
locationKey
- The table location key- Returns:
- The new TableLocation
-
getName
Description copied from interface:TableLocationProvider
allow TableLocationProvider instances to have names.- Specified by:
getName
in interfaceTableLocationProvider
-
toStringDetailed
Description copied from interface:TableKey
Optional toString path with more implementation detail.- Specified by:
toStringDetailed
in interfaceTableKey
- Returns:
- detailed conversion to string
-
onTimeout
Description copied from interface:RequestResultHandler
Invoked when the specified request timed out before a response was received.- Specified by:
onTimeout
in interfaceRequestResultHandler
- Parameters:
request
- the request object.
-
onRejection
public void onRejection(@NotNull TableDataRequest request, String rejectionMessage, TableDataProtocol.RequestRejectionType requestRejectionType) Description copied from interface:RequestResultHandler
Invoked when the specified request was rejected. This typically happens during subscription to a location- Specified by:
onRejection
in interfaceRequestResultHandler
- Parameters:
request
- the request object.rejectionMessage
- a message for context about the rejectionrequestRejectionType
- what type of rejection was received
-
onComplete
Description copied from interface:RequestResultHandler
Invoked when the request completed successfully.- Specified by:
onComplete
in interfaceRequestResultHandler
- Parameters:
request
- the request object
-
onTableLocationKeyAdded
Description copied from interface:RequestResultHandler
Invoked in response to atable locations request
for each discoveredTableLocationKey
.- Specified by:
onTableLocationKeyAdded
in interfaceRequestResultHandler
- Parameters:
locationKey
- the discoveredTableLocationKey
-
onTableLocationKeyRemoved
Description copied from interface:RequestResultHandler
Invoked when the upstream provider has removed, or detected a removed location.- Specified by:
onTableLocationKeyRemoved
in interfaceRequestResultHandler
- Parameters:
locationKey
- theTableLocationKey
that was removed
-
onTableLocationState
Description copied from interface:RequestResultHandler
Invoked in response to alocation refresh request
.- Specified by:
onTableLocationState
in interfaceRequestResultHandler
- Parameters:
state
- the updatedTableLocationState
for the location requested
-
checkHasSubscribers
public boolean checkHasSubscribers()Description copied from class:SubscriptionAggregator
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.- Specified by:
checkHasSubscribers
in interfaceRequestResultHandler
- Overrides:
checkHasSubscribers
in classSubscriptionAggregator<TableLocationProvider.Listener>
- Returns:
- true if there are valid subscribers, else false
-