Class SystemIndices

java.lang.Object
org.elasticsearch.indices.SystemIndices

public class SystemIndices extends Object
This class holds the SystemIndexDescriptor objects that represent system indices the node knows about. Methods for determining if an index should be a system index are also provided to reduce the locations within the code that need to deal with SystemIndexDescriptors.
  • Field Details

  • Constructor Details

    • SystemIndices

      public SystemIndices(List<SystemIndices.Feature> pluginAndModuleFeatures)
      Initialize the SystemIndices object
      Parameters:
      pluginAndModuleFeatures - A list of features from which we will load system indices. These features come from plugins and modules. Non-plugin system features such as Tasks will be added automatically.
  • Method Details

    • isSystemName

      public boolean isSystemName(String name)
      Checks whether the given name matches a reserved name or pattern that is intended for use by a system component. The name is checked against index names, aliases, data stream names, and the names of indices that back a system data stream.
    • isSystemIndex

      public boolean isSystemIndex(Index index)
      Determines whether a given index is a system index by comparing its name to the collection of loaded SystemIndexDescriptors
      Parameters:
      index - the Index object to check against loaded SystemIndexDescriptors
      Returns:
      true if the Index's name matches a pattern from a SystemIndexDescriptor
    • isSystemIndex

      public boolean isSystemIndex(String indexName)
      Determines whether a given index is a system index by comparing its name to the collection of loaded SystemIndexDescriptors. This will also match alias names that belong to system indices.
      Parameters:
      indexName - the index name to check against loaded SystemIndexDescriptors
      Returns:
      true if the index name matches a pattern from a SystemIndexDescriptor
    • isSystemDataStream

      public boolean isSystemDataStream(String name)
      Determines whether the provided name matches that of a system data stream that has been defined by a SystemDataStreamDescriptor
    • isSystemIndexBackingDataStream

      public boolean isSystemIndexBackingDataStream(String name)
      Determines whether the provided name matches that of an index that backs a system data stream.
    • isNetNewSystemIndex

      public boolean isNetNewSystemIndex(String indexName)
      Checks whether an index is a net-new system index, meaning we can apply non-BWC behavior to it.
      Parameters:
      indexName - The index name to check.
      Returns:
      true if the given index is covered by a net-new system index descriptor, false otherwise.
    • getExecutorSelector

      public ExecutorSelector getExecutorSelector()
      Used to determine which executor should be used for operations on this index. See ExecutorSelector docs for details.
    • findMatchingDescriptor

      @Nullable public SystemIndexDescriptor findMatchingDescriptor(String name)
      Finds a single matching SystemIndexDescriptor, if any, for the given index name.
      Parameters:
      name - the name of the index
      Returns:
      The matching SystemIndexDescriptor or null if no descriptor is found
      Throws:
      IllegalStateException - if multiple descriptors match the name
    • findMatchingDataStreamDescriptor

      @Nullable public SystemDataStreamDescriptor findMatchingDataStreamDescriptor(String name)
      Finds a single matching SystemDataStreamDescriptor, if any, for the given DataStream name.
      Parameters:
      name - the name of the DataStream
      Returns:
      The matching SystemDataStreamDescriptor or null if no descriptor is found
      Throws:
      IllegalStateException - if multiple descriptors match the name
    • getProductSystemIndexMetadataPredicate

      public Predicate<IndexMetadata> getProductSystemIndexMetadataPredicate(ThreadContext threadContext)
      Builds a predicate that tests if a system index should be accessible based on the provided product name contained in headers.
      Parameters:
      threadContext - the threadContext containing headers used for system index access
      Returns:
      Predicate to check external system index metadata with
    • getProductSystemIndexNamePredicate

      public Predicate<String> getProductSystemIndexNamePredicate(ThreadContext threadContext)
      Builds a predicate that tests if a system index name should be accessible based on the provided product name contained in headers.
      Parameters:
      threadContext - the threadContext containing headers used for system index access
      Returns:
      Predicate to check external system index names with
    • getFeatureNames

      public Set<String> getFeatureNames()
      Get a set of feature names. This is useful for checking whether particular features are present on the node.
      Returns:
      A set of all feature names
    • getFeature

      public SystemIndices.Feature getFeature(String name)
      Get a feature by name.
      Parameters:
      name - Name of a feature.
      Returns:
      The corresponding feature if it exists on this node, null otherwise.
    • getFeatures

      public Collection<SystemIndices.Feature> getFeatures()
      Get a collection of the Features this SystemIndices object is managing.
      Returns:
      A collection of Features.
    • validateDataStreamAccess

      public SystemDataStreamDescriptor validateDataStreamAccess(String dataStreamName, ThreadContext threadContext)
    • dataStreamAccessException

      public IllegalArgumentException dataStreamAccessException(ThreadContext threadContext, Collection<String> names)
    • netNewSystemIndexAccessException

      public IllegalArgumentException netNewSystemIndexAccessException(ThreadContext threadContext, Collection<String> names)
    • getSystemIndexAccessLevel

      public SystemIndices.SystemIndexAccessLevel getSystemIndexAccessLevel(ThreadContext threadContext)
      Determines what level of system index access should be allowed in the current context.
      Returns:
      SystemIndices.SystemIndexAccessLevel.ALL if unrestricted system index access should be allowed, SystemIndices.SystemIndexAccessLevel.RESTRICTED if a subset of system index access should be allowed, or SystemIndices.SystemIndexAccessLevel.NONE if no system index access should be allowed.
    • validateFeatureName

      public static void validateFeatureName(String name, String plugin)
      Check that a feature name is not reserved
      Parameters:
      name - Name of feature
      plugin - Name of plugin providing the feature