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(Map<String,SystemIndices.Feature> pluginAndModulesDescriptors)
      Initialize the SystemIndices object
      Parameters:
      pluginAndModulesDescriptors - A map of this node's feature names to feature objects.
  • 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
    • getFeatures

      public Map<String,SystemIndices.Feature> getFeatures()
    • 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