Module org.elasticsearch.xcore
Class IndexTemplateRegistry
java.lang.Object
org.elasticsearch.xpack.core.template.IndexTemplateRegistry
- All Implemented Interfaces:
ClusterStateListener
- Direct Known Subclasses:
YamlTemplateRegistry
Abstracts the logic of managing versioned index templates, ingest pipelines and lifecycle policies for plugins that require such things.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Clientprotected final ClusterServiceprotected final List<LifecyclePolicy> protected final ConcurrentMap<String, AtomicBoolean> protected final ConcurrentMap<String, AtomicBoolean> protected final Settingsprotected final ConcurrentMap<String, AtomicBoolean> protected final ThreadPoolprotected final org.elasticsearch.xcontent.NamedXContentRegistry -
Constructor Summary
ConstructorsConstructorDescriptionIndexTemplateRegistry(Settings nodeSettings, ClusterService clusterService, ThreadPool threadPool, Client client, org.elasticsearch.xcontent.NamedXContentRegistry xContentRegistry) -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanAllows registries to opt-in for automatic rollover of "relevant" data streams immediately after a composable index template gets updated, including its initial installation.voidprotected Map<String, ComponentTemplate> Retrieves return a list ofIndexTemplateConfigthat represents the component templates that should be installed and managed.protected Map<String, ComposableIndexTemplate> Retrieves return a list ofIndexTemplateConfigthat represents the composable templates that should be installed and managed.protected List<IngestPipelineConfig> Retrieves a list ofIngestPipelineConfigthat represents the ingest pipelines that should be installed and managed.protected List<IndexTemplateConfig> Retrieves return a list ofIndexTemplateConfigthat represents the index templates that should be installed and managed.protected List<LifecyclePolicyConfig> Returns the configured configurations for the lifecycle policies.protected List<LifecyclePolicy> Retrieves a list ofLifecyclePolicythat represents the ILM policies that should be installed and managed.protected abstract StringRetrieves an identifier that is used to identify which plugin is asking for this.voidInitialize the template registry, adding it as a listener so templates will be installed as necessaryprotected booleanA method that can be overridden to add additional conditions to be satisfied before installing the template registry components.protected booleanisUpgradeRequired(LifecyclePolicy currentPolicy, LifecyclePolicy newPolicy) Determines whether an index lifecycle policy should be upgraded to a newer version.protected voidonPutPipelineFailure(String pipelineId, Exception e) Called when creation of an ingest pipeline fails.protected voidonPutPolicyFailure(LifecyclePolicy policy, Exception e) Called when creation of a lifecycle policy fails.protected voidonPutTemplateFailure(String templateName, Exception e) Called when creation of an index template fails.protected static Map<String, ComposableIndexTemplate> parseComposableTemplates(IndexTemplateConfig... config) protected booleanWhether the registry should only apply changes when running on the master node.
-
Field Details
-
settings
-
client
-
threadPool
-
xContentRegistry
protected final org.elasticsearch.xcontent.NamedXContentRegistry xContentRegistry -
clusterService
-
templateCreationsInProgress
-
policyCreationsInProgress
-
pipelineCreationsInProgress
-
lifecyclePolicies
-
-
Constructor Details
-
IndexTemplateRegistry
public IndexTemplateRegistry(Settings nodeSettings, ClusterService clusterService, ThreadPool threadPool, Client client, org.elasticsearch.xcontent.NamedXContentRegistry xContentRegistry)
-
-
Method Details
-
getLifecycleConfigs
Returns the configured configurations for the lifecycle policies. Subclasses should provide the ILM configurations and they will be loaded if we're not running data stream only mode (controlled viaDataStreamLifecycle.DATA_STREAMS_LIFECYCLE_ONLY_SETTING_NAME). The loaded lifecycle configurations will be installed if returned bygetLifecyclePolicies(). Child classes have a chance to overridegetLifecyclePolicies()in case they want additional control over if these policies should be installed or not (say, if they belong to functionalities that can be enabled/disabled via a flag).- Returns:
- The lifecycle policies configurations that pertain to this template registry.
-
initialize
public void initialize()Initialize the template registry, adding it as a listener so templates will be installed as necessary -
getLegacyTemplateConfigs
Retrieves return a list ofIndexTemplateConfigthat represents the index templates that should be installed and managed.- Returns:
- The configurations for the templates that should be installed.
-
getComponentTemplateConfigs
Retrieves return a list ofIndexTemplateConfigthat represents the component templates that should be installed and managed. Component templates are always installed prior composable templates, so they may be referenced by a composable template.- Returns:
- The configurations for the templates that should be installed.
-
getComposableTemplateConfigs
Retrieves return a list ofIndexTemplateConfigthat represents the composable templates that should be installed and managed.- Returns:
- The configurations for the templates that should be installed.
-
getLifecyclePolicies
Retrieves a list ofLifecyclePolicythat represents the ILM policies that should be installed and managed. Only called if ILM is enabled.- Returns:
- The lifecycle policies that should be installed.
-
getIngestPipelines
Retrieves a list ofIngestPipelineConfigthat represents the ingest pipelines that should be installed and managed.- Returns:
- The configurations for ingest pipelines that should be installed.
-
getOrigin
Retrieves an identifier that is used to identify which plugin is asking for this.- Returns:
- A string ID for the plugin managing these templates.
-
onPutTemplateFailure
Called when creation of an index template fails.- Parameters:
templateName- the template name that failed to be created.e- The exception that caused the failure.
-
onPutPolicyFailure
Called when creation of a lifecycle policy fails.- Parameters:
policy- The lifecycle policy that failed to be created.e- The exception that caused the failure.
-
clusterChanged
- Specified by:
clusterChangedin interfaceClusterStateListener
-
isClusterReady
A method that can be overridden to add additional conditions to be satisfied before installing the template registry components. -
requiresMasterNode
protected boolean requiresMasterNode()Whether the registry should only apply changes when running on the master node. This is useful for plugins where certain actions are performed on master nodes and the templates should match the respective version. -
isUpgradeRequired
Determines whether an index lifecycle policy should be upgraded to a newer version.- Parameters:
currentPolicy- The current lifecycle policy. Never null.newPolicy- The new lifecycle policy. Never null.- Returns:
trueifnewPolicyshould replacecurrentPolicy.
-
parseComposableTemplates
protected static Map<String,ComposableIndexTemplate> parseComposableTemplates(IndexTemplateConfig... config) -
applyRolloverAfterTemplateV2Update
protected boolean applyRolloverAfterTemplateV2Update()Allows registries to opt-in for automatic rollover of "relevant" data streams immediately after a composable index template gets updated, including its initial installation. If set totrue, then every time a composable index template is being updated, all data streams of which name matches this template's index patterns AND of all matching templates the upgraded one has the highest priority, will be rolled over.- Returns:
trueif this registry wants to apply automatic rollovers after template V2 upgrades
-
onPutPipelineFailure
Called when creation of an ingest pipeline fails.- Parameters:
pipelineId- the pipeline that failed to be created.e- The exception that caused the failure.
-