Remove trappy timeouts from GetMappingsRequest (#120035)

Relates #107984
This commit is contained in:
Niels Bauman 2025-01-14 12:39:41 +10:00 committed by GitHub
parent 455fde2849
commit 4605ecf44d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
42 changed files with 208 additions and 106 deletions

View file

@ -596,7 +596,7 @@ public class DataStreamIT extends ESIntegTestCase {
verifyResolvability(dataStreamName, indicesAdmin().prepareGetFieldMappings(dataStreamName), false);
verifyResolvability(dataStreamName, indicesAdmin().preparePutMapping(dataStreamName).setSource("""
{"_doc":{"properties": {"my_field":{"type":"keyword"}}}}""", XContentType.JSON), false);
verifyResolvability(dataStreamName, indicesAdmin().prepareGetMappings(dataStreamName), false);
verifyResolvability(dataStreamName, indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, dataStreamName), false);
verifyResolvability(
dataStreamName,
indicesAdmin().prepareUpdateSettings(dataStreamName).setSettings(Settings.builder().put("index.number_of_replicas", 0)),
@ -643,7 +643,7 @@ public class DataStreamIT extends ESIntegTestCase {
verifyResolvability(wildcardExpression, indicesAdmin().prepareGetFieldMappings(wildcardExpression), false);
verifyResolvability(wildcardExpression, indicesAdmin().preparePutMapping(wildcardExpression).setSource("""
{"_doc":{"properties": {"my_field":{"type":"keyword"}}}}""", XContentType.JSON), false);
verifyResolvability(wildcardExpression, indicesAdmin().prepareGetMappings(wildcardExpression), false);
verifyResolvability(wildcardExpression, indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, wildcardExpression), false);
verifyResolvability(wildcardExpression, indicesAdmin().prepareGetSettings(wildcardExpression), false);
verifyResolvability(
wildcardExpression,
@ -1180,7 +1180,7 @@ public class DataStreamIT extends ESIntegTestCase {
DataStreamTimestampFieldMapper.NAME,
Map.of("enabled", true)
);
GetMappingsResponse getMappingsResponse = indicesAdmin().prepareGetMappings("logs-foobar").get();
GetMappingsResponse getMappingsResponse = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "logs-foobar").get();
assertThat(getMappingsResponse.getMappings().size(), equalTo(2));
assertThat(getMappingsResponse.getMappings().get(backingIndex1).getSourceAsMap(), equalTo(expectedMapping));
assertThat(getMappingsResponse.getMappings().get(backingIndex2).getSourceAsMap(), equalTo(expectedMapping));
@ -1195,7 +1195,7 @@ public class DataStreamIT extends ESIntegTestCase {
.setSource("{\"properties\":{\"my_field\":{\"type\":\"keyword\"}}}", XContentType.JSON)
.get();
// The mappings of all backing indices should be updated:
getMappingsResponse = indicesAdmin().prepareGetMappings("logs-foobar").get();
getMappingsResponse = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "logs-foobar").get();
assertThat(getMappingsResponse.getMappings().size(), equalTo(2));
assertThat(getMappingsResponse.getMappings().get(backingIndex1).getSourceAsMap(), equalTo(expectedMapping));
assertThat(getMappingsResponse.getMappings().get(backingIndex2).getSourceAsMap(), equalTo(expectedMapping));

View file

@ -91,7 +91,7 @@ public class SizeMappingIT extends ESIntegTestCase {
"Expected size field mapping to be " + (enabled ? "enabled" : "disabled") + " for %s",
index
);
GetMappingsResponse getMappingsResponse = indicesAdmin().prepareGetMappings(index).get();
GetMappingsResponse getMappingsResponse = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, index).get();
Map<String, Object> mappingSource = getMappingsResponse.getMappings().get(index).getSourceAsMap();
assertThat(errMsg, mappingSource, hasKey("_size"));
String sizeAsString = mappingSource.get("_size").toString();

View file

@ -519,7 +519,7 @@ public class IndicesRequestIT extends ESIntegTestCase {
public void testGetMappings() {
interceptTransportActions(GetMappingsAction.NAME);
GetMappingsRequest getMappingsRequest = new GetMappingsRequest().indices(randomIndicesOrAliases());
GetMappingsRequest getMappingsRequest = new GetMappingsRequest(TEST_REQUEST_TIMEOUT).indices(randomIndicesOrAliases());
internalCluster().coordOnlyNodeClient().admin().indices().getMappings(getMappingsRequest).actionGet();
clearInterceptedActions();

View file

@ -120,7 +120,7 @@ public class CreateIndexIT extends ESIntegTestCase {
)
);
GetMappingsResponse response = indicesAdmin().prepareGetMappings("test").get();
GetMappingsResponse response = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "test").get();
MappingMetadata mappings = response.mappings().get("test");
assertNotNull(mappings);
@ -130,7 +130,7 @@ public class CreateIndexIT extends ESIntegTestCase {
public void testEmptyNestedMappings() throws Exception {
assertAcked(prepareCreate("test").setMapping(XContentFactory.jsonBuilder().startObject().endObject()));
GetMappingsResponse response = indicesAdmin().prepareGetMappings("test").get();
GetMappingsResponse response = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "test").get();
MappingMetadata mappings = response.mappings().get("test");
assertNotNull(mappings);
@ -150,7 +150,7 @@ public class CreateIndexIT extends ESIntegTestCase {
prepareCreate("test").setMapping(XContentFactory.jsonBuilder().startObject().startObject("_doc").endObject().endObject())
);
GetMappingsResponse response = indicesAdmin().prepareGetMappings("test").get();
GetMappingsResponse response = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "test").get();
MappingMetadata mappings = response.mappings().get("test");
assertNotNull(mappings);

View file

@ -357,8 +357,9 @@ public class CreateSystemIndicesIT extends ESIntegTestCase {
* Fetch the mappings and settings for {@link TestSystemIndexDescriptor#INDEX_NAME} and verify that they match the expected values.
*/
private void assertMappingsAndSettings(String expectedMappings, String concreteIndex) {
final GetMappingsResponse getMappingsResponse = indicesAdmin().getMappings(new GetMappingsRequest().indices(INDEX_NAME))
.actionGet();
final GetMappingsResponse getMappingsResponse = indicesAdmin().getMappings(
new GetMappingsRequest(TEST_REQUEST_TIMEOUT).indices(INDEX_NAME)
).actionGet();
final Map<String, MappingMetadata> mappings = getMappingsResponse.getMappings();
assertThat(

View file

@ -55,7 +55,7 @@ public class BulkIntegrationIT extends ESIntegTestCase {
bulkBuilder.add(bulkAction.getBytes(StandardCharsets.UTF_8), 0, bulkAction.length(), null, XContentType.JSON);
bulkBuilder.get();
assertBusy(() -> {
GetMappingsResponse mappingsResponse = indicesAdmin().prepareGetMappings().get();
GetMappingsResponse mappingsResponse = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT).get();
assertTrue(mappingsResponse.getMappings().containsKey("logstash-2014.03.30"));
});
}

View file

@ -258,11 +258,14 @@ public class SimpleClusterStateIT extends ESIntegTestCase {
.setTimeout(TimeValue.timeValueMinutes(1))
);
ensureGreen(); // wait for green state, so its both green, and there are no more pending events
MappingMetadata masterMappingMetadata = indicesAdmin().prepareGetMappings("test").get().getMappings().get("test");
MappingMetadata masterMappingMetadata = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "test")
.get()
.getMappings()
.get("test");
for (Client client : clients()) {
MappingMetadata mappingMetadata = client.admin()
.indices()
.prepareGetMappings("test")
.prepareGetMappings(TEST_REQUEST_TIMEOUT, "test")
.setLocal(true)
.get()
.getMappings()

View file

@ -115,7 +115,7 @@ public class MetadataNodesIT extends ESIntegTestCase {
)
.get();
GetMappingsResponse getMappingsResponse = indicesAdmin().prepareGetMappings(index).get();
GetMappingsResponse getMappingsResponse = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, index).get();
assertNotNull(
((Map<String, ?>) (getMappingsResponse.getMappings().get(index).getSourceAsMap().get("properties"))).get("integer_field")
);
@ -146,7 +146,7 @@ public class MetadataNodesIT extends ESIntegTestCase {
)
.get();
getMappingsResponse = indicesAdmin().prepareGetMappings(index).get();
getMappingsResponse = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, index).get();
assertNotNull(
((Map<String, ?>) (getMappingsResponse.getMappings().get(index).getSourceAsMap().get("properties"))).get("float_field")
);

View file

@ -97,7 +97,7 @@ public class HiddenIndexIT extends ESIntegTestCase {
assertAcked(indicesAdmin().prepareCreate("a_hidden_index").setSettings(Settings.builder().put("index.hidden", true).build()));
GetMappingsResponse mappingsResponse = indicesAdmin().prepareGetMappings("a_hidden_index").get();
GetMappingsResponse mappingsResponse = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "a_hidden_index").get();
assertThat(mappingsResponse.mappings().size(), is(1));
MappingMetadata mappingMetadata = mappingsResponse.mappings().get("a_hidden_index");
assertNotNull(mappingMetadata);

View file

@ -96,7 +96,11 @@ public class DynamicMappingIT extends ESIntegTestCase {
client().prepareIndex("index").setId("1").setSource("a.x", 1).get();
client().prepareIndex("index").setId("2").setSource("a.y", 2).get();
Map<String, Object> mappings = indicesAdmin().prepareGetMappings("index").get().mappings().get("index").sourceAsMap();
Map<String, Object> mappings = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "index")
.get()
.mappings()
.get("index")
.sourceAsMap();
assertTrue(new WriteField("properties.a", () -> mappings).exists());
assertTrue(new WriteField("properties.a.properties.x", () -> mappings).exists());
}
@ -183,7 +187,7 @@ public class DynamicMappingIT extends ESIntegTestCase {
for (int i = 0; i < numberOfFieldsToCreate; ++i) {
assertTrue(client().prepareGet("index", Integer.toString(i)).get().isExists());
}
GetMappingsResponse mappings = indicesAdmin().prepareGetMappings("index").get();
GetMappingsResponse mappings = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "index").get();
MappingMetadata indexMappings = mappings.getMappings().get("index");
assertNotNull(indexMappings);
Map<String, Object> typeMappingsMap = indexMappings.getSourceAsMap();
@ -214,7 +218,11 @@ public class DynamicMappingIT extends ESIntegTestCase {
for (int i = 0; i < numberOfDocsToCreate; ++i) {
assertTrue(client().prepareGet("index", Integer.toString(i)).get().isExists());
}
Map<String, Object> index = indicesAdmin().prepareGetMappings("index").get().getMappings().get("index").getSourceAsMap();
Map<String, Object> index = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "index")
.get()
.getMappings()
.get("index")
.getSourceAsMap();
for (int i = 0, j = 1; i < numberOfDocsToCreate; i++, j++) {
assertThat(new WriteField("properties.field" + i + ".type", () -> index).get(null), is(oneOf("long", "float")));
assertThat(new WriteField("properties.field" + j + ".type", () -> index).get(null), is(oneOf("long", "float")));
@ -806,7 +814,11 @@ public class DynamicMappingIT extends ESIntegTestCase {
assertEquals(RestStatus.CREATED, indexResponse.status());
assertBusy(() -> {
Map<String, Object> mappings = indicesAdmin().prepareGetMappings("test").get().mappings().get("test").sourceAsMap();
Map<String, Object> mappings = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "test")
.get()
.mappings()
.get("test")
.sourceAsMap();
@SuppressWarnings("unchecked")
Map<String, Object> properties = (Map<String, Object>) mappings.get("properties");
assertEquals(4, properties.size());
@ -851,7 +863,11 @@ public class DynamicMappingIT extends ESIntegTestCase {
assertEquals(RestStatus.CREATED, indexResponse.status());
assertBusy(() -> {
Map<String, Object> mappings = indicesAdmin().prepareGetMappings("test").get().mappings().get("test").sourceAsMap();
Map<String, Object> mappings = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "test")
.get()
.mappings()
.get("test")
.sourceAsMap();
Map<String, Object> properties = (Map<String, Object>) mappings.get("properties");
Map<String, Object> foo = (Map<String, Object>) properties.get("foo");
properties = (Map<String, Object>) foo.get("properties");

View file

@ -37,7 +37,7 @@ public class MultiFieldsIntegrationIT extends ESIntegTestCase {
public void testMultiFields() throws Exception {
assertAcked(indicesAdmin().prepareCreate("my-index").setMapping(createTypeSource()));
GetMappingsResponse getMappingsResponse = indicesAdmin().prepareGetMappings("my-index").get();
GetMappingsResponse getMappingsResponse = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "my-index").get();
MappingMetadata mappingMetadata = getMappingsResponse.mappings().get("my-index");
assertThat(mappingMetadata, not(nullValue()));
Map<String, Object> mappingSource = mappingMetadata.sourceAsMap();
@ -53,7 +53,7 @@ public class MultiFieldsIntegrationIT extends ESIntegTestCase {
assertAcked(indicesAdmin().preparePutMapping("my-index").setSource(createPutMappingSource()));
getMappingsResponse = indicesAdmin().prepareGetMappings("my-index").get();
getMappingsResponse = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "my-index").get();
mappingMetadata = getMappingsResponse.mappings().get("my-index");
assertThat(mappingMetadata, not(nullValue()));
mappingSource = mappingMetadata.sourceAsMap();
@ -74,7 +74,7 @@ public class MultiFieldsIntegrationIT extends ESIntegTestCase {
public void testGeoPointMultiField() throws Exception {
assertAcked(indicesAdmin().prepareCreate("my-index").setMapping(createMappingSource("geo_point")));
GetMappingsResponse getMappingsResponse = indicesAdmin().prepareGetMappings("my-index").get();
GetMappingsResponse getMappingsResponse = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "my-index").get();
MappingMetadata mappingMetadata = getMappingsResponse.mappings().get("my-index");
assertThat(mappingMetadata, not(nullValue()));
Map<String, Object> mappingSource = mappingMetadata.sourceAsMap();
@ -102,7 +102,7 @@ public class MultiFieldsIntegrationIT extends ESIntegTestCase {
public void testCompletionMultiField() throws Exception {
assertAcked(indicesAdmin().prepareCreate("my-index").setMapping(createMappingSource("completion")));
GetMappingsResponse getMappingsResponse = indicesAdmin().prepareGetMappings("my-index").get();
GetMappingsResponse getMappingsResponse = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "my-index").get();
MappingMetadata mappingMetadata = getMappingsResponse.mappings().get("my-index");
assertThat(mappingMetadata, not(nullValue()));
Map<String, Object> mappingSource = mappingMetadata.sourceAsMap();
@ -123,7 +123,7 @@ public class MultiFieldsIntegrationIT extends ESIntegTestCase {
public void testIpMultiField() throws Exception {
assertAcked(indicesAdmin().prepareCreate("my-index").setMapping(createMappingSource("ip")));
GetMappingsResponse getMappingsResponse = indicesAdmin().prepareGetMappings("my-index").get();
GetMappingsResponse getMappingsResponse = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "my-index").get();
MappingMetadata mappingMetadata = getMappingsResponse.mappings().get("my-index");
assertThat(mappingMetadata, not(nullValue()));
Map<String, Object> mappingSource = mappingMetadata.sourceAsMap();

View file

@ -537,26 +537,26 @@ public class IndicesOptionsIntegrationIT extends ESIntegTestCase {
}
verify(indicesAdmin().preparePutMapping("foo").setSource("field", "type=text"), false);
assertThat(indicesAdmin().prepareGetMappings("foo").get().mappings().get("foo"), notNullValue());
assertThat(indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "foo").get().mappings().get("foo"), notNullValue());
verify(indicesAdmin().preparePutMapping("b*").setSource("field", "type=text"), false);
assertThat(indicesAdmin().prepareGetMappings("bar").get().mappings().get("bar"), notNullValue());
assertThat(indicesAdmin().prepareGetMappings("barbaz").get().mappings().get("barbaz"), notNullValue());
assertThat(indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "bar").get().mappings().get("bar"), notNullValue());
assertThat(indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "barbaz").get().mappings().get("barbaz"), notNullValue());
verify(indicesAdmin().preparePutMapping("_all").setSource("field", "type=text"), false);
assertThat(indicesAdmin().prepareGetMappings("foo").get().mappings().get("foo"), notNullValue());
assertThat(indicesAdmin().prepareGetMappings("foobar").get().mappings().get("foobar"), notNullValue());
assertThat(indicesAdmin().prepareGetMappings("bar").get().mappings().get("bar"), notNullValue());
assertThat(indicesAdmin().prepareGetMappings("barbaz").get().mappings().get("barbaz"), notNullValue());
assertThat(indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "foo").get().mappings().get("foo"), notNullValue());
assertThat(indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "foobar").get().mappings().get("foobar"), notNullValue());
assertThat(indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "bar").get().mappings().get("bar"), notNullValue());
assertThat(indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "barbaz").get().mappings().get("barbaz"), notNullValue());
verify(indicesAdmin().preparePutMapping().setSource("field", "type=text"), false);
assertThat(indicesAdmin().prepareGetMappings("foo").get().mappings().get("foo"), notNullValue());
assertThat(indicesAdmin().prepareGetMappings("foobar").get().mappings().get("foobar"), notNullValue());
assertThat(indicesAdmin().prepareGetMappings("bar").get().mappings().get("bar"), notNullValue());
assertThat(indicesAdmin().prepareGetMappings("barbaz").get().mappings().get("barbaz"), notNullValue());
assertThat(indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "foo").get().mappings().get("foo"), notNullValue());
assertThat(indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "foobar").get().mappings().get("foobar"), notNullValue());
assertThat(indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "bar").get().mappings().get("bar"), notNullValue());
assertThat(indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "barbaz").get().mappings().get("barbaz"), notNullValue());
verify(indicesAdmin().preparePutMapping("c*").setSource("field", "type=text"), true);
assertAcked(indicesAdmin().prepareClose("barbaz").get());
verify(indicesAdmin().preparePutMapping("barbaz").setSource("field", "type=text"), false);
assertThat(indicesAdmin().prepareGetMappings("barbaz").get().mappings().get("barbaz"), notNullValue());
assertThat(indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "barbaz").get().mappings().get("barbaz"), notNullValue());
}
public static final class TestPlugin extends Plugin {
@ -664,7 +664,7 @@ public class IndicesOptionsIntegrationIT extends ESIntegTestCase {
}
static GetMappingsRequestBuilder getMapping(String... indices) {
return indicesAdmin().prepareGetMappings(indices);
return indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, indices);
}
static GetSettingsRequestBuilder getSettings(String... indices) {

View file

@ -123,8 +123,9 @@ public class SystemIndexMappingUpdateServiceIT extends ESIntegTestCase {
* Fetch the mappings and settings for {@link TestSystemIndexDescriptor#INDEX_NAME} and verify that they match the expected values.
*/
private void assertMappingsAndSettings(String expectedMappings) {
final GetMappingsResponse getMappingsResponse = indicesAdmin().getMappings(new GetMappingsRequest().indices(INDEX_NAME))
.actionGet();
final GetMappingsResponse getMappingsResponse = indicesAdmin().getMappings(
new GetMappingsRequest(TEST_REQUEST_TIMEOUT).indices(INDEX_NAME)
).actionGet();
final Map<String, MappingMetadata> mappings = getMappingsResponse.getMappings();
assertThat(

View file

@ -198,7 +198,7 @@ public class SimpleGetFieldMappingsIT extends ESIntegTestCase {
try {
enableIndexBlock("test", SETTING_BLOCKS_METADATA);
assertBlocked(indicesAdmin().prepareGetMappings(), INDEX_METADATA_BLOCK);
assertBlocked(indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT), INDEX_METADATA_BLOCK);
} finally {
disableIndexBlock("test", SETTING_BLOCKS_METADATA);
}

View file

@ -42,7 +42,7 @@ public class SimpleGetMappingsIT extends ESIntegTestCase {
public void testGetMappingsWhereThereAreNone() {
createIndex("index");
GetMappingsResponse response = indicesAdmin().prepareGetMappings().get();
GetMappingsResponse response = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT).get();
assertThat(response.mappings().containsKey("index"), equalTo(true));
assertEquals(MappingMetadata.EMPTY_MAPPINGS, response.mappings().get("index"));
}
@ -70,19 +70,19 @@ public class SimpleGetMappingsIT extends ESIntegTestCase {
assertThat(clusterHealth.isTimedOut(), equalTo(false));
// Get all mappings
GetMappingsResponse response = indicesAdmin().prepareGetMappings().get();
GetMappingsResponse response = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT).get();
assertThat(response.mappings().size(), equalTo(2));
assertThat(response.mappings().get("indexa"), notNullValue());
assertThat(response.mappings().get("indexb"), notNullValue());
// Get all mappings, via wildcard support
response = indicesAdmin().prepareGetMappings("*").get();
response = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "*").get();
assertThat(response.mappings().size(), equalTo(2));
assertThat(response.mappings().get("indexa"), notNullValue());
assertThat(response.mappings().get("indexb"), notNullValue());
// Get mappings in indexa
response = indicesAdmin().prepareGetMappings("indexa").get();
response = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "indexa").get();
assertThat(response.mappings().size(), equalTo(1));
assertThat(response.mappings().get("indexa"), notNullValue());
}
@ -94,7 +94,7 @@ public class SimpleGetMappingsIT extends ESIntegTestCase {
for (String block : Arrays.asList(SETTING_BLOCKS_READ, SETTING_BLOCKS_WRITE, SETTING_READ_ONLY)) {
try {
enableIndexBlock("test", block);
GetMappingsResponse response = indicesAdmin().prepareGetMappings().get();
GetMappingsResponse response = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT).get();
assertThat(response.mappings().size(), equalTo(1));
assertNotNull(response.mappings().get("test"));
} finally {
@ -104,7 +104,7 @@ public class SimpleGetMappingsIT extends ESIntegTestCase {
try {
enableIndexBlock("test", SETTING_BLOCKS_METADATA);
assertBlocked(indicesAdmin().prepareGetMappings(), INDEX_METADATA_BLOCK);
assertBlocked(indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT), INDEX_METADATA_BLOCK);
} finally {
disableIndexBlock("test", SETTING_BLOCKS_METADATA);
}

View file

@ -109,7 +109,7 @@ public class UpdateMappingIntegrationIT extends ESIntegTestCase {
assertThat(putMappingResponse.isAcknowledged(), equalTo(true));
GetMappingsResponse getMappingsResponse = indicesAdmin().prepareGetMappings("test").get();
GetMappingsResponse getMappingsResponse = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "test").get();
assertThat(getMappingsResponse.mappings().get("test").source().toString(), equalTo("""
{"_doc":{"properties":{"body":{"type":"text"},"date":{"type":"integer"}}}}"""));
}
@ -123,7 +123,7 @@ public class UpdateMappingIntegrationIT extends ESIntegTestCase {
assertThat(putMappingResponse.isAcknowledged(), equalTo(true));
GetMappingsResponse getMappingsResponse = indicesAdmin().prepareGetMappings("test").get();
GetMappingsResponse getMappingsResponse = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "test").get();
assertThat(getMappingsResponse.mappings().get("test").source().toString(), equalTo("""
{"_doc":{"properties":{"date":{"type":"integer"}}}}"""));
}
@ -215,7 +215,10 @@ public class UpdateMappingIntegrationIT extends ESIntegTestCase {
.get();
assertThat(response.isAcknowledged(), equalTo(true));
GetMappingsResponse getMappingResponse = client2.admin().indices().prepareGetMappings(indexName).get();
GetMappingsResponse getMappingResponse = client2.admin()
.indices()
.prepareGetMappings(TEST_REQUEST_TIMEOUT, indexName)
.get();
MappingMetadata mappings = getMappingResponse.getMappings().get(indexName);
@SuppressWarnings("unchecked")
Map<String, Object> properties = (Map<String, Object>) mappings.getSourceAsMap().get("properties");
@ -284,7 +287,7 @@ public class UpdateMappingIntegrationIT extends ESIntegTestCase {
* Waits for the given mapping type to exists on the master node.
*/
private void assertMappingOnMaster(final String index, final String... fieldNames) {
GetMappingsResponse response = indicesAdmin().prepareGetMappings(index).get();
GetMappingsResponse response = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, index).get();
MappingMetadata mappings = response.getMappings().get(index);
assertThat(mappings, notNullValue());

View file

@ -12,6 +12,7 @@ package org.elasticsearch.action.admin.indices.mapping.get;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.support.master.info.ClusterInfoRequest;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.tasks.CancellableTask;
import org.elasticsearch.tasks.Task;
import org.elasticsearch.tasks.TaskId;
@ -21,7 +22,9 @@ import java.util.Map;
public class GetMappingsRequest extends ClusterInfoRequest<GetMappingsRequest> {
public GetMappingsRequest() {}
public GetMappingsRequest(TimeValue masterTimeout) {
super(masterTimeout);
}
public GetMappingsRequest(StreamInput in) throws IOException {
super(in);

View file

@ -11,13 +11,14 @@ package org.elasticsearch.action.admin.indices.mapping.get;
import org.elasticsearch.action.support.master.info.ClusterInfoRequestBuilder;
import org.elasticsearch.client.internal.ElasticsearchClient;
import org.elasticsearch.core.TimeValue;
public class GetMappingsRequestBuilder extends ClusterInfoRequestBuilder<
GetMappingsRequest,
GetMappingsResponse,
GetMappingsRequestBuilder> {
public GetMappingsRequestBuilder(ElasticsearchClient client, String... indices) {
super(client, GetMappingsAction.INSTANCE, new GetMappingsRequest().indices(indices));
public GetMappingsRequestBuilder(ElasticsearchClient client, TimeValue masterTimeout, String... indices) {
super(client, GetMappingsAction.INSTANCE, new GetMappingsRequest(masterTimeout).indices(indices));
}
}

View file

@ -16,6 +16,7 @@ import org.elasticsearch.action.support.master.MasterNodeReadRequest;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.core.TimeValue;
import java.io.IOException;
@ -27,11 +28,22 @@ public abstract class ClusterInfoRequest<Request extends ClusterInfoRequest<Requ
private IndicesOptions indicesOptions = IndicesOptions.strictExpandOpen();
public ClusterInfoRequest(TimeValue masterTimeout) {
super(masterTimeout);
}
public ClusterInfoRequest(TimeValue masterTimeout, IndicesOptions indicesOptions) {
super(masterTimeout);
this.indicesOptions = indicesOptions;
}
@Deprecated(forRemoval = true)
public ClusterInfoRequest() {
super(TRAPPY_IMPLICIT_DEFAULT_MASTER_NODE_TIMEOUT);
}
// So subclasses can override the default indices options, if needed
@Deprecated(forRemoval = true)
protected ClusterInfoRequest(IndicesOptions indicesOptions) {
super(TRAPPY_IMPLICIT_DEFAULT_MASTER_NODE_TIMEOUT);
this.indicesOptions = indicesOptions;

View file

@ -267,8 +267,8 @@ public class IndicesAdminClient implements ElasticsearchClient {
return execute(GetMappingsAction.INSTANCE, request);
}
public GetMappingsRequestBuilder prepareGetMappings(String... indices) {
return new GetMappingsRequestBuilder(this, indices);
public GetMappingsRequestBuilder prepareGetMappings(TimeValue masterTimeout, String... indices) {
return new GetMappingsRequestBuilder(this, masterTimeout, indices);
}
public void getFieldMappings(GetFieldMappingsRequest request, ActionListener<GetFieldMappingsResponse> listener) {

View file

@ -13,7 +13,6 @@ import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsRequest;
import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.client.internal.node.NodeClient;
import org.elasticsearch.common.Strings;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.http.HttpChannel;
import org.elasticsearch.rest.BaseRestHandler;
import org.elasticsearch.rest.RestRequest;
@ -51,11 +50,9 @@ public class RestGetMappingAction extends BaseRestHandler {
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
final String[] indices = Strings.splitStringByCommaToArray(request.param("index"));
final GetMappingsRequest getMappingsRequest = new GetMappingsRequest();
final GetMappingsRequest getMappingsRequest = new GetMappingsRequest(getMasterNodeTimeout(request));
getMappingsRequest.indices(indices);
getMappingsRequest.indicesOptions(IndicesOptions.fromRequest(request, getMappingsRequest.indicesOptions()));
final TimeValue timeout = getMasterNodeTimeout(request);
getMappingsRequest.masterNodeTimeout(timeout);
getMappingsRequest.local(request.paramAsBoolean("local", getMappingsRequest.local()));
final HttpChannel httpChannel = request.getHttpChannel();
return channel -> new RestCancellableNodeClient(client, httpChannel).admin()

View file

@ -54,7 +54,7 @@ public class FieldFilterMapperPluginTests extends ESSingleNodeTestCase {
}
public void testGetMappings() {
GetMappingsResponse getMappingsResponse = indicesAdmin().prepareGetMappings().get();
GetMappingsResponse getMappingsResponse = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT).get();
assertExpectedMappings(getMappingsResponse.mappings());
}
@ -71,7 +71,7 @@ public class FieldFilterMapperPluginTests extends ESSingleNodeTestCase {
assertFieldMappings(mappings.get("filtered"), FILTERED_FLAT_FIELDS);
// double check that submitting the filtered mappings to an unfiltered index leads to the same get field mappings output
// as the one coming from a filtered index with same mappings
GetMappingsResponse getMappingsResponse = indicesAdmin().prepareGetMappings("filtered").get();
GetMappingsResponse getMappingsResponse = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "filtered").get();
MappingMetadata filtered = getMappingsResponse.getMappings().get("filtered");
assertAcked(indicesAdmin().prepareCreate("test").setMapping(filtered.getSourceAsMap()));
GetFieldMappingsResponse response = indicesAdmin().prepareGetFieldMappings("test").setFields("*").get();
@ -98,7 +98,7 @@ public class FieldFilterMapperPluginTests extends ESSingleNodeTestCase {
assertFieldCaps(filtered, filteredFields);
// double check that submitting the filtered mappings to an unfiltered index leads to the same field_caps output
// as the one coming from a filtered index with same mappings
GetMappingsResponse getMappingsResponse = indicesAdmin().prepareGetMappings("filtered").get();
GetMappingsResponse getMappingsResponse = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "filtered").get();
MappingMetadata filteredMapping = getMappingsResponse.getMappings().get("filtered");
assertAcked(indicesAdmin().prepareCreate("test").setMapping(filteredMapping.getSourceAsMap()));
FieldCapabilitiesResponse test = client().fieldCaps(new FieldCapabilitiesRequest().fields("*").indices("test")).actionGet();
@ -155,7 +155,7 @@ public class FieldFilterMapperPluginTests extends ESSingleNodeTestCase {
private void assertMappingsAreValid(Map<String, Object> sourceAsMap) {
// check that the returned filtered mappings are still valid mappings by submitting them and retrieving them back
assertAcked(indicesAdmin().prepareCreate("test").setMapping(sourceAsMap));
GetMappingsResponse testMappingsResponse = indicesAdmin().prepareGetMappings("test").get();
GetMappingsResponse testMappingsResponse = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "test").get();
assertEquals(1, testMappingsResponse.getMappings().size());
// the mappings are returned unfiltered for this index, yet they are the same as the previous ones that were returned filtered
assertFiltered(testMappingsResponse.getMappings().get("test"));

View file

@ -43,7 +43,7 @@ public abstract class NonDynamicFieldMapperTestCase extends ESSingleNodeTestCase
""", getMapping());
var resp = client().admin().indices().prepareCreate("test").setMapping(mapping).get();
assertTrue(resp.isAcknowledged());
var mappingsResp = client().admin().indices().prepareGetMappings("test").get();
var mappingsResp = client().admin().indices().prepareGetMappings(TEST_REQUEST_TIMEOUT, "test").get();
var mappingMetadata = mappingsResp.getMappings().get("test");
var fieldType = XContentMapValues.extractValue("properties.field.type", mappingMetadata.getSourceAsMap());
assertThat(fieldType, equalTo(getTypeName()));
@ -149,7 +149,7 @@ public abstract class NonDynamicFieldMapperTestCase extends ESSingleNodeTestCase
var resp = client().prepareIndex("test1").setSource("field", "hello world").get();
assertThat(resp.status(), equalTo(RestStatus.CREATED));
var mappingsResp = client().admin().indices().prepareGetMappings("test1").get();
var mappingsResp = client().admin().indices().prepareGetMappings(TEST_REQUEST_TIMEOUT, "test1").get();
var mappingMetadata = mappingsResp.getMappings().get("test1");
var fieldType = XContentMapValues.extractValue("properties.field.type", mappingMetadata.getSourceAsMap());
assertThat(fieldType, equalTo(getTypeName()));

View file

@ -488,7 +488,7 @@ public class CcrRepositoryIT extends CcrIntegTestCase {
clusterStateRequest.indices(followerIndex);
MappingMetadata mappingMetadata = followerClient().admin()
.indices()
.prepareGetMappings("index2")
.prepareGetMappings(TEST_REQUEST_TIMEOUT, "index2")
.get()
.getMappings()
.get("index2");

View file

@ -371,7 +371,12 @@ public class IndexFollowingIT extends CcrIntegTestCase {
}
assertBusy(() -> assertHitCount(followerClient().prepareSearch("index2"), firstBatchNumDocs));
MappingMetadata mappingMetadata = followerClient().admin().indices().prepareGetMappings("index2").get().getMappings().get("index2");
MappingMetadata mappingMetadata = followerClient().admin()
.indices()
.prepareGetMappings(TEST_REQUEST_TIMEOUT, "index2")
.get()
.getMappings()
.get("index2");
assertThat(XContentMapValues.extractValue("properties.f.type", mappingMetadata.sourceAsMap()), equalTo("integer"));
assertThat(XContentMapValues.extractValue("properties.k", mappingMetadata.sourceAsMap()), nullValue());
@ -382,7 +387,12 @@ public class IndexFollowingIT extends CcrIntegTestCase {
}
assertBusy(() -> assertHitCount(followerClient().prepareSearch("index2"), firstBatchNumDocs + secondBatchNumDocs));
mappingMetadata = followerClient().admin().indices().prepareGetMappings("index2").get().getMappings().get("index2");
mappingMetadata = followerClient().admin()
.indices()
.prepareGetMappings(TEST_REQUEST_TIMEOUT, "index2")
.get()
.getMappings()
.get("index2");
assertThat(XContentMapValues.extractValue("properties.f.type", mappingMetadata.sourceAsMap()), equalTo("integer"));
assertThat(XContentMapValues.extractValue("properties.k.type", mappingMetadata.sourceAsMap()), equalTo("long"));
pauseFollow("index2");
@ -410,7 +420,12 @@ public class IndexFollowingIT extends CcrIntegTestCase {
assertBusy(() -> assertHitCount(followerClient().prepareSearch("index2"), 1));
pauseFollow("index2");
MappingMetadata mappingMetadata = followerClient().admin().indices().prepareGetMappings("index2").get().getMappings().get("index2");
MappingMetadata mappingMetadata = followerClient().admin()
.indices()
.prepareGetMappings(TEST_REQUEST_TIMEOUT, "index2")
.get()
.getMappings()
.get("index2");
assertThat(XContentMapValues.extractValue("properties.f.type", mappingMetadata.sourceAsMap()), equalTo("long"));
assertThat(XContentMapValues.extractValue("properties.k", mappingMetadata.sourceAsMap()), nullValue());
}
@ -1188,7 +1203,7 @@ public class IndexFollowingIT extends CcrIntegTestCase {
assertThat(getSettingsResponse.getSetting("follower", "index.analysis.analyzer.my_analyzer.type"), equalTo("custom"));
assertThat(getSettingsResponse.getSetting("follower", "index.analysis.analyzer.my_analyzer.tokenizer"), equalTo("keyword"));
GetMappingsRequest getMappingsRequest = new GetMappingsRequest();
GetMappingsRequest getMappingsRequest = new GetMappingsRequest(TEST_REQUEST_TIMEOUT);
getMappingsRequest.indices("follower");
GetMappingsResponse getMappingsResponse = followerClient().admin().indices().getMappings(getMappingsRequest).actionGet();
MappingMetadata mappingMetadata = getMappingsResponse.getMappings().get("follower");

View file

@ -197,7 +197,7 @@ public class SourceOnlySnapshotIT extends AbstractSnapshotIntegTestCase {
}
private static void assertMappings(String sourceIdx, boolean requireRouting, boolean useNested) throws IOException {
GetMappingsResponse getMappingsResponse = client().admin().indices().prepareGetMappings(sourceIdx).get();
GetMappingsResponse getMappingsResponse = client().admin().indices().prepareGetMappings(TEST_REQUEST_TIMEOUT, sourceIdx).get();
MappingMetadata mapping = getMappingsResponse.getMappings().get(sourceIdx);
String nested = useNested ? """
,"incorrect":{"type":"object"},"nested":{"type":"nested","properties":{"value":{"type":"long"}}}""" : "";

View file

@ -285,7 +285,7 @@ public class TransportDownsampleAction extends AcknowledgedTransportMasterNodeAc
// At any point if there is an issue, delete the downsample index
// 1. Extract source index mappings
final GetMappingsRequest getMappingsRequest = new GetMappingsRequest().indices(sourceIndexName);
final GetMappingsRequest getMappingsRequest = new GetMappingsRequest(request.masterNodeTimeout()).indices(sourceIndexName);
getMappingsRequest.setParentTask(parentTask);
client.admin().indices().getMappings(getMappingsRequest, listener.delegateFailureAndWrap((delegate, getMappingsResponse) -> {
final Map<String, Object> sourceIndexMappings = getMappingsResponse.mappings()

View file

@ -1179,7 +1179,7 @@ public class DownsampleActionSingleNodeTests extends ESSingleNodeTestCase {
@SuppressWarnings("unchecked")
private void assertDownsampleIndex(String sourceIndex, String downsampleIndex, DownsampleConfig config) throws Exception {
// Retrieve field information for the metric fields
final GetMappingsResponse getMappingsResponse = indicesAdmin().prepareGetMappings(sourceIndex).get();
final GetMappingsResponse getMappingsResponse = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, sourceIndex).get();
final Map<String, Object> sourceIndexMappings = getMappingsResponse.mappings()
.entrySet()
.stream()
@ -1221,8 +1221,9 @@ public class DownsampleActionSingleNodeTests extends ESSingleNodeTestCase {
assertFieldMappings(config, metricFields, mappings);
GetMappingsResponse indexMappings = indicesAdmin().getMappings(new GetMappingsRequest().indices(downsampleIndex, sourceIndex))
.actionGet();
GetMappingsResponse indexMappings = indicesAdmin().getMappings(
new GetMappingsRequest(TEST_REQUEST_TIMEOUT).indices(downsampleIndex, sourceIndex)
).actionGet();
Map<String, String> downsampleIndexProperties = (Map<String, String>) indexMappings.mappings()
.get(downsampleIndex)
.sourceAsMap()

View file

@ -110,7 +110,8 @@ public class CreateIndexFromSourceActionIT extends ESIntegTestCase {
client().execute(CreateIndexFromSourceAction.INSTANCE, new CreateIndexFromSourceAction.Request(sourceIndex, destIndex))
);
var mappingsResponse = indicesAdmin().getMappings(new GetMappingsRequest().indices(sourceIndex, destIndex)).actionGet();
var mappingsResponse = indicesAdmin().getMappings(new GetMappingsRequest(TEST_REQUEST_TIMEOUT).indices(sourceIndex, destIndex))
.actionGet();
Map<String, MappingMetadata> mappings = mappingsResponse.mappings();
var destMappings = mappings.get(destIndex).sourceAsMap();
var sourceMappings = mappings.get(sourceIndex).sourceAsMap();
@ -224,7 +225,7 @@ public class CreateIndexFromSourceActionIT extends ESIntegTestCase {
)
);
var mappingsResponse = indicesAdmin().getMappings(new GetMappingsRequest().indices(destIndex)).actionGet();
var mappingsResponse = indicesAdmin().getMappings(new GetMappingsRequest(TEST_REQUEST_TIMEOUT).indices(destIndex)).actionGet();
Map<String, MappingMetadata> mappings = mappingsResponse.mappings();
var destMappings = mappings.get(destIndex).sourceAsMap();

View file

@ -213,7 +213,8 @@ public class ReindexDatastreamIndexTransportActionIT extends ESIntegTestCase {
.actionGet()
.getDestIndex();
var mappingsResponse = indicesAdmin().getMappings(new GetMappingsRequest().indices(sourceIndex, destIndex)).actionGet();
var mappingsResponse = indicesAdmin().getMappings(new GetMappingsRequest(TEST_REQUEST_TIMEOUT).indices(sourceIndex, destIndex))
.actionGet();
Map<String, MappingMetadata> mappings = mappingsResponse.mappings();
var destMappings = mappings.get(destIndex).sourceAsMap();
var sourceMappings = mappings.get(sourceIndex).sourceAsMap();
@ -319,7 +320,8 @@ public class ReindexDatastreamIndexTransportActionIT extends ESIntegTestCase {
// verify mappings from templates copied to dest index
{
var mappingsResponse = indicesAdmin().getMappings(new GetMappingsRequest().indices(sourceIndex, destIndex)).actionGet();
var mappingsResponse = indicesAdmin().getMappings(new GetMappingsRequest(TEST_REQUEST_TIMEOUT).indices(sourceIndex, destIndex))
.actionGet();
var destMappings = mappingsResponse.mappings().get(destIndex).sourceAsMap();
var sourceMappings = mappingsResponse.mappings().get(sourceIndex).sourceAsMap();
assertEquals(sourceMappings, destMappings);

View file

@ -255,7 +255,7 @@ public class JobResultsProviderIT extends MlSingleNodeTestCase {
// Assert that the mappings contain all the additional fields: field1, field2, field3, etc.
String sharedResultsIndex = AnomalyDetectorsIndexFields.RESULTS_INDEX_PREFIX + AnomalyDetectorsIndexFields.RESULTS_INDEX_DEFAULT;
GetMappingsRequest request = new GetMappingsRequest().indices(sharedResultsIndex);
GetMappingsRequest request = new GetMappingsRequest(TEST_REQUEST_TIMEOUT).indices(sharedResultsIndex);
GetMappingsResponse response = client().execute(GetMappingsAction.INSTANCE, request).actionGet();
Map<String, MappingMetadata> indexMappings = response.getMappings();
assertNotNull(indexMappings);
@ -506,7 +506,7 @@ public class JobResultsProviderIT extends MlSingleNodeTestCase {
}
private Map<String, Object> getIndexMappingProperties(String index) {
GetMappingsRequest request = new GetMappingsRequest().indices(index);
GetMappingsRequest request = new GetMappingsRequest(TEST_REQUEST_TIMEOUT).indices(index);
GetMappingsResponse response = client().execute(GetMappingsAction.INSTANCE, request).actionGet();
Map<String, MappingMetadata> indexMappings = response.getMappings();
assertNotNull(indexMappings);

View file

@ -223,7 +223,7 @@ public class TransportStartDataFrameAnalyticsAction extends TransportMasterNodeA
);
// Get start context
getStartContext(request.getId(), task, startContextListener);
getStartContext(request.getId(), task, startContextListener, request.masterNodeTimeout());
}
private void estimateMemoryUsageAndUpdateMemoryTracker(StartContext startContext, ActionListener<StartContext> listener) {
@ -264,7 +264,7 @@ public class TransportStartDataFrameAnalyticsAction extends TransportMasterNodeA
}
private void getStartContext(String id, Task task, ActionListener<StartContext> finalListener) {
private void getStartContext(String id, Task task, ActionListener<StartContext> finalListener, TimeValue masterTimeout) {
ParentTaskAssigningClient parentTaskClient = new ParentTaskAssigningClient(client, task.getParentTaskId());
@ -320,6 +320,7 @@ public class TransportStartDataFrameAnalyticsAction extends TransportMasterNodeA
.<StartContext>andThen(
(l, startContext) -> MappingsMerger.mergeMappings(
parentTaskClient,
masterTimeout,
startContext.config.getHeaders(),
startContext.config.getSource(),
l.map(ignored -> startContext)

View file

@ -38,6 +38,7 @@ import org.elasticsearch.xpack.core.ml.dataframe.DataFrameAnalyticsConfig;
import org.elasticsearch.xpack.core.ml.dataframe.DataFrameAnalyticsDest;
import org.elasticsearch.xpack.core.ml.dataframe.analyses.RequiredField;
import org.elasticsearch.xpack.core.ml.utils.ExceptionsHelper;
import org.elasticsearch.xpack.ml.MachineLearning;
import java.time.Clock;
import java.util.Arrays;
@ -147,6 +148,7 @@ public final class DestinationIndex {
final Settings settings = settings(settingsResponse, destIndexAllowedSettings);
MappingsMerger.mergeMappings(
client,
MachineLearning.HARD_CODED_MACHINE_LEARNING_MASTER_NODE_TIMEOUT,
config.getHeaders(),
config.getSource(),
delegate.delegateFailureAndWrap(

View file

@ -12,6 +12,7 @@ import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsRequest;
import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsResponse;
import org.elasticsearch.client.internal.Client;
import org.elasticsearch.cluster.metadata.MappingMetadata;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.index.mapper.MapperService;
import org.elasticsearch.xpack.core.ClientHelper;
import org.elasticsearch.xpack.core.ml.dataframe.DataFrameAnalyticsSource;
@ -34,6 +35,7 @@ public final class MappingsMerger {
public static void mergeMappings(
Client client,
TimeValue masterTimeout,
Map<String, String> headers,
DataFrameAnalyticsSource source,
ActionListener<MappingMetadata> listener
@ -43,7 +45,7 @@ public final class MappingsMerger {
listener::onFailure
);
GetMappingsRequest getMappingsRequest = new GetMappingsRequest();
GetMappingsRequest getMappingsRequest = new GetMappingsRequest(masterTimeout);
getMappingsRequest.indices(source.getIndex());
ClientHelper.executeWithHeadersAsync(headers, ML_ORIGIN, client, GetMappingsAction.INSTANCE, getMappingsRequest, mappingsListener);
}

View file

@ -126,6 +126,7 @@ import org.elasticsearch.xpack.core.ml.stats.ForecastStats;
import org.elasticsearch.xpack.core.ml.stats.StatsAccumulator;
import org.elasticsearch.xpack.core.ml.utils.ExceptionsHelper;
import org.elasticsearch.xpack.core.security.support.Exceptions;
import org.elasticsearch.xpack.ml.MachineLearning;
import org.elasticsearch.xpack.ml.job.categorization.GrokPatternCreator;
import org.elasticsearch.xpack.ml.job.persistence.InfluencersQueryBuilder.InfluencersQuery;
import org.elasticsearch.xpack.ml.job.process.autodetect.params.AutodetectParams;
@ -392,7 +393,10 @@ public class JobResultsProvider {
addTermsMapping(indexMappings, indexName, termFields, listener);
}, listener::onFailure);
GetMappingsRequest getMappingsRequest = client.admin().indices().prepareGetMappings(indexName).request();
GetMappingsRequest getMappingsRequest = client.admin()
.indices()
.prepareGetMappings(MachineLearning.HARD_CODED_MACHINE_LEARNING_MASTER_NODE_TIMEOUT, indexName)
.request();
executeAsyncWithOrigin(
client.threadPool().getThreadContext(),
ML_ORIGIN,

View file

@ -199,7 +199,7 @@ public class TransportPutRollupJobAction extends AcknowledgedTransportMasterNode
ActionListener.wrap(createIndexResponse -> startPersistentTask(job, listener, persistentTasksService), e -> {
if (e instanceof ResourceAlreadyExistsException) {
logger.debug("Rolled index already exists for rollup job [" + job.getConfig().getId() + "], updating metadata.");
updateMapping(job, listener, persistentTasksService, client, logger);
updateMapping(job, listener, persistentTasksService, client, logger, request.masterNodeTimeout());
} else {
String msg = "Could not create index for rollup job [" + job.getConfig().getId() + "]";
logger.error(msg);
@ -249,7 +249,8 @@ public class TransportPutRollupJobAction extends AcknowledgedTransportMasterNode
ActionListener<AcknowledgedResponse> listener,
PersistentTasksService persistentTasksService,
Client client,
Logger logger
Logger logger,
TimeValue masterTimeout
) {
final String indexName = job.getConfig().getRollupIndex();
@ -304,7 +305,7 @@ public class TransportPutRollupJobAction extends AcknowledgedTransportMasterNode
);
};
GetMappingsRequest request = new GetMappingsRequest();
GetMappingsRequest request = new GetMappingsRequest(masterTimeout);
client.execute(GetMappingsAction.INSTANCE, request, ActionListener.wrap(getMappingResponseHandler, e -> {
String msg = "Could not update mappings for rollup job [" + job.getConfig().getId() + "]";
logger.error(msg);

View file

@ -166,7 +166,14 @@ public class PutJobStateMachineTests extends ESTestCase {
return null;
}).when(client).execute(eq(GetMappingsAction.INSTANCE), any(GetMappingsRequest.class), requestCaptor.capture());
TransportPutRollupJobAction.updateMapping(job, testListener, mock(PersistentTasksService.class), client, logger);
TransportPutRollupJobAction.updateMapping(
job,
testListener,
mock(PersistentTasksService.class),
client,
logger,
TEST_REQUEST_TIMEOUT
);
verify(client).execute(eq(GetMappingsAction.INSTANCE), any(GetMappingsRequest.class), any());
}
@ -201,7 +208,14 @@ public class PutJobStateMachineTests extends ESTestCase {
return null;
}).when(client).execute(eq(GetMappingsAction.INSTANCE), any(GetMappingsRequest.class), requestCaptor.capture());
TransportPutRollupJobAction.updateMapping(job, testListener, mock(PersistentTasksService.class), client, logger);
TransportPutRollupJobAction.updateMapping(
job,
testListener,
mock(PersistentTasksService.class),
client,
logger,
TEST_REQUEST_TIMEOUT
);
verify(client).execute(eq(GetMappingsAction.INSTANCE), any(GetMappingsRequest.class), any());
}
@ -238,7 +252,14 @@ public class PutJobStateMachineTests extends ESTestCase {
return null;
}).when(client).execute(eq(GetMappingsAction.INSTANCE), any(GetMappingsRequest.class), requestCaptor.capture());
TransportPutRollupJobAction.updateMapping(job, testListener, mock(PersistentTasksService.class), client, logger);
TransportPutRollupJobAction.updateMapping(
job,
testListener,
mock(PersistentTasksService.class),
client,
logger,
TEST_REQUEST_TIMEOUT
);
verify(client).execute(eq(GetMappingsAction.INSTANCE), any(GetMappingsRequest.class), any());
}
@ -272,7 +293,14 @@ public class PutJobStateMachineTests extends ESTestCase {
return null;
}).when(client).execute(eq(GetMappingsAction.INSTANCE), any(GetMappingsRequest.class), requestCaptor.capture());
TransportPutRollupJobAction.updateMapping(job, testListener, mock(PersistentTasksService.class), client, logger);
TransportPutRollupJobAction.updateMapping(
job,
testListener,
mock(PersistentTasksService.class),
client,
logger,
TEST_REQUEST_TIMEOUT
);
verify(client).execute(eq(GetMappingsAction.INSTANCE), any(GetMappingsRequest.class), any());
}
@ -318,7 +346,14 @@ public class PutJobStateMachineTests extends ESTestCase {
return null;
}).when(client).execute(eq(TransportPutMappingAction.TYPE), any(PutMappingRequest.class), requestCaptor2.capture());
TransportPutRollupJobAction.updateMapping(job, testListener, mock(PersistentTasksService.class), client, logger);
TransportPutRollupJobAction.updateMapping(
job,
testListener,
mock(PersistentTasksService.class),
client,
logger,
TEST_REQUEST_TIMEOUT
);
verify(client).execute(eq(GetMappingsAction.INSTANCE), any(GetMappingsRequest.class), any());
verify(client).execute(eq(TransportPutMappingAction.TYPE), any(PutMappingRequest.class), any());
}

View file

@ -287,28 +287,28 @@ public class DocumentAndFieldLevelSecurityTests extends SecurityIntegTestCase {
{
GetMappingsResponse getMappingsResponse = client().filterWithHeader(
Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user1", USERS_PASSWD))
).admin().indices().prepareGetMappings("test").get();
).admin().indices().prepareGetMappings(TEST_REQUEST_TIMEOUT, "test").get();
assertExpectedMetadataFields(getMappingsResponse.getMappings(), "field1");
}
{
GetMappingsResponse getMappingsResponse = client().filterWithHeader(
Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user2", USERS_PASSWD))
).admin().indices().prepareGetMappings("test").get();
).admin().indices().prepareGetMappings(TEST_REQUEST_TIMEOUT, "test").get();
assertExpectedMetadataFields(getMappingsResponse.getMappings(), "field2");
}
{
GetMappingsResponse getMappingsResponse = client().filterWithHeader(
Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user3", USERS_PASSWD))
).admin().indices().prepareGetMappings("test").get();
).admin().indices().prepareGetMappings(TEST_REQUEST_TIMEOUT, "test").get();
assertExpectedMetadataFields(getMappingsResponse.getMappings(), "field1");
}
{
GetMappingsResponse getMappingsResponse = client().filterWithHeader(
Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user4", USERS_PASSWD))
).admin().indices().prepareGetMappings("test").get();
).admin().indices().prepareGetMappings(TEST_REQUEST_TIMEOUT, "test").get();
assertExpectedMetadataFields(getMappingsResponse.getMappings(), "field1", "field2");
}
}

View file

@ -166,7 +166,7 @@ public class KibanaUserRoleIntegTests extends NativeRealmIntegTestCase {
GetMappingsResponse response = client().filterWithHeader(
singletonMap("Authorization", UsernamePasswordToken.basicAuthHeaderValue("kibana_user", USERS_PASSWD))
).admin().indices().prepareGetMappings("logstash-*").get();
).admin().indices().prepareGetMappings(TEST_REQUEST_TIMEOUT, "logstash-*").get();
Map<String, MappingMetadata> mappingsMap = response.getMappings();
assertNotNull(mappingsMap);
assertNotNull(mappingsMap.get(index));

View file

@ -172,7 +172,8 @@ public class HistoryTemplateHttpMappingsTests extends AbstractWatcherIntegration
// ensure that enabled is set to false
List<Boolean> indexed = new ArrayList<>();
GetMappingsResponse mappingsResponse = indicesAdmin().prepareGetMappings(HistoryStoreField.INDEX_PREFIX + "*").get();
GetMappingsResponse mappingsResponse = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, HistoryStoreField.INDEX_PREFIX + "*")
.get();
for (MappingMetadata mapping : mappingsResponse.getMappings().values()) {
Map<String, Object> docMapping = mapping.getSourceAsMap();
if (abortAtInput) {

View file

@ -46,7 +46,7 @@ public class HistoryTemplateTimeMappingsTests extends AbstractWatcherIntegration
assertWatchWithMinimumActionsCount("_id", ExecutionState.EXECUTED, 1);
assertBusy(() -> {
GetMappingsResponse mappingsResponse = indicesAdmin().prepareGetMappings()
GetMappingsResponse mappingsResponse = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT)
.setIndicesOptions(IndicesOptions.strictExpandHidden())
.get();
assertThat(mappingsResponse, notNullValue());

View file

@ -120,7 +120,7 @@ public class HistoryIntegrationTests extends AbstractWatcherIntegrationTestCase
assertBusy(() -> { assertHitCount(getWatchHistory(), 1); });
// as fields with dots are allowed in 5.0 again, the mapping must be checked in addition
GetMappingsResponse response = indicesAdmin().prepareGetMappings(".watcher-history*").get();
GetMappingsResponse response = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, ".watcher-history*").get();
XContentSource source = new XContentSource(
response.getMappings().values().iterator().next().source().uncompressed(),
XContentType.JSON
@ -162,7 +162,7 @@ public class HistoryIntegrationTests extends AbstractWatcherIntegrationTestCase
assertBusy(() -> { assertHitCount(getWatchHistory(), 1); });
// as fields with dots are allowed in 5.0 again, the mapping must be checked in addition
GetMappingsResponse response = indicesAdmin().prepareGetMappings(".watcher-history*").get();
GetMappingsResponse response = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, ".watcher-history*").get();
XContentSource source = new XContentSource(
response.getMappings().values().iterator().next().source().uncompressed(),
XContentType.JSON
@ -225,7 +225,7 @@ public class HistoryIntegrationTests extends AbstractWatcherIntegrationTestCase
assertBusy(() -> {
// also ensure that the status field is disabled in the watch history
GetMappingsResponse response = indicesAdmin().prepareGetMappings(".watcher-history*").get();
GetMappingsResponse response = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, ".watcher-history*").get();
XContentSource mappingSource = new XContentSource(
response.getMappings().values().iterator().next().source().uncompressed(),
XContentType.JSON