Class MetadataCreateIndexService
java.lang.Object
org.elasticsearch.cluster.metadata.MetadataCreateIndexService
Service responsible for submitting create index requests
-
Field Summary
-
Constructor Summary
ConstructorDescriptionMetadataCreateIndexService(Settings settings, ClusterService clusterService, IndicesService indicesService, AllocationService allocationService, AliasValidator aliasValidator, ShardLimitValidator shardLimitValidator, Environment env, IndexScopedSettings indexScopedSettings, ThreadPool threadPool, org.elasticsearch.common.xcontent.NamedXContentRegistry xContentRegistry, SystemIndices systemIndices, boolean forbidPrivateIndexSettings)
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a provider to be invoked to get additional index settings prior to an index being createdapplyCreateIndexRequest(ClusterState currentState, CreateIndexClusterStateUpdateRequest request, boolean silent)
applyCreateIndexRequest(ClusterState currentState, CreateIndexClusterStateUpdateRequest request, boolean silent, BiConsumer<Metadata.Builder,IndexMetadata> metadataTransformer)
Handles the cluster state transition to a version that reflects theCreateIndexClusterStateUpdateRequest
.static int
calculateNumRoutingShards(int numShards, Version indexVersionCreated)
Returns a default number of routing shards based on the number of shards of the index.collectV2Mappings(Map<String,String> requestMappings, List<CompressedXContent> templateMappings, org.elasticsearch.common.xcontent.NamedXContentRegistry xContentRegistry)
collectV2Mappings(Map<String,String> requestMappings, ClusterState currentState, String templateName, org.elasticsearch.common.xcontent.NamedXContentRegistry xContentRegistry, String indexName)
void
createIndex(CreateIndexClusterStateUpdateRequest request, ActionListener<ShardsAcknowledgedResponse> listener)
Creates an index in the cluster state and waits for the specified number of shard copies to become active (as specified inCreateIndexClusterStateUpdateRequest.waitForActiveShards()
) before sending the response on the listener.static List<AliasMetadata>
resolveAndValidateAliases(String index, Set<Alias> aliases, List<Map<String,AliasMetadata>> templateAliases, Metadata metadata, AliasValidator aliasValidator, org.elasticsearch.common.xcontent.NamedXContentRegistry xContentRegistry, SearchExecutionContext searchExecutionContext, Function<String,String> indexNameExpressionResolver)
Validate and resolve the aliases explicitly set for the index, together with the ones inherited from the specified templates.boolean
validateDotIndex(String index, Boolean isHidden)
Validates (if this index has a dot-prefixed name) whether it follows the rules for dot-prefixed indices.void
validateIndexName(String index, ClusterState state)
Validate the name for an index against some static rules and a cluster state.static void
validateIndexOrAliasName(String index, BiFunction<String,String,? extends RuntimeException> exceptionCtor)
Validate the name for an index or alias against some static rules.void
validateIndexSettings(String indexName, Settings settings, boolean forbidPrivateIndexSettings)
static void
validateTranslogRetentionSettings(Settings indexSettings)
-
Field Details
-
MAX_INDEX_NAME_BYTES
public static final int MAX_INDEX_NAME_BYTES- See Also:
- Constant Field Values
-
-
Constructor Details
-
MetadataCreateIndexService
public MetadataCreateIndexService(Settings settings, ClusterService clusterService, IndicesService indicesService, AllocationService allocationService, AliasValidator aliasValidator, ShardLimitValidator shardLimitValidator, Environment env, IndexScopedSettings indexScopedSettings, ThreadPool threadPool, org.elasticsearch.common.xcontent.NamedXContentRegistry xContentRegistry, SystemIndices systemIndices, boolean forbidPrivateIndexSettings)
-
-
Method Details
-
addAdditionalIndexSettingProvider
Add a provider to be invoked to get additional index settings prior to an index being created -
validateIndexName
Validate the name for an index against some static rules and a cluster state. -
validateDotIndex
Validates (if this index has a dot-prefixed name) whether it follows the rules for dot-prefixed indices.- Parameters:
index
- The name of the index in questionisHidden
- Whether or not this is a hidden index
-
getSystemIndices
-
validateIndexOrAliasName
public static void validateIndexOrAliasName(String index, BiFunction<String,String,? extends RuntimeException> exceptionCtor)Validate the name for an index or alias against some static rules. -
createIndex
public void createIndex(CreateIndexClusterStateUpdateRequest request, ActionListener<ShardsAcknowledgedResponse> listener)Creates an index in the cluster state and waits for the specified number of shard copies to become active (as specified inCreateIndexClusterStateUpdateRequest.waitForActiveShards()
) before sending the response on the listener. If the index creation was successfully applied on the cluster state, thenAcknowledgedResponse.isAcknowledged()
will return true, otherwise it will return false and no waiting will occur for started shards (ShardsAcknowledgedResponse.isShardsAcknowledged()
will also be false). If the index creation in the cluster state was successful and the requisite shard copies were started before the timeout, thenShardsAcknowledgedResponse.isShardsAcknowledged()
will return true, otherwise if the operation timed out, then it will return false.- Parameters:
request
- the index creation cluster state update requestlistener
- the listener on which to send the index creation cluster state update response
-
applyCreateIndexRequest
public ClusterState applyCreateIndexRequest(ClusterState currentState, CreateIndexClusterStateUpdateRequest request, boolean silent, BiConsumer<Metadata.Builder,IndexMetadata> metadataTransformer) throws ExceptionHandles the cluster state transition to a version that reflects theCreateIndexClusterStateUpdateRequest
. All the requested changes are firstly validated before mutating theClusterState
.- Throws:
Exception
-
applyCreateIndexRequest
public ClusterState applyCreateIndexRequest(ClusterState currentState, CreateIndexClusterStateUpdateRequest request, boolean silent) throws Exception- Throws:
Exception
-
collectV2Mappings
public static List<Map<String,Map<String,Object>>> collectV2Mappings(Map<String,String> requestMappings, ClusterState currentState, String templateName, org.elasticsearch.common.xcontent.NamedXContentRegistry xContentRegistry, String indexName) throws Exception- Throws:
Exception
-
collectV2Mappings
public static List<Map<String,Map<String,Object>>> collectV2Mappings(Map<String,String> requestMappings, List<CompressedXContent> templateMappings, org.elasticsearch.common.xcontent.NamedXContentRegistry xContentRegistry) throws Exception- Throws:
Exception
-
resolveAndValidateAliases
public static List<AliasMetadata> resolveAndValidateAliases(String index, Set<Alias> aliases, List<Map<String,AliasMetadata>> templateAliases, Metadata metadata, AliasValidator aliasValidator, org.elasticsearch.common.xcontent.NamedXContentRegistry xContentRegistry, SearchExecutionContext searchExecutionContext, Function<String,String> indexNameExpressionResolver)Validate and resolve the aliases explicitly set for the index, together with the ones inherited from the specified templates. The template mappings are applied in the order they are encountered in the list (clients should make sure the lower index, closer to the head of the list, templates have the highestIndexTemplateMetadata.order()
)- Returns:
- the list of resolved aliases, with the explicitly provided aliases occurring first (having a higher priority) followed by the ones inherited from the templates
-
validateIndexSettings
public void validateIndexSettings(String indexName, Settings settings, boolean forbidPrivateIndexSettings) throws IndexCreationException- Throws:
IndexCreationException
-
calculateNumRoutingShards
Returns a default number of routing shards based on the number of shards of the index. The default number of routing shards will allow any index to be split at least once and at most 10 times by a factor of two. The closer the number or shards gets to 1024 the less default split operations are supported -
validateTranslogRetentionSettings
-