Package org.elasticsearch.indices
Class SystemIndices
java.lang.Object
org.elasticsearch.indices.SystemIndices
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 SystemIndexDescriptor
s.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Class holding a description of a stateful feature.static enum
-
Field Summary
-
Constructor Summary
ConstructorDescriptionSystemIndices
(Map<String, SystemIndices.Feature> pluginAndModulesDescriptors) Initialize the SystemIndices object -
Method Summary
Modifier and TypeMethodDescriptiondataStreamAccessException
(ThreadContext threadContext, Collection<String> names) Finds a single matchingSystemDataStreamDescriptor
, if any, for the given DataStream name.findMatchingDescriptor
(String name) Finds a single matchingSystemIndexDescriptor
, if any, for the given index name.Used to determine which executor should be used for operations on this index.getProductSystemIndexMetadataPredicate
(ThreadContext threadContext) Builds a predicate that tests if a system index should be accessible based on the provided product name contained in headers.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.getSystemIndexAccessLevel
(ThreadContext threadContext) Determines what level of system index access should be allowed in the current context.org.apache.lucene.util.automaton.Automaton
boolean
isNetNewSystemIndex
(String indexName) Checks whether an index is a net-new system index, meaning we can apply non-BWC behavior to it.boolean
isSystemDataStream
(String name) Determines whether the provided name matches that of a system data stream that has been defined by aSystemDataStreamDescriptor
boolean
isSystemIndex
(String indexName) Determines whether a given index is a system index by comparing its name to the collection of loadedSystemIndexDescriptor
s.boolean
isSystemIndex
(Index index) Determines whether a given index is a system index by comparing its name to the collection of loadedSystemIndexDescriptor
sboolean
Determines whether the provided name matches that of an index that backs a system data stream.boolean
isSystemName
(String name) Checks whether the given name matches a reserved name or pattern that is intended for use by a system component.netNewSystemIndexAccessException
(ThreadContext threadContext, Collection<String> names) validateDataStreamAccess
(String dataStreamName, ThreadContext threadContext) static void
validateFeatureName
(String name, String plugin) Check that a feature name is not reserved
-
Field Details
-
SYSTEM_INDEX_ACCESS_CONTROL_HEADER_KEY
- See Also:
-
EXTERNAL_SYSTEM_INDEX_ACCESS_CONTROL_HEADER_KEY
- See Also:
-
UPGRADED_INDEX_SUFFIX
- See Also:
-
-
Constructor Details
-
SystemIndices
Initialize the SystemIndices object- Parameters:
pluginAndModulesDescriptors
- A map of this node's feature names to feature objects.
-
-
Method Details
-
isSystemName
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
Determines whether a given index is a system index by comparing its name to the collection of loadedSystemIndexDescriptor
s- Parameters:
index
- theIndex
object to check against loadedSystemIndexDescriptor
s- Returns:
- true if the
Index
's name matches a pattern from aSystemIndexDescriptor
-
isSystemIndex
Determines whether a given index is a system index by comparing its name to the collection of loadedSystemIndexDescriptor
s. This will also match alias names that belong to system indices.- Parameters:
indexName
- the index name to check against loadedSystemIndexDescriptor
s- Returns:
- true if the index name matches a pattern from a
SystemIndexDescriptor
-
isSystemDataStream
Determines whether the provided name matches that of a system data stream that has been defined by aSystemDataStreamDescriptor
-
isSystemIndexBackingDataStream
Determines whether the provided name matches that of an index that backs a system data stream. -
getSystemNameAutomaton
public org.apache.lucene.util.automaton.Automaton getSystemNameAutomaton()- Returns:
- An
Automaton
that tests whether strings are names of system indices, aliases, or data streams.
-
isNetNewSystemIndex
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
Used to determine which executor should be used for operations on this index. SeeExecutorSelector
docs for details. -
findMatchingDescriptor
Finds a single matchingSystemIndexDescriptor
, if any, for the given index name.- Parameters:
name
- the name of the index- Returns:
- The matching
SystemIndexDescriptor
ornull
if no descriptor is found - Throws:
IllegalStateException
- if multiple descriptors match the name
-
findMatchingDataStreamDescriptor
Finds a single matchingSystemDataStreamDescriptor
, if any, for the given DataStream name.- Parameters:
name
- the name of the DataStream- Returns:
- The matching
SystemDataStreamDescriptor
ornull
if no descriptor is found - Throws:
IllegalStateException
- if multiple descriptors match the name
-
getProductSystemIndexMetadataPredicate
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
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
-
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
Determines what level of system index access should be allowed in the current context.- Parameters:
threadContext
- the current thread context that has headers associated with the current request- 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, orSystemIndices.SystemIndexAccessLevel.NONE
if no system index access should be allowed.
-
validateFeatureName
Check that a feature name is not reserved- Parameters:
name
- Name of featureplugin
- Name of plugin providing the feature
-