Interface AbstractDataProvider<T>

Type Parameters:
T - the provided data type
All Known Subinterfaces:
IndexArchiveProvider, SuggestDataProvider
All Known Implementing Classes:
CompoundIndexArchiveProvider, CompoundIndexArchiveProvider.DefaultChildIndexArchiveProvider, ElasticsearchSuggestDataProvider, MergingSuggestDataProvider, S3ArchiveProvider

public interface AbstractDataProvider<T>
General common interface for the different data providers. They are all used by the same principles: First they are instantiated and configured, then asked if they have data for a specific index. If that's the case, data is pulled initially and then regularly whenever 'getLastDataModTime' returns a newer timestamp.
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    This method is always called directly after instantiating the data provider with its no-args-constructor.
    long
    Get the timestamp from when the data was modified the last time.
    boolean
    hasData(String indexName)
    Respond with 'true' if this provider is generally able to provide data for the requested index.
    loadData(String indexName)
     
  • Method Details

    • configure

      default void configure(Map<String,Object> config)

      This method is always called directly after instantiating the data provider with its no-args-constructor. The given configuration is passed through the QuerySuggestManager and might be empty.

      If this data provider is unusable due to missing configuration, it should throw an Exception, so it will be dropped

      Parameters:
      config - specific data provider configuration (never null, but may be empty)
    • hasData

      boolean hasData(String indexName)

      Respond with 'true' if this provider is generally able to provide data for the requested index. This is a quick check when initializing the suggesters, so it should not take too long.

      It's also possible to return a static "true" here and do the expensive availability check at the getLastDataModTime method, which is called async. If getLastDataModTime returns a value < 0, data update are canceled as well.

      Parameters:
      indexName - identifier for the requested data
      Returns:
      if data is available
    • getLastDataModTime

      long getLastDataModTime(String indexName) throws IOException

      Get the timestamp from when the data was modified the last time. For every change of that timestamp, the data will be pulled and indexed into suggest index.

      Setting the timestamp at the data is optional, but if it is set there, it MUST be the same timestamp, otherwise the data is rejected. This feature is used to avoid potential concurrency issues.

      If data is not available at all, a value < 0 should be returned.

      Parameters:
      indexName - identifier for the requested data
      Returns:
      unix timestamp in millis
      Throws:
      IOException - if resource is not available
    • loadData

      T loadData(String indexName) throws IOException
      Parameters:
      indexName - identifier for the requested data
      Returns:
      suggest data
      Throws:
      IOException - if data couldn't be loaded