Module org.elasticsearch.server
Class MetadataIndexTemplateService
java.lang.Object
org.elasticsearch.cluster.metadata.MetadataIndexTemplateService
Service responsible for submitting index templates updates
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMetadataIndexTemplateService(ClusterService clusterService, MetadataCreateIndexService metadataCreateIndexService, IndicesService indicesService, IndexScopedSettings indexScopedSettings, NamedXContentRegistry xContentRegistry, SystemIndices systemIndices, IndexSettingProviders indexSettingProviders, DataStreamGlobalRetentionSettings globalRetentionSettings) -
Method Summary
Modifier and TypeMethodDescriptionaddComponentTemplate(ClusterState currentState, boolean create, String name, ComponentTemplate template) addIndexTemplateV2(ClusterState currentState, boolean create, String name, ComposableIndexTemplate template) addIndexTemplateV2(ClusterState currentState, boolean create, String name, ComposableIndexTemplate template, boolean validateV2Overlaps) static List<CompressedXContent> collectMappings(ClusterState state, String templateName, String indexName) Collect the given v2 template into an ordered list of mappings.static List<CompressedXContent> collectMappings(ComposableIndexTemplate template, Map<String, ComponentTemplate> componentTemplates, String indexName) Collect the given v2 template into an ordered list of mappings.static DataStreamLifecyclecomposeDataLifecycles(List<DataStreamLifecycle> lifecycles) This method composes a series of lifecycles to a final one.composeDataStreamOptions(List<ResettableValue<DataStreamOptions.Template>> dataStreamOptionsList) This method composes a series of data streams options to a final one.findConflictingV1Templates(ClusterState state, String candidateName, List<String> indexPatterns) Return a map of v1 template names to their index patterns for v1 templates that would overlap with the given v2 template's index patterns.findConflictingV2Templates(ClusterState state, String candidateName, List<String> indexPatterns) Return a map of v2 template names to their index patterns for v2 templates that would overlap with the given template's index patterns.static List<IndexTemplateMetadata> findV1Templates(Metadata metadata, String indexName, Boolean isHidden) Finds index templates whose index pattern matched with the given index name.static StringfindV2Template(Metadata metadata, String indexName, boolean isHidden) Return the name (id) of the highest matching index template for the given index name.static ClusterStateinnerRemoveComponentTemplate(ClusterState currentState, String... names) static ClusterStateinnerRemoveIndexTemplateV2(ClusterState currentState, String... names) voidputComponentTemplate(String cause, boolean create, String name, TimeValue masterTimeout, ComponentTemplate template, ActionListener<AcknowledgedResponse> listener) Add the given component template to the cluster state.voidputIndexTemplateV2(String cause, boolean create, String name, TimeValue masterTimeout, ComposableIndexTemplate template, ActionListener<AcknowledgedResponse> listener) Add the given index template to the cluster state.voidputTemplate(MetadataIndexTemplateService.PutRequest request, TimeValue timeout, ActionListener<AcknowledgedResponse> listener) voidremoveComponentTemplate(String[] names, TimeValue masterTimeout, ClusterState state, ActionListener<AcknowledgedResponse> listener) Remove the given component template from the cluster state.voidremoveIndexTemplateV2(String[] names, TimeValue masterTimeout, ActionListener<AcknowledgedResponse> listener) Remove the given index template from the cluster state.voidremoveTemplates(String templatePattern, TimeValue timeout, ActionListener<AcknowledgedResponse> listener) static List<Map<String, AliasMetadata>> resolveAliases(List<IndexTemplateMetadata> templates) Resolve the given v1 templates into an ordered list of aliasesstatic List<Map<String, AliasMetadata>> resolveAliases(Metadata metadata, String templateName) Resolve the given v2 template name into an ordered list of aliasesresolveDataStreamOptions(ComposableIndexTemplate template, Map<String, ComponentTemplate> componentTemplates) Resolve the provided v2 template and component templates into aResettableValue<DataStreamOptions>objectresolveDataStreamOptions(Metadata metadata, String templateName) Resolve the given v2 template into aResettableValue<DataStreamOptions>objectstatic DataStreamLifecycleresolveLifecycle(ComposableIndexTemplate template, Map<String, ComponentTemplate> componentTemplates) Resolve the provided v2 template and component templates into aDataStreamLifecycleobjectstatic DataStreamLifecycleresolveLifecycle(Metadata metadata, String templateName) Resolve the given v2 template into aDataStreamLifecycleobjectstatic SettingsresolveSettings(List<IndexTemplateMetadata> templates) Resolve index settings for the given list of v1 templates, templates are apply in reverse order since they should be provided in order of priority/orderstatic SettingsresolveSettings(ComposableIndexTemplate template, Map<String, ComponentTemplate> componentTemplates) Resolve the provided v2 template and component templates into a collectedSettingsobjectstatic SettingsresolveSettings(Metadata metadata, String templateName) Resolve the given v2 template into a collectedSettingsobjectv2TemplateOverlaps(ClusterState currentState, String name, ComposableIndexTemplate template, boolean validate) Calculates the conflicting v2 index template overlaps for a given composable index template.static voidvalidateV2TemplateRequest(Metadata metadata, String name, ComposableIndexTemplate template)
-
Field Details
-
DEFAULT_TIMESTAMP_FIELD
- See Also:
-
DEFAULT_TIMESTAMP_MAPPING_WITHOUT_ROUTING
-
-
Constructor Details
-
MetadataIndexTemplateService
@Inject public MetadataIndexTemplateService(ClusterService clusterService, MetadataCreateIndexService metadataCreateIndexService, IndicesService indicesService, IndexScopedSettings indexScopedSettings, NamedXContentRegistry xContentRegistry, SystemIndices systemIndices, IndexSettingProviders indexSettingProviders, DataStreamGlobalRetentionSettings globalRetentionSettings)
-
-
Method Details
-
removeTemplates
public void removeTemplates(String templatePattern, TimeValue timeout, ActionListener<AcknowledgedResponse> listener) -
putComponentTemplate
public void putComponentTemplate(String cause, boolean create, String name, TimeValue masterTimeout, ComponentTemplate template, ActionListener<AcknowledgedResponse> listener) Add the given component template to the cluster state. Ifcreateis true, an exception will be thrown if the component template already exists -
addComponentTemplate
public ClusterState addComponentTemplate(ClusterState currentState, boolean create, String name, ComponentTemplate template) throws Exception - Throws:
Exception
-
removeComponentTemplate
public void removeComponentTemplate(String[] names, TimeValue masterTimeout, ClusterState state, ActionListener<AcknowledgedResponse> listener) Remove the given component template from the cluster state. The component template name supports simple regex wildcards for removing multiple component templates at a time. -
innerRemoveComponentTemplate
-
putIndexTemplateV2
public void putIndexTemplateV2(String cause, boolean create, String name, TimeValue masterTimeout, ComposableIndexTemplate template, ActionListener<AcknowledgedResponse> listener) Add the given index template to the cluster state. Ifcreateis true, an exception will be thrown if the component template already exists -
validateV2TemplateRequest
public static void validateV2TemplateRequest(Metadata metadata, String name, ComposableIndexTemplate template) -
addIndexTemplateV2
public ClusterState addIndexTemplateV2(ClusterState currentState, boolean create, String name, ComposableIndexTemplate template) throws Exception - Throws:
Exception
-
addIndexTemplateV2
public ClusterState addIndexTemplateV2(ClusterState currentState, boolean create, String name, ComposableIndexTemplate template, boolean validateV2Overlaps) throws Exception - Throws:
Exception
-
v2TemplateOverlaps
public static Map<String,List<String>> v2TemplateOverlaps(ClusterState currentState, String name, ComposableIndexTemplate template, boolean validate) Calculates the conflicting v2 index template overlaps for a given composable index template. Optionally if validate is true we throw anIllegalArgumentExceptionwith information about the conflicting templates.This method doesn't check for conflicting overlaps with v1 templates.
- Parameters:
currentState- the current cluster statename- the composable index template nametemplate- the full composable index template object we check for overlapsvalidate- should we throwIllegalArgumentExceptionif conflicts are found or just compute them- Returns:
- a map of v2 template names to their index patterns for v2 templates that would overlap with the given template
-
findConflictingV1Templates
public static Map<String,List<String>> findConflictingV1Templates(ClusterState state, String candidateName, List<String> indexPatterns) Return a map of v1 template names to their index patterns for v1 templates that would overlap with the given v2 template's index patterns. -
findConflictingV2Templates
public static Map<String,List<String>> findConflictingV2Templates(ClusterState state, String candidateName, List<String> indexPatterns) Return a map of v2 template names to their index patterns for v2 templates that would overlap with the given template's index patterns. -
removeIndexTemplateV2
public void removeIndexTemplateV2(String[] names, TimeValue masterTimeout, ActionListener<AcknowledgedResponse> listener) Remove the given index template from the cluster state. The index template name supports simple regex wildcards for removing multiple index templates at a time. -
innerRemoveIndexTemplateV2
-
putTemplate
public void putTemplate(MetadataIndexTemplateService.PutRequest request, TimeValue timeout, ActionListener<AcknowledgedResponse> listener) -
findV1Templates
public static List<IndexTemplateMetadata> findV1Templates(Metadata metadata, String indexName, @Nullable Boolean isHidden) Finds index templates whose index pattern matched with the given index name. In the case of hidden indices, a template with a match all pattern or global template will not be returned.- Parameters:
metadata- TheMetadatacontaining all of theIndexTemplateMetadatavaluesindexName- The name of the index that templates are being found forisHidden- Whether or not the index is known to be hidden. May benullif the index being hidden has not been explicitly requested. Whennullif the result of template application results in a hidden index, then global templates will not be returned- Returns:
- a list of templates sorted by
IndexTemplateMetadata.order()descending.
-
findV2Template
@Nullable public static String findV2Template(Metadata metadata, String indexName, boolean isHidden) Return the name (id) of the highest matching index template for the given index name. In the event that no templates are matched,nullis returned. -
collectMappings
public static List<CompressedXContent> collectMappings(ClusterState state, String templateName, String indexName) Collect the given v2 template into an ordered list of mappings. -
collectMappings
public static List<CompressedXContent> collectMappings(ComposableIndexTemplate template, Map<String, ComponentTemplate> componentTemplates, String indexName) Collect the given v2 template into an ordered list of mappings. -
resolveSettings
Resolve index settings for the given list of v1 templates, templates are apply in reverse order since they should be provided in order of priority/order -
resolveSettings
Resolve the given v2 template into a collectedSettingsobject -
resolveSettings
public static Settings resolveSettings(ComposableIndexTemplate template, Map<String, ComponentTemplate> componentTemplates) Resolve the provided v2 template and component templates into a collectedSettingsobject -
resolveAliases
Resolve the given v1 templates into an ordered list of aliases -
resolveAliases
public static List<Map<String,AliasMetadata>> resolveAliases(Metadata metadata, String templateName) Resolve the given v2 template name into an ordered list of aliases -
resolveLifecycle
@Nullable public static DataStreamLifecycle resolveLifecycle(Metadata metadata, String templateName) Resolve the given v2 template into aDataStreamLifecycleobject -
resolveLifecycle
@Nullable public static DataStreamLifecycle resolveLifecycle(ComposableIndexTemplate template, Map<String, ComponentTemplate> componentTemplates) Resolve the provided v2 template and component templates into aDataStreamLifecycleobject -
composeDataLifecycles
@Nullable public static DataStreamLifecycle composeDataLifecycles(List<DataStreamLifecycle> lifecycles) This method composes a series of lifecycles to a final one. The lifecycles are getting composed one level deep, meaning that the keys present on the latest lifecycle will override the ones of the others. If a key is missing then it keeps the value of the previous lifecycles. For example, if we have the following two lifecycles: [ { "lifecycle": { "enabled": true, "data_retention" : "10d" } }, { "lifecycle": { "enabled": true, "data_retention" : "20d" } } ] The result will be { "lifecycle": { "enabled": true, "data_retention" : "20d"}} because the second data retention overrides the first. However, if we have the following two lifecycles: [ { "lifecycle": { "enabled": false, "data_retention" : "10d" } }, { "lifecycle": { "enabled": true } } ] The result will be { "lifecycle": { "enabled": true, "data_retention" : "10d"} } because the latest lifecycle does not have any information on retention.- Parameters:
lifecycles- a sorted list of lifecycles in the order that they will be composed- Returns:
- the final lifecycle
-
resolveDataStreamOptions
public static ResettableValue<DataStreamOptions.Template> resolveDataStreamOptions(Metadata metadata, String templateName) Resolve the given v2 template into aResettableValue<DataStreamOptions>object -
resolveDataStreamOptions
public static ResettableValue<DataStreamOptions.Template> resolveDataStreamOptions(ComposableIndexTemplate template, Map<String, ComponentTemplate> componentTemplates) Resolve the provided v2 template and component templates into aResettableValue<DataStreamOptions>object -
composeDataStreamOptions
public static ResettableValue<DataStreamOptions.Template> composeDataStreamOptions(List<ResettableValue<DataStreamOptions.Template>> dataStreamOptionsList) This method composes a series of data streams options to a final one. Since currently the data stream options contains only the failure store configuration which also contains only one field, the composition is a bit trivial. But we introduce the mechanics that will help extend it really easily.- Parameters:
dataStreamOptionsList- a sorted list of data stream options in the order that they will be composed- Returns:
- the final data stream option configuration
-