Package com.illumon.iris.db.v2.locations
Class AbstractTableLocationProvider
java.lang.Object
com.illumon.iris.db.v2.locations.SubscriptionAggregator<TableLocationProvider.Listener>
com.illumon.iris.db.v2.locations.AbstractTableLocationProvider
- All Implemented Interfaces:
com.fishlib.base.log.LogOutputAppendable
,TableKey
,TableLocationProvider
,NamedImplementation
- Direct Known Subclasses:
ReadOnlyLocalTableLocationProvider
,WritableLocalTableLocationProvider
public abstract class AbstractTableLocationProvider extends SubscriptionAggregator<TableLocationProvider.Listener> implements TableLocationProvider
Partial TableLocationProvider implementation for use by TableDataService implementations.
It implements an interface similar to TableLocationProvider.Listener for implementation classes to use when communicating with the parent.
Note that implementations are responsible for determining when it's appropriate to call setInitialized()
and/or override doInitialization()
.
-
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
-
Field Summary
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractTableLocationProvider(TableKey tableKey, boolean supportsSubscriptions)
-
Method Summary
Modifier and Type Method Description protected void
deliverInitialSnapshot(TableLocationProvider.Listener listener)
Prompt listeners to record current state, under the subscriptions lock.protected void
doInitialization()
Initialization method for subclasses to override, in case simply callingTableLocationProvider.refresh()
is inappropriate.TableLocationProvider
ensureInitialized()
Ensure that this location provider is initialized.CharSequence
getNamespace()
protected TableLookupKey<String>
getTableKey()
TableLocation
getTableLocationIfPresent(TableLocationKey tableLocationKey)
Collection<TableLocation>
getTableLocations()
Get this provider's currently available locations.CharSequence
getTableName()
TableType
getTableType()
void
handleTableLocationKey(TableLocationKey locationKey)
Deliver a possibly-new key.protected boolean
isInitialized()
Internal method for subclasses to call to determine if they need to callensureInitialized()
, if doing so might entail extra work (e.g.protected abstract TableLocation
makeTableLocation(TableLocationKey locationKey)
Make a new implementation-appropriate TableLocation from the supplied key.protected void
setInitialized()
Internal method for subclasses to call when they consider themselves to have been initialized.String
toString()
Methods inherited from class com.illumon.iris.db.v2.locations.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 com.illumon.iris.db.v2.locations.TableKey
append, asTableIdentifier, toStringDetailed, toStringHelper, writeTo
Methods inherited from interface com.illumon.iris.db.v2.locations.TableLocationProvider
getName, getTableLocation, getTableLocation, refresh, subscribe, supportsSubscriptions, unsubscribe
-
Constructor Details
-
AbstractTableLocationProvider
- Parameters:
tableKey
- A key whose field values will be deep-copied to this providersupportsSubscriptions
- Whether this provider should support subscriptions
-
-
Method Details
-
toString
-
getTableKey
-
getNamespace
- Specified by:
getNamespace
in interfaceTableKey
- Returns:
- The namespace enclosing this table
-
getTableName
- Specified by:
getTableName
in interfaceTableKey
- Returns:
- The name of this table
-
getTableType
- Specified by:
getTableType
in interfaceTableKey
- Returns:
- The type of this table (which generally dictates storage, metadata-availability, etc)
-
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
-
makeTableLocation
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. -
getTableLocations
Description copied from interface:TableLocationProvider
Get this provider's currently available locations. Locations returned may have null size - that is, they may not "exist" for application purposes.- Specified by:
getTableLocations
in interfaceTableLocationProvider
- Returns:
- A collection of locations available from this provider
-
getTableLocationIfPresent
@Nullable public TableLocation getTableLocationIfPresent(@NotNull TableLocationKey tableLocationKey)- Specified by:
getTableLocationIfPresent
in interfaceTableLocationProvider
- Parameters:
tableLocationKey
- A key specifying the location to get- Returns:
- The TableLocation matching the given key if present, else null
-