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 protectedAbstractTableLocationProvider(TableKey tableKey, boolean supportsSubscriptions) -
Method Summary
Modifier and Type Method Description protected voiddeliverInitialSnapshot(TableLocationProvider.Listener listener)Prompt listeners to record current state, under the subscriptions lock.protected voiddoInitialization()Initialization method for subclasses to override, in case simply callingTableLocationProvider.refresh()is inappropriate.TableLocationProviderensureInitialized()Ensure that this location provider is initialized.CharSequencegetNamespace()protected TableLookupKey<String>getTableKey()TableLocationgetTableLocationIfPresent(TableLocationKey tableLocationKey)Collection<TableLocation>getTableLocations()Get this provider's currently available locations.CharSequencegetTableName()TableTypegetTableType()voidhandleTableLocationKey(TableLocationKey locationKey)Deliver a possibly-new key.protected booleanisInitialized()Internal method for subclasses to call to determine if they need to callensureInitialized(), if doing so might entail extra work (e.g.protected abstract TableLocationmakeTableLocation(TableLocationKey locationKey)Make a new implementation-appropriate TableLocation from the supplied key.protected voidsetInitialized()Internal method for subclasses to call when they consider themselves to have been initialized.StringtoString()Methods inherited from class com.illumon.iris.db.v2.locations.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 com.illumon.iris.db.v2.locations.TableKey
append, asTableIdentifier, toStringDetailed, toStringHelper, writeToMethods 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:
getNamespacein interfaceTableKey- Returns:
- The namespace enclosing this table
-
getTableName
- Specified by:
getTableNamein interfaceTableKey- Returns:
- The name of this table
-
getTableType
- Specified by:
getTableTypein interfaceTableKey- Returns:
- The type of this table (which generally dictates storage, metadata-availability, etc)
-
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
-
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: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. -
getTableLocations
Description copied from interface:TableLocationProviderGet this provider's currently available locations. Locations returned may have null size - that is, they may not "exist" for application purposes.- Specified by:
getTableLocationsin interfaceTableLocationProvider- Returns:
- A collection of locations available from this provider
-
getTableLocationIfPresent
@Nullable public TableLocation getTableLocationIfPresent(@NotNull TableLocationKey tableLocationKey)- Specified by:
getTableLocationIfPresentin interfaceTableLocationProvider- Parameters:
tableLocationKey- A key specifying the location to get- Returns:
- The TableLocation matching the given key if present, else null
-