Class SingleTableLocationProvider

java.lang.Object
com.illumon.iris.db.v2.locations.SingleTableLocationProvider
All Implemented Interfaces:
com.fishlib.base.log.LogOutputAppendable, TableKey, TableLocationProvider, NamedImplementation

public class SingleTableLocationProvider extends Object implements TableLocationProvider
A TableLocationProvider that provides access to exactly one, previously-known TableLocation.
  • Constructor Details

    • SingleTableLocationProvider

      public SingleTableLocationProvider(@NotNull TableLocation tableLocation)
      Parameters:
      tableLocation - The only table location that this provider will ever provide
  • Method Details

    • mark

      public void mark(long mark)
      Description copied from interface: TableLocationProvider
      Indicate the start of a sweep of locations. This will be used to detect locations that have been removed from downstream.
      Specified by:
      mark in interface TableLocationProvider
      Parameters:
      mark - the value to set
    • removeUnvisited

      public boolean removeUnvisited(long stamp)
      Description copied from interface: TableLocationProvider
      Removes any locations that were not visited after the given mark time.
      Specified by:
      removeUnvisited in interface TableLocationProvider
      Parameters:
      stamp - any locations last visited before this mark will be removed.
      Returns:
      true if any locations were removed.
    • supportsSubscriptions

      public boolean supportsSubscriptions()
      Description copied from interface: TableLocationProvider
      Does this provider support subscriptions? That is, can this provider ever have ticking data?
      Specified by:
      supportsSubscriptions in interface TableLocationProvider
      Returns:
      True if this provider supports subscriptions.
    • subscribe

      public void subscribe(@NotNull TableLocationProvider.Listener listener)
      Description copied from interface: TableLocationProvider

      Subscribe to pushed location additions. Subscribing more than once with the same listener without an intervening unsubscribe is an error, and may result in undefined behavior.

      This is a possibly asynchronous operation - listener will receive 0 or more handleTableLocation callbacks, followed by 0 or 1 handleException callbacks during invocation and continuing after completion, on a thread determined by the implementation. As noted in BasicTableDataListener.handleException(TableDataException), an exception callback signifies that the subscription is no longer valid, and no unsubscribe is required in that case. Callers must not hold any lock that prevents notification delivery while subscribing. Callers must guard against duplicate notifications.

      This method only guarantees eventually consistent state. To force a state update, use refresh() after subscription completes.

      Specified by:
      subscribe in interface TableLocationProvider
      Parameters:
      listener - A listener.
    • unsubscribe

      public void unsubscribe(@NotNull TableLocationProvider.Listener listener)
      Description copied from interface: TableLocationProvider
      Unsubscribe from pushed location additions.
      Specified by:
      unsubscribe in interface TableLocationProvider
      Parameters:
      listener - The listener to forget about.
    • refresh

      public void refresh()
      Description copied from interface: TableLocationProvider
      Initialize or refresh state information about the list of existing locations.
      Specified by:
      refresh in interface TableLocationProvider
    • 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 interface TableLocationProvider
    • refreshAndRescan

      public void refreshAndRescan(@NotNull Consumer<TableLocationKey> locationKeyObserver)
      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 interface TableLocationProvider
      Parameters:
      locationKeyObserver - call this TableLocationKey consumer with each location encountered (instead of the default)
    • ensureInitialized

      public TableLocationProvider ensureInitialized()
      Description copied from interface: TableLocationProvider
      Ensure that this location provider is initialized. Mainly useful in cases where it cannot be otherwise guaranteed that TableLocationProvider.refresh() or TableLocationProvider.subscribe(Listener) has been called prior to calls to the various table location fetch methods.
      Specified by:
      ensureInitialized in interface TableLocationProvider
      Returns:
      this, to allow method chaining
    • getTableLocations

      @NotNull public Collection<TableLocation> 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 interface TableLocationProvider
      Returns:
      A collection of locations available from this provider
    • getTableLocationIfPresent

      @Nullable public TableLocation getTableLocationIfPresent(@NotNull TableLocationKey tableLocationKey)
      Specified by:
      getTableLocationIfPresent in interface TableLocationProvider
      Parameters:
      tableLocationKey - A key specifying the location to get
      Returns:
      The TableLocation matching the given key if present, else null
    • removeTableLocationKey

      public void removeTableLocationKey(@NotNull TableLocationKey locationKey)
      Description copied from interface: TableLocationProvider
      Remove the given table location from the tableLocations map. Use with caution: the intent is that when a TableLocationProvider is told that a location is gone, we should quit providing it in the list of locations, and quit asking downstream providers how big it is.
      Specified by:
      removeTableLocationKey in interface TableLocationProvider
      Parameters:
      locationKey - the TableLocation to remove
    • getNamespace

      @NotNull public CharSequence getNamespace()
      Specified by:
      getNamespace in interface TableKey
      Returns:
      The namespace enclosing this table
    • getTableName

      @NotNull public CharSequence getTableName()
      Specified by:
      getTableName in interface TableKey
      Returns:
      The name of this table
    • getTableType

      @NotNull public TableType getTableType()
      Specified by:
      getTableType in interface TableKey
      Returns:
      The type of this table (which generally dictates storage, metadata-availability, etc)