mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-03-24 17:09:48 +00:00
Backports the following commits to 7.x: Rename template V2 classes to ComposableTemplate (#57183)
This commit is contained in:
parent
4d5be7c817
commit
c0f732b9f6
@ -49,22 +49,22 @@ import org.elasticsearch.client.indices.CloseIndexResponse;
|
||||
import org.elasticsearch.client.indices.CreateIndexRequest;
|
||||
import org.elasticsearch.client.indices.CreateIndexResponse;
|
||||
import org.elasticsearch.client.indices.DeleteAliasRequest;
|
||||
import org.elasticsearch.client.indices.DeleteIndexTemplateV2Request;
|
||||
import org.elasticsearch.client.indices.DeleteComposableIndexTemplateRequest;
|
||||
import org.elasticsearch.client.indices.FreezeIndexRequest;
|
||||
import org.elasticsearch.client.indices.GetFieldMappingsRequest;
|
||||
import org.elasticsearch.client.indices.GetFieldMappingsResponse;
|
||||
import org.elasticsearch.client.indices.GetIndexRequest;
|
||||
import org.elasticsearch.client.indices.GetIndexResponse;
|
||||
import org.elasticsearch.client.indices.GetIndexTemplateV2Request;
|
||||
import org.elasticsearch.client.indices.GetComposableIndexTemplateRequest;
|
||||
import org.elasticsearch.client.indices.GetIndexTemplatesRequest;
|
||||
import org.elasticsearch.client.indices.GetIndexTemplatesResponse;
|
||||
import org.elasticsearch.client.indices.GetIndexTemplatesV2Response;
|
||||
import org.elasticsearch.client.indices.GetComposableIndexTemplatesResponse;
|
||||
import org.elasticsearch.client.indices.GetMappingsRequest;
|
||||
import org.elasticsearch.client.indices.GetMappingsResponse;
|
||||
import org.elasticsearch.client.indices.IndexTemplateV2ExistRequest;
|
||||
import org.elasticsearch.client.indices.ComposableIndexTemplateExistRequest;
|
||||
import org.elasticsearch.client.indices.IndexTemplatesExistRequest;
|
||||
import org.elasticsearch.client.indices.PutIndexTemplateRequest;
|
||||
import org.elasticsearch.client.indices.PutIndexTemplateV2Request;
|
||||
import org.elasticsearch.client.indices.PutComposableIndexTemplateRequest;
|
||||
import org.elasticsearch.client.indices.PutMappingRequest;
|
||||
import org.elasticsearch.client.indices.ReloadAnalyzersRequest;
|
||||
import org.elasticsearch.client.indices.ReloadAnalyzersResponse;
|
||||
@ -1305,7 +1305,7 @@ public final class IndicesClient {
|
||||
* @return the response
|
||||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public AcknowledgedResponse putIndexTemplate(PutIndexTemplateV2Request putIndexTemplateRequest, RequestOptions options)
|
||||
public AcknowledgedResponse putIndexTemplate(PutComposableIndexTemplateRequest putIndexTemplateRequest, RequestOptions options)
|
||||
throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(putIndexTemplateRequest, IndicesRequestConverters::putIndexTemplate,
|
||||
options, AcknowledgedResponse::fromXContent, emptySet());
|
||||
@ -1320,7 +1320,7 @@ public final class IndicesClient {
|
||||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable putIndexTemplateAsync(PutIndexTemplateV2Request putIndexTemplateRequest,
|
||||
public Cancellable putIndexTemplateAsync(PutComposableIndexTemplateRequest putIndexTemplateRequest,
|
||||
RequestOptions options, ActionListener<AcknowledgedResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(putIndexTemplateRequest, IndicesRequestConverters::putIndexTemplate,
|
||||
options, AcknowledgedResponse::fromXContent, listener, emptySet());
|
||||
@ -1424,10 +1424,10 @@ public final class IndicesClient {
|
||||
* @return the response
|
||||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public GetIndexTemplatesV2Response getIndexTemplate(GetIndexTemplateV2Request getIndexTemplatesRequest,
|
||||
RequestOptions options) throws IOException {
|
||||
public GetComposableIndexTemplatesResponse getIndexTemplate(GetComposableIndexTemplateRequest getIndexTemplatesRequest,
|
||||
RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(getIndexTemplatesRequest, IndicesRequestConverters::getIndexTemplates,
|
||||
options, GetIndexTemplatesV2Response::fromXContent, emptySet());
|
||||
options, GetComposableIndexTemplatesResponse::fromXContent, emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1439,10 +1439,10 @@ public final class IndicesClient {
|
||||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable getIndexTemplateAsync(GetIndexTemplateV2Request getIndexTemplatesRequest, RequestOptions options,
|
||||
ActionListener<GetIndexTemplatesV2Response> listener) {
|
||||
public Cancellable getIndexTemplateAsync(GetComposableIndexTemplateRequest getIndexTemplatesRequest, RequestOptions options,
|
||||
ActionListener<GetComposableIndexTemplatesResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(getIndexTemplatesRequest,
|
||||
IndicesRequestConverters::getIndexTemplates, options, GetIndexTemplatesV2Response::fromXContent, listener, emptySet());
|
||||
IndicesRequestConverters::getIndexTemplates, options, GetComposableIndexTemplatesResponse::fromXContent, listener, emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1538,7 +1538,7 @@ public final class IndicesClient {
|
||||
* @return true if any index templates in the request exist, false otherwise
|
||||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public boolean existsIndexTemplate(IndexTemplateV2ExistRequest indexTemplatesRequest,
|
||||
public boolean existsIndexTemplate(ComposableIndexTemplateExistRequest indexTemplatesRequest,
|
||||
RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequest(indexTemplatesRequest,
|
||||
IndicesRequestConverters::templatesExist, options,
|
||||
@ -1552,7 +1552,7 @@ public final class IndicesClient {
|
||||
* @param listener the listener to be notified upon request completion. The listener will be called with the value {@code true}
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable existsIndexTemplateAsync(IndexTemplateV2ExistRequest indexTemplatesExistRequest,
|
||||
public Cancellable existsIndexTemplateAsync(ComposableIndexTemplateExistRequest indexTemplatesExistRequest,
|
||||
RequestOptions options,
|
||||
ActionListener<Boolean> listener) {
|
||||
|
||||
@ -1676,7 +1676,8 @@ public final class IndicesClient {
|
||||
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
|
||||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public AcknowledgedResponse deleteIndexTemplate(DeleteIndexTemplateV2Request request, RequestOptions options) throws IOException {
|
||||
public AcknowledgedResponse deleteIndexTemplate(DeleteComposableIndexTemplateRequest request,
|
||||
RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request, IndicesRequestConverters::deleteIndexTemplate,
|
||||
options, AcknowledgedResponse::fromXContent, emptySet());
|
||||
}
|
||||
@ -1690,7 +1691,7 @@ public final class IndicesClient {
|
||||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable deleteIndexTemplateAsync(DeleteIndexTemplateV2Request request, RequestOptions options,
|
||||
public Cancellable deleteIndexTemplateAsync(DeleteComposableIndexTemplateRequest request, RequestOptions options,
|
||||
ActionListener<AcknowledgedResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(request, IndicesRequestConverters::deleteIndexTemplate,
|
||||
options, AcknowledgedResponse::fromXContent, listener, emptySet());
|
||||
|
@ -42,17 +42,17 @@ import org.elasticsearch.client.indices.AnalyzeRequest;
|
||||
import org.elasticsearch.client.indices.CloseIndexRequest;
|
||||
import org.elasticsearch.client.indices.CreateIndexRequest;
|
||||
import org.elasticsearch.client.indices.DeleteAliasRequest;
|
||||
import org.elasticsearch.client.indices.DeleteIndexTemplateV2Request;
|
||||
import org.elasticsearch.client.indices.DeleteComposableIndexTemplateRequest;
|
||||
import org.elasticsearch.client.indices.FreezeIndexRequest;
|
||||
import org.elasticsearch.client.indices.GetFieldMappingsRequest;
|
||||
import org.elasticsearch.client.indices.GetIndexRequest;
|
||||
import org.elasticsearch.client.indices.GetIndexTemplateV2Request;
|
||||
import org.elasticsearch.client.indices.GetComposableIndexTemplateRequest;
|
||||
import org.elasticsearch.client.indices.GetIndexTemplatesRequest;
|
||||
import org.elasticsearch.client.indices.GetMappingsRequest;
|
||||
import org.elasticsearch.client.indices.IndexTemplateV2ExistRequest;
|
||||
import org.elasticsearch.client.indices.ComposableIndexTemplateExistRequest;
|
||||
import org.elasticsearch.client.indices.IndexTemplatesExistRequest;
|
||||
import org.elasticsearch.client.indices.PutIndexTemplateRequest;
|
||||
import org.elasticsearch.client.indices.PutIndexTemplateV2Request;
|
||||
import org.elasticsearch.client.indices.PutComposableIndexTemplateRequest;
|
||||
import org.elasticsearch.client.indices.PutMappingRequest;
|
||||
import org.elasticsearch.client.indices.ReloadAnalyzersRequest;
|
||||
import org.elasticsearch.client.indices.ResizeRequest;
|
||||
@ -585,7 +585,7 @@ final class IndicesRequestConverters {
|
||||
return request;
|
||||
}
|
||||
|
||||
static Request putIndexTemplate(PutIndexTemplateV2Request putIndexTemplateRequest) throws IOException {
|
||||
static Request putIndexTemplate(PutComposableIndexTemplateRequest putIndexTemplateRequest) throws IOException {
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_index_template")
|
||||
.addPathPart(putIndexTemplateRequest.name()).build();
|
||||
Request request = new Request(HttpPut.METHOD_NAME, endpoint);
|
||||
@ -608,15 +608,16 @@ final class IndicesRequestConverters {
|
||||
Request request = new Request(HttpPost.METHOD_NAME, endpoint);
|
||||
RequestConverters.Params params = new RequestConverters.Params();
|
||||
params.withMasterTimeout(simulateIndexTemplateRequest.masterNodeTimeout());
|
||||
PutIndexTemplateV2Request putIndexTemplateV2Request = simulateIndexTemplateRequest.indexTemplateV2Request();
|
||||
if (putIndexTemplateV2Request != null) {
|
||||
if (putIndexTemplateV2Request.create()) {
|
||||
PutComposableIndexTemplateRequest putComposableIndexTemplateRequest = simulateIndexTemplateRequest.indexTemplateV2Request();
|
||||
if (putComposableIndexTemplateRequest != null) {
|
||||
if (putComposableIndexTemplateRequest.create()) {
|
||||
params.putParam("create", Boolean.TRUE.toString());
|
||||
}
|
||||
if (Strings.hasText(putIndexTemplateV2Request.cause())) {
|
||||
params.putParam("cause", putIndexTemplateV2Request.cause());
|
||||
if (Strings.hasText(putComposableIndexTemplateRequest.cause())) {
|
||||
params.putParam("cause", putComposableIndexTemplateRequest.cause());
|
||||
}
|
||||
request.setEntity(RequestConverters.createEntity(putIndexTemplateV2Request, RequestConverters.REQUEST_BODY_CONTENT_TYPE));
|
||||
request.setEntity(RequestConverters.createEntity(putComposableIndexTemplateRequest,
|
||||
RequestConverters.REQUEST_BODY_CONTENT_TYPE));
|
||||
}
|
||||
request.addParameters(params.asMap());
|
||||
return request;
|
||||
@ -674,7 +675,7 @@ final class IndicesRequestConverters {
|
||||
return request;
|
||||
}
|
||||
|
||||
static Request getIndexTemplates(GetIndexTemplateV2Request getIndexTemplatesRequest) {
|
||||
static Request getIndexTemplates(GetComposableIndexTemplateRequest getIndexTemplatesRequest) {
|
||||
final String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_index_template")
|
||||
.addPathPart(getIndexTemplatesRequest.name())
|
||||
@ -700,7 +701,7 @@ final class IndicesRequestConverters {
|
||||
return request;
|
||||
}
|
||||
|
||||
static Request templatesExist(IndexTemplateV2ExistRequest indexTemplatesExistRequest) {
|
||||
static Request templatesExist(ComposableIndexTemplateExistRequest indexTemplatesExistRequest) {
|
||||
final String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPartAsIs("_index_template")
|
||||
.addPathPart(indexTemplatesExistRequest.name())
|
||||
@ -759,7 +760,7 @@ final class IndicesRequestConverters {
|
||||
return request;
|
||||
}
|
||||
|
||||
static Request deleteIndexTemplate(DeleteIndexTemplateV2Request deleteIndexTemplateRequest) {
|
||||
static Request deleteIndexTemplate(DeleteComposableIndexTemplateRequest deleteIndexTemplateRequest) {
|
||||
String name = deleteIndexTemplateRequest.getName();
|
||||
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_index_template").addPathPart(name).build();
|
||||
Request request = new Request(HttpDelete.METHOD_NAME, endpoint);
|
||||
|
@ -24,14 +24,14 @@ import org.elasticsearch.common.Strings;
|
||||
/**
|
||||
* A request to check for the existence of index templates
|
||||
*/
|
||||
public class IndexTemplateV2ExistRequest extends GetComponentTemplatesRequest {
|
||||
public class ComposableIndexTemplateExistRequest extends GetComponentTemplatesRequest {
|
||||
|
||||
/**
|
||||
* Create a request to check for the existence of index template. Name must be provided
|
||||
*
|
||||
* @param name the name of template to check for the existence of
|
||||
*/
|
||||
public IndexTemplateV2ExistRequest(String name) {
|
||||
public ComposableIndexTemplateExistRequest(String name) {
|
||||
super(name);
|
||||
if (Strings.isNullOrEmpty(name)) {
|
||||
throw new IllegalArgumentException("must provide index template name");
|
@ -21,11 +21,11 @@ package org.elasticsearch.client.indices;
|
||||
|
||||
import org.elasticsearch.client.TimedRequest;
|
||||
|
||||
public class DeleteIndexTemplateV2Request extends TimedRequest {
|
||||
public class DeleteComposableIndexTemplateRequest extends TimedRequest {
|
||||
|
||||
private final String name;
|
||||
|
||||
public DeleteIndexTemplateV2Request(String name) {
|
||||
public DeleteComposableIndexTemplateRequest(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ import org.elasticsearch.common.unit.TimeValue;
|
||||
/**
|
||||
* A request to read the content of index templates
|
||||
*/
|
||||
public class GetIndexTemplateV2Request implements Validatable {
|
||||
public class GetComposableIndexTemplateRequest implements Validatable {
|
||||
|
||||
private final String name;
|
||||
|
||||
@ -40,7 +40,7 @@ public class GetIndexTemplateV2Request implements Validatable {
|
||||
*
|
||||
* @param name the name of template to read
|
||||
*/
|
||||
public GetIndexTemplateV2Request(String name) {
|
||||
public GetComposableIndexTemplateRequest(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
@ -18,7 +18,7 @@
|
||||
*/
|
||||
package org.elasticsearch.client.indices;
|
||||
|
||||
import org.elasticsearch.cluster.metadata.IndexTemplateV2;
|
||||
import org.elasticsearch.cluster.metadata.ComposableIndexTemplate;
|
||||
import org.elasticsearch.common.ParseField;
|
||||
import org.elasticsearch.common.xcontent.ConstructingObjectParser;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
@ -32,33 +32,33 @@ import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
public class GetIndexTemplatesV2Response {
|
||||
public class GetComposableIndexTemplatesResponse {
|
||||
|
||||
public static final ParseField NAME = new ParseField("name");
|
||||
public static final ParseField INDEX_TEMPLATES = new ParseField("index_templates");
|
||||
public static final ParseField INDEX_TEMPLATE = new ParseField("index_template");
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static final ConstructingObjectParser<Map<String, IndexTemplateV2>, Void> PARSER =
|
||||
private static final ConstructingObjectParser<Map<String, ComposableIndexTemplate>, Void> PARSER =
|
||||
new ConstructingObjectParser<>("index_templates", false,
|
||||
a -> ((List<NamedIndexTemplate>) a[0]).stream().collect(Collectors.toMap(n -> n.name, n -> n.indexTemplate,
|
||||
(n1, n2) -> n1, LinkedHashMap::new)));
|
||||
|
||||
private static final ConstructingObjectParser<NamedIndexTemplate, Void> INNER_PARSER =
|
||||
new ConstructingObjectParser<>("named_index_template", false,
|
||||
a -> new NamedIndexTemplate((String) a[0], (IndexTemplateV2) a[1]));
|
||||
a -> new NamedIndexTemplate((String) a[0], (ComposableIndexTemplate) a[1]));
|
||||
|
||||
static {
|
||||
INNER_PARSER.declareString(ConstructingObjectParser.constructorArg(), NAME);
|
||||
INNER_PARSER.declareObject(ConstructingObjectParser.constructorArg(), IndexTemplateV2.PARSER, INDEX_TEMPLATE);
|
||||
INNER_PARSER.declareObject(ConstructingObjectParser.constructorArg(), ComposableIndexTemplate.PARSER, INDEX_TEMPLATE);
|
||||
PARSER.declareObjectArray(ConstructingObjectParser.constructorArg(), INNER_PARSER, INDEX_TEMPLATES);
|
||||
}
|
||||
|
||||
private static class NamedIndexTemplate {
|
||||
String name;
|
||||
IndexTemplateV2 indexTemplate;
|
||||
ComposableIndexTemplate indexTemplate;
|
||||
|
||||
private NamedIndexTemplate(String name, IndexTemplateV2 indexTemplate) {
|
||||
private NamedIndexTemplate(String name, ComposableIndexTemplate indexTemplate) {
|
||||
this.name = name;
|
||||
this.indexTemplate = indexTemplate;
|
||||
}
|
||||
@ -69,19 +69,19 @@ public class GetIndexTemplatesV2Response {
|
||||
return "GetIndexTemplatesResponse [indexTemplates=" + indexTemplates + "]";
|
||||
}
|
||||
|
||||
private final Map<String, IndexTemplateV2> indexTemplates;
|
||||
private final Map<String, ComposableIndexTemplate> indexTemplates;
|
||||
|
||||
GetIndexTemplatesV2Response(Map<String, IndexTemplateV2> indexTemplates) {
|
||||
GetComposableIndexTemplatesResponse(Map<String, ComposableIndexTemplate> indexTemplates) {
|
||||
this.indexTemplates = Collections.unmodifiableMap(new LinkedHashMap<>(indexTemplates));
|
||||
}
|
||||
|
||||
public Map<String, IndexTemplateV2> getIndexTemplates() {
|
||||
public Map<String, ComposableIndexTemplate> getIndexTemplates() {
|
||||
return indexTemplates;
|
||||
}
|
||||
|
||||
|
||||
public static GetIndexTemplatesV2Response fromXContent(XContentParser parser) throws IOException {
|
||||
return new GetIndexTemplatesV2Response(PARSER.apply(parser, null));
|
||||
public static GetComposableIndexTemplatesResponse fromXContent(XContentParser parser) throws IOException {
|
||||
return new GetComposableIndexTemplatesResponse(PARSER.apply(parser, null));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -100,7 +100,7 @@ public class GetIndexTemplatesV2Response {
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
GetIndexTemplatesV2Response other = (GetIndexTemplatesV2Response) obj;
|
||||
GetComposableIndexTemplatesResponse other = (GetComposableIndexTemplatesResponse) obj;
|
||||
return Objects.equals(indexTemplates, other.indexTemplates);
|
||||
}
|
||||
|
@ -19,7 +19,7 @@
|
||||
package org.elasticsearch.client.indices;
|
||||
|
||||
import org.elasticsearch.client.TimedRequest;
|
||||
import org.elasticsearch.cluster.metadata.IndexTemplateV2;
|
||||
import org.elasticsearch.cluster.metadata.ComposableIndexTemplate;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
@ -29,7 +29,7 @@ import java.io.IOException;
|
||||
/**
|
||||
* A request to create an index template.
|
||||
*/
|
||||
public class PutIndexTemplateV2Request extends TimedRequest implements ToXContentObject {
|
||||
public class PutComposableIndexTemplateRequest extends TimedRequest implements ToXContentObject {
|
||||
|
||||
private String name;
|
||||
|
||||
@ -37,12 +37,12 @@ public class PutIndexTemplateV2Request extends TimedRequest implements ToXConten
|
||||
|
||||
private boolean create;
|
||||
|
||||
private IndexTemplateV2 indexTemplate;
|
||||
private ComposableIndexTemplate indexTemplate;
|
||||
|
||||
/**
|
||||
* Sets the name of the index template.
|
||||
*/
|
||||
public PutIndexTemplateV2Request name(String name) {
|
||||
public PutComposableIndexTemplateRequest name(String name) {
|
||||
if (Strings.isNullOrEmpty(name)) {
|
||||
throw new IllegalArgumentException("name cannot be null or empty");
|
||||
}
|
||||
@ -61,7 +61,7 @@ public class PutIndexTemplateV2Request extends TimedRequest implements ToXConten
|
||||
* Set to {@code true} to force only creation, not an update of an index template. If it already
|
||||
* exists, it will fail with an {@link IllegalArgumentException}.
|
||||
*/
|
||||
public PutIndexTemplateV2Request create(boolean create) {
|
||||
public PutComposableIndexTemplateRequest create(boolean create) {
|
||||
this.create = create;
|
||||
return this;
|
||||
}
|
||||
@ -73,7 +73,7 @@ public class PutIndexTemplateV2Request extends TimedRequest implements ToXConten
|
||||
/**
|
||||
* The index template to create.
|
||||
*/
|
||||
public PutIndexTemplateV2Request indexTemplate(IndexTemplateV2 indexTemplate) {
|
||||
public PutComposableIndexTemplateRequest indexTemplate(ComposableIndexTemplate indexTemplate) {
|
||||
this.indexTemplate = indexTemplate;
|
||||
return this;
|
||||
}
|
||||
@ -81,7 +81,7 @@ public class PutIndexTemplateV2Request extends TimedRequest implements ToXConten
|
||||
/**
|
||||
* The cause for this index template creation.
|
||||
*/
|
||||
public PutIndexTemplateV2Request cause(String cause) {
|
||||
public PutComposableIndexTemplateRequest cause(String cause) {
|
||||
this.cause = cause;
|
||||
return this;
|
||||
}
|
@ -31,7 +31,7 @@ public class SimulateIndexTemplateRequest extends TimedRequest {
|
||||
private String indexName;
|
||||
|
||||
@Nullable
|
||||
private PutIndexTemplateV2Request indexTemplateV2Request;
|
||||
private PutComposableIndexTemplateRequest indexTemplateV2Request;
|
||||
|
||||
public SimulateIndexTemplateRequest(String indexName) {
|
||||
if (Strings.isNullOrEmpty(indexName)) {
|
||||
@ -62,7 +62,7 @@ public class SimulateIndexTemplateRequest extends TimedRequest {
|
||||
* An optional new template request will be part of the index template simulation.
|
||||
*/
|
||||
@Nullable
|
||||
public PutIndexTemplateV2Request indexTemplateV2Request() {
|
||||
public PutComposableIndexTemplateRequest indexTemplateV2Request() {
|
||||
return indexTemplateV2Request;
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ public class SimulateIndexTemplateRequest extends TimedRequest {
|
||||
* Optionally, define a new template request which will included in the index simulation as if it was an index template stored in the
|
||||
* system. The new template will be validated just as a regular, standalone, live, new index template request.
|
||||
*/
|
||||
public SimulateIndexTemplateRequest indexTemplateV2Request(@Nullable PutIndexTemplateV2Request indexTemplateV2Request) {
|
||||
public SimulateIndexTemplateRequest indexTemplateV2Request(@Nullable PutComposableIndexTemplateRequest indexTemplateV2Request) {
|
||||
this.indexTemplateV2Request = indexTemplateV2Request;
|
||||
return this;
|
||||
}
|
||||
|
@ -62,23 +62,23 @@ import org.elasticsearch.client.indices.CloseIndexResponse;
|
||||
import org.elasticsearch.client.indices.CreateIndexRequest;
|
||||
import org.elasticsearch.client.indices.CreateIndexResponse;
|
||||
import org.elasticsearch.client.indices.DeleteAliasRequest;
|
||||
import org.elasticsearch.client.indices.DeleteIndexTemplateV2Request;
|
||||
import org.elasticsearch.client.indices.DeleteComposableIndexTemplateRequest;
|
||||
import org.elasticsearch.client.indices.FreezeIndexRequest;
|
||||
import org.elasticsearch.client.indices.GetFieldMappingsRequest;
|
||||
import org.elasticsearch.client.indices.GetFieldMappingsResponse;
|
||||
import org.elasticsearch.client.indices.GetIndexRequest;
|
||||
import org.elasticsearch.client.indices.GetIndexResponse;
|
||||
import org.elasticsearch.client.indices.GetIndexTemplateV2Request;
|
||||
import org.elasticsearch.client.indices.GetComposableIndexTemplateRequest;
|
||||
import org.elasticsearch.client.indices.GetIndexTemplatesRequest;
|
||||
import org.elasticsearch.client.indices.GetIndexTemplatesResponse;
|
||||
import org.elasticsearch.client.indices.GetIndexTemplatesV2Response;
|
||||
import org.elasticsearch.client.indices.GetComposableIndexTemplatesResponse;
|
||||
import org.elasticsearch.client.indices.GetMappingsRequest;
|
||||
import org.elasticsearch.client.indices.GetMappingsResponse;
|
||||
import org.elasticsearch.client.indices.IndexTemplateMetadata;
|
||||
import org.elasticsearch.client.indices.IndexTemplateV2ExistRequest;
|
||||
import org.elasticsearch.client.indices.ComposableIndexTemplateExistRequest;
|
||||
import org.elasticsearch.client.indices.IndexTemplatesExistRequest;
|
||||
import org.elasticsearch.client.indices.PutIndexTemplateRequest;
|
||||
import org.elasticsearch.client.indices.PutIndexTemplateV2Request;
|
||||
import org.elasticsearch.client.indices.PutComposableIndexTemplateRequest;
|
||||
import org.elasticsearch.client.indices.PutMappingRequest;
|
||||
import org.elasticsearch.client.indices.ReloadAnalyzersRequest;
|
||||
import org.elasticsearch.client.indices.ReloadAnalyzersResponse;
|
||||
@ -89,7 +89,7 @@ import org.elasticsearch.client.indices.rollover.RolloverRequest;
|
||||
import org.elasticsearch.client.indices.rollover.RolloverResponse;
|
||||
import org.elasticsearch.cluster.metadata.AliasMetadata;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetadata;
|
||||
import org.elasticsearch.cluster.metadata.IndexTemplateV2;
|
||||
import org.elasticsearch.cluster.metadata.ComposableIndexTemplate;
|
||||
import org.elasticsearch.cluster.metadata.MappingMetadata;
|
||||
import org.elasticsearch.cluster.metadata.Template;
|
||||
import org.elasticsearch.common.Strings;
|
||||
@ -2039,41 +2039,41 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
|
||||
AliasMetadata alias = AliasMetadata.builder("alias").writeIndex(true).build();
|
||||
Template template = new Template(settings, mappings, Collections.singletonMap("alias", alias));
|
||||
List<String> pattern = Collections.singletonList("pattern");
|
||||
IndexTemplateV2 indexTemplate =
|
||||
new IndexTemplateV2(pattern, template, Collections.emptyList(), 1L, 1L, new HashMap<>(), null);
|
||||
PutIndexTemplateV2Request putIndexTemplateV2Request =
|
||||
new PutIndexTemplateV2Request().name(templateName).create(true).indexTemplate(indexTemplate);
|
||||
ComposableIndexTemplate indexTemplate =
|
||||
new ComposableIndexTemplate(pattern, template, Collections.emptyList(), 1L, 1L, new HashMap<>(), null);
|
||||
PutComposableIndexTemplateRequest putComposableIndexTemplateRequest =
|
||||
new PutComposableIndexTemplateRequest().name(templateName).create(true).indexTemplate(indexTemplate);
|
||||
|
||||
AcknowledgedResponse response = execute(putIndexTemplateV2Request,
|
||||
AcknowledgedResponse response = execute(putComposableIndexTemplateRequest,
|
||||
highLevelClient().indices()::putIndexTemplate, highLevelClient().indices()::putIndexTemplateAsync);
|
||||
assertThat(response.isAcknowledged(), equalTo(true));
|
||||
|
||||
IndexTemplateV2ExistRequest indexTemplateV2ExistRequest = new IndexTemplateV2ExistRequest(templateName);
|
||||
boolean exist = execute(indexTemplateV2ExistRequest,
|
||||
ComposableIndexTemplateExistRequest composableIndexTemplateExistRequest = new ComposableIndexTemplateExistRequest(templateName);
|
||||
boolean exist = execute(composableIndexTemplateExistRequest,
|
||||
highLevelClient().indices()::existsIndexTemplate, highLevelClient().indices()::existsIndexTemplateAsync);
|
||||
|
||||
assertTrue(exist);
|
||||
|
||||
GetIndexTemplateV2Request getIndexTemplateV2Request = new GetIndexTemplateV2Request(templateName);
|
||||
GetIndexTemplatesV2Response getResponse = execute(getIndexTemplateV2Request,
|
||||
GetComposableIndexTemplateRequest getComposableIndexTemplateRequest = new GetComposableIndexTemplateRequest(templateName);
|
||||
GetComposableIndexTemplatesResponse getResponse = execute(getComposableIndexTemplateRequest,
|
||||
highLevelClient().indices()::getIndexTemplate, highLevelClient().indices()::getIndexTemplateAsync);
|
||||
|
||||
assertThat(getResponse.getIndexTemplates().size(), equalTo(1));
|
||||
assertThat(getResponse.getIndexTemplates().containsKey(templateName), equalTo(true));
|
||||
assertThat(getResponse.getIndexTemplates().get(templateName), equalTo(indexTemplate));
|
||||
|
||||
DeleteIndexTemplateV2Request deleteIndexTemplateV2Request = new DeleteIndexTemplateV2Request(templateName);
|
||||
response = execute(deleteIndexTemplateV2Request, highLevelClient().indices()::deleteIndexTemplate,
|
||||
DeleteComposableIndexTemplateRequest deleteComposableIndexTemplateRequest = new DeleteComposableIndexTemplateRequest(templateName);
|
||||
response = execute(deleteComposableIndexTemplateRequest, highLevelClient().indices()::deleteIndexTemplate,
|
||||
highLevelClient().indices()::deleteIndexTemplateAsync);
|
||||
assertThat(response.isAcknowledged(), equalTo(true));
|
||||
|
||||
ElasticsearchStatusException statusException = expectThrows(ElasticsearchStatusException.class,
|
||||
() -> execute(getIndexTemplateV2Request,
|
||||
() -> execute(getComposableIndexTemplateRequest,
|
||||
highLevelClient().indices()::getIndexTemplate, highLevelClient().indices()::getIndexTemplateAsync));
|
||||
|
||||
assertThat(statusException.status(), equalTo(RestStatus.NOT_FOUND));
|
||||
|
||||
exist = execute(indexTemplateV2ExistRequest,
|
||||
exist = execute(composableIndexTemplateExistRequest,
|
||||
highLevelClient().indices()::existsIndexTemplate, highLevelClient().indices()::existsIndexTemplateAsync);
|
||||
|
||||
assertFalse(exist);
|
||||
@ -2086,22 +2086,22 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
|
||||
AliasMetadata alias = AliasMetadata.builder("alias").writeIndex(true).build();
|
||||
Template template = new Template(settings, mappings, org.elasticsearch.common.collect.Map.of("alias", alias));
|
||||
List<String> pattern = org.elasticsearch.common.collect.List.of("pattern");
|
||||
IndexTemplateV2 indexTemplate =
|
||||
new IndexTemplateV2(pattern, template, Collections.emptyList(), 1L, 1L, new HashMap<>(), null);
|
||||
PutIndexTemplateV2Request putIndexTemplateV2Request =
|
||||
new PutIndexTemplateV2Request().name(templateName).create(true).indexTemplate(indexTemplate);
|
||||
ComposableIndexTemplate indexTemplate =
|
||||
new ComposableIndexTemplate(pattern, template, Collections.emptyList(), 1L, 1L, new HashMap<>(), null);
|
||||
PutComposableIndexTemplateRequest putComposableIndexTemplateRequest =
|
||||
new PutComposableIndexTemplateRequest().name(templateName).create(true).indexTemplate(indexTemplate);
|
||||
|
||||
AcknowledgedResponse response = execute(putIndexTemplateV2Request,
|
||||
AcknowledgedResponse response = execute(putComposableIndexTemplateRequest,
|
||||
highLevelClient().indices()::putIndexTemplate, highLevelClient().indices()::putIndexTemplateAsync);
|
||||
assertThat(response.isAcknowledged(), equalTo(true));
|
||||
|
||||
SimulateIndexTemplateRequest simulateIndexTemplateRequest = new SimulateIndexTemplateRequest("pattern");
|
||||
AliasMetadata simulationAlias = AliasMetadata.builder("simulation-alias").writeIndex(true).build();
|
||||
IndexTemplateV2 simulationTemplate = new IndexTemplateV2(pattern, new Template(null, null,
|
||||
ComposableIndexTemplate simulationTemplate = new ComposableIndexTemplate(pattern, new Template(null, null,
|
||||
org.elasticsearch.common.collect.Map.of("simulation-alias", simulationAlias)), Collections.emptyList(), 2L, 1L,
|
||||
new HashMap<>(), null);
|
||||
PutIndexTemplateV2Request newIndexTemplateReq =
|
||||
new PutIndexTemplateV2Request().name("used-for-simulation").create(true).indexTemplate(indexTemplate);
|
||||
PutComposableIndexTemplateRequest newIndexTemplateReq =
|
||||
new PutComposableIndexTemplateRequest().name("used-for-simulation").create(true).indexTemplate(indexTemplate);
|
||||
newIndexTemplateReq.indexTemplate(simulationTemplate);
|
||||
simulateIndexTemplateRequest.indexTemplateV2Request(newIndexTemplateReq);
|
||||
|
||||
|
@ -66,24 +66,24 @@ import org.elasticsearch.client.indices.CloseIndexResponse;
|
||||
import org.elasticsearch.client.indices.CreateIndexRequest;
|
||||
import org.elasticsearch.client.indices.CreateIndexResponse;
|
||||
import org.elasticsearch.client.indices.DeleteAliasRequest;
|
||||
import org.elasticsearch.client.indices.DeleteIndexTemplateV2Request;
|
||||
import org.elasticsearch.client.indices.DeleteComposableIndexTemplateRequest;
|
||||
import org.elasticsearch.client.indices.DetailAnalyzeResponse;
|
||||
import org.elasticsearch.client.indices.FreezeIndexRequest;
|
||||
import org.elasticsearch.client.indices.GetFieldMappingsRequest;
|
||||
import org.elasticsearch.client.indices.GetFieldMappingsResponse;
|
||||
import org.elasticsearch.client.indices.GetIndexRequest;
|
||||
import org.elasticsearch.client.indices.GetIndexResponse;
|
||||
import org.elasticsearch.client.indices.GetIndexTemplateV2Request;
|
||||
import org.elasticsearch.client.indices.GetComposableIndexTemplateRequest;
|
||||
import org.elasticsearch.client.indices.GetIndexTemplatesRequest;
|
||||
import org.elasticsearch.client.indices.GetIndexTemplatesResponse;
|
||||
import org.elasticsearch.client.indices.GetIndexTemplatesV2Response;
|
||||
import org.elasticsearch.client.indices.GetComposableIndexTemplatesResponse;
|
||||
import org.elasticsearch.client.indices.GetMappingsRequest;
|
||||
import org.elasticsearch.client.indices.GetMappingsResponse;
|
||||
import org.elasticsearch.client.indices.IndexTemplateMetadata;
|
||||
import org.elasticsearch.client.indices.IndexTemplatesExistRequest;
|
||||
import org.elasticsearch.client.indices.PutComponentTemplateRequest;
|
||||
import org.elasticsearch.client.indices.PutIndexTemplateRequest;
|
||||
import org.elasticsearch.client.indices.PutIndexTemplateV2Request;
|
||||
import org.elasticsearch.client.indices.PutComposableIndexTemplateRequest;
|
||||
import org.elasticsearch.client.indices.PutMappingRequest;
|
||||
import org.elasticsearch.client.indices.ReloadAnalyzersRequest;
|
||||
import org.elasticsearch.client.indices.ReloadAnalyzersResponse;
|
||||
@ -95,7 +95,7 @@ import org.elasticsearch.client.indices.rollover.RolloverRequest;
|
||||
import org.elasticsearch.client.indices.rollover.RolloverResponse;
|
||||
import org.elasticsearch.cluster.metadata.AliasMetadata;
|
||||
import org.elasticsearch.cluster.metadata.ComponentTemplate;
|
||||
import org.elasticsearch.cluster.metadata.IndexTemplateV2;
|
||||
import org.elasticsearch.cluster.metadata.ComposableIndexTemplate;
|
||||
import org.elasticsearch.cluster.metadata.MappingMetadata;
|
||||
import org.elasticsearch.cluster.metadata.Template;
|
||||
import org.elasticsearch.common.compress.CompressedXContent;
|
||||
@ -2371,15 +2371,17 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
|
||||
Template template = new Template(Settings.builder().put("index.number_of_shards", 3).put("index.number_of_replicas", 1).build(),
|
||||
new CompressedXContent("{ \"properties\": { \"message\": { \"type\": \"text\" } } }"),
|
||||
null);
|
||||
PutIndexTemplateV2Request putRequest = new PutIndexTemplateV2Request()
|
||||
PutComposableIndexTemplateRequest putRequest = new PutComposableIndexTemplateRequest()
|
||||
.name("my-template")
|
||||
.indexTemplate(new IndexTemplateV2(Arrays.asList("pattern-1", "log-*"), template, null, null, null, null));
|
||||
.indexTemplate(
|
||||
new ComposableIndexTemplate(Arrays.asList("pattern-1", "log-*"), template, null, null, null, null)
|
||||
);
|
||||
assertTrue(client.indices().putIndexTemplate(putRequest, RequestOptions.DEFAULT).isAcknowledged());
|
||||
}
|
||||
|
||||
// tag::get-index-templates-v2-request
|
||||
GetIndexTemplateV2Request request = new GetIndexTemplateV2Request("my-template"); // <1>
|
||||
request = new GetIndexTemplateV2Request("my-*"); // <2>
|
||||
GetComposableIndexTemplateRequest request = new GetComposableIndexTemplateRequest("my-template"); // <1>
|
||||
request = new GetComposableIndexTemplateRequest("my-*"); // <2>
|
||||
// end::get-index-templates-v2-request
|
||||
|
||||
// tag::get-index-templates-v2-request-masterTimeout
|
||||
@ -2388,21 +2390,21 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
|
||||
// end::get-index-templates-v2-request-masterTimeout
|
||||
|
||||
// tag::get-index-templates-v2-execute
|
||||
GetIndexTemplatesV2Response getTemplatesResponse = client.indices().getIndexTemplate(request, RequestOptions.DEFAULT);
|
||||
GetComposableIndexTemplatesResponse getTemplatesResponse = client.indices().getIndexTemplate(request, RequestOptions.DEFAULT);
|
||||
// end::get-index-templates-v2-execute
|
||||
|
||||
// tag::get-index-templates-v2-response
|
||||
Map<String, IndexTemplateV2> templates = getTemplatesResponse.getIndexTemplates(); // <1>
|
||||
Map<String, ComposableIndexTemplate> templates = getTemplatesResponse.getIndexTemplates(); // <1>
|
||||
// end::get-index-templates-v2-response
|
||||
|
||||
assertThat(templates.size(), is(1));
|
||||
assertThat(templates.get("my-template"), is(notNullValue()));
|
||||
|
||||
// tag::get-index-templates-v2-execute-listener
|
||||
ActionListener<GetIndexTemplatesV2Response> listener =
|
||||
new ActionListener<GetIndexTemplatesV2Response>() {
|
||||
ActionListener<GetComposableIndexTemplatesResponse> listener =
|
||||
new ActionListener<GetComposableIndexTemplatesResponse>() {
|
||||
@Override
|
||||
public void onResponse(GetIndexTemplatesV2Response response) {
|
||||
public void onResponse(GetComposableIndexTemplatesResponse response) {
|
||||
// <1>
|
||||
}
|
||||
|
||||
@ -2429,28 +2431,27 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
|
||||
|
||||
{
|
||||
// tag::put-index-template-v2-request
|
||||
PutIndexTemplateV2Request request = new PutIndexTemplateV2Request()
|
||||
PutComposableIndexTemplateRequest request = new PutComposableIndexTemplateRequest()
|
||||
.name("my-template"); // <1>
|
||||
IndexTemplateV2 indexTemplateV2 =
|
||||
new IndexTemplateV2(Arrays.asList("pattern-1", "log-*"), null, null, null, null, null); // <2>
|
||||
request.indexTemplate(indexTemplateV2);
|
||||
|
||||
ComposableIndexTemplate composableIndexTemplate =
|
||||
new ComposableIndexTemplate(Arrays.asList("pattern-1", "log-*"), null, null, null, null, null); // <2>
|
||||
request.indexTemplate(composableIndexTemplate);
|
||||
assertTrue(client.indices().putIndexTemplate(request, RequestOptions.DEFAULT).isAcknowledged());
|
||||
// end::put-index-template-v2-request
|
||||
}
|
||||
|
||||
{
|
||||
// tag::put-index-template-v2-request-settings
|
||||
PutIndexTemplateV2Request request = new PutIndexTemplateV2Request()
|
||||
PutComposableIndexTemplateRequest request = new PutComposableIndexTemplateRequest()
|
||||
.name("my-template");
|
||||
Settings settings = Settings.builder() // <1>
|
||||
.put("index.number_of_shards", 3)
|
||||
.put("index.number_of_replicas", 1)
|
||||
.build();
|
||||
Template template = new Template(settings, null, null); // <2>
|
||||
IndexTemplateV2 indexTemplateV2 =
|
||||
new IndexTemplateV2(Arrays.asList("pattern-1", "log-*"), template, null, null, null, null); // <3>
|
||||
request.indexTemplate(indexTemplateV2);
|
||||
ComposableIndexTemplate composableIndexTemplate = new ComposableIndexTemplate(Arrays.asList("pattern-1", "log-*"),
|
||||
template, null, null, null, null); // <3>
|
||||
request.indexTemplate(composableIndexTemplate);
|
||||
|
||||
assertTrue(client.indices().putIndexTemplate(request, RequestOptions.DEFAULT).isAcknowledged());
|
||||
// end::put-index-template-v2-request-settings
|
||||
@ -2465,12 +2466,12 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
"}"; // <1>
|
||||
PutIndexTemplateV2Request request = new PutIndexTemplateV2Request()
|
||||
PutComposableIndexTemplateRequest request = new PutComposableIndexTemplateRequest()
|
||||
.name("my-template");
|
||||
Template template = new Template(null, new CompressedXContent(mappingJson), null); // <2>
|
||||
IndexTemplateV2 indexTemplateV2 =
|
||||
new IndexTemplateV2(Arrays.asList("pattern-1", "log-*"), template, null, null, null, null); // <3>
|
||||
request.indexTemplate(indexTemplateV2);
|
||||
ComposableIndexTemplate composableIndexTemplate = new ComposableIndexTemplate(Arrays.asList("pattern-1", "log-*"),
|
||||
template, null, null, null, null); // <3>
|
||||
request.indexTemplate(composableIndexTemplate);
|
||||
|
||||
assertTrue(client.indices().putIndexTemplate(request, RequestOptions.DEFAULT).isAcknowledged());
|
||||
// end::put-index-template-v2-request-mappings-json
|
||||
@ -2478,7 +2479,7 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
|
||||
|
||||
{
|
||||
// tag::put-index-template-v2-request-aliases
|
||||
PutIndexTemplateV2Request request = new PutIndexTemplateV2Request()
|
||||
PutComposableIndexTemplateRequest request = new PutComposableIndexTemplateRequest()
|
||||
.name("my-template");
|
||||
AliasMetadata twitterAlias = AliasMetadata.builder("twitter_alias").build(); // <1>
|
||||
AliasMetadata placeholderAlias = AliasMetadata.builder("{index}_alias").searchRouting("xyz").build(); // <2>
|
||||
@ -2486,9 +2487,9 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
|
||||
aliases.put("twitter_alias", twitterAlias);
|
||||
aliases.put("{index}_alias", placeholderAlias);
|
||||
Template template = new Template(null, null, aliases); // <3>
|
||||
IndexTemplateV2 indexTemplateV2 =
|
||||
new IndexTemplateV2(Arrays.asList("pattern-1", "log-*"), template, null, null, null, null);
|
||||
request.indexTemplate(indexTemplateV2);
|
||||
ComposableIndexTemplate composableIndexTemplate = new ComposableIndexTemplate(Arrays.asList("pattern-1", "log-*"),
|
||||
template, null, null, null, null); // <4>
|
||||
request.indexTemplate(composableIndexTemplate);
|
||||
|
||||
assertTrue(client.indices().putIndexTemplate(request, RequestOptions.DEFAULT).isAcknowledged());
|
||||
// end::put-index-template-v2-request-aliases
|
||||
@ -2501,11 +2502,12 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
|
||||
RequestOptions.DEFAULT);
|
||||
|
||||
// tag::put-index-template-v2-request-component-template
|
||||
PutIndexTemplateV2Request request = new PutIndexTemplateV2Request()
|
||||
PutComposableIndexTemplateRequest request = new PutComposableIndexTemplateRequest()
|
||||
.name("my-template");
|
||||
IndexTemplateV2 indexTemplateV2 =
|
||||
new IndexTemplateV2(Arrays.asList("pattern-1", "log-*"), null, Arrays.asList("ct1"), null, null, null); // <1>
|
||||
request.indexTemplate(indexTemplateV2);
|
||||
ComposableIndexTemplate composableIndexTemplate =
|
||||
new ComposableIndexTemplate(Arrays.asList("pattern-1", "log-*"), null,
|
||||
Collections.singletonList("ct1"), null, null, null); // <1>
|
||||
request.indexTemplate(composableIndexTemplate);
|
||||
|
||||
assertTrue(client.indices().putIndexTemplate(request, RequestOptions.DEFAULT).isAcknowledged());
|
||||
// end::put-index-template-v2-request-component-template
|
||||
@ -2513,11 +2515,11 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
|
||||
|
||||
{
|
||||
// tag::put-index-template-v2-request-priority
|
||||
PutIndexTemplateV2Request request = new PutIndexTemplateV2Request()
|
||||
PutComposableIndexTemplateRequest request = new PutComposableIndexTemplateRequest()
|
||||
.name("my-template");
|
||||
IndexTemplateV2 indexTemplateV2 =
|
||||
new IndexTemplateV2(Arrays.asList("pattern-1", "log-*"), null, null, 20L, null, null); // <1>
|
||||
request.indexTemplate(indexTemplateV2);
|
||||
ComposableIndexTemplate composableIndexTemplate = new ComposableIndexTemplate(Arrays.asList("pattern-1", "log-*"),
|
||||
null, null, 20L, null, null); // <1>
|
||||
request.indexTemplate(composableIndexTemplate);
|
||||
|
||||
assertTrue(client.indices().putIndexTemplate(request, RequestOptions.DEFAULT).isAcknowledged());
|
||||
// end::put-index-template-v2-request-priority
|
||||
@ -2525,11 +2527,11 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
|
||||
|
||||
{
|
||||
// tag::put-index-template-v2-request-version
|
||||
PutIndexTemplateV2Request request = new PutIndexTemplateV2Request()
|
||||
PutComposableIndexTemplateRequest request = new PutComposableIndexTemplateRequest()
|
||||
.name("my-template");
|
||||
IndexTemplateV2 indexTemplateV2 =
|
||||
new IndexTemplateV2(Arrays.asList("pattern-1", "log-*"), null, null, null, 3L, null); // <1>
|
||||
request.indexTemplate(indexTemplateV2);
|
||||
ComposableIndexTemplate composableIndexTemplate = new ComposableIndexTemplate(Arrays.asList("pattern-1", "log-*"),
|
||||
null, null, null, 3L, null); // <1>
|
||||
request.indexTemplate(composableIndexTemplate);
|
||||
|
||||
assertTrue(client.indices().putIndexTemplate(request, RequestOptions.DEFAULT).isAcknowledged());
|
||||
// end::put-index-template-v2-request-version
|
||||
@ -2582,16 +2584,16 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
|
||||
public void testDeleteIndexTemplateV2() throws Exception {
|
||||
RestHighLevelClient client = highLevelClient();
|
||||
{
|
||||
PutIndexTemplateV2Request request = new PutIndexTemplateV2Request()
|
||||
PutComposableIndexTemplateRequest request = new PutComposableIndexTemplateRequest()
|
||||
.name("my-template");
|
||||
IndexTemplateV2 indexTemplateV2 =
|
||||
new IndexTemplateV2(Arrays.asList("pattern-1", "log-*"), null, null, null, null, null); // <2>
|
||||
request.indexTemplate(indexTemplateV2);
|
||||
ComposableIndexTemplate composableIndexTemplate = new ComposableIndexTemplate(Arrays.asList("pattern-1", "log-*"),
|
||||
null, null, null, null, null); // <2>
|
||||
request.indexTemplate(composableIndexTemplate);
|
||||
assertTrue(client.indices().putIndexTemplate(request, RequestOptions.DEFAULT).isAcknowledged());
|
||||
}
|
||||
|
||||
// tag::delete-index-template-v2-request
|
||||
DeleteIndexTemplateV2Request deleteRequest = new DeleteIndexTemplateV2Request("my-template"); // <1>
|
||||
DeleteComposableIndexTemplateRequest deleteRequest = new DeleteComposableIndexTemplateRequest("my-template"); // <1>
|
||||
// end::delete-index-template-v2-request
|
||||
|
||||
// tag::delete-index-template-v2-request-masterTimeout
|
||||
@ -2608,11 +2610,11 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
|
||||
assertThat(acknowledged, equalTo(true));
|
||||
|
||||
{
|
||||
PutIndexTemplateV2Request request = new PutIndexTemplateV2Request()
|
||||
PutComposableIndexTemplateRequest request = new PutComposableIndexTemplateRequest()
|
||||
.name("my-template");
|
||||
IndexTemplateV2 indexTemplateV2 =
|
||||
new IndexTemplateV2(Arrays.asList("pattern-1", "log-*"), null, null, null, null, null); // <2>
|
||||
request.indexTemplate(indexTemplateV2);
|
||||
ComposableIndexTemplate composableIndexTemplate = new ComposableIndexTemplate(Arrays.asList("pattern-1", "log-*"),
|
||||
null, null, null, null, null); // <2>
|
||||
request.indexTemplate(composableIndexTemplate);
|
||||
assertTrue(client.indices().putIndexTemplate(request, RequestOptions.DEFAULT).isAcknowledged());
|
||||
}
|
||||
|
||||
@ -2645,24 +2647,24 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
|
||||
RestHighLevelClient client = highLevelClient();
|
||||
|
||||
{
|
||||
PutIndexTemplateV2Request request = new PutIndexTemplateV2Request()
|
||||
PutComposableIndexTemplateRequest request = new PutComposableIndexTemplateRequest()
|
||||
.name("my-template"); // <1>
|
||||
Template template = new Template(Settings.builder().put("index.number_of_replicas", 3).build(), null, null);
|
||||
IndexTemplateV2 indexTemplateV2 =
|
||||
new IndexTemplateV2(Arrays.asList("pattern-1", "log-*"), template, null, null, null, null);
|
||||
request.indexTemplate(indexTemplateV2);
|
||||
ComposableIndexTemplate composableIndexTemplate = new ComposableIndexTemplate(Arrays.asList("pattern-1", "log-*"),
|
||||
template, null, null, null, null);
|
||||
request.indexTemplate(composableIndexTemplate);
|
||||
assertTrue(client.indices().putIndexTemplate(request, RequestOptions.DEFAULT).isAcknowledged());
|
||||
}
|
||||
|
||||
// tag::simulate-index-template-request
|
||||
SimulateIndexTemplateRequest simulateRequest = new SimulateIndexTemplateRequest("log-000001"); // <1>
|
||||
PutIndexTemplateV2Request newIndexTemplateRequest = new PutIndexTemplateV2Request()
|
||||
PutComposableIndexTemplateRequest newIndexTemplateRequest = new PutComposableIndexTemplateRequest()
|
||||
.name("used-for-simulation");
|
||||
Settings settings = Settings.builder().put("index.number_of_shards", 6).build();
|
||||
Template template = new Template(settings, null, null); // <2>
|
||||
IndexTemplateV2 indexTemplateV2 =
|
||||
new IndexTemplateV2(Arrays.asList("log-*"), template, null, 90L, null, null);
|
||||
newIndexTemplateRequest.indexTemplate(indexTemplateV2);
|
||||
ComposableIndexTemplate composableIndexTemplate = new ComposableIndexTemplate(Arrays.asList("log-*"),
|
||||
template, null, 90L, null, null);
|
||||
newIndexTemplateRequest.indexTemplate(composableIndexTemplate);
|
||||
|
||||
simulateRequest.indexTemplateV2Request(newIndexTemplateRequest); // <2>
|
||||
// end::simulate-index-template-request
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package org.elasticsearch.client.indices;
|
||||
|
||||
import org.elasticsearch.cluster.metadata.IndexTemplateV2;
|
||||
import org.elasticsearch.cluster.metadata.ComposableIndexTemplate;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
|
||||
@ -33,34 +33,34 @@ import static org.elasticsearch.client.indices.GetComponentTemplatesResponseTest
|
||||
import static org.elasticsearch.client.indices.GetComponentTemplatesResponseTests.randomTemplate;
|
||||
import static org.elasticsearch.test.AbstractXContentTestCase.xContentTester;
|
||||
|
||||
public class GetIndexTemplatesV2ResponseTests extends ESTestCase {
|
||||
public class GetComposableIndexTemplatesResponseTests extends ESTestCase {
|
||||
|
||||
public void testFromXContent() throws Exception {
|
||||
xContentTester(
|
||||
this::createParser,
|
||||
GetIndexTemplatesV2ResponseTests::createTestInstance,
|
||||
GetIndexTemplatesV2ResponseTests::toXContent,
|
||||
GetIndexTemplatesV2Response::fromXContent)
|
||||
GetComposableIndexTemplatesResponseTests::createTestInstance,
|
||||
GetComposableIndexTemplatesResponseTests::toXContent,
|
||||
GetComposableIndexTemplatesResponse::fromXContent)
|
||||
.supportsUnknownFields(true)
|
||||
.randomFieldsExcludeFilter(a -> true)
|
||||
.test();
|
||||
}
|
||||
|
||||
private static GetIndexTemplatesV2Response createTestInstance() {
|
||||
Map<String, IndexTemplateV2> templates = new HashMap<>();
|
||||
private static GetComposableIndexTemplatesResponse createTestInstance() {
|
||||
Map<String, ComposableIndexTemplate> templates = new HashMap<>();
|
||||
if (randomBoolean()) {
|
||||
int count = randomInt(10);
|
||||
for (int i = 0; i < count; i++) {
|
||||
templates.put(randomAlphaOfLength(10), randomIndexTemplate());
|
||||
}
|
||||
}
|
||||
return new GetIndexTemplatesV2Response(templates);
|
||||
return new GetComposableIndexTemplatesResponse(templates);
|
||||
}
|
||||
|
||||
private static void toXContent(GetIndexTemplatesV2Response response, XContentBuilder builder) throws IOException {
|
||||
private static void toXContent(GetComposableIndexTemplatesResponse response, XContentBuilder builder) throws IOException {
|
||||
builder.startObject();
|
||||
builder.startArray("index_templates");
|
||||
for (Map.Entry<String, IndexTemplateV2> e : response.getIndexTemplates().entrySet()) {
|
||||
for (Map.Entry<String, ComposableIndexTemplate> e : response.getIndexTemplates().entrySet()) {
|
||||
builder.startObject();
|
||||
builder.field("name", e.getKey());
|
||||
builder.field("index_template");
|
||||
@ -71,11 +71,11 @@ public class GetIndexTemplatesV2ResponseTests extends ESTestCase {
|
||||
builder.endObject();
|
||||
}
|
||||
|
||||
private static IndexTemplateV2 randomIndexTemplate() {
|
||||
private static ComposableIndexTemplate randomIndexTemplate() {
|
||||
List<String> patterns = Arrays.asList(generateRandomStringArray(10, 10, false, false));
|
||||
List<String> composedOf = null;
|
||||
Map<String, Object> meta = null;
|
||||
IndexTemplateV2.DataStreamTemplate dataStreamTemplate = null;
|
||||
ComposableIndexTemplate.DataStreamTemplate dataStreamTemplate = null;
|
||||
if (randomBoolean()) {
|
||||
composedOf = Arrays.asList(generateRandomStringArray(10, 10, false, false));
|
||||
}
|
||||
@ -86,8 +86,8 @@ public class GetIndexTemplatesV2ResponseTests extends ESTestCase {
|
||||
Long priority = randomBoolean() ? null : randomNonNegativeLong();
|
||||
Long version = randomBoolean() ? null : randomNonNegativeLong();
|
||||
if (randomBoolean()) {
|
||||
dataStreamTemplate = new IndexTemplateV2.DataStreamTemplate(randomAlphaOfLength(8));
|
||||
dataStreamTemplate = new ComposableIndexTemplate.DataStreamTemplate(randomAlphaOfLength(8));
|
||||
}
|
||||
return new IndexTemplateV2(patterns, randomTemplate(), composedOf, priority, version, meta, dataStreamTemplate);
|
||||
return new ComposableIndexTemplate(patterns, randomTemplate(), composedOf, priority, version, meta, dataStreamTemplate);
|
||||
}
|
||||
}
|
@ -5,12 +5,12 @@
|
||||
--
|
||||
|
||||
[id="{upid}-{api}"]
|
||||
=== Delete Index Template V2 API
|
||||
=== Delete Composable Index Template API
|
||||
|
||||
[id="{upid}-{api}-request"]
|
||||
==== Request
|
||||
|
||||
The Delete Index Template V2 API allows you to delete an index template.
|
||||
The Delete Composable Index Template API allows you to delete an index template.
|
||||
|
||||
["source","java",subs="attributes,callouts,macros"]
|
||||
--------------------------------------------------
|
||||
|
@ -5,12 +5,12 @@
|
||||
--
|
||||
|
||||
[id="{upid}-{api}"]
|
||||
=== Get Index Templates V2 API
|
||||
=== Get Composable Index Templates API
|
||||
|
||||
The Get Index Templates API allows to retrieve information about one or more index templates.
|
||||
|
||||
[id="{upid}-{api}-request"]
|
||||
==== Get Index Templates V2 Request
|
||||
==== Get Composable Index Templates Request
|
||||
|
||||
A +{request}+ specifies one, or a wildcard expression of index template names
|
||||
to get. To return all index templates, omit the name altogether or use a value of `*`.
|
||||
|
@ -5,10 +5,10 @@
|
||||
--
|
||||
|
||||
[id="{upid}-{api}"]
|
||||
=== Put Index Template V2 API
|
||||
=== Put Composable Index Template API
|
||||
|
||||
[id="{upid}-{api}-request"]
|
||||
==== Put Index Template V2 Request
|
||||
==== Put Composable Index Template Request
|
||||
|
||||
A +{request}+ specifies the `name` of a template and the index template configuration
|
||||
which consists of the `patterns` that control whether the template should be applied
|
||||
@ -108,7 +108,7 @@ include-tagged::{doc-tests-file}[{api}-request-masterTimeout]
|
||||
include::../execution.asciidoc[]
|
||||
|
||||
[id="{upid}-{api}-response"]
|
||||
==== Put Index Template V2 Response
|
||||
==== Put Composable Index Template Response
|
||||
|
||||
The returned +{response}+ allows to retrieve information about the
|
||||
executed operation as follows:
|
||||
|
@ -28,7 +28,7 @@ include::../execution.asciidoc[]
|
||||
The returned +{response}+ includes a resolved `Template` object containing
|
||||
the resolved settings, mappings and aliases of the index template that matched
|
||||
and would be applied to the index with the provided name (if any). It will
|
||||
also return a `Map` of index templates (both V1 and V2) names and their
|
||||
also return a `Map` of index templates (both legacy and composable) names and their
|
||||
corresponding index patterns:
|
||||
|
||||
["source","java",subs="attributes,callouts,macros"]
|
||||
|
@ -4,14 +4,14 @@
|
||||
<titleabbrev>Index template</titleabbrev>
|
||||
++++
|
||||
|
||||
This documentation is about V2 (version 2) index templates. For V1 templates please see the
|
||||
<<indices-templates-v1,V1 template documentation>>.
|
||||
This documentation is about composable templates. For legacy templates please see the
|
||||
<<indices-templates-v1,legacy template documentation>>.
|
||||
|
||||
[NOTE]
|
||||
====
|
||||
In {es} 7.8 V2 templates were introduced. When a V2 index template matches a given index it always
|
||||
takes precedence over a V1 template. If no V2 index template matches, a V1 template may still match
|
||||
and be applied.
|
||||
In {es} 7.8 composable templates were introduced. When a composable template matches a given index
|
||||
it always takes precedence over a legacy template. If no composable template matches, a legacy
|
||||
template may still match and be applied.
|
||||
====
|
||||
|
||||
An index template is a way to tell {es} how to configure an index when it is created. Templates are
|
||||
|
@ -4,14 +4,14 @@
|
||||
<titleabbrev>Put index template</titleabbrev>
|
||||
++++
|
||||
|
||||
This documentation is about V1 (version 1) index templates, which are deprecated and will be
|
||||
replaced by V2 templates. For information about V2 templates, see <<indices-templates>>.
|
||||
This documentation is about legacy index templates, which are deprecated and will be replaced by
|
||||
composable templates. For information about composable templates, see <<indices-templates>>.
|
||||
|
||||
[NOTE]
|
||||
====
|
||||
In {es} 7.8 V2 templates were introduced. When a V2 index template matches a given index it always
|
||||
takes precedence over a V1 template. If no V2 index template matches, a V1 template may still match
|
||||
and be applied.
|
||||
In {es} 7.8 composable templates were introduced. When a composable template matches a given index
|
||||
it always takes precedence over a legacy template. If no composable template matches, a legacy
|
||||
template may still match and be applied.
|
||||
====
|
||||
|
||||
Creates or updates an index template.
|
||||
|
@ -21,7 +21,7 @@ setup:
|
||||
|
||||
- do:
|
||||
allowed_warnings:
|
||||
- "index [test-0] matches multiple v1 templates [global, index_template], v2 index templates will only match a single index template"
|
||||
- "index [test-0] matches multiple legacy templates [global, index_template], composable templates will only match a single template"
|
||||
bulk:
|
||||
refresh: true
|
||||
body:
|
||||
|
@ -284,7 +284,7 @@
|
||||
$/
|
||||
|
||||
---
|
||||
"Mixture of V1 and V2 templates":
|
||||
"Mixture of legacy and composable templates":
|
||||
- skip:
|
||||
version: " - 7.7.99"
|
||||
reason: "format changed in 7.8 to accomodate V2 index templates"
|
||||
|
@ -114,7 +114,7 @@
|
||||
- match: {body: null}
|
||||
|
||||
---
|
||||
"Simulate index matches overlapping V1 and V2 templates":
|
||||
"Simulate index matches overlapping legacy and composable templates":
|
||||
- skip:
|
||||
version: " - 7.8.99"
|
||||
reason: "simulate index template API format changed in 7.9 to drop _doc"
|
||||
|
@ -83,7 +83,7 @@
|
||||
- is_true: template.aliases.test_alias
|
||||
|
||||
---
|
||||
"Simulate template matches overlapping V1 and V2 templates":
|
||||
"Simulate template matches overlapping legacy and composable templates":
|
||||
- skip:
|
||||
version: " - 7.99.99"
|
||||
reason: "not yet backported"
|
||||
|
@ -28,9 +28,9 @@ import org.elasticsearch.action.admin.indices.datastream.GetDataStreamAction;
|
||||
import org.elasticsearch.action.admin.indices.get.GetIndexRequest;
|
||||
import org.elasticsearch.action.admin.indices.get.GetIndexResponse;
|
||||
import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsResponse;
|
||||
import org.elasticsearch.action.admin.indices.template.delete.DeleteIndexTemplateV2Action;
|
||||
import org.elasticsearch.action.admin.indices.template.delete.DeleteComposableIndexTemplateAction;
|
||||
import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest;
|
||||
import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateV2Action;
|
||||
import org.elasticsearch.action.admin.indices.template.put.PutComposableIndexTemplateAction;
|
||||
import org.elasticsearch.action.index.IndexRequest;
|
||||
import org.elasticsearch.action.index.IndexResponse;
|
||||
import org.elasticsearch.action.ingest.PutPipelineRequest;
|
||||
@ -38,7 +38,7 @@ import org.elasticsearch.action.support.master.AcknowledgedResponse;
|
||||
import org.elasticsearch.action.support.replication.ReplicationRequest;
|
||||
import org.elasticsearch.cluster.metadata.DataStream;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetadata;
|
||||
import org.elasticsearch.cluster.metadata.IndexTemplateV2;
|
||||
import org.elasticsearch.cluster.metadata.ComposableIndexTemplate;
|
||||
import org.elasticsearch.cluster.metadata.Template;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
@ -222,15 +222,15 @@ public class BulkIntegrationIT extends ESIntegTestCase {
|
||||
public void testMixedAutoCreate() {
|
||||
Settings settings = Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0).build();
|
||||
|
||||
PutIndexTemplateV2Action.Request createTemplateRequest = new PutIndexTemplateV2Action.Request("logs-foo");
|
||||
PutComposableIndexTemplateAction.Request createTemplateRequest = new PutComposableIndexTemplateAction.Request("logs-foo");
|
||||
createTemplateRequest.indexTemplate(
|
||||
new IndexTemplateV2(
|
||||
new ComposableIndexTemplate(
|
||||
Collections.singletonList("logs-foo*"),
|
||||
new Template(settings, null, null),
|
||||
null, null, null, null,
|
||||
new IndexTemplateV2.DataStreamTemplate("@timestamp"))
|
||||
new ComposableIndexTemplate.DataStreamTemplate("@timestamp"))
|
||||
);
|
||||
client().execute(PutIndexTemplateV2Action.INSTANCE, createTemplateRequest).actionGet();
|
||||
client().execute(PutComposableIndexTemplateAction.INSTANCE, createTemplateRequest).actionGet();
|
||||
|
||||
BulkRequest bulkRequest = new BulkRequest();
|
||||
bulkRequest.add(new IndexRequest("logs-foobar").opType(CREATE).source("{}", XContentType.JSON));
|
||||
@ -274,8 +274,8 @@ public class BulkIntegrationIT extends ESIntegTestCase {
|
||||
assertThat(getIndexResponse.getIndices(), hasItemInArray("logs-barfoo2"));
|
||||
assertThat(getIndexResponse.getIndices(), hasItemInArray("logs-barfoo3"));
|
||||
|
||||
DeleteIndexTemplateV2Action.Request deleteTemplateRequest = new DeleteIndexTemplateV2Action.Request("*");
|
||||
client().execute(DeleteIndexTemplateV2Action.INSTANCE, deleteTemplateRequest).actionGet();
|
||||
DeleteComposableIndexTemplateAction.Request deleteTemplateRequest = new DeleteComposableIndexTemplateAction.Request("*");
|
||||
client().execute(DeleteComposableIndexTemplateAction.INSTANCE, deleteTemplateRequest).actionGet();
|
||||
}
|
||||
|
||||
public void testAutoCreateV1TemplateNoDataStream() {
|
||||
|
@ -154,15 +154,15 @@ import org.elasticsearch.action.admin.indices.stats.IndicesStatsAction;
|
||||
import org.elasticsearch.action.admin.indices.stats.TransportIndicesStatsAction;
|
||||
import org.elasticsearch.action.admin.indices.template.delete.DeleteComponentTemplateAction;
|
||||
import org.elasticsearch.action.admin.indices.template.delete.DeleteIndexTemplateAction;
|
||||
import org.elasticsearch.action.admin.indices.template.delete.DeleteIndexTemplateV2Action;
|
||||
import org.elasticsearch.action.admin.indices.template.delete.DeleteComposableIndexTemplateAction;
|
||||
import org.elasticsearch.action.admin.indices.template.delete.TransportDeleteComponentTemplateAction;
|
||||
import org.elasticsearch.action.admin.indices.template.delete.TransportDeleteIndexTemplateAction;
|
||||
import org.elasticsearch.action.admin.indices.template.delete.TransportDeleteIndexTemplateV2Action;
|
||||
import org.elasticsearch.action.admin.indices.template.delete.TransportDeleteComposableIndexTemplateAction;
|
||||
import org.elasticsearch.action.admin.indices.template.get.GetComponentTemplateAction;
|
||||
import org.elasticsearch.action.admin.indices.template.get.GetIndexTemplateV2Action;
|
||||
import org.elasticsearch.action.admin.indices.template.get.GetComposableIndexTemplateAction;
|
||||
import org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesAction;
|
||||
import org.elasticsearch.action.admin.indices.template.get.TransportGetComponentTemplateAction;
|
||||
import org.elasticsearch.action.admin.indices.template.get.TransportGetIndexTemplateV2Action;
|
||||
import org.elasticsearch.action.admin.indices.template.get.TransportGetComposableIndexTemplateAction;
|
||||
import org.elasticsearch.action.admin.indices.template.get.TransportGetIndexTemplatesAction;
|
||||
import org.elasticsearch.action.admin.indices.template.post.SimulateIndexTemplateAction;
|
||||
import org.elasticsearch.action.admin.indices.template.post.SimulateTemplateAction;
|
||||
@ -170,10 +170,10 @@ import org.elasticsearch.action.admin.indices.template.post.TransportSimulateInd
|
||||
import org.elasticsearch.action.admin.indices.template.post.TransportSimulateTemplateAction;
|
||||
import org.elasticsearch.action.admin.indices.template.put.PutComponentTemplateAction;
|
||||
import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateAction;
|
||||
import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateV2Action;
|
||||
import org.elasticsearch.action.admin.indices.template.put.PutComposableIndexTemplateAction;
|
||||
import org.elasticsearch.action.admin.indices.template.put.TransportPutComponentTemplateAction;
|
||||
import org.elasticsearch.action.admin.indices.template.put.TransportPutIndexTemplateAction;
|
||||
import org.elasticsearch.action.admin.indices.template.put.TransportPutIndexTemplateV2Action;
|
||||
import org.elasticsearch.action.admin.indices.template.put.TransportPutComposableIndexTemplateAction;
|
||||
import org.elasticsearch.action.admin.indices.upgrade.get.TransportUpgradeStatusAction;
|
||||
import org.elasticsearch.action.admin.indices.upgrade.get.UpgradeStatusAction;
|
||||
import org.elasticsearch.action.admin.indices.upgrade.post.TransportUpgradeAction;
|
||||
@ -297,7 +297,7 @@ import org.elasticsearch.rest.action.admin.indices.RestDeleteComponentTemplateAc
|
||||
import org.elasticsearch.rest.action.admin.indices.RestDeleteDataStreamAction;
|
||||
import org.elasticsearch.rest.action.admin.indices.RestDeleteIndexAction;
|
||||
import org.elasticsearch.rest.action.admin.indices.RestDeleteIndexTemplateAction;
|
||||
import org.elasticsearch.rest.action.admin.indices.RestDeleteIndexTemplateV2Action;
|
||||
import org.elasticsearch.rest.action.admin.indices.RestDeleteComposableIndexTemplateAction;
|
||||
import org.elasticsearch.rest.action.admin.indices.RestFlushAction;
|
||||
import org.elasticsearch.rest.action.admin.indices.RestForceMergeAction;
|
||||
import org.elasticsearch.rest.action.admin.indices.RestGetAliasesAction;
|
||||
@ -305,7 +305,7 @@ import org.elasticsearch.rest.action.admin.indices.RestGetComponentTemplateActio
|
||||
import org.elasticsearch.rest.action.admin.indices.RestGetDataStreamsAction;
|
||||
import org.elasticsearch.rest.action.admin.indices.RestGetFieldMappingAction;
|
||||
import org.elasticsearch.rest.action.admin.indices.RestGetIndexTemplateAction;
|
||||
import org.elasticsearch.rest.action.admin.indices.RestGetIndexTemplateV2Action;
|
||||
import org.elasticsearch.rest.action.admin.indices.RestGetComposableIndexTemplateAction;
|
||||
import org.elasticsearch.rest.action.admin.indices.RestGetIndicesAction;
|
||||
import org.elasticsearch.rest.action.admin.indices.RestGetMappingAction;
|
||||
import org.elasticsearch.rest.action.admin.indices.RestGetSettingsAction;
|
||||
@ -318,7 +318,7 @@ import org.elasticsearch.rest.action.admin.indices.RestIndicesStatsAction;
|
||||
import org.elasticsearch.rest.action.admin.indices.RestOpenIndexAction;
|
||||
import org.elasticsearch.rest.action.admin.indices.RestPutComponentTemplateAction;
|
||||
import org.elasticsearch.rest.action.admin.indices.RestPutIndexTemplateAction;
|
||||
import org.elasticsearch.rest.action.admin.indices.RestPutIndexTemplateV2Action;
|
||||
import org.elasticsearch.rest.action.admin.indices.RestPutComposableIndexTemplateAction;
|
||||
import org.elasticsearch.rest.action.admin.indices.RestPutMappingAction;
|
||||
import org.elasticsearch.rest.action.admin.indices.RestRecoveryAction;
|
||||
import org.elasticsearch.rest.action.admin.indices.RestRefreshAction;
|
||||
@ -549,9 +549,9 @@ public class ActionModule extends AbstractModule {
|
||||
actions.register(PutComponentTemplateAction.INSTANCE, TransportPutComponentTemplateAction.class);
|
||||
actions.register(GetComponentTemplateAction.INSTANCE, TransportGetComponentTemplateAction.class);
|
||||
actions.register(DeleteComponentTemplateAction.INSTANCE, TransportDeleteComponentTemplateAction.class);
|
||||
actions.register(PutIndexTemplateV2Action.INSTANCE, TransportPutIndexTemplateV2Action.class);
|
||||
actions.register(GetIndexTemplateV2Action.INSTANCE, TransportGetIndexTemplateV2Action.class);
|
||||
actions.register(DeleteIndexTemplateV2Action.INSTANCE, TransportDeleteIndexTemplateV2Action.class);
|
||||
actions.register(PutComposableIndexTemplateAction.INSTANCE, TransportPutComposableIndexTemplateAction.class);
|
||||
actions.register(GetComposableIndexTemplateAction.INSTANCE, TransportGetComposableIndexTemplateAction.class);
|
||||
actions.register(DeleteComposableIndexTemplateAction.INSTANCE, TransportDeleteComposableIndexTemplateAction.class);
|
||||
actions.register(SimulateIndexTemplateAction.INSTANCE, TransportSimulateIndexTemplateAction.class);
|
||||
actions.register(SimulateTemplateAction.INSTANCE, TransportSimulateTemplateAction.class);
|
||||
actions.register(ValidateQueryAction.INSTANCE, TransportValidateQueryAction.class);
|
||||
@ -692,9 +692,9 @@ public class ActionModule extends AbstractModule {
|
||||
registerHandler.accept(new RestPutComponentTemplateAction());
|
||||
registerHandler.accept(new RestGetComponentTemplateAction());
|
||||
registerHandler.accept(new RestDeleteComponentTemplateAction());
|
||||
registerHandler.accept(new RestPutIndexTemplateV2Action());
|
||||
registerHandler.accept(new RestGetIndexTemplateV2Action());
|
||||
registerHandler.accept(new RestDeleteIndexTemplateV2Action());
|
||||
registerHandler.accept(new RestPutComposableIndexTemplateAction());
|
||||
registerHandler.accept(new RestGetComposableIndexTemplateAction());
|
||||
registerHandler.accept(new RestDeleteComposableIndexTemplateAction());
|
||||
registerHandler.accept(new RestSimulateIndexTemplateAction());
|
||||
registerHandler.accept(new RestSimulateTemplateAction());
|
||||
|
||||
|
@ -30,8 +30,8 @@ import org.elasticsearch.cluster.ack.ClusterStateUpdateResponse;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.metadata.IndexTemplateV2;
|
||||
import org.elasticsearch.cluster.metadata.IndexTemplateV2.DataStreamTemplate;
|
||||
import org.elasticsearch.cluster.metadata.ComposableIndexTemplate;
|
||||
import org.elasticsearch.cluster.metadata.ComposableIndexTemplate.DataStreamTemplate;
|
||||
import org.elasticsearch.cluster.metadata.Metadata;
|
||||
import org.elasticsearch.cluster.metadata.MetadataCreateDataStreamService;
|
||||
import org.elasticsearch.cluster.metadata.MetadataCreateDataStreamService.CreateDataStreamClusterStateUpdateRequest;
|
||||
@ -149,9 +149,9 @@ public final class AutoCreateAction extends ActionType<CreateIndexResponse> {
|
||||
static DataStreamTemplate resolveAutoCreateDataStream(CreateIndexRequest request, Metadata metadata) {
|
||||
String v2Template = MetadataIndexTemplateService.findV2Template(metadata, request.index(), false);
|
||||
if (v2Template != null) {
|
||||
IndexTemplateV2 indexTemplateV2 = metadata.templatesV2().get(v2Template);
|
||||
if (indexTemplateV2.getDataStreamTemplate() != null) {
|
||||
return indexTemplateV2.getDataStreamTemplate();
|
||||
ComposableIndexTemplate composableIndexTemplate = metadata.templatesV2().get(v2Template);
|
||||
if (composableIndexTemplate.getDataStreamTemplate() != null) {
|
||||
return composableIndexTemplate.getDataStreamTemplate();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,12 +31,12 @@ import java.util.Objects;
|
||||
|
||||
import static org.elasticsearch.action.ValidateActions.addValidationError;
|
||||
|
||||
public class DeleteIndexTemplateV2Action extends ActionType<AcknowledgedResponse> {
|
||||
public class DeleteComposableIndexTemplateAction extends ActionType<AcknowledgedResponse> {
|
||||
|
||||
public static final DeleteIndexTemplateV2Action INSTANCE = new DeleteIndexTemplateV2Action();
|
||||
public static final DeleteComposableIndexTemplateAction INSTANCE = new DeleteComposableIndexTemplateAction();
|
||||
public static final String NAME = "indices:admin/index_template/delete";
|
||||
|
||||
private DeleteIndexTemplateV2Action() {
|
||||
private DeleteComposableIndexTemplateAction() {
|
||||
super(NAME, AcknowledgedResponse::new);
|
||||
}
|
||||
|
@ -38,19 +38,20 @@ import org.elasticsearch.transport.TransportService;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class TransportDeleteIndexTemplateV2Action
|
||||
extends TransportMasterNodeAction<DeleteIndexTemplateV2Action.Request, AcknowledgedResponse> {
|
||||
public class TransportDeleteComposableIndexTemplateAction
|
||||
extends TransportMasterNodeAction<DeleteComposableIndexTemplateAction.Request, AcknowledgedResponse> {
|
||||
|
||||
private static final Logger logger = LogManager.getLogger(TransportDeleteIndexTemplateV2Action.class);
|
||||
private static final Logger logger = LogManager.getLogger(TransportDeleteComposableIndexTemplateAction.class);
|
||||
|
||||
private final MetadataIndexTemplateService indexTemplateService;
|
||||
|
||||
@Inject
|
||||
public TransportDeleteIndexTemplateV2Action(TransportService transportService, ClusterService clusterService,
|
||||
ThreadPool threadPool, MetadataIndexTemplateService indexTemplateService,
|
||||
ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(DeleteIndexTemplateV2Action.NAME, transportService, clusterService, threadPool, actionFilters,
|
||||
DeleteIndexTemplateV2Action.Request::new, indexNameExpressionResolver);
|
||||
public TransportDeleteComposableIndexTemplateAction(TransportService transportService, ClusterService clusterService,
|
||||
ThreadPool threadPool, MetadataIndexTemplateService indexTemplateService,
|
||||
ActionFilters actionFilters,
|
||||
IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(DeleteComposableIndexTemplateAction.NAME, transportService, clusterService, threadPool, actionFilters,
|
||||
DeleteComposableIndexTemplateAction.Request::new, indexNameExpressionResolver);
|
||||
this.indexTemplateService = indexTemplateService;
|
||||
}
|
||||
|
||||
@ -66,12 +67,12 @@ public class TransportDeleteIndexTemplateV2Action
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ClusterBlockException checkBlock(DeleteIndexTemplateV2Action.Request request, ClusterState state) {
|
||||
protected ClusterBlockException checkBlock(DeleteComposableIndexTemplateAction.Request request, ClusterState state) {
|
||||
return state.blocks().globalBlockedException(ClusterBlockLevel.METADATA_WRITE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void masterOperation(final DeleteIndexTemplateV2Action.Request request, final ClusterState state,
|
||||
protected void masterOperation(final DeleteComposableIndexTemplateAction.Request request, final ClusterState state,
|
||||
final ActionListener<AcknowledgedResponse> listener) {
|
||||
indexTemplateService.removeIndexTemplateV2(request.name(), request.masterNodeTimeout(), listener);
|
||||
}
|
@ -23,7 +23,7 @@ import org.elasticsearch.action.ActionRequestValidationException;
|
||||
import org.elasticsearch.action.ActionResponse;
|
||||
import org.elasticsearch.action.ActionType;
|
||||
import org.elasticsearch.action.support.master.MasterNodeReadRequest;
|
||||
import org.elasticsearch.cluster.metadata.IndexTemplateV2;
|
||||
import org.elasticsearch.cluster.metadata.ComposableIndexTemplate;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.ParseField;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
@ -36,13 +36,13 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
public class GetIndexTemplateV2Action extends ActionType<GetIndexTemplateV2Action.Response> {
|
||||
public class GetComposableIndexTemplateAction extends ActionType<GetComposableIndexTemplateAction.Response> {
|
||||
|
||||
public static final GetIndexTemplateV2Action INSTANCE = new GetIndexTemplateV2Action();
|
||||
public static final GetComposableIndexTemplateAction INSTANCE = new GetComposableIndexTemplateAction();
|
||||
public static final String NAME = "indices:admin/index_template/get";
|
||||
|
||||
private GetIndexTemplateV2Action() {
|
||||
super(NAME, GetIndexTemplateV2Action.Response::new);
|
||||
private GetComposableIndexTemplateAction() {
|
||||
super(NAME, GetComposableIndexTemplateAction.Response::new);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -113,29 +113,29 @@ public class GetIndexTemplateV2Action extends ActionType<GetIndexTemplateV2Actio
|
||||
public static final ParseField INDEX_TEMPLATES = new ParseField("index_templates");
|
||||
public static final ParseField INDEX_TEMPLATE = new ParseField("index_template");
|
||||
|
||||
private final Map<String, IndexTemplateV2> indexTemplates;
|
||||
private final Map<String, ComposableIndexTemplate> indexTemplates;
|
||||
|
||||
public Response(StreamInput in) throws IOException {
|
||||
super(in);
|
||||
int size = in.readVInt();
|
||||
indexTemplates = new HashMap<>();
|
||||
for (int i = 0 ; i < size ; i++) {
|
||||
indexTemplates.put(in.readString(), new IndexTemplateV2(in));
|
||||
indexTemplates.put(in.readString(), new ComposableIndexTemplate(in));
|
||||
}
|
||||
}
|
||||
|
||||
public Response(Map<String, IndexTemplateV2> indexTemplates) {
|
||||
public Response(Map<String, ComposableIndexTemplate> indexTemplates) {
|
||||
this.indexTemplates = indexTemplates;
|
||||
}
|
||||
|
||||
public Map<String, IndexTemplateV2> indexTemplates() {
|
||||
public Map<String, ComposableIndexTemplate> indexTemplates() {
|
||||
return indexTemplates;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
out.writeVInt(indexTemplates.size());
|
||||
for (Map.Entry<String, IndexTemplateV2> indexTemplate : indexTemplates.entrySet()) {
|
||||
for (Map.Entry<String, ComposableIndexTemplate> indexTemplate : indexTemplates.entrySet()) {
|
||||
out.writeString(indexTemplate.getKey());
|
||||
indexTemplate.getValue().writeTo(out);
|
||||
}
|
||||
@ -145,7 +145,7 @@ public class GetIndexTemplateV2Action extends ActionType<GetIndexTemplateV2Actio
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
GetIndexTemplateV2Action.Response that = (GetIndexTemplateV2Action.Response) o;
|
||||
GetComposableIndexTemplateAction.Response that = (GetComposableIndexTemplateAction.Response) o;
|
||||
return Objects.equals(indexTemplates, that.indexTemplates);
|
||||
}
|
||||
|
||||
@ -158,7 +158,7 @@ public class GetIndexTemplateV2Action extends ActionType<GetIndexTemplateV2Actio
|
||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
builder.startObject();
|
||||
builder.startArray(INDEX_TEMPLATES.getPreferredName());
|
||||
for (Map.Entry<String, IndexTemplateV2> indexTemplate : this.indexTemplates.entrySet()) {
|
||||
for (Map.Entry<String, ComposableIndexTemplate> indexTemplate : this.indexTemplates.entrySet()) {
|
||||
builder.startObject();
|
||||
builder.field(NAME.getPreferredName(), indexTemplate.getKey());
|
||||
builder.field(INDEX_TEMPLATE.getPreferredName(), indexTemplate.getValue());
|
@ -26,7 +26,7 @@ import org.elasticsearch.action.support.master.TransportMasterNodeReadAction;
|
||||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.metadata.IndexTemplateV2;
|
||||
import org.elasticsearch.cluster.metadata.ComposableIndexTemplate;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.service.ClusterService;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
@ -39,15 +39,15 @@ import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class TransportGetIndexTemplateV2Action
|
||||
extends TransportMasterNodeReadAction<GetIndexTemplateV2Action.Request, GetIndexTemplateV2Action.Response> {
|
||||
public class TransportGetComposableIndexTemplateAction
|
||||
extends TransportMasterNodeReadAction<GetComposableIndexTemplateAction.Request, GetComposableIndexTemplateAction.Response> {
|
||||
|
||||
@Inject
|
||||
public TransportGetIndexTemplateV2Action(TransportService transportService, ClusterService clusterService,
|
||||
ThreadPool threadPool, ActionFilters actionFilters,
|
||||
IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(GetIndexTemplateV2Action.NAME, transportService, clusterService, threadPool, actionFilters,
|
||||
GetIndexTemplateV2Action.Request::new, indexNameExpressionResolver);
|
||||
public TransportGetComposableIndexTemplateAction(TransportService transportService, ClusterService clusterService,
|
||||
ThreadPool threadPool, ActionFilters actionFilters,
|
||||
IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(GetComposableIndexTemplateAction.NAME, transportService, clusterService, threadPool, actionFilters,
|
||||
GetComposableIndexTemplateAction.Request::new, indexNameExpressionResolver);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -56,30 +56,30 @@ public class TransportGetIndexTemplateV2Action
|
||||
}
|
||||
|
||||
@Override
|
||||
protected GetIndexTemplateV2Action.Response read(StreamInput in) throws IOException {
|
||||
return new GetIndexTemplateV2Action.Response(in);
|
||||
protected GetComposableIndexTemplateAction.Response read(StreamInput in) throws IOException {
|
||||
return new GetComposableIndexTemplateAction.Response(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ClusterBlockException checkBlock(GetIndexTemplateV2Action.Request request, ClusterState state) {
|
||||
protected ClusterBlockException checkBlock(GetComposableIndexTemplateAction.Request request, ClusterState state) {
|
||||
return state.blocks().globalBlockedException(ClusterBlockLevel.METADATA_READ);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void masterOperation(GetIndexTemplateV2Action.Request request, ClusterState state,
|
||||
ActionListener<GetIndexTemplateV2Action.Response> listener) {
|
||||
Map<String, IndexTemplateV2> allTemplates = state.metadata().templatesV2();
|
||||
protected void masterOperation(GetComposableIndexTemplateAction.Request request, ClusterState state,
|
||||
ActionListener<GetComposableIndexTemplateAction.Response> listener) {
|
||||
Map<String, ComposableIndexTemplate> allTemplates = state.metadata().templatesV2();
|
||||
|
||||
// If we did not ask for a specific name, then we return all templates
|
||||
if (request.name() == null) {
|
||||
listener.onResponse(new GetIndexTemplateV2Action.Response(allTemplates));
|
||||
listener.onResponse(new GetComposableIndexTemplateAction.Response(allTemplates));
|
||||
return;
|
||||
}
|
||||
|
||||
final Map<String, IndexTemplateV2> results = new HashMap<>();
|
||||
final Map<String, ComposableIndexTemplate> results = new HashMap<>();
|
||||
String name = request.name();
|
||||
if (Regex.isSimpleMatchPattern(name)) {
|
||||
for (Map.Entry<String, IndexTemplateV2> entry : allTemplates.entrySet()) {
|
||||
for (Map.Entry<String, ComposableIndexTemplate> entry : allTemplates.entrySet()) {
|
||||
if (Regex.simpleMatch(name, entry.getKey())) {
|
||||
results.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
@ -90,6 +90,6 @@ public class TransportGetIndexTemplateV2Action
|
||||
throw new ResourceNotFoundException("index template matching [" + request.name() + "] not found");
|
||||
}
|
||||
|
||||
listener.onResponse(new GetIndexTemplateV2Action.Response(results));
|
||||
listener.onResponse(new GetComposableIndexTemplateAction.Response(results));
|
||||
}
|
||||
}
|
@ -20,7 +20,7 @@
|
||||
package org.elasticsearch.action.admin.indices.template.post;
|
||||
|
||||
import org.elasticsearch.action.ActionRequestValidationException;
|
||||
import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateV2Action;
|
||||
import org.elasticsearch.action.admin.indices.template.put.PutComposableIndexTemplateAction;
|
||||
import org.elasticsearch.action.support.master.MasterNodeReadRequest;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.Strings;
|
||||
@ -35,7 +35,7 @@ public class SimulateIndexTemplateRequest extends MasterNodeReadRequest<Simulate
|
||||
private String indexName;
|
||||
|
||||
@Nullable
|
||||
private PutIndexTemplateV2Action.Request indexTemplateRequest;
|
||||
private PutComposableIndexTemplateAction.Request indexTemplateRequest;
|
||||
|
||||
public SimulateIndexTemplateRequest(String indexName) {
|
||||
if (Strings.isNullOrEmpty(indexName)) {
|
||||
@ -47,7 +47,7 @@ public class SimulateIndexTemplateRequest extends MasterNodeReadRequest<Simulate
|
||||
public SimulateIndexTemplateRequest(StreamInput in) throws IOException {
|
||||
super(in);
|
||||
indexName = in.readString();
|
||||
indexTemplateRequest = in.readOptionalWriteable(PutIndexTemplateV2Action.Request::new);
|
||||
indexTemplateRequest = in.readOptionalWriteable(PutComposableIndexTemplateAction.Request::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -71,7 +71,7 @@ public class SimulateIndexTemplateRequest extends MasterNodeReadRequest<Simulate
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public PutIndexTemplateV2Action.Request getIndexTemplateRequest() {
|
||||
public PutComposableIndexTemplateAction.Request getIndexTemplateRequest() {
|
||||
return indexTemplateRequest;
|
||||
}
|
||||
|
||||
@ -80,7 +80,7 @@ public class SimulateIndexTemplateRequest extends MasterNodeReadRequest<Simulate
|
||||
return this;
|
||||
}
|
||||
|
||||
public SimulateIndexTemplateRequest indexTemplateRequest(PutIndexTemplateV2Action.Request indexTemplateRequest) {
|
||||
public SimulateIndexTemplateRequest indexTemplateRequest(PutComposableIndexTemplateAction.Request indexTemplateRequest) {
|
||||
this.indexTemplateRequest = indexTemplateRequest;
|
||||
return this;
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ package org.elasticsearch.action.admin.indices.template.post;
|
||||
import org.elasticsearch.action.ActionRequestValidationException;
|
||||
import org.elasticsearch.action.ActionType;
|
||||
import org.elasticsearch.action.ValidateActions;
|
||||
import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateV2Action;
|
||||
import org.elasticsearch.action.admin.indices.template.put.PutComposableIndexTemplateAction;
|
||||
import org.elasticsearch.action.support.master.MasterNodeReadRequest;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
@ -50,7 +50,7 @@ public class SimulateTemplateAction extends ActionType<SimulateIndexTemplateResp
|
||||
private String templateName;
|
||||
|
||||
@Nullable
|
||||
private PutIndexTemplateV2Action.Request indexTemplateRequest;
|
||||
private PutComposableIndexTemplateAction.Request indexTemplateRequest;
|
||||
|
||||
public Request() { }
|
||||
|
||||
@ -61,7 +61,7 @@ public class SimulateTemplateAction extends ActionType<SimulateIndexTemplateResp
|
||||
this.templateName = templateName;
|
||||
}
|
||||
|
||||
public Request(PutIndexTemplateV2Action.Request indexTemplateRequest) {
|
||||
public Request(PutComposableIndexTemplateAction.Request indexTemplateRequest) {
|
||||
if (indexTemplateRequest == null) {
|
||||
throw new IllegalArgumentException("index template body must be present");
|
||||
}
|
||||
@ -71,7 +71,7 @@ public class SimulateTemplateAction extends ActionType<SimulateIndexTemplateResp
|
||||
public Request(StreamInput in) throws IOException {
|
||||
super(in);
|
||||
templateName = in.readOptionalString();
|
||||
indexTemplateRequest = in.readOptionalWriteable(PutIndexTemplateV2Action.Request::new);
|
||||
indexTemplateRequest = in.readOptionalWriteable(PutComposableIndexTemplateAction.Request::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -101,7 +101,7 @@ public class SimulateTemplateAction extends ActionType<SimulateIndexTemplateResp
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public PutIndexTemplateV2Action.Request getIndexTemplateRequest() {
|
||||
public PutComposableIndexTemplateAction.Request getIndexTemplateRequest() {
|
||||
return indexTemplateRequest;
|
||||
}
|
||||
|
||||
@ -110,7 +110,7 @@ public class SimulateTemplateAction extends ActionType<SimulateIndexTemplateResp
|
||||
return this;
|
||||
}
|
||||
|
||||
public Request indexTemplateRequest(PutIndexTemplateV2Action.Request indexTemplateRequest) {
|
||||
public Request indexTemplateRequest(PutComposableIndexTemplateAction.Request indexTemplateRequest) {
|
||||
this.indexTemplateRequest = indexTemplateRequest;
|
||||
return this;
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ import org.elasticsearch.cluster.metadata.AliasMetadata;
|
||||
import org.elasticsearch.cluster.metadata.AliasValidator;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetadata;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.metadata.IndexTemplateV2;
|
||||
import org.elasticsearch.cluster.metadata.ComposableIndexTemplate;
|
||||
import org.elasticsearch.cluster.metadata.Metadata;
|
||||
import org.elasticsearch.cluster.metadata.MetadataCreateIndexService;
|
||||
import org.elasticsearch.cluster.metadata.MetadataIndexTemplateService;
|
||||
@ -118,7 +118,7 @@ public class TransportSimulateIndexTemplateAction
|
||||
}
|
||||
|
||||
final ClusterState tempClusterState = resolveTemporaryState(matchingTemplate, request.getIndexName(), stateWithTemplate);
|
||||
IndexTemplateV2 templateV2 = tempClusterState.metadata().templatesV2().get(matchingTemplate);
|
||||
ComposableIndexTemplate templateV2 = tempClusterState.metadata().templatesV2().get(matchingTemplate);
|
||||
assert templateV2 != null : "the matched template must exist";
|
||||
|
||||
final Template template = resolveTemplate(matchingTemplate, request.getIndexName(), stateWithTemplate,
|
||||
|
@ -27,7 +27,7 @@ import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.metadata.AliasValidator;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.metadata.IndexTemplateV2;
|
||||
import org.elasticsearch.cluster.metadata.ComposableIndexTemplate;
|
||||
import org.elasticsearch.cluster.metadata.MetadataIndexTemplateService;
|
||||
import org.elasticsearch.cluster.metadata.Template;
|
||||
import org.elasticsearch.cluster.service.ClusterService;
|
||||
@ -129,7 +129,7 @@ public class TransportSimulateTemplateAction
|
||||
|
||||
final ClusterState tempClusterState =
|
||||
TransportSimulateIndexTemplateAction.resolveTemporaryState(matchingTemplate, temporaryIndexName, stateWithTemplate);
|
||||
IndexTemplateV2 templateV2 = tempClusterState.metadata().templatesV2().get(matchingTemplate);
|
||||
ComposableIndexTemplate templateV2 = tempClusterState.metadata().templatesV2().get(matchingTemplate);
|
||||
assert templateV2 != null : "the matched template must exist";
|
||||
|
||||
Map<String, List<String>> overlapping = new HashMap<>();
|
||||
|
@ -26,7 +26,7 @@ import org.elasticsearch.action.support.IndicesOptions;
|
||||
import org.elasticsearch.action.support.master.AcknowledgedResponse;
|
||||
import org.elasticsearch.action.support.master.MasterNodeRequest;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetadata;
|
||||
import org.elasticsearch.cluster.metadata.IndexTemplateV2;
|
||||
import org.elasticsearch.cluster.metadata.ComposableIndexTemplate;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
@ -38,12 +38,12 @@ import java.util.Objects;
|
||||
|
||||
import static org.elasticsearch.action.ValidateActions.addValidationError;
|
||||
|
||||
public class PutIndexTemplateV2Action extends ActionType<AcknowledgedResponse> {
|
||||
public class PutComposableIndexTemplateAction extends ActionType<AcknowledgedResponse> {
|
||||
|
||||
public static final PutIndexTemplateV2Action INSTANCE = new PutIndexTemplateV2Action();
|
||||
public static final PutComposableIndexTemplateAction INSTANCE = new PutComposableIndexTemplateAction();
|
||||
public static final String NAME = "indices:admin/index_template/put";
|
||||
|
||||
private PutIndexTemplateV2Action() {
|
||||
private PutComposableIndexTemplateAction() {
|
||||
super(NAME, AcknowledgedResponse::new);
|
||||
}
|
||||
|
||||
@ -55,14 +55,14 @@ public class PutIndexTemplateV2Action extends ActionType<AcknowledgedResponse> {
|
||||
@Nullable
|
||||
private String cause;
|
||||
private boolean create;
|
||||
private IndexTemplateV2 indexTemplate;
|
||||
private ComposableIndexTemplate indexTemplate;
|
||||
|
||||
public Request(StreamInput in) throws IOException {
|
||||
super(in);
|
||||
this.name = in.readString();
|
||||
this.cause = in.readOptionalString();
|
||||
this.create = in.readBoolean();
|
||||
this.indexTemplate = new IndexTemplateV2(in);
|
||||
this.indexTemplate = new ComposableIndexTemplate(in);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -97,7 +97,7 @@ public class PutIndexTemplateV2Action extends ActionType<AcknowledgedResponse> {
|
||||
} else {
|
||||
if (indexTemplate.indexPatterns().stream().anyMatch(Regex::isMatchAllPattern)) {
|
||||
if (IndexMetadata.INDEX_HIDDEN_SETTING.exists(indexTemplate.template().settings())) {
|
||||
validationException = addValidationError("global V2 templates may not specify the setting "
|
||||
validationException = addValidationError("global composable templates may not specify the setting "
|
||||
+ IndexMetadata.INDEX_HIDDEN_SETTING.getKey(),
|
||||
validationException
|
||||
);
|
||||
@ -146,12 +146,12 @@ public class PutIndexTemplateV2Action extends ActionType<AcknowledgedResponse> {
|
||||
/**
|
||||
* The index template that will be inserted into the cluster state
|
||||
*/
|
||||
public Request indexTemplate(IndexTemplateV2 template) {
|
||||
public Request indexTemplate(ComposableIndexTemplate template) {
|
||||
this.indexTemplate = template;
|
||||
return this;
|
||||
}
|
||||
|
||||
public IndexTemplateV2 indexTemplate() {
|
||||
public ComposableIndexTemplate indexTemplate() {
|
||||
return this.indexTemplate;
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.metadata.IndexTemplateV2;
|
||||
import org.elasticsearch.cluster.metadata.ComposableIndexTemplate;
|
||||
import org.elasticsearch.cluster.metadata.MetadataIndexTemplateService;
|
||||
import org.elasticsearch.cluster.service.ClusterService;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
@ -37,17 +37,17 @@ import org.elasticsearch.transport.TransportService;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class TransportPutIndexTemplateV2Action
|
||||
extends TransportMasterNodeAction<PutIndexTemplateV2Action.Request, AcknowledgedResponse> {
|
||||
public class TransportPutComposableIndexTemplateAction
|
||||
extends TransportMasterNodeAction<PutComposableIndexTemplateAction.Request, AcknowledgedResponse> {
|
||||
|
||||
private final MetadataIndexTemplateService indexTemplateService;
|
||||
|
||||
@Inject
|
||||
public TransportPutIndexTemplateV2Action(TransportService transportService, ClusterService clusterService,
|
||||
ThreadPool threadPool, MetadataIndexTemplateService indexTemplateService,
|
||||
ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(PutIndexTemplateV2Action.NAME, transportService, clusterService, threadPool, actionFilters,
|
||||
PutIndexTemplateV2Action.Request::new, indexNameExpressionResolver);
|
||||
public TransportPutComposableIndexTemplateAction(TransportService transportService, ClusterService clusterService,
|
||||
ThreadPool threadPool, MetadataIndexTemplateService indexTemplateService,
|
||||
ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(PutComposableIndexTemplateAction.NAME, transportService, clusterService, threadPool, actionFilters,
|
||||
PutComposableIndexTemplateAction.Request::new, indexNameExpressionResolver);
|
||||
this.indexTemplateService = indexTemplateService;
|
||||
}
|
||||
|
||||
@ -63,14 +63,14 @@ public class TransportPutIndexTemplateV2Action
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ClusterBlockException checkBlock(PutIndexTemplateV2Action.Request request, ClusterState state) {
|
||||
protected ClusterBlockException checkBlock(PutComposableIndexTemplateAction.Request request, ClusterState state) {
|
||||
return state.blocks().globalBlockedException(ClusterBlockLevel.METADATA_WRITE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void masterOperation(final PutIndexTemplateV2Action.Request request, final ClusterState state,
|
||||
protected void masterOperation(final PutComposableIndexTemplateAction.Request request, final ClusterState state,
|
||||
final ActionListener<AcknowledgedResponse> listener) {
|
||||
IndexTemplateV2 indexTemplate = request.indexTemplate();
|
||||
ComposableIndexTemplate indexTemplate = request.indexTemplate();
|
||||
indexTemplateService.putIndexTemplateV2(request.cause(), request.create(), request.name(), request.masterNodeTimeout(),
|
||||
indexTemplate, listener);
|
||||
}
|
@ -26,7 +26,7 @@ import org.elasticsearch.cluster.metadata.ComponentTemplateMetadata;
|
||||
import org.elasticsearch.cluster.metadata.DataStreamMetadata;
|
||||
import org.elasticsearch.cluster.metadata.IndexGraveyard;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.metadata.IndexTemplateV2Metadata;
|
||||
import org.elasticsearch.cluster.metadata.ComposableIndexTemplateMetadata;
|
||||
import org.elasticsearch.cluster.metadata.Metadata;
|
||||
import org.elasticsearch.cluster.metadata.MetadataDeleteIndexService;
|
||||
import org.elasticsearch.cluster.metadata.MetadataIndexAliasesService;
|
||||
@ -138,8 +138,8 @@ public class ClusterModule extends AbstractModule {
|
||||
PersistentTasksCustomMetadata::readDiffFrom);
|
||||
registerMetadataCustom(entries, ComponentTemplateMetadata.TYPE, ComponentTemplateMetadata::new,
|
||||
ComponentTemplateMetadata::readDiffFrom);
|
||||
registerMetadataCustom(entries, IndexTemplateV2Metadata.TYPE, IndexTemplateV2Metadata::new,
|
||||
IndexTemplateV2Metadata::readDiffFrom);
|
||||
registerMetadataCustom(entries, ComposableIndexTemplateMetadata.TYPE, ComposableIndexTemplateMetadata::new,
|
||||
ComposableIndexTemplateMetadata::readDiffFrom);
|
||||
registerMetadataCustom(entries, DataStreamMetadata.TYPE, DataStreamMetadata::new, DataStreamMetadata::readDiffFrom);
|
||||
// Task Status (not Diffable)
|
||||
entries.add(new Entry(Task.Status.class, PersistentTasksNodeService.Status.NAME, PersistentTasksNodeService.Status::new));
|
||||
@ -190,8 +190,8 @@ public class ClusterModule extends AbstractModule {
|
||||
PersistentTasksCustomMetadata::fromXContent));
|
||||
entries.add(new NamedXContentRegistry.Entry(Metadata.Custom.class, new ParseField(ComponentTemplateMetadata.TYPE),
|
||||
ComponentTemplateMetadata::fromXContent));
|
||||
entries.add(new NamedXContentRegistry.Entry(Metadata.Custom.class, new ParseField(IndexTemplateV2Metadata.TYPE),
|
||||
IndexTemplateV2Metadata::fromXContent));
|
||||
entries.add(new NamedXContentRegistry.Entry(Metadata.Custom.class, new ParseField(ComposableIndexTemplateMetadata.TYPE),
|
||||
ComposableIndexTemplateMetadata::fromXContent));
|
||||
entries.add(new NamedXContentRegistry.Entry(Metadata.Custom.class, new ParseField(DataStreamMetadata.TYPE),
|
||||
DataStreamMetadata::fromXContent));
|
||||
return entries;
|
||||
|
@ -44,7 +44,7 @@ import java.util.Objects;
|
||||
* ids corresponding to component templates that should be composed in order when creating a new
|
||||
* index.
|
||||
*/
|
||||
public class IndexTemplateV2 extends AbstractDiffable<IndexTemplateV2> implements ToXContentObject {
|
||||
public class ComposableIndexTemplate extends AbstractDiffable<ComposableIndexTemplate> implements ToXContentObject {
|
||||
private static final ParseField INDEX_PATTERNS = new ParseField("index_patterns");
|
||||
private static final ParseField TEMPLATE = new ParseField("template");
|
||||
private static final ParseField PRIORITY = new ParseField("priority");
|
||||
@ -54,8 +54,9 @@ public class IndexTemplateV2 extends AbstractDiffable<IndexTemplateV2> implement
|
||||
private static final ParseField DATA_STREAM = new ParseField("data_stream");
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static final ConstructingObjectParser<IndexTemplateV2, Void> PARSER = new ConstructingObjectParser<>("index_template", false,
|
||||
a -> new IndexTemplateV2((List<String>) a[0],
|
||||
public static final ConstructingObjectParser<ComposableIndexTemplate, Void> PARSER = new ConstructingObjectParser<>("index_template",
|
||||
false,
|
||||
a -> new ComposableIndexTemplate((List<String>) a[0],
|
||||
(Template) a[1],
|
||||
(List<String>) a[2],
|
||||
(Long) a[3],
|
||||
@ -87,22 +88,22 @@ public class IndexTemplateV2 extends AbstractDiffable<IndexTemplateV2> implement
|
||||
@Nullable
|
||||
private final DataStreamTemplate dataStreamTemplate;
|
||||
|
||||
static Diff<IndexTemplateV2> readITV2DiffFrom(StreamInput in) throws IOException {
|
||||
return AbstractDiffable.readDiffFrom(IndexTemplateV2::new, in);
|
||||
static Diff<ComposableIndexTemplate> readITV2DiffFrom(StreamInput in) throws IOException {
|
||||
return AbstractDiffable.readDiffFrom(ComposableIndexTemplate::new, in);
|
||||
}
|
||||
|
||||
public static IndexTemplateV2 parse(XContentParser parser) throws IOException {
|
||||
public static ComposableIndexTemplate parse(XContentParser parser) throws IOException {
|
||||
return PARSER.parse(parser, null);
|
||||
}
|
||||
|
||||
public IndexTemplateV2(List<String> indexPatterns, @Nullable Template template, @Nullable List<String> componentTemplates,
|
||||
@Nullable Long priority, @Nullable Long version, @Nullable Map<String, Object> metadata) {
|
||||
public ComposableIndexTemplate(List<String> indexPatterns, @Nullable Template template, @Nullable List<String> componentTemplates,
|
||||
@Nullable Long priority, @Nullable Long version, @Nullable Map<String, Object> metadata) {
|
||||
this(indexPatterns, template, componentTemplates, priority, version, metadata, null);
|
||||
}
|
||||
|
||||
public IndexTemplateV2(List<String> indexPatterns, @Nullable Template template, @Nullable List<String> componentTemplates,
|
||||
@Nullable Long priority, @Nullable Long version, @Nullable Map<String, Object> metadata,
|
||||
@Nullable DataStreamTemplate dataStreamTemplate) {
|
||||
public ComposableIndexTemplate(List<String> indexPatterns, @Nullable Template template, @Nullable List<String> componentTemplates,
|
||||
@Nullable Long priority, @Nullable Long version, @Nullable Map<String, Object> metadata,
|
||||
@Nullable DataStreamTemplate dataStreamTemplate) {
|
||||
this.indexPatterns = indexPatterns;
|
||||
this.template = template;
|
||||
this.componentTemplates = componentTemplates;
|
||||
@ -112,7 +113,7 @@ public class IndexTemplateV2 extends AbstractDiffable<IndexTemplateV2> implement
|
||||
this.dataStreamTemplate = dataStreamTemplate;
|
||||
}
|
||||
|
||||
public IndexTemplateV2(StreamInput in) throws IOException {
|
||||
public ComposableIndexTemplate(StreamInput in) throws IOException {
|
||||
this.indexPatterns = in.readStringList();
|
||||
if (in.readBoolean()) {
|
||||
this.template = new Template(in);
|
||||
@ -227,7 +228,7 @@ public class IndexTemplateV2 extends AbstractDiffable<IndexTemplateV2> implement
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
IndexTemplateV2 other = (IndexTemplateV2) obj;
|
||||
ComposableIndexTemplate other = (ComposableIndexTemplate) obj;
|
||||
return Objects.equals(this.indexPatterns, other.indexPatterns) &&
|
||||
Objects.equals(this.template, other.template) &&
|
||||
Objects.equals(this.componentTemplates, other.componentTemplates) &&
|
@ -38,42 +38,42 @@ import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* The {@link IndexTemplateV2Metadata} class is a custom {@link Metadata.Custom} implementation that
|
||||
* stores a map of ids to {@link IndexTemplateV2} templates.
|
||||
* The {@link ComposableIndexTemplateMetadata} class is a custom {@link Metadata.Custom} implementation that
|
||||
* stores a map of ids to {@link ComposableIndexTemplate} templates.
|
||||
*/
|
||||
public class IndexTemplateV2Metadata implements Metadata.Custom {
|
||||
public class ComposableIndexTemplateMetadata implements Metadata.Custom {
|
||||
public static final String TYPE = "index_template";
|
||||
private static final ParseField INDEX_TEMPLATE = new ParseField("index_template");
|
||||
@SuppressWarnings("unchecked")
|
||||
private static final ConstructingObjectParser<IndexTemplateV2Metadata, Void> PARSER = new ConstructingObjectParser<>(TYPE, false,
|
||||
a -> new IndexTemplateV2Metadata((Map<String, IndexTemplateV2>) a[0]));
|
||||
private static final ConstructingObjectParser<ComposableIndexTemplateMetadata, Void> PARSER = new ConstructingObjectParser<>(TYPE,
|
||||
false, a -> new ComposableIndexTemplateMetadata((Map<String, ComposableIndexTemplate>) a[0]));
|
||||
|
||||
static {
|
||||
PARSER.declareObject(ConstructingObjectParser.constructorArg(), (p, c) -> {
|
||||
Map<String, IndexTemplateV2> templates = new HashMap<>();
|
||||
Map<String, ComposableIndexTemplate> templates = new HashMap<>();
|
||||
while (p.nextToken() != XContentParser.Token.END_OBJECT) {
|
||||
String name = p.currentName();
|
||||
templates.put(name, IndexTemplateV2.parse(p));
|
||||
templates.put(name, ComposableIndexTemplate.parse(p));
|
||||
}
|
||||
return templates;
|
||||
}, INDEX_TEMPLATE);
|
||||
}
|
||||
|
||||
private final Map<String, IndexTemplateV2> indexTemplates;
|
||||
private final Map<String, ComposableIndexTemplate> indexTemplates;
|
||||
|
||||
public IndexTemplateV2Metadata(Map<String, IndexTemplateV2> templates) {
|
||||
public ComposableIndexTemplateMetadata(Map<String, ComposableIndexTemplate> templates) {
|
||||
this.indexTemplates = templates;
|
||||
}
|
||||
|
||||
public IndexTemplateV2Metadata(StreamInput in) throws IOException {
|
||||
this.indexTemplates = in.readMap(StreamInput::readString, IndexTemplateV2::new);
|
||||
public ComposableIndexTemplateMetadata(StreamInput in) throws IOException {
|
||||
this.indexTemplates = in.readMap(StreamInput::readString, ComposableIndexTemplate::new);
|
||||
}
|
||||
|
||||
public static IndexTemplateV2Metadata fromXContent(XContentParser parser) throws IOException {
|
||||
public static ComposableIndexTemplateMetadata fromXContent(XContentParser parser) throws IOException {
|
||||
return PARSER.parse(parser, null);
|
||||
}
|
||||
|
||||
public Map<String, IndexTemplateV2> indexTemplates() {
|
||||
public Map<String, ComposableIndexTemplate> indexTemplates() {
|
||||
return indexTemplates;
|
||||
}
|
||||
|
||||
@ -84,11 +84,11 @@ public class IndexTemplateV2Metadata implements Metadata.Custom {
|
||||
|
||||
@Override
|
||||
public Diff<Metadata.Custom> diff(Metadata.Custom before) {
|
||||
return new IndexTemplateV2MetadataDiff((IndexTemplateV2Metadata) before, this);
|
||||
return new ComposableIndexTemplateMetadataDiff((ComposableIndexTemplateMetadata) before, this);
|
||||
}
|
||||
|
||||
public static NamedDiff<Metadata.Custom> readDiffFrom(StreamInput in) throws IOException {
|
||||
return new IndexTemplateV2MetadataDiff(in);
|
||||
return new ComposableIndexTemplateMetadataDiff(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -109,7 +109,7 @@ public class IndexTemplateV2Metadata implements Metadata.Custom {
|
||||
@Override
|
||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
builder.startObject(INDEX_TEMPLATE.getPreferredName());
|
||||
for (Map.Entry<String, IndexTemplateV2> template : indexTemplates.entrySet()) {
|
||||
for (Map.Entry<String, ComposableIndexTemplate> template : indexTemplates.entrySet()) {
|
||||
builder.field(template.getKey(), template.getValue());
|
||||
}
|
||||
builder.endObject();
|
||||
@ -129,7 +129,7 @@ public class IndexTemplateV2Metadata implements Metadata.Custom {
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
IndexTemplateV2Metadata other = (IndexTemplateV2Metadata) obj;
|
||||
ComposableIndexTemplateMetadata other = (ComposableIndexTemplateMetadata) obj;
|
||||
return Objects.equals(this.indexTemplates, other.indexTemplates);
|
||||
}
|
||||
|
||||
@ -138,23 +138,23 @@ public class IndexTemplateV2Metadata implements Metadata.Custom {
|
||||
return Strings.toString(this);
|
||||
}
|
||||
|
||||
static class IndexTemplateV2MetadataDiff implements NamedDiff<Metadata.Custom> {
|
||||
static class ComposableIndexTemplateMetadataDiff implements NamedDiff<Metadata.Custom> {
|
||||
|
||||
final Diff<Map<String, IndexTemplateV2>> indexTemplateDiff;
|
||||
final Diff<Map<String, ComposableIndexTemplate>> indexTemplateDiff;
|
||||
|
||||
IndexTemplateV2MetadataDiff(IndexTemplateV2Metadata before, IndexTemplateV2Metadata after) {
|
||||
ComposableIndexTemplateMetadataDiff(ComposableIndexTemplateMetadata before, ComposableIndexTemplateMetadata after) {
|
||||
this.indexTemplateDiff = DiffableUtils.diff(before.indexTemplates, after.indexTemplates,
|
||||
DiffableUtils.getStringKeySerializer());
|
||||
}
|
||||
|
||||
IndexTemplateV2MetadataDiff(StreamInput in) throws IOException {
|
||||
ComposableIndexTemplateMetadataDiff(StreamInput in) throws IOException {
|
||||
this.indexTemplateDiff = DiffableUtils.readJdkMapDiff(in, DiffableUtils.getStringKeySerializer(),
|
||||
IndexTemplateV2::new, IndexTemplateV2::readITV2DiffFrom);
|
||||
ComposableIndexTemplate::new, ComposableIndexTemplate::readITV2DiffFrom);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Metadata.Custom apply(Metadata.Custom part) {
|
||||
return new IndexTemplateV2Metadata(indexTemplateDiff.apply(((IndexTemplateV2Metadata) part).indexTemplates));
|
||||
return new ComposableIndexTemplateMetadata(indexTemplateDiff.apply(((ComposableIndexTemplateMetadata) part).indexTemplates));
|
||||
}
|
||||
|
||||
@Override
|
@ -745,9 +745,9 @@ public class Metadata implements Iterable<IndexMetadata>, Diffable<Metadata>, To
|
||||
.orElse(Collections.emptyMap());
|
||||
}
|
||||
|
||||
public Map<String, IndexTemplateV2> templatesV2() {
|
||||
return Optional.ofNullable((IndexTemplateV2Metadata) this.custom(IndexTemplateV2Metadata.TYPE))
|
||||
.map(IndexTemplateV2Metadata::indexTemplates)
|
||||
public Map<String, ComposableIndexTemplate> templatesV2() {
|
||||
return Optional.ofNullable((ComposableIndexTemplateMetadata) this.custom(ComposableIndexTemplateMetadata.TYPE))
|
||||
.map(ComposableIndexTemplateMetadata::indexTemplates)
|
||||
.orElse(Collections.emptyMap());
|
||||
}
|
||||
|
||||
@ -1193,31 +1193,31 @@ public class Metadata implements Iterable<IndexMetadata>, Diffable<Metadata>, To
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder indexTemplates(Map<String, IndexTemplateV2> indexTemplates) {
|
||||
this.customs.put(IndexTemplateV2Metadata.TYPE, new IndexTemplateV2Metadata(indexTemplates));
|
||||
public Builder indexTemplates(Map<String, ComposableIndexTemplate> indexTemplates) {
|
||||
this.customs.put(ComposableIndexTemplateMetadata.TYPE, new ComposableIndexTemplateMetadata(indexTemplates));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder put(String name, IndexTemplateV2 indexTemplate) {
|
||||
public Builder put(String name, ComposableIndexTemplate indexTemplate) {
|
||||
Objects.requireNonNull(indexTemplate, "it is invalid to add a null index template: " + name);
|
||||
// ಠ_ಠ at ImmutableOpenMap
|
||||
Map<String, IndexTemplateV2> existingTemplates =
|
||||
Optional.ofNullable((IndexTemplateV2Metadata) this.customs.get(IndexTemplateV2Metadata.TYPE))
|
||||
Map<String, ComposableIndexTemplate> existingTemplates =
|
||||
Optional.ofNullable((ComposableIndexTemplateMetadata) this.customs.get(ComposableIndexTemplateMetadata.TYPE))
|
||||
.map(itmd -> new HashMap<>(itmd.indexTemplates()))
|
||||
.orElse(new HashMap<>());
|
||||
existingTemplates.put(name, indexTemplate);
|
||||
this.customs.put(IndexTemplateV2Metadata.TYPE, new IndexTemplateV2Metadata(existingTemplates));
|
||||
this.customs.put(ComposableIndexTemplateMetadata.TYPE, new ComposableIndexTemplateMetadata(existingTemplates));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder removeIndexTemplate(String name) {
|
||||
// ಠ_ಠ at ImmutableOpenMap
|
||||
Map<String, IndexTemplateV2> existingTemplates =
|
||||
Optional.ofNullable((IndexTemplateV2Metadata) this.customs.get(IndexTemplateV2Metadata.TYPE))
|
||||
Map<String, ComposableIndexTemplate> existingTemplates =
|
||||
Optional.ofNullable((ComposableIndexTemplateMetadata) this.customs.get(ComposableIndexTemplateMetadata.TYPE))
|
||||
.map(itmd -> new HashMap<>(itmd.indexTemplates()))
|
||||
.orElse(new HashMap<>());
|
||||
existingTemplates.remove(name);
|
||||
this.customs.put(IndexTemplateV2Metadata.TYPE, new IndexTemplateV2Metadata(existingTemplates));
|
||||
this.customs.put(ComposableIndexTemplateMetadata.TYPE, new ComposableIndexTemplateMetadata(existingTemplates));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -341,9 +341,9 @@ public class MetadataCreateIndexService {
|
||||
request.index(), isHiddenFromRequest);
|
||||
|
||||
if (v1Templates.size() > 1) {
|
||||
DEPRECATION_LOGGER.deprecatedAndMaybeLog("index_template_multiple_match", "index [{}] matches multiple v1 templates " +
|
||||
"[{}], v2 index templates will only match a single index template", request.index(),
|
||||
v1Templates.stream().map(IndexTemplateMetadata::name).sorted().collect(Collectors.joining(", ")));
|
||||
DEPRECATION_LOGGER.deprecatedAndMaybeLog("index_template_multiple_match",
|
||||
"index [{}] matches multiple legacy templates [{}], composable templates will only match a single template",
|
||||
request.index(), v1Templates.stream().map(IndexTemplateMetadata::name).sorted().collect(Collectors.joining(", ")));
|
||||
}
|
||||
|
||||
return applyCreateIndexRequestWithV1Templates(currentState, request, silent, v1Templates, metadataTransformer);
|
||||
|
@ -201,10 +201,10 @@ public class MetadataIndexTemplateService {
|
||||
if (create == false && finalSettings != null) {
|
||||
// if the CT is specifying the `index.hidden` setting it cannot be part of any global template
|
||||
if (IndexMetadata.INDEX_HIDDEN_SETTING.exists(finalSettings)) {
|
||||
Map<String, IndexTemplateV2> existingTemplates = currentState.metadata().templatesV2();
|
||||
Map<String, ComposableIndexTemplate> existingTemplates = currentState.metadata().templatesV2();
|
||||
List<String> globalTemplatesThatUseThisComponent = new ArrayList<>();
|
||||
for (Map.Entry<String, IndexTemplateV2> entry : existingTemplates.entrySet()) {
|
||||
IndexTemplateV2 templateV2 = entry.getValue();
|
||||
for (Map.Entry<String, ComposableIndexTemplate> entry : existingTemplates.entrySet()) {
|
||||
ComposableIndexTemplate templateV2 = entry.getValue();
|
||||
if (templateV2.composedOf().contains(name) && templateV2.indexPatterns().stream().anyMatch(Regex::isMatchAllPattern)) {
|
||||
// global templates don't support configuring the `index.hidden` setting so we don't need to resolve the settings as
|
||||
// no other component template can remove this setting from the resolved settings, so just invalidate this update
|
||||
@ -325,7 +325,7 @@ public class MetadataIndexTemplateService {
|
||||
* exception will be thrown if the component template already exists
|
||||
*/
|
||||
public void putIndexTemplateV2(final String cause, final boolean create, final String name, final TimeValue masterTimeout,
|
||||
final IndexTemplateV2 template, final ActionListener<AcknowledgedResponse> listener) {
|
||||
final ComposableIndexTemplate template, final ActionListener<AcknowledgedResponse> listener) {
|
||||
validateV2TemplateRequest(clusterService.state().metadata(), name, template);
|
||||
clusterService.submitStateUpdateTask("create-index-template-v2 [" + name + "], cause [" + cause + "]",
|
||||
new ClusterStateUpdateTask(Priority.URGENT) {
|
||||
@ -352,11 +352,11 @@ public class MetadataIndexTemplateService {
|
||||
});
|
||||
}
|
||||
|
||||
public static void validateV2TemplateRequest(Metadata metadata, String name, IndexTemplateV2 template) {
|
||||
public static void validateV2TemplateRequest(Metadata metadata, String name, ComposableIndexTemplate template) {
|
||||
if (template.indexPatterns().stream().anyMatch(Regex::isMatchAllPattern)) {
|
||||
Settings mergedSettings = resolveSettings(metadata, template);
|
||||
if (IndexMetadata.INDEX_HIDDEN_SETTING.exists(mergedSettings)) {
|
||||
throw new InvalidIndexTemplateException(name, "global V2 templates may not specify the setting "
|
||||
throw new InvalidIndexTemplateException(name, "global composable templates may not specify the setting "
|
||||
+ IndexMetadata.INDEX_HIDDEN_SETTING.getKey());
|
||||
}
|
||||
}
|
||||
@ -373,7 +373,7 @@ public class MetadataIndexTemplateService {
|
||||
}
|
||||
|
||||
public ClusterState addIndexTemplateV2(final ClusterState currentState, final boolean create,
|
||||
final String name, final IndexTemplateV2 template) throws Exception {
|
||||
final String name, final ComposableIndexTemplate template) throws Exception {
|
||||
if (create && currentState.metadata().templatesV2().containsKey(name)) {
|
||||
throw new IllegalArgumentException("index template [" + name + "] already exists");
|
||||
}
|
||||
@ -410,7 +410,7 @@ public class MetadataIndexTemplateService {
|
||||
deprecationLogger.deprecatedAndMaybeLog("index_template_pattern_overlap", warning);
|
||||
}
|
||||
|
||||
IndexTemplateV2 finalIndexTemplate = template;
|
||||
ComposableIndexTemplate finalIndexTemplate = template;
|
||||
Template innerTemplate = template.template();
|
||||
if (innerTemplate != null) {
|
||||
// We may need to normalize index settings, so do that also
|
||||
@ -438,7 +438,7 @@ public class MetadataIndexTemplateService {
|
||||
}
|
||||
final Template finalTemplate = new Template(finalSettings,
|
||||
stringMappings == null ? null : new CompressedXContent(stringMappings), innerTemplate.aliases());
|
||||
finalIndexTemplate = new IndexTemplateV2(template.indexPatterns(), finalTemplate, template.composedOf(),
|
||||
finalIndexTemplate = new ComposableIndexTemplate(template.indexPatterns(), finalTemplate, template.composedOf(),
|
||||
template.priority(), template.version(), template.metadata(), template.getDataStreamTemplate());
|
||||
}
|
||||
|
||||
@ -462,7 +462,7 @@ public class MetadataIndexTemplateService {
|
||||
IndexTemplateMetadata template = cursor.value;
|
||||
Automaton v1automaton = Regex.simpleMatchToAutomaton(template.patterns().toArray(Strings.EMPTY_ARRAY));
|
||||
if (Operations.isEmpty(Operations.intersection(v2automaton, v1automaton)) == false) {
|
||||
logger.debug("index template {} and old template {} would overlap: {} <=> {}",
|
||||
logger.debug("composable template {} and legacy template {} would overlap: {} <=> {}",
|
||||
candidateName, name, indexPatterns, template.patterns());
|
||||
overlappingTemplates.put(name, template.patterns());
|
||||
}
|
||||
@ -493,13 +493,13 @@ public class MetadataIndexTemplateService {
|
||||
final List<String> indexPatterns, boolean checkPriority, long priority) {
|
||||
Automaton v1automaton = Regex.simpleMatchToAutomaton(indexPatterns.toArray(Strings.EMPTY_ARRAY));
|
||||
Map<String, List<String>> overlappingTemplates = new HashMap<>();
|
||||
for (Map.Entry<String, IndexTemplateV2> entry : state.metadata().templatesV2().entrySet()) {
|
||||
for (Map.Entry<String, ComposableIndexTemplate> entry : state.metadata().templatesV2().entrySet()) {
|
||||
String name = entry.getKey();
|
||||
IndexTemplateV2 template = entry.getValue();
|
||||
ComposableIndexTemplate template = entry.getValue();
|
||||
Automaton v2automaton = Regex.simpleMatchToAutomaton(template.indexPatterns().toArray(Strings.EMPTY_ARRAY));
|
||||
if (Operations.isEmpty(Operations.intersection(v1automaton, v2automaton)) == false) {
|
||||
if (checkPriority == false || priority == template.priorityOrZero()) {
|
||||
logger.debug("old template {} and index template {} would overlap: {} <=> {}",
|
||||
logger.debug("legacy template {} and composable template {} would overlap: {} <=> {}",
|
||||
candidateName, name, indexPatterns, template.indexPatterns());
|
||||
overlappingTemplates.put(name, template.indexPatterns());
|
||||
}
|
||||
@ -627,9 +627,9 @@ public class MetadataIndexTemplateService {
|
||||
|
||||
Map<String, List<String>> overlaps = findConflictingV2Templates(currentState, request.name, request.indexPatterns);
|
||||
if (overlaps.size() > 0) {
|
||||
String warning = String.format(Locale.ROOT, "template [%s] has index patterns %s matching patterns" +
|
||||
" from existing index templates [%s] with patterns (%s); this template [%s] may be ignored in favor of " +
|
||||
"an index template at index creation time",
|
||||
String warning = String.format(Locale.ROOT, "legacy template [%s] has index patterns %s matching patterns" +
|
||||
" from existing composable templates [%s] with patterns (%s); this template [%s] may be ignored in favor" +
|
||||
" of a composable template at index creation time",
|
||||
request.name,
|
||||
request.indexPatterns,
|
||||
Strings.collectionToCommaDelimitedString(overlaps.keySet()),
|
||||
@ -733,10 +733,10 @@ public class MetadataIndexTemplateService {
|
||||
@Nullable
|
||||
public static String findV2Template(Metadata metadata, String indexName, boolean isHidden) {
|
||||
final Predicate<String> patternMatchPredicate = pattern -> Regex.simpleMatch(pattern, indexName);
|
||||
final Map<IndexTemplateV2, String> matchedTemplates = new HashMap<>();
|
||||
for (Map.Entry<String, IndexTemplateV2> entry : metadata.templatesV2().entrySet()) {
|
||||
final Map<ComposableIndexTemplate, String> matchedTemplates = new HashMap<>();
|
||||
for (Map.Entry<String, ComposableIndexTemplate> entry : metadata.templatesV2().entrySet()) {
|
||||
final String name = entry.getKey();
|
||||
final IndexTemplateV2 template = entry.getValue();
|
||||
final ComposableIndexTemplate template = entry.getValue();
|
||||
if (isHidden == false) {
|
||||
final boolean matched = template.indexPatterns().stream().anyMatch(patternMatchPredicate);
|
||||
if (matched) {
|
||||
@ -756,11 +756,11 @@ public class MetadataIndexTemplateService {
|
||||
return null;
|
||||
}
|
||||
|
||||
final List<IndexTemplateV2> candidates = new ArrayList<>(matchedTemplates.keySet());
|
||||
CollectionUtil.timSort(candidates, Comparator.comparing(IndexTemplateV2::priorityOrZero, Comparator.reverseOrder()));
|
||||
final List<ComposableIndexTemplate> candidates = new ArrayList<>(matchedTemplates.keySet());
|
||||
CollectionUtil.timSort(candidates, Comparator.comparing(ComposableIndexTemplate::priorityOrZero, Comparator.reverseOrder()));
|
||||
|
||||
assert candidates.size() > 0 : "we should have returned early with no candidates";
|
||||
IndexTemplateV2 winner = candidates.get(0);
|
||||
ComposableIndexTemplate winner = candidates.get(0);
|
||||
String winnerName = matchedTemplates.get(winner);
|
||||
|
||||
// if the winner template is a global template that specifies the `index.hidden` setting (which is not allowed, so it'd be due to
|
||||
@ -780,7 +780,7 @@ public class MetadataIndexTemplateService {
|
||||
* Resolve the given v2 template into an ordered list of mappings
|
||||
*/
|
||||
public static List<CompressedXContent> resolveMappings(final ClusterState state, final String templateName) {
|
||||
final IndexTemplateV2 template = state.metadata().templatesV2().get(templateName);
|
||||
final ComposableIndexTemplate template = state.metadata().templatesV2().get(templateName);
|
||||
assert template != null : "attempted to resolve mappings for a template [" + templateName +
|
||||
"] that did not exist in the cluster state";
|
||||
if (template == null) {
|
||||
@ -819,7 +819,7 @@ public class MetadataIndexTemplateService {
|
||||
* Resolve the given v2 template into a collected {@link Settings} object
|
||||
*/
|
||||
public static Settings resolveSettings(final Metadata metadata, final String templateName) {
|
||||
final IndexTemplateV2 template = metadata.templatesV2().get(templateName);
|
||||
final ComposableIndexTemplate template = metadata.templatesV2().get(templateName);
|
||||
assert template != null : "attempted to resolve settings for a template [" + templateName +
|
||||
"] that did not exist in the cluster state";
|
||||
if (template == null) {
|
||||
@ -828,7 +828,7 @@ public class MetadataIndexTemplateService {
|
||||
return resolveSettings(metadata, template);
|
||||
}
|
||||
|
||||
private static Settings resolveSettings(Metadata metadata, IndexTemplateV2 template) {
|
||||
private static Settings resolveSettings(Metadata metadata, ComposableIndexTemplate template) {
|
||||
final Map<String, ComponentTemplate> componentTemplates = metadata.componentTemplates();
|
||||
List<Settings> componentSettings = template.composedOf().stream()
|
||||
.map(componentTemplates::get)
|
||||
@ -868,7 +868,7 @@ public class MetadataIndexTemplateService {
|
||||
* Resolve the given v2 template into an ordered list of aliases
|
||||
*/
|
||||
public static List<Map<String, AliasMetadata>> resolveAliases(final Metadata metadata, final String templateName) {
|
||||
final IndexTemplateV2 template = metadata.templatesV2().get(templateName);
|
||||
final ComposableIndexTemplate template = metadata.templatesV2().get(templateName);
|
||||
assert template != null : "attempted to resolve aliases for a template [" + templateName +
|
||||
"] that did not exist in the cluster state";
|
||||
if (template == null) {
|
||||
@ -959,7 +959,7 @@ public class MetadataIndexTemplateService {
|
||||
validate(name, template.template(), Collections.emptyList());
|
||||
}
|
||||
|
||||
private void validate(String name, IndexTemplateV2 template) {
|
||||
private void validate(String name, ComposableIndexTemplate template) {
|
||||
validate(name, template.template(), template.indexPatterns());
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package org.elasticsearch.rest.action.admin.indices;
|
||||
|
||||
import org.elasticsearch.action.admin.indices.template.delete.DeleteIndexTemplateV2Action;
|
||||
import org.elasticsearch.action.admin.indices.template.delete.DeleteComposableIndexTemplateAction;
|
||||
import org.elasticsearch.client.node.NodeClient;
|
||||
import org.elasticsearch.rest.BaseRestHandler;
|
||||
import org.elasticsearch.rest.RestRequest;
|
||||
@ -31,7 +31,7 @@ import java.util.List;
|
||||
|
||||
import static org.elasticsearch.rest.RestRequest.Method.DELETE;
|
||||
|
||||
public class RestDeleteIndexTemplateV2Action extends BaseRestHandler {
|
||||
public class RestDeleteComposableIndexTemplateAction extends BaseRestHandler {
|
||||
|
||||
@Override
|
||||
public List<Route> routes() {
|
||||
@ -40,15 +40,15 @@ public class RestDeleteIndexTemplateV2Action extends BaseRestHandler {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "delete_index_template_v2_action";
|
||||
return "delete_composable_index_template_action";
|
||||
}
|
||||
|
||||
@Override
|
||||
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
|
||||
|
||||
DeleteIndexTemplateV2Action.Request deleteReq = new DeleteIndexTemplateV2Action.Request(request.param("name"));
|
||||
DeleteComposableIndexTemplateAction.Request deleteReq = new DeleteComposableIndexTemplateAction.Request(request.param("name"));
|
||||
deleteReq.masterNodeTimeout(request.paramAsTime("master_timeout", deleteReq.masterNodeTimeout()));
|
||||
|
||||
return channel -> client.execute(DeleteIndexTemplateV2Action.INSTANCE, deleteReq, new RestToXContentListener<>(channel));
|
||||
return channel -> client.execute(DeleteComposableIndexTemplateAction.INSTANCE, deleteReq, new RestToXContentListener<>(channel));
|
||||
}
|
||||
}
|
@ -19,7 +19,7 @@
|
||||
|
||||
package org.elasticsearch.rest.action.admin.indices;
|
||||
|
||||
import org.elasticsearch.action.admin.indices.template.get.GetIndexTemplateV2Action;
|
||||
import org.elasticsearch.action.admin.indices.template.get.GetComposableIndexTemplateAction;
|
||||
import org.elasticsearch.client.node.NodeClient;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.rest.BaseRestHandler;
|
||||
@ -37,7 +37,7 @@ import static org.elasticsearch.rest.RestRequest.Method.HEAD;
|
||||
import static org.elasticsearch.rest.RestStatus.NOT_FOUND;
|
||||
import static org.elasticsearch.rest.RestStatus.OK;
|
||||
|
||||
public class RestGetIndexTemplateV2Action extends BaseRestHandler {
|
||||
public class RestGetComposableIndexTemplateAction extends BaseRestHandler {
|
||||
|
||||
@Override
|
||||
public List<Route> routes() {
|
||||
@ -49,12 +49,12 @@ public class RestGetIndexTemplateV2Action extends BaseRestHandler {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "get_index_template_v2_action";
|
||||
return "get_composable_index_template_action";
|
||||
}
|
||||
|
||||
@Override
|
||||
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
|
||||
final GetIndexTemplateV2Action.Request getRequest = new GetIndexTemplateV2Action.Request(request.param("name"));
|
||||
final GetComposableIndexTemplateAction.Request getRequest = new GetComposableIndexTemplateAction.Request(request.param("name"));
|
||||
|
||||
getRequest.local(request.paramAsBoolean("local", getRequest.local()));
|
||||
getRequest.masterNodeTimeout(request.paramAsTime("master_timeout", getRequest.masterNodeTimeout()));
|
||||
@ -62,10 +62,10 @@ public class RestGetIndexTemplateV2Action extends BaseRestHandler {
|
||||
final boolean implicitAll = getRequest.name() == null;
|
||||
|
||||
return channel ->
|
||||
client.execute(GetIndexTemplateV2Action.INSTANCE, getRequest,
|
||||
new RestToXContentListener<GetIndexTemplateV2Action.Response>(channel) {
|
||||
client.execute(GetComposableIndexTemplateAction.INSTANCE, getRequest,
|
||||
new RestToXContentListener<GetComposableIndexTemplateAction.Response>(channel) {
|
||||
@Override
|
||||
protected RestStatus getStatus(final GetIndexTemplateV2Action.Response response) {
|
||||
protected RestStatus getStatus(final GetComposableIndexTemplateAction.Response response) {
|
||||
final boolean templateExists = response.indexTemplates().isEmpty() == false;
|
||||
return (templateExists || implicitAll) ? OK : NOT_FOUND;
|
||||
}
|
@ -19,9 +19,9 @@
|
||||
|
||||
package org.elasticsearch.rest.action.admin.indices;
|
||||
|
||||
import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateV2Action;
|
||||
import org.elasticsearch.action.admin.indices.template.put.PutComposableIndexTemplateAction;
|
||||
import org.elasticsearch.client.node.NodeClient;
|
||||
import org.elasticsearch.cluster.metadata.IndexTemplateV2;
|
||||
import org.elasticsearch.cluster.metadata.ComposableIndexTemplate;
|
||||
import org.elasticsearch.rest.BaseRestHandler;
|
||||
import org.elasticsearch.rest.RestRequest;
|
||||
import org.elasticsearch.rest.action.RestToXContentListener;
|
||||
@ -33,7 +33,7 @@ import java.util.List;
|
||||
import static org.elasticsearch.rest.RestRequest.Method.POST;
|
||||
import static org.elasticsearch.rest.RestRequest.Method.PUT;
|
||||
|
||||
public class RestPutIndexTemplateV2Action extends BaseRestHandler {
|
||||
public class RestPutComposableIndexTemplateAction extends BaseRestHandler {
|
||||
|
||||
@Override
|
||||
public List<Route> routes() {
|
||||
@ -44,18 +44,18 @@ public class RestPutIndexTemplateV2Action extends BaseRestHandler {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "put_index_template_v2_action";
|
||||
return "put_composable_index_template_action";
|
||||
}
|
||||
|
||||
@Override
|
||||
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
|
||||
|
||||
PutIndexTemplateV2Action.Request putRequest = new PutIndexTemplateV2Action.Request(request.param("name"));
|
||||
PutComposableIndexTemplateAction.Request putRequest = new PutComposableIndexTemplateAction.Request(request.param("name"));
|
||||
putRequest.masterNodeTimeout(request.paramAsTime("master_timeout", putRequest.masterNodeTimeout()));
|
||||
putRequest.create(request.paramAsBoolean("create", false));
|
||||
putRequest.cause(request.param("cause", "api"));
|
||||
putRequest.indexTemplate(IndexTemplateV2.parse(request.contentParser()));
|
||||
putRequest.indexTemplate(ComposableIndexTemplate.parse(request.contentParser()));
|
||||
|
||||
return channel -> client.execute(PutIndexTemplateV2Action.INSTANCE, putRequest, new RestToXContentListener<>(channel));
|
||||
return channel -> client.execute(PutComposableIndexTemplateAction.INSTANCE, putRequest, new RestToXContentListener<>(channel));
|
||||
}
|
||||
}
|
@ -21,9 +21,9 @@ package org.elasticsearch.rest.action.admin.indices;
|
||||
|
||||
import org.elasticsearch.action.admin.indices.template.post.SimulateIndexTemplateAction;
|
||||
import org.elasticsearch.action.admin.indices.template.post.SimulateIndexTemplateRequest;
|
||||
import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateV2Action;
|
||||
import org.elasticsearch.action.admin.indices.template.put.PutComposableIndexTemplateAction;
|
||||
import org.elasticsearch.client.node.NodeClient;
|
||||
import org.elasticsearch.cluster.metadata.IndexTemplateV2;
|
||||
import org.elasticsearch.cluster.metadata.ComposableIndexTemplate;
|
||||
import org.elasticsearch.rest.BaseRestHandler;
|
||||
import org.elasticsearch.rest.RestRequest;
|
||||
import org.elasticsearch.rest.action.RestToXContentListener;
|
||||
@ -52,8 +52,9 @@ public class RestSimulateIndexTemplateAction extends BaseRestHandler {
|
||||
simulateIndexTemplateRequest.masterNodeTimeout(request.paramAsTime("master_timeout",
|
||||
simulateIndexTemplateRequest.masterNodeTimeout()));
|
||||
if (request.hasContent()) {
|
||||
PutIndexTemplateV2Action.Request indexTemplateRequest = new PutIndexTemplateV2Action.Request("simulating_template");
|
||||
indexTemplateRequest.indexTemplate(IndexTemplateV2.parse(request.contentParser()));
|
||||
PutComposableIndexTemplateAction.Request indexTemplateRequest =
|
||||
new PutComposableIndexTemplateAction.Request("simulating_template");
|
||||
indexTemplateRequest.indexTemplate(ComposableIndexTemplate.parse(request.contentParser()));
|
||||
indexTemplateRequest.create(request.paramAsBoolean("create", false));
|
||||
indexTemplateRequest.cause(request.param("cause", "api"));
|
||||
|
||||
|
@ -20,9 +20,9 @@
|
||||
package org.elasticsearch.rest.action.admin.indices;
|
||||
|
||||
import org.elasticsearch.action.admin.indices.template.post.SimulateTemplateAction;
|
||||
import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateV2Action;
|
||||
import org.elasticsearch.action.admin.indices.template.put.PutComposableIndexTemplateAction;
|
||||
import org.elasticsearch.client.node.NodeClient;
|
||||
import org.elasticsearch.cluster.metadata.IndexTemplateV2;
|
||||
import org.elasticsearch.cluster.metadata.ComposableIndexTemplate;
|
||||
import org.elasticsearch.rest.BaseRestHandler;
|
||||
import org.elasticsearch.rest.RestRequest;
|
||||
import org.elasticsearch.rest.action.RestToXContentListener;
|
||||
@ -51,8 +51,9 @@ public class RestSimulateTemplateAction extends BaseRestHandler {
|
||||
SimulateTemplateAction.Request simulateRequest = new SimulateTemplateAction.Request();
|
||||
simulateRequest.templateName(request.param("name"));
|
||||
if (request.hasContent()) {
|
||||
PutIndexTemplateV2Action.Request indexTemplateRequest = new PutIndexTemplateV2Action.Request("simulating_template");
|
||||
indexTemplateRequest.indexTemplate(IndexTemplateV2.parse(request.contentParser()));
|
||||
PutComposableIndexTemplateAction.Request indexTemplateRequest =
|
||||
new PutComposableIndexTemplateAction.Request("simulating_template");
|
||||
indexTemplateRequest.indexTemplate(ComposableIndexTemplate.parse(request.contentParser()));
|
||||
indexTemplateRequest.create(request.paramAsBoolean("create", false));
|
||||
indexTemplateRequest.cause(request.param("cause", "api"));
|
||||
|
||||
|
@ -24,7 +24,7 @@ import org.elasticsearch.action.admin.cluster.state.ClusterStateRequest;
|
||||
import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse;
|
||||
import org.elasticsearch.client.node.NodeClient;
|
||||
import org.elasticsearch.cluster.metadata.IndexTemplateMetadata;
|
||||
import org.elasticsearch.cluster.metadata.IndexTemplateV2;
|
||||
import org.elasticsearch.cluster.metadata.ComposableIndexTemplate;
|
||||
import org.elasticsearch.cluster.metadata.Metadata;
|
||||
import org.elasticsearch.common.Table;
|
||||
import org.elasticsearch.common.regex.Regex;
|
||||
@ -103,9 +103,9 @@ public class RestTemplatesAction extends AbstractCatAction {
|
||||
}
|
||||
}
|
||||
|
||||
for (Map.Entry<String, IndexTemplateV2> entry : metadata.templatesV2().entrySet()) {
|
||||
for (Map.Entry<String, ComposableIndexTemplate> entry : metadata.templatesV2().entrySet()) {
|
||||
String name = entry.getKey();
|
||||
IndexTemplateV2 template = entry.getValue();
|
||||
ComposableIndexTemplate template = entry.getValue();
|
||||
if (patternString == null || Regex.simpleMatch(patternString, name)) {
|
||||
table.startRow();
|
||||
table.addCell(name);
|
||||
|
@ -19,8 +19,8 @@
|
||||
|
||||
package org.elasticsearch.action.admin.indices.create;
|
||||
|
||||
import org.elasticsearch.cluster.metadata.IndexTemplateV2;
|
||||
import org.elasticsearch.cluster.metadata.IndexTemplateV2.DataStreamTemplate;
|
||||
import org.elasticsearch.cluster.metadata.ComposableIndexTemplate;
|
||||
import org.elasticsearch.cluster.metadata.ComposableIndexTemplate.DataStreamTemplate;
|
||||
import org.elasticsearch.cluster.metadata.Metadata;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
|
||||
@ -37,10 +37,11 @@ public class AutoCreateActionTests extends ESTestCase {
|
||||
{
|
||||
Metadata.Builder mdBuilder = new Metadata.Builder();
|
||||
DataStreamTemplate dataStreamTemplate = new DataStreamTemplate("@timestamp");
|
||||
mdBuilder.put("1", new IndexTemplateV2(Collections.singletonList("legacy-logs-*"), null, null, 10L, null, null, null));
|
||||
mdBuilder.put("2", new IndexTemplateV2(Collections.singletonList("logs-*"), null, null, 20L, null, null, dataStreamTemplate));
|
||||
mdBuilder.put("3",
|
||||
new IndexTemplateV2(Collections.singletonList("logs-foobar"), null, null, 30L, null, null, dataStreamTemplate));
|
||||
mdBuilder.put("1", new ComposableIndexTemplate(Collections.singletonList("legacy-logs-*"), null, null, 10L, null, null, null));
|
||||
mdBuilder.put("2", new ComposableIndexTemplate(Collections.singletonList("logs-*"),
|
||||
null, null, 20L, null, null, dataStreamTemplate));
|
||||
mdBuilder.put("3", new ComposableIndexTemplate(Collections.singletonList("logs-foobar"),
|
||||
null, null, 30L, null, null, dataStreamTemplate));
|
||||
metadata = mdBuilder.build();
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ import org.elasticsearch.cluster.metadata.IndexAbstraction;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetadata;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.metadata.IndexTemplateMetadata;
|
||||
import org.elasticsearch.cluster.metadata.IndexTemplateV2;
|
||||
import org.elasticsearch.cluster.metadata.ComposableIndexTemplate;
|
||||
import org.elasticsearch.cluster.metadata.Metadata;
|
||||
import org.elasticsearch.cluster.metadata.MetadataCreateIndexService;
|
||||
import org.elasticsearch.cluster.metadata.MetadataIndexAliasesService;
|
||||
@ -352,7 +352,8 @@ public class MetadataRolloverServiceTests extends ESTestCase {
|
||||
Map<String, AliasMetadata> aliases = new HashMap<>();
|
||||
aliases.put("foo-write", AliasMetadata.builder("foo-write").build());
|
||||
aliases.put("bar-write", AliasMetadata.builder("bar-write").writeIndex(randomBoolean()).build());
|
||||
final IndexTemplateV2 template = new IndexTemplateV2(Arrays.asList("foo-*", "bar-*"), new Template(null, null, aliases),
|
||||
final ComposableIndexTemplate template = new ComposableIndexTemplate(Arrays.asList("foo-*", "bar-*"),
|
||||
new Template(null, null, aliases),
|
||||
null, null, null, null, null);
|
||||
|
||||
final Metadata metadata = Metadata.builder().put(createMetadata(randomAlphaOfLengthBetween(5, 7)), false)
|
||||
@ -369,7 +370,7 @@ public class MetadataRolloverServiceTests extends ESTestCase {
|
||||
aliases.put("foo-write", AliasMetadata.builder("foo-write").build());
|
||||
aliases.put("bar-write", AliasMetadata.builder("bar-write").writeIndex(randomBoolean()).build());
|
||||
final ComponentTemplate ct = new ComponentTemplate(new Template(null, null, aliases), null, null);
|
||||
final IndexTemplateV2 template = new IndexTemplateV2(Arrays.asList("foo-*", "bar-*"), null,
|
||||
final ComposableIndexTemplate template = new ComposableIndexTemplate(Arrays.asList("foo-*", "bar-*"), null,
|
||||
Collections.singletonList("ct"), null, null, null, null);
|
||||
|
||||
final Metadata metadata = Metadata.builder().put(createMetadata(randomAlphaOfLengthBetween(5, 7)), false)
|
||||
@ -404,7 +405,8 @@ public class MetadataRolloverServiceTests extends ESTestCase {
|
||||
Map<String, AliasMetadata> aliases = new HashMap<>();
|
||||
aliases.put("foo-write", AliasMetadata.builder("foo-write").build());
|
||||
aliases.put("bar-write", AliasMetadata.builder("bar-write").writeIndex(randomBoolean()).build());
|
||||
final IndexTemplateV2 template = new IndexTemplateV2(Collections.singletonList("*"), new Template(null, null, aliases),
|
||||
final ComposableIndexTemplate template = new ComposableIndexTemplate(Collections.singletonList("*"),
|
||||
new Template(null, null, aliases),
|
||||
null, null, null, null, null);
|
||||
|
||||
final Metadata metadata = Metadata.builder().put(createMetadata(randomAlphaOfLengthBetween(5, 7)), false)
|
||||
@ -425,7 +427,7 @@ public class MetadataRolloverServiceTests extends ESTestCase {
|
||||
aliases.put("foo-write", AliasMetadata.builder("foo-write").build());
|
||||
aliases.put("bar-write", AliasMetadata.builder("bar-write").writeIndex(randomBoolean()).build());
|
||||
final ComponentTemplate ct = new ComponentTemplate(new Template(null, null, aliases), null, null);
|
||||
final IndexTemplateV2 template = new IndexTemplateV2(Collections.singletonList("*"), null,
|
||||
final ComposableIndexTemplate template = new ComposableIndexTemplate(Collections.singletonList("*"), null,
|
||||
Collections.singletonList("ct"), null, null, null, null);
|
||||
|
||||
final Metadata metadata = Metadata.builder().put(createMetadata(randomAlphaOfLengthBetween(5, 7)), false)
|
||||
|
@ -24,19 +24,21 @@ import org.elasticsearch.test.AbstractWireSerializingTestCase;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class DeleteIndexTemplateV2RequestTests extends AbstractWireSerializingTestCase<DeleteIndexTemplateV2Action.Request> {
|
||||
public class DeleteComposableIndexTemplateRequestTests
|
||||
extends AbstractWireSerializingTestCase<DeleteComposableIndexTemplateAction.Request> {
|
||||
@Override
|
||||
protected Writeable.Reader<DeleteIndexTemplateV2Action.Request> instanceReader() {
|
||||
return DeleteIndexTemplateV2Action.Request::new;
|
||||
protected Writeable.Reader<DeleteComposableIndexTemplateAction.Request> instanceReader() {
|
||||
return DeleteComposableIndexTemplateAction.Request::new;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DeleteIndexTemplateV2Action.Request createTestInstance() {
|
||||
return new DeleteIndexTemplateV2Action.Request(randomAlphaOfLength(5));
|
||||
protected DeleteComposableIndexTemplateAction.Request createTestInstance() {
|
||||
return new DeleteComposableIndexTemplateAction.Request(randomAlphaOfLength(5));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DeleteIndexTemplateV2Action.Request mutateInstance(DeleteIndexTemplateV2Action.Request instance) throws IOException {
|
||||
protected DeleteComposableIndexTemplateAction.Request mutateInstance(DeleteComposableIndexTemplateAction.Request instance)
|
||||
throws IOException {
|
||||
return randomValueOtherThan(instance, this::createTestInstance);
|
||||
}
|
||||
}
|
@ -24,19 +24,20 @@ import org.elasticsearch.test.AbstractWireSerializingTestCase;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class GetIndexTemplateV2RequestTests extends AbstractWireSerializingTestCase<GetIndexTemplateV2Action.Request> {
|
||||
public class GetComposableIndexTemplateRequestTests extends AbstractWireSerializingTestCase<GetComposableIndexTemplateAction.Request> {
|
||||
@Override
|
||||
protected Writeable.Reader<GetIndexTemplateV2Action.Request> instanceReader() {
|
||||
return GetIndexTemplateV2Action.Request::new;
|
||||
protected Writeable.Reader<GetComposableIndexTemplateAction.Request> instanceReader() {
|
||||
return GetComposableIndexTemplateAction.Request::new;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected GetIndexTemplateV2Action.Request createTestInstance() {
|
||||
return new GetIndexTemplateV2Action.Request(randomBoolean() ? null : randomAlphaOfLength(4));
|
||||
protected GetComposableIndexTemplateAction.Request createTestInstance() {
|
||||
return new GetComposableIndexTemplateAction.Request(randomBoolean() ? null : randomAlphaOfLength(4));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected GetIndexTemplateV2Action.Request mutateInstance(GetIndexTemplateV2Action.Request instance) throws IOException {
|
||||
protected GetComposableIndexTemplateAction.Request mutateInstance(GetComposableIndexTemplateAction.Request instance)
|
||||
throws IOException {
|
||||
return randomValueOtherThan(instance, this::createTestInstance);
|
||||
}
|
||||
}
|
@ -19,8 +19,8 @@
|
||||
|
||||
package org.elasticsearch.action.admin.indices.template.get;
|
||||
|
||||
import org.elasticsearch.cluster.metadata.IndexTemplateV2;
|
||||
import org.elasticsearch.cluster.metadata.IndexTemplateV2Tests;
|
||||
import org.elasticsearch.cluster.metadata.ComposableIndexTemplate;
|
||||
import org.elasticsearch.cluster.metadata.ComposableIndexTemplateTests;
|
||||
import org.elasticsearch.common.io.stream.Writeable;
|
||||
import org.elasticsearch.test.AbstractWireSerializingTestCase;
|
||||
|
||||
@ -29,26 +29,27 @@ import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class GetIndexTemplateV2ResponseTests extends AbstractWireSerializingTestCase<GetIndexTemplateV2Action.Response> {
|
||||
public class GetComposableIndexTemplateResponseTests extends AbstractWireSerializingTestCase<GetComposableIndexTemplateAction.Response> {
|
||||
@Override
|
||||
protected Writeable.Reader<GetIndexTemplateV2Action.Response> instanceReader() {
|
||||
return GetIndexTemplateV2Action.Response::new;
|
||||
protected Writeable.Reader<GetComposableIndexTemplateAction.Response> instanceReader() {
|
||||
return GetComposableIndexTemplateAction.Response::new;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected GetIndexTemplateV2Action.Response createTestInstance() {
|
||||
protected GetComposableIndexTemplateAction.Response createTestInstance() {
|
||||
if (randomBoolean()) {
|
||||
return new GetIndexTemplateV2Action.Response(Collections.emptyMap());
|
||||
return new GetComposableIndexTemplateAction.Response(Collections.emptyMap());
|
||||
}
|
||||
Map<String, IndexTemplateV2> templates = new HashMap<>();
|
||||
Map<String, ComposableIndexTemplate> templates = new HashMap<>();
|
||||
for (int i = 0; i < randomIntBetween(1, 4); i++) {
|
||||
templates.put(randomAlphaOfLength(4), IndexTemplateV2Tests.randomInstance());
|
||||
templates.put(randomAlphaOfLength(4), ComposableIndexTemplateTests.randomInstance());
|
||||
}
|
||||
return new GetIndexTemplateV2Action.Response(templates);
|
||||
return new GetComposableIndexTemplateAction.Response(templates);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected GetIndexTemplateV2Action.Response mutateInstance(GetIndexTemplateV2Action.Response instance) throws IOException {
|
||||
protected GetComposableIndexTemplateAction.Response mutateInstance(GetComposableIndexTemplateAction.Response instance)
|
||||
throws IOException {
|
||||
return randomValueOtherThan(instance, this::createTestInstance);
|
||||
}
|
||||
}
|
@ -20,16 +20,17 @@
|
||||
package org.elasticsearch.action.admin.indices.template.post;
|
||||
|
||||
import org.elasticsearch.action.ActionRequestValidationException;
|
||||
import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateV2Action;
|
||||
import org.elasticsearch.action.admin.indices.template.put.PutComposableIndexTemplateAction;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetadata;
|
||||
import org.elasticsearch.cluster.metadata.IndexTemplateV2;
|
||||
import org.elasticsearch.cluster.metadata.IndexTemplateV2Tests;
|
||||
import org.elasticsearch.cluster.metadata.ComposableIndexTemplate;
|
||||
import org.elasticsearch.cluster.metadata.ComposableIndexTemplateTests;
|
||||
import org.elasticsearch.cluster.metadata.Template;
|
||||
import org.elasticsearch.common.io.stream.Writeable;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.test.AbstractWireSerializingTestCase;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.hamcrest.Matchers.is;
|
||||
@ -45,8 +46,8 @@ public class SimulateIndexTemplateRequestTests extends AbstractWireSerializingTe
|
||||
@Override
|
||||
protected SimulateIndexTemplateRequest createTestInstance() {
|
||||
SimulateIndexTemplateRequest req = new SimulateIndexTemplateRequest(randomAlphaOfLength(10));
|
||||
PutIndexTemplateV2Action.Request newTemplateRequest = new PutIndexTemplateV2Action.Request(randomAlphaOfLength(4));
|
||||
newTemplateRequest.indexTemplate(IndexTemplateV2Tests.randomInstance());
|
||||
PutComposableIndexTemplateAction.Request newTemplateRequest = new PutComposableIndexTemplateAction.Request(randomAlphaOfLength(4));
|
||||
newTemplateRequest.indexTemplate(ComposableIndexTemplateTests.randomInstance());
|
||||
req.indexTemplateRequest(newTemplateRequest);
|
||||
return req;
|
||||
}
|
||||
@ -63,10 +64,10 @@ public class SimulateIndexTemplateRequestTests extends AbstractWireSerializingTe
|
||||
|
||||
public void testAddingGlobalTemplateWithHiddenIndexSettingIsIllegal() {
|
||||
Template template = new Template(Settings.builder().put(IndexMetadata.SETTING_INDEX_HIDDEN, true).build(), null, null);
|
||||
IndexTemplateV2 globalTemplate = new IndexTemplateV2(org.elasticsearch.common.collect.List.of("*"), template, null, null, null,
|
||||
null, null);
|
||||
ComposableIndexTemplate globalTemplate = new ComposableIndexTemplate(Collections.singletonList("*"),
|
||||
template, null, null, null, null, null);
|
||||
|
||||
PutIndexTemplateV2Action.Request request = new PutIndexTemplateV2Action.Request("test");
|
||||
PutComposableIndexTemplateAction.Request request = new PutComposableIndexTemplateAction.Request("test");
|
||||
request.indexTemplate(globalTemplate);
|
||||
|
||||
SimulateIndexTemplateRequest simulateRequest = new SimulateIndexTemplateRequest("testing");
|
||||
@ -77,6 +78,6 @@ public class SimulateIndexTemplateRequestTests extends AbstractWireSerializingTe
|
||||
List<String> validationErrors = validationException.validationErrors();
|
||||
assertThat(validationErrors.size(), is(1));
|
||||
String error = validationErrors.get(0);
|
||||
assertThat(error, is("global V2 templates may not specify the setting " + IndexMetadata.SETTING_INDEX_HIDDEN));
|
||||
assertThat(error, is("global composable templates may not specify the setting " + IndexMetadata.SETTING_INDEX_HIDDEN));
|
||||
}
|
||||
}
|
||||
|
@ -20,10 +20,10 @@
|
||||
package org.elasticsearch.action.admin.indices.template.post;
|
||||
|
||||
import org.elasticsearch.action.ActionRequestValidationException;
|
||||
import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateV2Action;
|
||||
import org.elasticsearch.action.admin.indices.template.put.PutComposableIndexTemplateAction;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetadata;
|
||||
import org.elasticsearch.cluster.metadata.IndexTemplateV2;
|
||||
import org.elasticsearch.cluster.metadata.IndexTemplateV2Tests;
|
||||
import org.elasticsearch.cluster.metadata.ComposableIndexTemplate;
|
||||
import org.elasticsearch.cluster.metadata.ComposableIndexTemplateTests;
|
||||
import org.elasticsearch.cluster.metadata.Template;
|
||||
import org.elasticsearch.common.io.stream.Writeable;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
@ -46,8 +46,8 @@ public class SimulateTemplateRequestTests extends AbstractWireSerializingTestCas
|
||||
@Override
|
||||
protected SimulateTemplateAction.Request createTestInstance() {
|
||||
SimulateTemplateAction.Request req = new SimulateTemplateAction.Request(randomAlphaOfLength(10));
|
||||
PutIndexTemplateV2Action.Request newTemplateRequest = new PutIndexTemplateV2Action.Request(randomAlphaOfLength(4));
|
||||
newTemplateRequest.indexTemplate(IndexTemplateV2Tests.randomInstance());
|
||||
PutComposableIndexTemplateAction.Request newTemplateRequest = new PutComposableIndexTemplateAction.Request(randomAlphaOfLength(4));
|
||||
newTemplateRequest.indexTemplate(ComposableIndexTemplateTests.randomInstance());
|
||||
req.indexTemplateRequest(newTemplateRequest);
|
||||
return req;
|
||||
}
|
||||
@ -59,14 +59,16 @@ public class SimulateTemplateRequestTests extends AbstractWireSerializingTestCas
|
||||
|
||||
public void testIndexNameCannotBeNullOrEmpty() {
|
||||
expectThrows(IllegalArgumentException.class, () -> new SimulateTemplateAction.Request((String) null));
|
||||
expectThrows(IllegalArgumentException.class, () -> new SimulateTemplateAction.Request((PutIndexTemplateV2Action.Request) null));
|
||||
expectThrows(IllegalArgumentException.class,
|
||||
() -> new SimulateTemplateAction.Request((PutComposableIndexTemplateAction.Request) null));
|
||||
}
|
||||
|
||||
public void testAddingGlobalTemplateWithHiddenIndexSettingIsIllegal() {
|
||||
Template template = new Template(Settings.builder().put(IndexMetadata.SETTING_INDEX_HIDDEN, true).build(), null, null);
|
||||
IndexTemplateV2 globalTemplate = new IndexTemplateV2(Collections.singletonList("*"), template, null, null, null, null, null);
|
||||
ComposableIndexTemplate globalTemplate = new ComposableIndexTemplate(Collections.singletonList("*"),
|
||||
template, null, null, null, null, null);
|
||||
|
||||
PutIndexTemplateV2Action.Request request = new PutIndexTemplateV2Action.Request("test");
|
||||
PutComposableIndexTemplateAction.Request request = new PutComposableIndexTemplateAction.Request("test");
|
||||
request.indexTemplate(globalTemplate);
|
||||
|
||||
SimulateTemplateAction.Request simulateRequest = new SimulateTemplateAction.Request("testing");
|
||||
@ -77,6 +79,6 @@ public class SimulateTemplateRequestTests extends AbstractWireSerializingTestCas
|
||||
List<String> validationErrors = validationException.validationErrors();
|
||||
assertThat(validationErrors.size(), is(1));
|
||||
String error = validationErrors.get(0);
|
||||
assertThat(error, is("global V2 templates may not specify the setting " + IndexMetadata.SETTING_INDEX_HIDDEN));
|
||||
assertThat(error, is("global composable templates may not specify the setting " + IndexMetadata.SETTING_INDEX_HIDDEN));
|
||||
}
|
||||
}
|
||||
|
@ -21,8 +21,8 @@ package org.elasticsearch.action.admin.indices.template.put;
|
||||
|
||||
import org.elasticsearch.action.ActionRequestValidationException;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetadata;
|
||||
import org.elasticsearch.cluster.metadata.IndexTemplateV2;
|
||||
import org.elasticsearch.cluster.metadata.IndexTemplateV2Tests;
|
||||
import org.elasticsearch.cluster.metadata.ComposableIndexTemplate;
|
||||
import org.elasticsearch.cluster.metadata.ComposableIndexTemplateTests;
|
||||
import org.elasticsearch.cluster.metadata.Template;
|
||||
import org.elasticsearch.common.io.stream.Writeable;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
@ -35,32 +35,33 @@ import java.util.List;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
|
||||
public class PutIndexTemplateV2RequestTests extends AbstractWireSerializingTestCase<PutIndexTemplateV2Action.Request> {
|
||||
public class PutComposableIndexTemplateRequestTests extends AbstractWireSerializingTestCase<PutComposableIndexTemplateAction.Request> {
|
||||
@Override
|
||||
protected Writeable.Reader<PutIndexTemplateV2Action.Request> instanceReader() {
|
||||
return PutIndexTemplateV2Action.Request::new;
|
||||
protected Writeable.Reader<PutComposableIndexTemplateAction.Request> instanceReader() {
|
||||
return PutComposableIndexTemplateAction.Request::new;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PutIndexTemplateV2Action.Request createTestInstance() {
|
||||
PutIndexTemplateV2Action.Request req = new PutIndexTemplateV2Action.Request(randomAlphaOfLength(4));
|
||||
protected PutComposableIndexTemplateAction.Request createTestInstance() {
|
||||
PutComposableIndexTemplateAction.Request req = new PutComposableIndexTemplateAction.Request(randomAlphaOfLength(4));
|
||||
req.cause(randomAlphaOfLength(4));
|
||||
req.create(randomBoolean());
|
||||
req.indexTemplate(IndexTemplateV2Tests.randomInstance());
|
||||
req.indexTemplate(ComposableIndexTemplateTests.randomInstance());
|
||||
return req;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PutIndexTemplateV2Action.Request mutateInstance(PutIndexTemplateV2Action.Request instance) throws IOException {
|
||||
protected PutComposableIndexTemplateAction.Request mutateInstance(PutComposableIndexTemplateAction.Request instance)
|
||||
throws IOException {
|
||||
return randomValueOtherThan(instance, this::createTestInstance);
|
||||
}
|
||||
|
||||
public void testPutGlobalTemplatesCannotHaveHiddenIndexSetting() {
|
||||
Template template = new Template(Settings.builder().put(IndexMetadata.SETTING_INDEX_HIDDEN, true).build(), null, null);
|
||||
IndexTemplateV2 globalTemplate = new IndexTemplateV2(org.elasticsearch.common.collect.List.of("*"), template, null, null, null,
|
||||
null, null);
|
||||
ComposableIndexTemplate globalTemplate = new ComposableIndexTemplate(org.elasticsearch.common.collect.List.of("*"),
|
||||
template, null, null, null, null, null);
|
||||
|
||||
PutIndexTemplateV2Action.Request request = new PutIndexTemplateV2Action.Request("test");
|
||||
PutComposableIndexTemplateAction.Request request = new PutComposableIndexTemplateAction.Request("test");
|
||||
request.indexTemplate(globalTemplate);
|
||||
|
||||
ActionRequestValidationException validationException = request.validate();
|
||||
@ -68,11 +69,11 @@ public class PutIndexTemplateV2RequestTests extends AbstractWireSerializingTestC
|
||||
List<String> validationErrors = validationException.validationErrors();
|
||||
assertThat(validationErrors.size(), is(1));
|
||||
String error = validationErrors.get(0);
|
||||
assertThat(error, is("global V2 templates may not specify the setting " + IndexMetadata.SETTING_INDEX_HIDDEN));
|
||||
assertThat(error, is("global composable templates may not specify the setting " + IndexMetadata.SETTING_INDEX_HIDDEN));
|
||||
}
|
||||
|
||||
public void testPutIndexTemplateV2RequestMustContainTemplate() {
|
||||
PutIndexTemplateV2Action.Request requestWithoutTemplate = new PutIndexTemplateV2Action.Request("test");
|
||||
PutComposableIndexTemplateAction.Request requestWithoutTemplate = new PutComposableIndexTemplateAction.Request("test");
|
||||
|
||||
ActionRequestValidationException validationException = requestWithoutTemplate.validate();
|
||||
assertThat(validationException, is(notNullValue()));
|
||||
@ -83,8 +84,8 @@ public class PutIndexTemplateV2RequestTests extends AbstractWireSerializingTestC
|
||||
}
|
||||
|
||||
public void testValidationOfPriority() {
|
||||
PutIndexTemplateV2Action.Request req = new PutIndexTemplateV2Action.Request("test");
|
||||
req.indexTemplate(new IndexTemplateV2(Arrays.asList("foo", "bar"), null, null, -5L, null, null, null));
|
||||
PutComposableIndexTemplateAction.Request req = new PutComposableIndexTemplateAction.Request("test");
|
||||
req.indexTemplate(new ComposableIndexTemplate(Arrays.asList("foo", "bar"), null, null, -5L, null, null, null));
|
||||
ActionRequestValidationException validationException = req.validate();
|
||||
assertThat(validationException, is(notNullValue()));
|
||||
List<String> validationErrors = validationException.validationErrors();
|
@ -36,7 +36,7 @@ import org.elasticsearch.cluster.metadata.AliasMetadata;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetadata;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.metadata.IndexTemplateMetadata;
|
||||
import org.elasticsearch.cluster.metadata.IndexTemplateV2;
|
||||
import org.elasticsearch.cluster.metadata.ComposableIndexTemplate;
|
||||
import org.elasticsearch.cluster.metadata.Metadata;
|
||||
import org.elasticsearch.cluster.metadata.Template;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||
@ -578,7 +578,7 @@ public class TransportBulkActionIngestTests extends ESTestCase {
|
||||
public void testFindDefaultPipelineFromV2TemplateMatch() {
|
||||
Exception exception = new Exception("fake exception");
|
||||
|
||||
IndexTemplateV2 t1 = new IndexTemplateV2(Collections.singletonList("missing_*"),
|
||||
ComposableIndexTemplate t1 = new ComposableIndexTemplate(Collections.singletonList("missing_*"),
|
||||
new Template(Settings.builder().put(IndexSettings.DEFAULT_PIPELINE.getKey(), "pipeline2").build(), null, null),
|
||||
null, null, null, null, null);
|
||||
|
||||
|
@ -27,32 +27,32 @@ import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class IndexTemplateV2MetadataTests extends AbstractNamedWriteableTestCase<IndexTemplateV2Metadata> {
|
||||
public class ComposableIndexTemplateMetadataTests extends AbstractNamedWriteableTestCase<ComposableIndexTemplateMetadata> {
|
||||
@Override
|
||||
protected IndexTemplateV2Metadata createTestInstance() {
|
||||
protected ComposableIndexTemplateMetadata createTestInstance() {
|
||||
if (randomBoolean()) {
|
||||
return new IndexTemplateV2Metadata(Collections.emptyMap());
|
||||
return new ComposableIndexTemplateMetadata(Collections.emptyMap());
|
||||
}
|
||||
Map<String, IndexTemplateV2> templates = new HashMap<>();
|
||||
Map<String, ComposableIndexTemplate> templates = new HashMap<>();
|
||||
for (int i = 0; i < randomIntBetween(1, 5); i++) {
|
||||
templates.put(randomAlphaOfLength(5), IndexTemplateV2Tests.randomInstance());
|
||||
templates.put(randomAlphaOfLength(5), ComposableIndexTemplateTests.randomInstance());
|
||||
}
|
||||
return new IndexTemplateV2Metadata(templates);
|
||||
return new ComposableIndexTemplateMetadata(templates);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IndexTemplateV2Metadata mutateInstance(IndexTemplateV2Metadata instance) throws IOException {
|
||||
protected ComposableIndexTemplateMetadata mutateInstance(ComposableIndexTemplateMetadata instance) throws IOException {
|
||||
return randomValueOtherThan(instance, this::createTestInstance);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NamedWriteableRegistry getNamedWriteableRegistry() {
|
||||
return new NamedWriteableRegistry(Collections.singletonList(new NamedWriteableRegistry.Entry(IndexTemplateV2Metadata.class,
|
||||
IndexTemplateV2Metadata.TYPE, IndexTemplateV2Metadata::new)));
|
||||
return new NamedWriteableRegistry(Collections.singletonList(new NamedWriteableRegistry.Entry(ComposableIndexTemplateMetadata.class,
|
||||
ComposableIndexTemplateMetadata.TYPE, ComposableIndexTemplateMetadata::new)));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<IndexTemplateV2Metadata> categoryClass() {
|
||||
return IndexTemplateV2Metadata.class;
|
||||
protected Class<ComposableIndexTemplateMetadata> categoryClass() {
|
||||
return ComposableIndexTemplateMetadata.class;
|
||||
}
|
||||
}
|
@ -32,9 +32,9 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class IndexTemplateV2Tests extends AbstractDiffableSerializationTestCase<IndexTemplateV2> {
|
||||
public class ComposableIndexTemplateTests extends AbstractDiffableSerializationTestCase<ComposableIndexTemplate> {
|
||||
@Override
|
||||
protected IndexTemplateV2 makeTestChanges(IndexTemplateV2 testInstance) {
|
||||
protected ComposableIndexTemplate makeTestChanges(ComposableIndexTemplate testInstance) {
|
||||
try {
|
||||
return mutateInstance(testInstance);
|
||||
} catch (IOException e) {
|
||||
@ -45,26 +45,26 @@ public class IndexTemplateV2Tests extends AbstractDiffableSerializationTestCase<
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Writeable.Reader<Diff<IndexTemplateV2>> diffReader() {
|
||||
return IndexTemplateV2::readITV2DiffFrom;
|
||||
protected Writeable.Reader<Diff<ComposableIndexTemplate>> diffReader() {
|
||||
return ComposableIndexTemplate::readITV2DiffFrom;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IndexTemplateV2 doParseInstance(XContentParser parser) throws IOException {
|
||||
return IndexTemplateV2.parse(parser);
|
||||
protected ComposableIndexTemplate doParseInstance(XContentParser parser) throws IOException {
|
||||
return ComposableIndexTemplate.parse(parser);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Writeable.Reader<IndexTemplateV2> instanceReader() {
|
||||
return IndexTemplateV2::new;
|
||||
protected Writeable.Reader<ComposableIndexTemplate> instanceReader() {
|
||||
return ComposableIndexTemplate::new;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IndexTemplateV2 createTestInstance() {
|
||||
protected ComposableIndexTemplate createTestInstance() {
|
||||
return randomInstance();
|
||||
}
|
||||
|
||||
public static IndexTemplateV2 randomInstance() {
|
||||
public static ComposableIndexTemplate randomInstance() {
|
||||
Settings settings = null;
|
||||
CompressedXContent mappings = null;
|
||||
Map<String, AliasMetadata> aliases = null;
|
||||
@ -87,11 +87,11 @@ public class IndexTemplateV2Tests extends AbstractDiffableSerializationTestCase<
|
||||
meta = randomMeta();
|
||||
}
|
||||
|
||||
IndexTemplateV2.DataStreamTemplate dataStreamTemplate = randomDataStreamTemplate();
|
||||
ComposableIndexTemplate.DataStreamTemplate dataStreamTemplate = randomDataStreamTemplate();
|
||||
|
||||
List<String> indexPatterns = randomList(1, 4, () -> randomAlphaOfLength(4));
|
||||
List<String> componentTemplates = randomList(0, 10, () -> randomAlphaOfLength(5));
|
||||
return new IndexTemplateV2(indexPatterns,
|
||||
return new ComposableIndexTemplate(indexPatterns,
|
||||
template,
|
||||
componentTemplates,
|
||||
randomBoolean() ? null : randomNonNegativeLong(),
|
||||
@ -140,28 +140,28 @@ public class IndexTemplateV2Tests extends AbstractDiffableSerializationTestCase<
|
||||
}
|
||||
}
|
||||
|
||||
private static IndexTemplateV2.DataStreamTemplate randomDataStreamTemplate() {
|
||||
private static ComposableIndexTemplate.DataStreamTemplate randomDataStreamTemplate() {
|
||||
if (randomBoolean()) {
|
||||
return null;
|
||||
} else {
|
||||
return new IndexTemplateV2.DataStreamTemplate(randomAlphaOfLength(8));
|
||||
return new ComposableIndexTemplate.DataStreamTemplate(randomAlphaOfLength(8));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IndexTemplateV2 mutateInstance(IndexTemplateV2 orig) throws IOException {
|
||||
protected ComposableIndexTemplate mutateInstance(ComposableIndexTemplate orig) throws IOException {
|
||||
return mutateTemplate(orig);
|
||||
}
|
||||
|
||||
public static IndexTemplateV2 mutateTemplate(IndexTemplateV2 orig) {
|
||||
public static ComposableIndexTemplate mutateTemplate(ComposableIndexTemplate orig) {
|
||||
switch (randomIntBetween(0, 6)) {
|
||||
case 0:
|
||||
List<String> newIndexPatterns = randomValueOtherThan(orig.indexPatterns(),
|
||||
() -> randomList(1, 4, () -> randomAlphaOfLength(4)));
|
||||
return new IndexTemplateV2(newIndexPatterns, orig.template(), orig.composedOf(),
|
||||
return new ComposableIndexTemplate(newIndexPatterns, orig.template(), orig.composedOf(),
|
||||
orig.priority(), orig.version(), orig.metadata(), orig.getDataStreamTemplate());
|
||||
case 1:
|
||||
return new IndexTemplateV2(orig.indexPatterns(),
|
||||
return new ComposableIndexTemplate(orig.indexPatterns(),
|
||||
randomValueOtherThan(orig.template(), () -> new Template(randomSettings(), randomMappings(), randomAliases())),
|
||||
orig.composedOf(),
|
||||
orig.priority(),
|
||||
@ -171,7 +171,7 @@ public class IndexTemplateV2Tests extends AbstractDiffableSerializationTestCase<
|
||||
case 2:
|
||||
List<String> newComposedOf = randomValueOtherThan(orig.composedOf(),
|
||||
() -> randomList(0, 10, () -> randomAlphaOfLength(5)));
|
||||
return new IndexTemplateV2(orig.indexPatterns(),
|
||||
return new ComposableIndexTemplate(orig.indexPatterns(),
|
||||
orig.template(),
|
||||
newComposedOf,
|
||||
orig.priority(),
|
||||
@ -179,7 +179,7 @@ public class IndexTemplateV2Tests extends AbstractDiffableSerializationTestCase<
|
||||
orig.metadata(),
|
||||
orig.getDataStreamTemplate());
|
||||
case 3:
|
||||
return new IndexTemplateV2(orig.indexPatterns(),
|
||||
return new ComposableIndexTemplate(orig.indexPatterns(),
|
||||
orig.template(),
|
||||
orig.composedOf(),
|
||||
randomValueOtherThan(orig.priority(), ESTestCase::randomNonNegativeLong),
|
||||
@ -187,7 +187,7 @@ public class IndexTemplateV2Tests extends AbstractDiffableSerializationTestCase<
|
||||
orig.metadata(),
|
||||
orig.getDataStreamTemplate());
|
||||
case 4:
|
||||
return new IndexTemplateV2(orig.indexPatterns(),
|
||||
return new ComposableIndexTemplate(orig.indexPatterns(),
|
||||
orig.template(),
|
||||
orig.composedOf(),
|
||||
orig.priority(),
|
||||
@ -195,21 +195,21 @@ public class IndexTemplateV2Tests extends AbstractDiffableSerializationTestCase<
|
||||
orig.metadata(),
|
||||
orig.getDataStreamTemplate());
|
||||
case 5:
|
||||
return new IndexTemplateV2(orig.indexPatterns(),
|
||||
return new ComposableIndexTemplate(orig.indexPatterns(),
|
||||
orig.template(),
|
||||
orig.composedOf(),
|
||||
orig.priority(),
|
||||
orig.version(),
|
||||
randomValueOtherThan(orig.metadata(), IndexTemplateV2Tests::randomMeta),
|
||||
randomValueOtherThan(orig.metadata(), ComposableIndexTemplateTests::randomMeta),
|
||||
orig.getDataStreamTemplate());
|
||||
case 6:
|
||||
return new IndexTemplateV2(orig.indexPatterns(),
|
||||
return new ComposableIndexTemplate(orig.indexPatterns(),
|
||||
orig.template(),
|
||||
orig.composedOf(),
|
||||
orig.priority(),
|
||||
orig.version(),
|
||||
orig.metadata(),
|
||||
randomValueOtherThan(orig.getDataStreamTemplate(), IndexTemplateV2Tests::randomDataStreamTemplate));
|
||||
randomValueOtherThan(orig.getDataStreamTemplate(), ComposableIndexTemplateTests::randomDataStreamTemplate));
|
||||
default:
|
||||
throw new IllegalStateException("illegal randomization branch");
|
||||
}
|
@ -1016,7 +1016,8 @@ public class MetadataCreateIndexServiceTests extends ESTestCase {
|
||||
boolean shouldBeText = randomBoolean();
|
||||
List<String> composedOf = shouldBeText ? Arrays.asList("ct2", "ct1") : Arrays.asList("ct1", "ct2");
|
||||
logger.info("--> the {} analyzer should win ({})", shouldBeText ? "text" : "keyword", composedOf);
|
||||
IndexTemplateV2 template = new IndexTemplateV2(Collections.singletonList("index"), null, composedOf, null, null, null, null);
|
||||
ComposableIndexTemplate template = new ComposableIndexTemplate(Collections.singletonList("index"),
|
||||
null, composedOf, null, null, null, null);
|
||||
|
||||
ClusterState state = ClusterState.builder(ClusterState.EMPTY_STATE)
|
||||
.metadata(Metadata.builder(Metadata.EMPTY_METADATA)
|
||||
@ -1074,8 +1075,8 @@ public class MetadataCreateIndexServiceTests extends ESTestCase {
|
||||
ComponentTemplate ct1 = new ComponentTemplate(ctt1, null, null);
|
||||
ComponentTemplate ct2 = new ComponentTemplate(ctt2, null, null);
|
||||
|
||||
IndexTemplateV2 template = new IndexTemplateV2(Collections.singletonList("index"), null, Arrays.asList("ct2", "ct1"),
|
||||
null, null, null, null);
|
||||
ComposableIndexTemplate template = new ComposableIndexTemplate(Collections.singletonList("index"),
|
||||
null, Arrays.asList("ct2", "ct1"), null, null, null, null);
|
||||
|
||||
ClusterState state = ClusterState.builder(ClusterState.EMPTY_STATE)
|
||||
.metadata(Metadata.builder(Metadata.EMPTY_METADATA)
|
||||
|
@ -307,19 +307,19 @@ public class MetadataIndexTemplateServiceTests extends ESSingleNodeTestCase {
|
||||
state = metadataIndexTemplateService.addComponentTemplate(state, true, "foo", componentTemplate);
|
||||
assertNotNull(state.metadata().componentTemplates().get("foo"));
|
||||
|
||||
IndexTemplateV2 firstGlobalIndexTemplate =
|
||||
new IndexTemplateV2(org.elasticsearch.common.collect.List.of("*"), template, org.elasticsearch.common.collect.List.of("foo"),
|
||||
1L, null, null, null);
|
||||
ComposableIndexTemplate firstGlobalIndexTemplate =
|
||||
new ComposableIndexTemplate(org.elasticsearch.common.collect.List.of("*"), template,
|
||||
org.elasticsearch.common.collect.List.of("foo"), 1L, null, null, null);
|
||||
state = metadataIndexTemplateService.addIndexTemplateV2(state, true, "globalindextemplate1", firstGlobalIndexTemplate);
|
||||
|
||||
IndexTemplateV2 secondGlobalIndexTemplate =
|
||||
new IndexTemplateV2(org.elasticsearch.common.collect.List.of("*"), template, org.elasticsearch.common.collect.List.of("foo"),
|
||||
2L, null, null, null);
|
||||
ComposableIndexTemplate secondGlobalIndexTemplate =
|
||||
new ComposableIndexTemplate(org.elasticsearch.common.collect.List.of("*"), template,
|
||||
org.elasticsearch.common.collect.List.of("foo"), 2L, null, null, null);
|
||||
state = metadataIndexTemplateService.addIndexTemplateV2(state, true, "globalindextemplate2", secondGlobalIndexTemplate);
|
||||
|
||||
IndexTemplateV2 fooPatternIndexTemplate =
|
||||
new IndexTemplateV2(org.elasticsearch.common.collect.List.of("foo-*"), template, org.elasticsearch.common.collect.List.of(
|
||||
"foo"), 3L, null, null, null);
|
||||
ComposableIndexTemplate fooPatternIndexTemplate =
|
||||
new ComposableIndexTemplate(org.elasticsearch.common.collect.List.of("foo-*"), template,
|
||||
org.elasticsearch.common.collect.List.of("foo"), 3L, null, null, null);
|
||||
state = metadataIndexTemplateService.addIndexTemplateV2(state, true, "foopatternindextemplate", fooPatternIndexTemplate);
|
||||
|
||||
// update the component template to set the index.hidden setting
|
||||
@ -340,15 +340,15 @@ public class MetadataIndexTemplateServiceTests extends ESSingleNodeTestCase {
|
||||
public void testAddIndexTemplateV2() throws Exception {
|
||||
ClusterState state = ClusterState.EMPTY_STATE;
|
||||
final MetadataIndexTemplateService metadataIndexTemplateService = getMetadataIndexTemplateService();
|
||||
IndexTemplateV2 template = IndexTemplateV2Tests.randomInstance();
|
||||
ComposableIndexTemplate template = ComposableIndexTemplateTests.randomInstance();
|
||||
state = metadataIndexTemplateService.addIndexTemplateV2(state, false, "foo", template);
|
||||
|
||||
assertNotNull(state.metadata().templatesV2().get("foo"));
|
||||
assertTemplatesEqual(state.metadata().templatesV2().get("foo"), template);
|
||||
|
||||
|
||||
IndexTemplateV2 newTemplate = randomValueOtherThanMany(t -> Objects.equals(template.priority(), t.priority()),
|
||||
IndexTemplateV2Tests::randomInstance);
|
||||
ComposableIndexTemplate newTemplate = randomValueOtherThanMany(t -> Objects.equals(template.priority(), t.priority()),
|
||||
ComposableIndexTemplateTests::randomInstance);
|
||||
|
||||
final ClusterState throwState = ClusterState.builder(state).build();
|
||||
IllegalArgumentException e = expectThrows(IllegalArgumentException.class,
|
||||
@ -362,7 +362,7 @@ public class MetadataIndexTemplateServiceTests extends ESSingleNodeTestCase {
|
||||
public void testUpdateIndexTemplateV2() throws Exception {
|
||||
ClusterState state = ClusterState.EMPTY_STATE;
|
||||
final MetadataIndexTemplateService metadataIndexTemplateService = getMetadataIndexTemplateService();
|
||||
IndexTemplateV2 template = IndexTemplateV2Tests.randomInstance();
|
||||
ComposableIndexTemplate template = ComposableIndexTemplateTests.randomInstance();
|
||||
state = metadataIndexTemplateService.addIndexTemplateV2(state, false, "foo", template);
|
||||
|
||||
assertNotNull(state.metadata().templatesV2().get("foo"));
|
||||
@ -370,8 +370,8 @@ public class MetadataIndexTemplateServiceTests extends ESSingleNodeTestCase {
|
||||
|
||||
List<String> patterns = new ArrayList<>(template.indexPatterns());
|
||||
patterns.add("new-pattern");
|
||||
template = new IndexTemplateV2(patterns, template.template(), template.composedOf(), template.priority(), template.version(),
|
||||
template.metadata(), null);
|
||||
template = new ComposableIndexTemplate(patterns, template.template(), template.composedOf(), template.priority(),
|
||||
template.version(), template.metadata(), null);
|
||||
state = metadataIndexTemplateService.addIndexTemplateV2(state, false, "foo", template);
|
||||
|
||||
assertNotNull(state.metadata().templatesV2().get("foo"));
|
||||
@ -379,7 +379,7 @@ public class MetadataIndexTemplateServiceTests extends ESSingleNodeTestCase {
|
||||
}
|
||||
|
||||
public void testRemoveIndexTemplateV2() throws Exception {
|
||||
IndexTemplateV2 template = IndexTemplateV2Tests.randomInstance();
|
||||
ComposableIndexTemplate template = ComposableIndexTemplateTests.randomInstance();
|
||||
final MetadataIndexTemplateService metadataIndexTemplateService = getMetadataIndexTemplateService();
|
||||
IndexTemplateMissingException e = expectThrows(IndexTemplateMissingException.class,
|
||||
() -> MetadataIndexTemplateService.innerRemoveIndexTemplateV2(ClusterState.EMPTY_STATE, "foo"));
|
||||
@ -408,7 +408,8 @@ public class MetadataIndexTemplateServiceTests extends ESSingleNodeTestCase {
|
||||
.build())
|
||||
.build();
|
||||
|
||||
IndexTemplateV2 v2Template = new IndexTemplateV2(Arrays.asList("foo-bar-*", "eggplant"), null, null, null, null, null, null);
|
||||
ComposableIndexTemplate v2Template = new ComposableIndexTemplate(Arrays.asList("foo-bar-*", "eggplant"),
|
||||
null, null, null, null, null, null);
|
||||
state = metadataIndexTemplateService.addIndexTemplateV2(state, false, "v2-template", v2Template);
|
||||
|
||||
assertWarnings("index template [v2-template] has index patterns [foo-bar-*, eggplant] matching patterns " +
|
||||
@ -444,8 +445,8 @@ public class MetadataIndexTemplateServiceTests extends ESSingleNodeTestCase {
|
||||
|
||||
waitToCreateComponentTemplate.await(10, TimeUnit.SECONDS);
|
||||
|
||||
IndexTemplateV2 globalIndexTemplate = new IndexTemplateV2(org.elasticsearch.common.collect.List.of("*"), null,
|
||||
org.elasticsearch.common.collect.List.of("ct-with-index-hidden-setting"), null, null, null, null);
|
||||
ComposableIndexTemplate globalIndexTemplate = new ComposableIndexTemplate(org.elasticsearch.common.collect.List.of("*"),
|
||||
null, org.elasticsearch.common.collect.List.of("ct-with-index-hidden-setting"), null, null, null, null);
|
||||
|
||||
expectThrows(InvalidIndexTemplateException.class, () ->
|
||||
metadataIndexTemplateService.putIndexTemplateV2("testing", true, "template-referencing-ct-with-hidden-index-setting",
|
||||
@ -469,16 +470,17 @@ public class MetadataIndexTemplateServiceTests extends ESSingleNodeTestCase {
|
||||
*/
|
||||
public void testPuttingV1StarTemplateGeneratesWarning() throws Exception {
|
||||
final MetadataIndexTemplateService metadataIndexTemplateService = getMetadataIndexTemplateService();
|
||||
IndexTemplateV2 v2Template = new IndexTemplateV2(Arrays.asList("foo-bar-*", "eggplant"), null, null, null, null, null, null);
|
||||
ComposableIndexTemplate v2Template = new ComposableIndexTemplate(Arrays.asList("foo-bar-*", "eggplant"),
|
||||
null, null, null, null, null, null);
|
||||
ClusterState state = metadataIndexTemplateService.addIndexTemplateV2(ClusterState.EMPTY_STATE, false, "v2-template", v2Template);
|
||||
|
||||
MetadataIndexTemplateService.PutRequest req = new MetadataIndexTemplateService.PutRequest("cause", "v1-template");
|
||||
req.patterns(Arrays.asList("*", "baz"));
|
||||
state = MetadataIndexTemplateService.innerPutTemplate(state, req, IndexTemplateMetadata.builder("v1-template"));
|
||||
|
||||
assertWarnings("template [v1-template] has index patterns [*, baz] matching patterns from existing " +
|
||||
"index templates [v2-template] with patterns (v2-template => [foo-bar-*, eggplant]); this template [v1-template] may " +
|
||||
"be ignored in favor of an index template at index creation time");
|
||||
assertWarnings("legacy template [v1-template] has index patterns [*, baz] matching patterns from existing " +
|
||||
"composable templates [v2-template] with patterns (v2-template => [foo-bar-*, eggplant]); this template [v1-template] may " +
|
||||
"be ignored in favor of a composable template at index creation time");
|
||||
|
||||
assertNotNull(state.metadata().templates().get("v1-template"));
|
||||
assertThat(state.metadata().templates().get("v1-template").patterns(), containsInAnyOrder("*", "baz"));
|
||||
@ -489,16 +491,17 @@ public class MetadataIndexTemplateServiceTests extends ESSingleNodeTestCase {
|
||||
*/
|
||||
public void testPuttingV1NonStarTemplateGeneratesWarning() throws Exception {
|
||||
final MetadataIndexTemplateService metadataIndexTemplateService = getMetadataIndexTemplateService();
|
||||
IndexTemplateV2 v2Template = new IndexTemplateV2(Arrays.asList("foo-bar-*", "eggplant"), null, null, null, null, null, null);
|
||||
ComposableIndexTemplate v2Template = new ComposableIndexTemplate(Arrays.asList("foo-bar-*", "eggplant"),
|
||||
null, null, null, null, null, null);
|
||||
ClusterState state = metadataIndexTemplateService.addIndexTemplateV2(ClusterState.EMPTY_STATE, false, "v2-template", v2Template);
|
||||
|
||||
MetadataIndexTemplateService.PutRequest req = new MetadataIndexTemplateService.PutRequest("cause", "v1-template");
|
||||
req.patterns(Arrays.asList("egg*", "baz"));
|
||||
MetadataIndexTemplateService.innerPutTemplate(state, req, IndexTemplateMetadata.builder("v1-template"));
|
||||
|
||||
assertWarnings("template [v1-template] has index patterns [egg*, baz] matching patterns " +
|
||||
"from existing index templates [v2-template] with patterns (v2-template => [foo-bar-*, eggplant]);" +
|
||||
" this template [v1-template] may be ignored in favor of an index template at index creation time");
|
||||
assertWarnings("legacy template [v1-template] has index patterns [egg*, baz] matching patterns " +
|
||||
"from existing composable templates [v2-template] with patterns (v2-template => [foo-bar-*, eggplant]);" +
|
||||
" this template [v1-template] may be ignored in favor of a composable template at index creation time");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -518,7 +521,8 @@ public class MetadataIndexTemplateServiceTests extends ESSingleNodeTestCase {
|
||||
.build())
|
||||
.build();
|
||||
|
||||
IndexTemplateV2 v2Template = new IndexTemplateV2(Arrays.asList("foo-bar-*", "eggplant"), null, null, null, null, null, null);
|
||||
ComposableIndexTemplate v2Template = new ComposableIndexTemplate(Arrays.asList("foo-bar-*", "eggplant"),
|
||||
null, null, null, null, null, null);
|
||||
state = metadataIndexTemplateService.addIndexTemplateV2(state, false, "v2-template", v2Template);
|
||||
|
||||
assertWarnings("index template [v2-template] has index patterns [foo-bar-*, eggplant] matching patterns " +
|
||||
@ -534,9 +538,9 @@ public class MetadataIndexTemplateServiceTests extends ESSingleNodeTestCase {
|
||||
req.patterns(Arrays.asList("fo*", "baz"));
|
||||
state = MetadataIndexTemplateService.innerPutTemplate(state, req, IndexTemplateMetadata.builder("v1-template"));
|
||||
|
||||
assertWarnings("template [v1-template] has index patterns [fo*, baz] matching patterns from existing " +
|
||||
"index templates [v2-template] with patterns (v2-template => [foo-bar-*, eggplant]); this template [v1-template] may " +
|
||||
"be ignored in favor of an index template at index creation time");
|
||||
assertWarnings("legacy template [v1-template] has index patterns [fo*, baz] matching patterns from existing " +
|
||||
"composable templates [v2-template] with patterns (v2-template => [foo-bar-*, eggplant]); this template [v1-template] may " +
|
||||
"be ignored in favor of a composable template at index creation time");
|
||||
|
||||
assertNotNull(state.metadata().templates().get("v1-template"));
|
||||
assertThat(state.metadata().templates().get("v1-template").patterns(), containsInAnyOrder("fo*", "baz"));
|
||||
@ -558,7 +562,8 @@ public class MetadataIndexTemplateServiceTests extends ESSingleNodeTestCase {
|
||||
.build())
|
||||
.build();
|
||||
|
||||
IndexTemplateV2 v2Template = new IndexTemplateV2(Arrays.asList("foo-bar-*", "eggplant"), null, null, null, null, null, null);
|
||||
ComposableIndexTemplate v2Template = new ComposableIndexTemplate(Arrays.asList("foo-bar-*", "eggplant"),
|
||||
null, null, null, null, null, null);
|
||||
state = metadataIndexTemplateService.addIndexTemplateV2(state, false, "v2-template", v2Template);
|
||||
|
||||
assertWarnings("index template [v2-template] has index patterns [foo-bar-*, eggplant] matching patterns " +
|
||||
@ -575,17 +580,19 @@ public class MetadataIndexTemplateServiceTests extends ESSingleNodeTestCase {
|
||||
final ClusterState finalState = state;
|
||||
MetadataIndexTemplateService.innerPutTemplate(finalState, req, IndexTemplateMetadata.builder("v1-template"));
|
||||
|
||||
assertWarnings("template [v1-template] has index patterns [egg*, baz] matching patterns " +
|
||||
"from existing index templates [v2-template] with patterns (v2-template => [foo-bar-*, eggplant]); " +
|
||||
"this template [v1-template] may be ignored in favor of an index template at index creation time");
|
||||
assertWarnings("legacy template [v1-template] has index patterns [egg*, baz] matching patterns " +
|
||||
"from existing composable templates [v2-template] with patterns (v2-template => [foo-bar-*, eggplant]); " +
|
||||
"this template [v1-template] may be ignored in favor of a composable template at index creation time");
|
||||
}
|
||||
|
||||
public void testPuttingOverlappingV2Template() throws Exception {
|
||||
{
|
||||
IndexTemplateV2 template = new IndexTemplateV2(Arrays.asList("egg*", "baz"), null, null, 1L, null, null, null);
|
||||
ComposableIndexTemplate template = new ComposableIndexTemplate(Arrays.asList("egg*", "baz"),
|
||||
null, null, 1L, null, null, null);
|
||||
MetadataIndexTemplateService metadataIndexTemplateService = getMetadataIndexTemplateService();
|
||||
ClusterState state = metadataIndexTemplateService.addIndexTemplateV2(ClusterState.EMPTY_STATE, false, "foo", template);
|
||||
IndexTemplateV2 newTemplate = new IndexTemplateV2(Arrays.asList("abc", "baz*"), null, null, 1L, null, null, null);
|
||||
ComposableIndexTemplate newTemplate = new ComposableIndexTemplate(Arrays.asList("abc", "baz*"),
|
||||
null, null, 1L, null, null, null);
|
||||
IllegalArgumentException e = expectThrows(IllegalArgumentException.class,
|
||||
() -> metadataIndexTemplateService.addIndexTemplateV2(state, false, "foo2", newTemplate));
|
||||
assertThat(e.getMessage(), equalTo("index template [foo2] has index patterns [abc, baz*] matching patterns from existing " +
|
||||
@ -594,10 +601,12 @@ public class MetadataIndexTemplateServiceTests extends ESSingleNodeTestCase {
|
||||
}
|
||||
|
||||
{
|
||||
IndexTemplateV2 template = new IndexTemplateV2(Arrays.asList("egg*", "baz"), null, null, null, null, null, null);
|
||||
ComposableIndexTemplate template = new ComposableIndexTemplate(Arrays.asList("egg*", "baz"),
|
||||
null, null, null, null, null, null);
|
||||
MetadataIndexTemplateService metadataIndexTemplateService = getMetadataIndexTemplateService();
|
||||
ClusterState state = metadataIndexTemplateService.addIndexTemplateV2(ClusterState.EMPTY_STATE, false, "foo", template);
|
||||
IndexTemplateV2 newTemplate = new IndexTemplateV2(Arrays.asList("abc", "baz*"), null, null, 0L, null, null, null);
|
||||
ComposableIndexTemplate newTemplate = new ComposableIndexTemplate(Arrays.asList("abc", "baz*"),
|
||||
null, null, 0L, null, null, null);
|
||||
IllegalArgumentException e = expectThrows(IllegalArgumentException.class,
|
||||
() -> metadataIndexTemplateService.addIndexTemplateV2(state, false, "foo2", newTemplate));
|
||||
assertThat(e.getMessage(), equalTo("index template [foo2] has index patterns [abc, baz*] matching patterns from existing " +
|
||||
@ -613,11 +622,11 @@ public class MetadataIndexTemplateServiceTests extends ESSingleNodeTestCase {
|
||||
|
||||
ComponentTemplate ct = ComponentTemplateTests.randomInstance();
|
||||
state = service.addComponentTemplate(state, true, "ct", ct);
|
||||
IndexTemplateV2 it =
|
||||
new IndexTemplateV2(Collections.singletonList("i*"), null, Collections.singletonList("ct"), null, 1L, null, null);
|
||||
ComposableIndexTemplate it = new ComposableIndexTemplate(Collections.singletonList("i*"),
|
||||
null, Collections.singletonList("ct"), null, 1L, null, null);
|
||||
state = service.addIndexTemplateV2(state, true, "my-template", it);
|
||||
IndexTemplateV2 it2 =
|
||||
new IndexTemplateV2(Collections.singletonList("in*"), null, Collections.singletonList("ct"), 10L, 2L, null, null);
|
||||
ComposableIndexTemplate it2 = new ComposableIndexTemplate(Collections.singletonList("in*"),
|
||||
null, Collections.singletonList("ct"), 10L, 2L, null, null);
|
||||
state = service.addIndexTemplateV2(state, true, "my-template2", it2);
|
||||
|
||||
String result = MetadataIndexTemplateService.findV2Template(state.metadata(), "index", randomBoolean());
|
||||
@ -632,11 +641,11 @@ public class MetadataIndexTemplateServiceTests extends ESSingleNodeTestCase {
|
||||
|
||||
ComponentTemplate ct = ComponentTemplateTests.randomInstance();
|
||||
state = service.addComponentTemplate(state, true, "ct", ct);
|
||||
IndexTemplateV2 it =
|
||||
new IndexTemplateV2(Collections.singletonList("i*"), null, Collections.singletonList("ct"), 0L, 1L, null, null);
|
||||
ComposableIndexTemplate it = new ComposableIndexTemplate(Collections.singletonList("i*"),
|
||||
null, Collections.singletonList("ct"), 0L, 1L, null, null);
|
||||
state = service.addIndexTemplateV2(state, true, "my-template", it);
|
||||
IndexTemplateV2 it2 =
|
||||
new IndexTemplateV2(Collections.singletonList("*"), null, Collections.singletonList("ct"), 10L, 2L, null, null);
|
||||
ComposableIndexTemplate it2 = new ComposableIndexTemplate(Collections.singletonList("*"),
|
||||
null, Collections.singletonList("ct"), 10L, 2L, null, null);
|
||||
state = service.addIndexTemplateV2(state, true, "my-template2", it2);
|
||||
|
||||
String result = MetadataIndexTemplateService.findV2Template(state.metadata(), "index", true);
|
||||
@ -648,11 +657,11 @@ public class MetadataIndexTemplateServiceTests extends ESSingleNodeTestCase {
|
||||
Template templateWithHiddenSetting = new Template(builder().put(IndexMetadata.SETTING_INDEX_HIDDEN, true).build(), null, null);
|
||||
try {
|
||||
// add an invalid global template that specifies the `index.hidden` setting
|
||||
IndexTemplateV2 invalidGlobalTemplate = new IndexTemplateV2(org.elasticsearch.common.collect.List.of("*"),
|
||||
ComposableIndexTemplate invalidGlobalTemplate = new ComposableIndexTemplate(org.elasticsearch.common.collect.List.of("*"),
|
||||
templateWithHiddenSetting, org.elasticsearch.common.collect.List.of("ct"), 5L, 1L, null, null);
|
||||
Metadata invalidGlobalTemplateMetadata = Metadata.builder().putCustom(IndexTemplateV2Metadata.TYPE,
|
||||
new IndexTemplateV2Metadata(org.elasticsearch.common.collect.Map.of("invalid_global_template", invalidGlobalTemplate)))
|
||||
.build();
|
||||
Metadata invalidGlobalTemplateMetadata = Metadata.builder().putCustom(ComposableIndexTemplateMetadata.TYPE,
|
||||
new ComposableIndexTemplateMetadata(org.elasticsearch.common.collect.Map.of("invalid_global_template",
|
||||
invalidGlobalTemplate))).build();
|
||||
|
||||
MetadataIndexTemplateService.findV2Template(invalidGlobalTemplateMetadata, "index-name", false);
|
||||
fail("expecting an exception as the matching global template is invalid");
|
||||
@ -684,7 +693,7 @@ public class MetadataIndexTemplateServiceTests extends ESSingleNodeTestCase {
|
||||
" }"), null), null, null);
|
||||
state = service.addComponentTemplate(state, true, "ct_high", ct1);
|
||||
state = service.addComponentTemplate(state, true, "ct_low", ct2);
|
||||
IndexTemplateV2 it = new IndexTemplateV2(Collections.singletonList("i*"),
|
||||
ComposableIndexTemplate it = new ComposableIndexTemplate(Collections.singletonList("i*"),
|
||||
new Template(null,
|
||||
new CompressedXContent("{\n" +
|
||||
" \"properties\": {\n" +
|
||||
@ -744,7 +753,7 @@ public class MetadataIndexTemplateServiceTests extends ESSingleNodeTestCase {
|
||||
null, null), null, null);
|
||||
state = service.addComponentTemplate(state, true, "ct_high", ct1);
|
||||
state = service.addComponentTemplate(state, true, "ct_low", ct2);
|
||||
IndexTemplateV2 it = new IndexTemplateV2(Collections.singletonList("i*"),
|
||||
ComposableIndexTemplate it = new ComposableIndexTemplate(Collections.singletonList("i*"),
|
||||
new Template(Settings.builder()
|
||||
.put("index.blocks.write", false)
|
||||
.put("index.number_of_shards", 3)
|
||||
@ -775,7 +784,7 @@ public class MetadataIndexTemplateServiceTests extends ESSingleNodeTestCase {
|
||||
ComponentTemplate ct2 = new ComponentTemplate(new Template(null, null, a2), null, null);
|
||||
state = service.addComponentTemplate(state, true, "ct_high", ct1);
|
||||
state = service.addComponentTemplate(state, true, "ct_low", ct2);
|
||||
IndexTemplateV2 it = new IndexTemplateV2(Collections.singletonList("i*"),
|
||||
ComposableIndexTemplate it = new ComposableIndexTemplate(Collections.singletonList("i*"),
|
||||
new Template(null, null, a3),
|
||||
Arrays.asList("ct_low", "ct_high"), 0L, 1L, null, null);
|
||||
state = service.addIndexTemplateV2(state, true, "my-template", it);
|
||||
@ -787,7 +796,7 @@ public class MetadataIndexTemplateServiceTests extends ESSingleNodeTestCase {
|
||||
}
|
||||
|
||||
public void testAddInvalidTemplate() throws Exception {
|
||||
IndexTemplateV2 template = new IndexTemplateV2(Collections.singletonList("a"), null,
|
||||
ComposableIndexTemplate template = new ComposableIndexTemplate(Collections.singletonList("a"), null,
|
||||
Arrays.asList("good", "bad"), null, null, null);
|
||||
ComponentTemplate ct = new ComponentTemplate(new Template(Settings.EMPTY, null, null), null, null);
|
||||
|
||||
@ -820,7 +829,7 @@ public class MetadataIndexTemplateServiceTests extends ESSingleNodeTestCase {
|
||||
}
|
||||
|
||||
public void testRemoveComponentTemplateInUse() throws Exception {
|
||||
IndexTemplateV2 template = new IndexTemplateV2(Collections.singletonList("a"), null,
|
||||
ComposableIndexTemplate template = new ComposableIndexTemplate(Collections.singletonList("a"), null,
|
||||
Collections.singletonList("ct"), null, null, null);
|
||||
ComponentTemplate ct = new ComponentTemplate(new Template(null, new CompressedXContent("{}"), null), null, null);
|
||||
|
||||
@ -928,10 +937,10 @@ public class MetadataIndexTemplateServiceTests extends ESSingleNodeTestCase {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void assertTemplatesEqual(IndexTemplateV2 actual, IndexTemplateV2 expected) {
|
||||
IndexTemplateV2 actualNoTemplate = new IndexTemplateV2(actual.indexPatterns(), null,
|
||||
public static void assertTemplatesEqual(ComposableIndexTemplate actual, ComposableIndexTemplate expected) {
|
||||
ComposableIndexTemplate actualNoTemplate = new ComposableIndexTemplate(actual.indexPatterns(), null,
|
||||
actual.composedOf(), actual.priority(), actual.version(), actual.metadata(), actual.getDataStreamTemplate());
|
||||
IndexTemplateV2 expectedNoTemplate = new IndexTemplateV2(expected.indexPatterns(), null,
|
||||
ComposableIndexTemplate expectedNoTemplate = new ComposableIndexTemplate(expected.indexPatterns(), null,
|
||||
expected.composedOf(), expected.priority(), expected.version(), expected.metadata(), expected.getDataStreamTemplate());
|
||||
|
||||
assertThat(actualNoTemplate, equalTo(expectedNoTemplate));
|
||||
|
@ -1132,7 +1132,7 @@ public class MetadataTests extends ESTestCase {
|
||||
.indexGraveyard(IndexGraveyardTests.createRandom())
|
||||
.version(randomNonNegativeLong())
|
||||
.put("component_template_" + randomAlphaOfLength(3), ComponentTemplateTests.randomInstance())
|
||||
.put("index_template_v2_" + randomAlphaOfLength(3), IndexTemplateV2Tests.randomInstance());
|
||||
.put("index_template_v2_" + randomAlphaOfLength(3), ComposableIndexTemplateTests.randomInstance());
|
||||
|
||||
DataStream randomDataStream = DataStreamTests.randomInstance();
|
||||
for (Index index : randomDataStream.getIndices()) {
|
||||
|
@ -69,7 +69,7 @@ public class ToAndFromJsonMetadataTests extends ESTestCase {
|
||||
new CompressedXContent("{\"baz\":\"eggplant\"}"),
|
||||
Collections.singletonMap("alias", AliasMetadata.builder("alias").build())),
|
||||
5L, Collections.singletonMap("my_meta", Collections.singletonMap("foo", "bar"))))
|
||||
.put("index_templatev2", new IndexTemplateV2(Arrays.asList("foo", "bar*"),
|
||||
.put("index_templatev2", new ComposableIndexTemplate(Arrays.asList("foo", "bar*"),
|
||||
new Template(Settings.builder().put("setting", "value").build(),
|
||||
new CompressedXContent("{\"baz\":\"eggplant\"}"),
|
||||
Collections.singletonMap("alias", AliasMetadata.builder("alias").build())),
|
||||
@ -77,7 +77,7 @@ public class ToAndFromJsonMetadataTests extends ESTestCase {
|
||||
5L,
|
||||
4L,
|
||||
Collections.singletonMap("my_meta", Collections.singletonMap("potato", "chicken")),
|
||||
randomBoolean() ? null : new IndexTemplateV2.DataStreamTemplate("@timestamp")))
|
||||
randomBoolean() ? null : new ComposableIndexTemplate.DataStreamTemplate("@timestamp")))
|
||||
.put(IndexMetadata.builder("test12")
|
||||
.settings(settings(Version.CURRENT)
|
||||
.put("setting1", "value1")
|
||||
|
@ -9,7 +9,7 @@ setup:
|
||||
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
|
||||
Content-Type: application/json
|
||||
allowed_warnings:
|
||||
- "index [.ml-meta] matches multiple v1 templates [.ml-meta, global], v2 index templates will only match a single index template"
|
||||
- "index [.ml-meta] matches multiple legacy templates [.ml-meta, global], composable templates will only match a single template"
|
||||
index:
|
||||
index: .ml-meta
|
||||
id: filter_imposter-filter
|
||||
@ -325,7 +325,7 @@ setup:
|
||||
index: ".ml-meta"
|
||||
- do:
|
||||
allowed_warnings:
|
||||
- "index [.ml-meta] matches multiple v1 templates [.ml-meta, global], v2 index templates will only match a single index template"
|
||||
- "index [.ml-meta] matches multiple legacy templates [.ml-meta, global], composable templates will only match a single template"
|
||||
indices.create:
|
||||
index: ".ml-meta"
|
||||
|
||||
|
@ -5,7 +5,7 @@ setup:
|
||||
- allowed_warnings
|
||||
- do:
|
||||
allowed_warnings:
|
||||
- "index [.ml-inference-000002] matches multiple v1 templates [.ml-inference-000002, global], v2 index templates will only match a single index template"
|
||||
- "index [.ml-inference-000002] matches multiple legacy templates [.ml-inference-000002, global], composable templates will only match a single template"
|
||||
headers:
|
||||
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
|
||||
index:
|
||||
|
@ -5,7 +5,7 @@ setup:
|
||||
- allowed_warnings
|
||||
- do:
|
||||
allowed_warnings:
|
||||
- "index [foo_rollup] matches multiple v1 templates [global, test], v2 index templates will only match a single index template"
|
||||
- "index [foo_rollup] matches multiple legacy templates [global, test], composable templates will only match a single template"
|
||||
indices.create:
|
||||
index: foo
|
||||
body:
|
||||
@ -278,7 +278,7 @@ setup:
|
||||
|
||||
- do:
|
||||
allowed_warnings:
|
||||
- "index [foo_rollup] matches multiple v1 templates [global, test], v2 index templates will only match a single index template"
|
||||
- "index [foo_rollup] matches multiple legacy templates [global, test], composable templates will only match a single template"
|
||||
headers:
|
||||
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
|
||||
rollup.put_job:
|
||||
|
Loading…
x
Reference in New Issue
Block a user