Class MetadataIndexTemplateService
java.lang.Object
org.elasticsearch.cluster.metadata.MetadataIndexTemplateService
public class MetadataIndexTemplateService
extends java.lang.Object
Service responsible for submitting index templates updates
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceMetadataIndexTemplateService.PutListenerstatic classMetadataIndexTemplateService.PutRequeststatic classMetadataIndexTemplateService.PutResponsestatic interfaceMetadataIndexTemplateService.RemoveListenerstatic classMetadataIndexTemplateService.RemoveRequeststatic classMetadataIndexTemplateService.RemoveResponse -
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDEFAULT_TIMESTAMP_FIELDstatic java.lang.StringDEFAULT_TIMESTAMP_MAPPING -
Constructor Summary
Constructors Constructor Description MetadataIndexTemplateService(ClusterService clusterService, MetadataCreateIndexService metadataCreateIndexService, AliasValidator aliasValidator, IndicesService indicesService, IndexScopedSettings indexScopedSettings, org.elasticsearch.common.xcontent.NamedXContentRegistry xContentRegistry) -
Method Summary
Modifier and Type Method Description ClusterStateaddIndexTemplateV2(ClusterState currentState, boolean create, java.lang.String name, ComposableIndexTemplate template)static java.util.List<CompressedXContent>collectMappings(ClusterState state, java.lang.String templateName, java.lang.String indexName)Collect the given v2 template into an ordered list of mappings.static java.util.Map<java.lang.String,java.util.List<java.lang.String>>findConflictingV1Templates(ClusterState state, java.lang.String candidateName, java.util.List<java.lang.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.static java.util.Map<java.lang.String,java.util.List<java.lang.String>>findConflictingV2Templates(ClusterState state, java.lang.String candidateName, java.util.List<java.lang.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 java.util.List<IndexTemplateMetadata>findV1Templates(Metadata metadata, java.lang.String indexName, java.lang.Boolean isHidden)Finds index templates whose index pattern matched with the given index name.static java.lang.StringfindV2Template(Metadata metadata, java.lang.String indexName, boolean isHidden)Return the name (id) of the highest matching index template for the given index name.voidputComponentTemplate(java.lang.String cause, boolean create, java.lang.String name, org.elasticsearch.common.unit.TimeValue masterTimeout, ComponentTemplate template, ActionListener<AcknowledgedResponse> listener)Add the given component template to the cluster state.voidputIndexTemplateV2(java.lang.String cause, boolean create, java.lang.String name, org.elasticsearch.common.unit.TimeValue masterTimeout, ComposableIndexTemplate template, ActionListener<AcknowledgedResponse> listener)Add the given index template to the cluster state.voidputTemplate(MetadataIndexTemplateService.PutRequest request, MetadataIndexTemplateService.PutListener listener)voidremoveComponentTemplate(java.lang.String name, org.elasticsearch.common.unit.TimeValue masterTimeout, ActionListener<AcknowledgedResponse> listener)Remove the given component template from the cluster state.voidremoveIndexTemplateV2(java.lang.String name, org.elasticsearch.common.unit.TimeValue masterTimeout, ActionListener<AcknowledgedResponse> listener)Remove the given index template from the cluster state.voidremoveTemplates(MetadataIndexTemplateService.RemoveRequest request, MetadataIndexTemplateService.RemoveListener listener)static java.util.List<java.util.Map<java.lang.String,AliasMetadata>>resolveAliases(java.util.List<IndexTemplateMetadata> templates)Resolve the given v1 templates into an ordered list of aliasesstatic java.util.List<java.util.Map<java.lang.String,AliasMetadata>>resolveAliases(Metadata metadata, java.lang.String templateName)Resolve the given v2 template into an ordered list of aliasesstatic SettingsresolveSettings(java.util.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(Metadata metadata, java.lang.String templateName)Resolve the given v2 template into a collectedSettingsobjectstatic voidvalidateV2TemplateRequest(Metadata metadata, java.lang.String name, ComposableIndexTemplate template)
-
Field Details
-
DEFAULT_TIMESTAMP_FIELD
public static final java.lang.String DEFAULT_TIMESTAMP_FIELD- See Also:
- Constant Field Values
-
DEFAULT_TIMESTAMP_MAPPING
public static final java.lang.String DEFAULT_TIMESTAMP_MAPPING- See Also:
- Constant Field Values
-
-
Constructor Details
-
MetadataIndexTemplateService
@Inject public MetadataIndexTemplateService(ClusterService clusterService, MetadataCreateIndexService metadataCreateIndexService, AliasValidator aliasValidator, IndicesService indicesService, IndexScopedSettings indexScopedSettings, org.elasticsearch.common.xcontent.NamedXContentRegistry xContentRegistry)
-
-
Method Details
-
removeTemplates
public void removeTemplates(MetadataIndexTemplateService.RemoveRequest request, MetadataIndexTemplateService.RemoveListener listener) -
putComponentTemplate
public void putComponentTemplate(java.lang.String cause, boolean create, java.lang.String name, org.elasticsearch.common.unit.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 -
removeComponentTemplate
public void removeComponentTemplate(java.lang.String name, org.elasticsearch.common.unit.TimeValue masterTimeout, 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. -
putIndexTemplateV2
public void putIndexTemplateV2(java.lang.String cause, boolean create, java.lang.String name, org.elasticsearch.common.unit.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, java.lang.String name, ComposableIndexTemplate template) -
addIndexTemplateV2
public ClusterState addIndexTemplateV2(ClusterState currentState, boolean create, java.lang.String name, ComposableIndexTemplate template) throws java.lang.Exception- Throws:
java.lang.Exception
-
findConflictingV1Templates
public static java.util.Map<java.lang.String,java.util.List<java.lang.String>> findConflictingV1Templates(ClusterState state, java.lang.String candidateName, java.util.List<java.lang.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 java.util.Map<java.lang.String,java.util.List<java.lang.String>> findConflictingV2Templates(ClusterState state, java.lang.String candidateName, java.util.List<java.lang.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(java.lang.String name, org.elasticsearch.common.unit.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. -
putTemplate
public void putTemplate(MetadataIndexTemplateService.PutRequest request, MetadataIndexTemplateService.PutListener listener) -
findV1Templates
public static java.util.List<IndexTemplateMetadata> findV1Templates(Metadata metadata, java.lang.String indexName, @Nullable java.lang.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 java.lang.String findV2Template(Metadata metadata, java.lang.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 java.util.List<CompressedXContent> collectMappings(ClusterState state, java.lang.String templateName, java.lang.String indexName) throws java.lang.ExceptionCollect the given v2 template into an ordered list of mappings.- Throws:
java.lang.Exception
-
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 -
resolveAliases
public static java.util.List<java.util.Map<java.lang.String,AliasMetadata>> resolveAliases(java.util.List<IndexTemplateMetadata> templates)Resolve the given v1 templates into an ordered list of aliases -
resolveAliases
public static java.util.List<java.util.Map<java.lang.String,AliasMetadata>> resolveAliases(Metadata metadata, java.lang.String templateName)Resolve the given v2 template into an ordered list of aliases
-