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().prepareGetFieldMappings(dataStreamName), false);
verifyResolvability(dataStreamName, indicesAdmin().preparePutMapping(dataStreamName).setSource(""" verifyResolvability(dataStreamName, indicesAdmin().preparePutMapping(dataStreamName).setSource("""
{"_doc":{"properties": {"my_field":{"type":"keyword"}}}}""", XContentType.JSON), false); {"_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( verifyResolvability(
dataStreamName, dataStreamName,
indicesAdmin().prepareUpdateSettings(dataStreamName).setSettings(Settings.builder().put("index.number_of_replicas", 0)), 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().prepareGetFieldMappings(wildcardExpression), false);
verifyResolvability(wildcardExpression, indicesAdmin().preparePutMapping(wildcardExpression).setSource(""" verifyResolvability(wildcardExpression, indicesAdmin().preparePutMapping(wildcardExpression).setSource("""
{"_doc":{"properties": {"my_field":{"type":"keyword"}}}}""", XContentType.JSON), false); {"_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, indicesAdmin().prepareGetSettings(wildcardExpression), false);
verifyResolvability( verifyResolvability(
wildcardExpression, wildcardExpression,
@ -1180,7 +1180,7 @@ public class DataStreamIT extends ESIntegTestCase {
DataStreamTimestampFieldMapper.NAME, DataStreamTimestampFieldMapper.NAME,
Map.of("enabled", true) 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().size(), equalTo(2));
assertThat(getMappingsResponse.getMappings().get(backingIndex1).getSourceAsMap(), equalTo(expectedMapping)); assertThat(getMappingsResponse.getMappings().get(backingIndex1).getSourceAsMap(), equalTo(expectedMapping));
assertThat(getMappingsResponse.getMappings().get(backingIndex2).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) .setSource("{\"properties\":{\"my_field\":{\"type\":\"keyword\"}}}", XContentType.JSON)
.get(); .get();
// The mappings of all backing indices should be updated: // 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().size(), equalTo(2));
assertThat(getMappingsResponse.getMappings().get(backingIndex1).getSourceAsMap(), equalTo(expectedMapping)); assertThat(getMappingsResponse.getMappings().get(backingIndex1).getSourceAsMap(), equalTo(expectedMapping));
assertThat(getMappingsResponse.getMappings().get(backingIndex2).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", "Expected size field mapping to be " + (enabled ? "enabled" : "disabled") + " for %s",
index 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(); Map<String, Object> mappingSource = getMappingsResponse.getMappings().get(index).getSourceAsMap();
assertThat(errMsg, mappingSource, hasKey("_size")); assertThat(errMsg, mappingSource, hasKey("_size"));
String sizeAsString = mappingSource.get("_size").toString(); String sizeAsString = mappingSource.get("_size").toString();

View file

@ -519,7 +519,7 @@ public class IndicesRequestIT extends ESIntegTestCase {
public void testGetMappings() { public void testGetMappings() {
interceptTransportActions(GetMappingsAction.NAME); 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(); internalCluster().coordOnlyNodeClient().admin().indices().getMappings(getMappingsRequest).actionGet();
clearInterceptedActions(); 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"); MappingMetadata mappings = response.mappings().get("test");
assertNotNull(mappings); assertNotNull(mappings);
@ -130,7 +130,7 @@ public class CreateIndexIT extends ESIntegTestCase {
public void testEmptyNestedMappings() throws Exception { public void testEmptyNestedMappings() throws Exception {
assertAcked(prepareCreate("test").setMapping(XContentFactory.jsonBuilder().startObject().endObject())); 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"); MappingMetadata mappings = response.mappings().get("test");
assertNotNull(mappings); assertNotNull(mappings);
@ -150,7 +150,7 @@ public class CreateIndexIT extends ESIntegTestCase {
prepareCreate("test").setMapping(XContentFactory.jsonBuilder().startObject().startObject("_doc").endObject().endObject()) 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"); MappingMetadata mappings = response.mappings().get("test");
assertNotNull(mappings); 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. * 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) { private void assertMappingsAndSettings(String expectedMappings, String concreteIndex) {
final GetMappingsResponse getMappingsResponse = indicesAdmin().getMappings(new GetMappingsRequest().indices(INDEX_NAME)) final GetMappingsResponse getMappingsResponse = indicesAdmin().getMappings(
.actionGet(); new GetMappingsRequest(TEST_REQUEST_TIMEOUT).indices(INDEX_NAME)
).actionGet();
final Map<String, MappingMetadata> mappings = getMappingsResponse.getMappings(); final Map<String, MappingMetadata> mappings = getMappingsResponse.getMappings();
assertThat( 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.add(bulkAction.getBytes(StandardCharsets.UTF_8), 0, bulkAction.length(), null, XContentType.JSON);
bulkBuilder.get(); bulkBuilder.get();
assertBusy(() -> { assertBusy(() -> {
GetMappingsResponse mappingsResponse = indicesAdmin().prepareGetMappings().get(); GetMappingsResponse mappingsResponse = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT).get();
assertTrue(mappingsResponse.getMappings().containsKey("logstash-2014.03.30")); assertTrue(mappingsResponse.getMappings().containsKey("logstash-2014.03.30"));
}); });
} }

View file

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

View file

@ -115,7 +115,7 @@ public class MetadataNodesIT extends ESIntegTestCase {
) )
.get(); .get();
GetMappingsResponse getMappingsResponse = indicesAdmin().prepareGetMappings(index).get(); GetMappingsResponse getMappingsResponse = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, index).get();
assertNotNull( assertNotNull(
((Map<String, ?>) (getMappingsResponse.getMappings().get(index).getSourceAsMap().get("properties"))).get("integer_field") ((Map<String, ?>) (getMappingsResponse.getMappings().get(index).getSourceAsMap().get("properties"))).get("integer_field")
); );
@ -146,7 +146,7 @@ public class MetadataNodesIT extends ESIntegTestCase {
) )
.get(); .get();
getMappingsResponse = indicesAdmin().prepareGetMappings(index).get(); getMappingsResponse = indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, index).get();
assertNotNull( assertNotNull(
((Map<String, ?>) (getMappingsResponse.getMappings().get(index).getSourceAsMap().get("properties"))).get("float_field") ((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())); 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)); assertThat(mappingsResponse.mappings().size(), is(1));
MappingMetadata mappingMetadata = mappingsResponse.mappings().get("a_hidden_index"); MappingMetadata mappingMetadata = mappingsResponse.mappings().get("a_hidden_index");
assertNotNull(mappingMetadata); 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("1").setSource("a.x", 1).get();
client().prepareIndex("index").setId("2").setSource("a.y", 2).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", () -> mappings).exists());
assertTrue(new WriteField("properties.a.properties.x", () -> 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) { for (int i = 0; i < numberOfFieldsToCreate; ++i) {
assertTrue(client().prepareGet("index", Integer.toString(i)).get().isExists()); 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"); MappingMetadata indexMappings = mappings.getMappings().get("index");
assertNotNull(indexMappings); assertNotNull(indexMappings);
Map<String, Object> typeMappingsMap = indexMappings.getSourceAsMap(); Map<String, Object> typeMappingsMap = indexMappings.getSourceAsMap();
@ -214,7 +218,11 @@ public class DynamicMappingIT extends ESIntegTestCase {
for (int i = 0; i < numberOfDocsToCreate; ++i) { for (int i = 0; i < numberOfDocsToCreate; ++i) {
assertTrue(client().prepareGet("index", Integer.toString(i)).get().isExists()); 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++) { 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" + i + ".type", () -> index).get(null), is(oneOf("long", "float")));
assertThat(new WriteField("properties.field" + j + ".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()); assertEquals(RestStatus.CREATED, indexResponse.status());
assertBusy(() -> { 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") @SuppressWarnings("unchecked")
Map<String, Object> properties = (Map<String, Object>) mappings.get("properties"); Map<String, Object> properties = (Map<String, Object>) mappings.get("properties");
assertEquals(4, properties.size()); assertEquals(4, properties.size());
@ -851,7 +863,11 @@ public class DynamicMappingIT extends ESIntegTestCase {
assertEquals(RestStatus.CREATED, indexResponse.status()); assertEquals(RestStatus.CREATED, indexResponse.status());
assertBusy(() -> { 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> properties = (Map<String, Object>) mappings.get("properties");
Map<String, Object> foo = (Map<String, Object>) properties.get("foo"); Map<String, Object> foo = (Map<String, Object>) properties.get("foo");
properties = (Map<String, Object>) foo.get("properties"); properties = (Map<String, Object>) foo.get("properties");

View file

@ -37,7 +37,7 @@ public class MultiFieldsIntegrationIT extends ESIntegTestCase {
public void testMultiFields() throws Exception { public void testMultiFields() throws Exception {
assertAcked(indicesAdmin().prepareCreate("my-index").setMapping(createTypeSource())); 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"); MappingMetadata mappingMetadata = getMappingsResponse.mappings().get("my-index");
assertThat(mappingMetadata, not(nullValue())); assertThat(mappingMetadata, not(nullValue()));
Map<String, Object> mappingSource = mappingMetadata.sourceAsMap(); Map<String, Object> mappingSource = mappingMetadata.sourceAsMap();
@ -53,7 +53,7 @@ public class MultiFieldsIntegrationIT extends ESIntegTestCase {
assertAcked(indicesAdmin().preparePutMapping("my-index").setSource(createPutMappingSource())); 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"); mappingMetadata = getMappingsResponse.mappings().get("my-index");
assertThat(mappingMetadata, not(nullValue())); assertThat(mappingMetadata, not(nullValue()));
mappingSource = mappingMetadata.sourceAsMap(); mappingSource = mappingMetadata.sourceAsMap();
@ -74,7 +74,7 @@ public class MultiFieldsIntegrationIT extends ESIntegTestCase {
public void testGeoPointMultiField() throws Exception { public void testGeoPointMultiField() throws Exception {
assertAcked(indicesAdmin().prepareCreate("my-index").setMapping(createMappingSource("geo_point"))); 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"); MappingMetadata mappingMetadata = getMappingsResponse.mappings().get("my-index");
assertThat(mappingMetadata, not(nullValue())); assertThat(mappingMetadata, not(nullValue()));
Map<String, Object> mappingSource = mappingMetadata.sourceAsMap(); Map<String, Object> mappingSource = mappingMetadata.sourceAsMap();
@ -102,7 +102,7 @@ public class MultiFieldsIntegrationIT extends ESIntegTestCase {
public void testCompletionMultiField() throws Exception { public void testCompletionMultiField() throws Exception {
assertAcked(indicesAdmin().prepareCreate("my-index").setMapping(createMappingSource("completion"))); 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"); MappingMetadata mappingMetadata = getMappingsResponse.mappings().get("my-index");
assertThat(mappingMetadata, not(nullValue())); assertThat(mappingMetadata, not(nullValue()));
Map<String, Object> mappingSource = mappingMetadata.sourceAsMap(); Map<String, Object> mappingSource = mappingMetadata.sourceAsMap();
@ -123,7 +123,7 @@ public class MultiFieldsIntegrationIT extends ESIntegTestCase {
public void testIpMultiField() throws Exception { public void testIpMultiField() throws Exception {
assertAcked(indicesAdmin().prepareCreate("my-index").setMapping(createMappingSource("ip"))); 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"); MappingMetadata mappingMetadata = getMappingsResponse.mappings().get("my-index");
assertThat(mappingMetadata, not(nullValue())); assertThat(mappingMetadata, not(nullValue()));
Map<String, Object> mappingSource = mappingMetadata.sourceAsMap(); 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); 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); verify(indicesAdmin().preparePutMapping("b*").setSource("field", "type=text"), false);
assertThat(indicesAdmin().prepareGetMappings("bar").get().mappings().get("bar"), notNullValue()); assertThat(indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "bar").get().mappings().get("bar"), notNullValue());
assertThat(indicesAdmin().prepareGetMappings("barbaz").get().mappings().get("barbaz"), notNullValue()); assertThat(indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "barbaz").get().mappings().get("barbaz"), notNullValue());
verify(indicesAdmin().preparePutMapping("_all").setSource("field", "type=text"), false); verify(indicesAdmin().preparePutMapping("_all").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());
assertThat(indicesAdmin().prepareGetMappings("foobar").get().mappings().get("foobar"), notNullValue()); assertThat(indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "foobar").get().mappings().get("foobar"), notNullValue());
assertThat(indicesAdmin().prepareGetMappings("bar").get().mappings().get("bar"), notNullValue()); assertThat(indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "bar").get().mappings().get("bar"), notNullValue());
assertThat(indicesAdmin().prepareGetMappings("barbaz").get().mappings().get("barbaz"), notNullValue()); assertThat(indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "barbaz").get().mappings().get("barbaz"), notNullValue());
verify(indicesAdmin().preparePutMapping().setSource("field", "type=text"), false); verify(indicesAdmin().preparePutMapping().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());
assertThat(indicesAdmin().prepareGetMappings("foobar").get().mappings().get("foobar"), notNullValue()); assertThat(indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "foobar").get().mappings().get("foobar"), notNullValue());
assertThat(indicesAdmin().prepareGetMappings("bar").get().mappings().get("bar"), notNullValue()); assertThat(indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "bar").get().mappings().get("bar"), notNullValue());
assertThat(indicesAdmin().prepareGetMappings("barbaz").get().mappings().get("barbaz"), notNullValue()); assertThat(indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, "barbaz").get().mappings().get("barbaz"), notNullValue());
verify(indicesAdmin().preparePutMapping("c*").setSource("field", "type=text"), true); verify(indicesAdmin().preparePutMapping("c*").setSource("field", "type=text"), true);
assertAcked(indicesAdmin().prepareClose("barbaz").get()); assertAcked(indicesAdmin().prepareClose("barbaz").get());
verify(indicesAdmin().preparePutMapping("barbaz").setSource("field", "type=text"), false); 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 { public static final class TestPlugin extends Plugin {
@ -664,7 +664,7 @@ public class IndicesOptionsIntegrationIT extends ESIntegTestCase {
} }
static GetMappingsRequestBuilder getMapping(String... indices) { static GetMappingsRequestBuilder getMapping(String... indices) {
return indicesAdmin().prepareGetMappings(indices); return indicesAdmin().prepareGetMappings(TEST_REQUEST_TIMEOUT, indices);
} }
static GetSettingsRequestBuilder getSettings(String... 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. * Fetch the mappings and settings for {@link TestSystemIndexDescriptor#INDEX_NAME} and verify that they match the expected values.
*/ */
private void assertMappingsAndSettings(String expectedMappings) { private void assertMappingsAndSettings(String expectedMappings) {
final GetMappingsResponse getMappingsResponse = indicesAdmin().getMappings(new GetMappingsRequest().indices(INDEX_NAME)) final GetMappingsResponse getMappingsResponse = indicesAdmin().getMappings(
.actionGet(); new GetMappingsRequest(TEST_REQUEST_TIMEOUT).indices(INDEX_NAME)
).actionGet();
final Map<String, MappingMetadata> mappings = getMappingsResponse.getMappings(); final Map<String, MappingMetadata> mappings = getMappingsResponse.getMappings();
assertThat( assertThat(

View file

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

View file

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

View file

@ -109,7 +109,7 @@ public class UpdateMappingIntegrationIT extends ESIntegTestCase {
assertThat(putMappingResponse.isAcknowledged(), equalTo(true)); 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(""" assertThat(getMappingsResponse.mappings().get("test").source().toString(), equalTo("""
{"_doc":{"properties":{"body":{"type":"text"},"date":{"type":"integer"}}}}""")); {"_doc":{"properties":{"body":{"type":"text"},"date":{"type":"integer"}}}}"""));
} }
@ -123,7 +123,7 @@ public class UpdateMappingIntegrationIT extends ESIntegTestCase {
assertThat(putMappingResponse.isAcknowledged(), equalTo(true)); 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(""" assertThat(getMappingsResponse.mappings().get("test").source().toString(), equalTo("""
{"_doc":{"properties":{"date":{"type":"integer"}}}}""")); {"_doc":{"properties":{"date":{"type":"integer"}}}}"""));
} }
@ -215,7 +215,10 @@ public class UpdateMappingIntegrationIT extends ESIntegTestCase {
.get(); .get();
assertThat(response.isAcknowledged(), equalTo(true)); 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); MappingMetadata mappings = getMappingResponse.getMappings().get(indexName);
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Map<String, Object> properties = (Map<String, Object>) mappings.getSourceAsMap().get("properties"); 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. * Waits for the given mapping type to exists on the master node.
*/ */
private void assertMappingOnMaster(final String index, final String... fieldNames) { 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); MappingMetadata mappings = response.getMappings().get(index);
assertThat(mappings, notNullValue()); 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.ActionRequestValidationException;
import org.elasticsearch.action.support.master.info.ClusterInfoRequest; import org.elasticsearch.action.support.master.info.ClusterInfoRequest;
import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.tasks.CancellableTask; import org.elasticsearch.tasks.CancellableTask;
import org.elasticsearch.tasks.Task; import org.elasticsearch.tasks.Task;
import org.elasticsearch.tasks.TaskId; import org.elasticsearch.tasks.TaskId;
@ -21,7 +22,9 @@ import java.util.Map;
public class GetMappingsRequest extends ClusterInfoRequest<GetMappingsRequest> { public class GetMappingsRequest extends ClusterInfoRequest<GetMappingsRequest> {
public GetMappingsRequest() {} public GetMappingsRequest(TimeValue masterTimeout) {
super(masterTimeout);
}
public GetMappingsRequest(StreamInput in) throws IOException { public GetMappingsRequest(StreamInput in) throws IOException {
super(in); 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.action.support.master.info.ClusterInfoRequestBuilder;
import org.elasticsearch.client.internal.ElasticsearchClient; import org.elasticsearch.client.internal.ElasticsearchClient;
import org.elasticsearch.core.TimeValue;
public class GetMappingsRequestBuilder extends ClusterInfoRequestBuilder< public class GetMappingsRequestBuilder extends ClusterInfoRequestBuilder<
GetMappingsRequest, GetMappingsRequest,
GetMappingsResponse, GetMappingsResponse,
GetMappingsRequestBuilder> { GetMappingsRequestBuilder> {
public GetMappingsRequestBuilder(ElasticsearchClient client, String... indices) { public GetMappingsRequestBuilder(ElasticsearchClient client, TimeValue masterTimeout, String... indices) {
super(client, GetMappingsAction.INSTANCE, new GetMappingsRequest().indices(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.Strings;
import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.core.TimeValue;
import java.io.IOException; import java.io.IOException;
@ -27,11 +28,22 @@ public abstract class ClusterInfoRequest<Request extends ClusterInfoRequest<Requ
private IndicesOptions indicesOptions = IndicesOptions.strictExpandOpen(); 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() { public ClusterInfoRequest() {
super(TRAPPY_IMPLICIT_DEFAULT_MASTER_NODE_TIMEOUT); super(TRAPPY_IMPLICIT_DEFAULT_MASTER_NODE_TIMEOUT);
} }
// So subclasses can override the default indices options, if needed // So subclasses can override the default indices options, if needed
@Deprecated(forRemoval = true)
protected ClusterInfoRequest(IndicesOptions indicesOptions) { protected ClusterInfoRequest(IndicesOptions indicesOptions) {
super(TRAPPY_IMPLICIT_DEFAULT_MASTER_NODE_TIMEOUT); super(TRAPPY_IMPLICIT_DEFAULT_MASTER_NODE_TIMEOUT);
this.indicesOptions = indicesOptions; this.indicesOptions = indicesOptions;

View file

@ -267,8 +267,8 @@ public class IndicesAdminClient implements ElasticsearchClient {
return execute(GetMappingsAction.INSTANCE, request); return execute(GetMappingsAction.INSTANCE, request);
} }
public GetMappingsRequestBuilder prepareGetMappings(String... indices) { public GetMappingsRequestBuilder prepareGetMappings(TimeValue masterTimeout, String... indices) {
return new GetMappingsRequestBuilder(this, indices); return new GetMappingsRequestBuilder(this, masterTimeout, indices);
} }
public void getFieldMappings(GetFieldMappingsRequest request, ActionListener<GetFieldMappingsResponse> listener) { 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.action.support.IndicesOptions;
import org.elasticsearch.client.internal.node.NodeClient; import org.elasticsearch.client.internal.node.NodeClient;
import org.elasticsearch.common.Strings; import org.elasticsearch.common.Strings;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.http.HttpChannel; import org.elasticsearch.http.HttpChannel;
import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.BaseRestHandler;
import org.elasticsearch.rest.RestRequest; import org.elasticsearch.rest.RestRequest;
@ -51,11 +50,9 @@ public class RestGetMappingAction extends BaseRestHandler {
@Override @Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
final String[] indices = Strings.splitStringByCommaToArray(request.param("index")); final String[] indices = Strings.splitStringByCommaToArray(request.param("index"));
final GetMappingsRequest getMappingsRequest = new GetMappingsRequest(); final GetMappingsRequest getMappingsRequest = new GetMappingsRequest(getMasterNodeTimeout(request));
getMappingsRequest.indices(indices); getMappingsRequest.indices(indices);
getMappingsRequest.indicesOptions(IndicesOptions.fromRequest(request, getMappingsRequest.indicesOptions())); getMappingsRequest.indicesOptions(IndicesOptions.fromRequest(request, getMappingsRequest.indicesOptions()));
final TimeValue timeout = getMasterNodeTimeout(request);
getMappingsRequest.masterNodeTimeout(timeout);
getMappingsRequest.local(request.paramAsBoolean("local", getMappingsRequest.local())); getMappingsRequest.local(request.paramAsBoolean("local", getMappingsRequest.local()));
final HttpChannel httpChannel = request.getHttpChannel(); final HttpChannel httpChannel = request.getHttpChannel();
return channel -> new RestCancellableNodeClient(client, httpChannel).admin() return channel -> new RestCancellableNodeClient(client, httpChannel).admin()

View file

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

View file

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

View file

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

View file

@ -371,7 +371,12 @@ public class IndexFollowingIT extends CcrIntegTestCase {
} }
assertBusy(() -> assertHitCount(followerClient().prepareSearch("index2"), firstBatchNumDocs)); 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.f.type", mappingMetadata.sourceAsMap()), equalTo("integer"));
assertThat(XContentMapValues.extractValue("properties.k", mappingMetadata.sourceAsMap()), nullValue()); assertThat(XContentMapValues.extractValue("properties.k", mappingMetadata.sourceAsMap()), nullValue());
@ -382,7 +387,12 @@ public class IndexFollowingIT extends CcrIntegTestCase {
} }
assertBusy(() -> assertHitCount(followerClient().prepareSearch("index2"), firstBatchNumDocs + secondBatchNumDocs)); 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.f.type", mappingMetadata.sourceAsMap()), equalTo("integer"));
assertThat(XContentMapValues.extractValue("properties.k.type", mappingMetadata.sourceAsMap()), equalTo("long")); assertThat(XContentMapValues.extractValue("properties.k.type", mappingMetadata.sourceAsMap()), equalTo("long"));
pauseFollow("index2"); pauseFollow("index2");
@ -410,7 +420,12 @@ public class IndexFollowingIT extends CcrIntegTestCase {
assertBusy(() -> assertHitCount(followerClient().prepareSearch("index2"), 1)); assertBusy(() -> assertHitCount(followerClient().prepareSearch("index2"), 1));
pauseFollow("index2"); 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.f.type", mappingMetadata.sourceAsMap()), equalTo("long"));
assertThat(XContentMapValues.extractValue("properties.k", mappingMetadata.sourceAsMap()), nullValue()); 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.type"), equalTo("custom"));
assertThat(getSettingsResponse.getSetting("follower", "index.analysis.analyzer.my_analyzer.tokenizer"), equalTo("keyword")); 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"); getMappingsRequest.indices("follower");
GetMappingsResponse getMappingsResponse = followerClient().admin().indices().getMappings(getMappingsRequest).actionGet(); GetMappingsResponse getMappingsResponse = followerClient().admin().indices().getMappings(getMappingsRequest).actionGet();
MappingMetadata mappingMetadata = getMappingsResponse.getMappings().get("follower"); 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 { 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); MappingMetadata mapping = getMappingsResponse.getMappings().get(sourceIdx);
String nested = useNested ? """ String nested = useNested ? """
,"incorrect":{"type":"object"},"nested":{"type":"nested","properties":{"value":{"type":"long"}}}""" : ""; ,"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 // At any point if there is an issue, delete the downsample index
// 1. Extract source index mappings // 1. Extract source index mappings
final GetMappingsRequest getMappingsRequest = new GetMappingsRequest().indices(sourceIndexName); final GetMappingsRequest getMappingsRequest = new GetMappingsRequest(request.masterNodeTimeout()).indices(sourceIndexName);
getMappingsRequest.setParentTask(parentTask); getMappingsRequest.setParentTask(parentTask);
client.admin().indices().getMappings(getMappingsRequest, listener.delegateFailureAndWrap((delegate, getMappingsResponse) -> { client.admin().indices().getMappings(getMappingsRequest, listener.delegateFailureAndWrap((delegate, getMappingsResponse) -> {
final Map<String, Object> sourceIndexMappings = getMappingsResponse.mappings() final Map<String, Object> sourceIndexMappings = getMappingsResponse.mappings()

View file

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

View file

@ -110,7 +110,8 @@ public class CreateIndexFromSourceActionIT extends ESIntegTestCase {
client().execute(CreateIndexFromSourceAction.INSTANCE, new CreateIndexFromSourceAction.Request(sourceIndex, destIndex)) 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(); Map<String, MappingMetadata> mappings = mappingsResponse.mappings();
var destMappings = mappings.get(destIndex).sourceAsMap(); var destMappings = mappings.get(destIndex).sourceAsMap();
var sourceMappings = mappings.get(sourceIndex).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(); Map<String, MappingMetadata> mappings = mappingsResponse.mappings();
var destMappings = mappings.get(destIndex).sourceAsMap(); var destMappings = mappings.get(destIndex).sourceAsMap();

View file

@ -213,7 +213,8 @@ public class ReindexDatastreamIndexTransportActionIT extends ESIntegTestCase {
.actionGet() .actionGet()
.getDestIndex(); .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(); Map<String, MappingMetadata> mappings = mappingsResponse.mappings();
var destMappings = mappings.get(destIndex).sourceAsMap(); var destMappings = mappings.get(destIndex).sourceAsMap();
var sourceMappings = mappings.get(sourceIndex).sourceAsMap(); var sourceMappings = mappings.get(sourceIndex).sourceAsMap();
@ -319,7 +320,8 @@ public class ReindexDatastreamIndexTransportActionIT extends ESIntegTestCase {
// verify mappings from templates copied to dest index // 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 destMappings = mappingsResponse.mappings().get(destIndex).sourceAsMap();
var sourceMappings = mappingsResponse.mappings().get(sourceIndex).sourceAsMap(); var sourceMappings = mappingsResponse.mappings().get(sourceIndex).sourceAsMap();
assertEquals(sourceMappings, destMappings); 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. // Assert that the mappings contain all the additional fields: field1, field2, field3, etc.
String sharedResultsIndex = AnomalyDetectorsIndexFields.RESULTS_INDEX_PREFIX + AnomalyDetectorsIndexFields.RESULTS_INDEX_DEFAULT; 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(); GetMappingsResponse response = client().execute(GetMappingsAction.INSTANCE, request).actionGet();
Map<String, MappingMetadata> indexMappings = response.getMappings(); Map<String, MappingMetadata> indexMappings = response.getMappings();
assertNotNull(indexMappings); assertNotNull(indexMappings);
@ -506,7 +506,7 @@ public class JobResultsProviderIT extends MlSingleNodeTestCase {
} }
private Map<String, Object> getIndexMappingProperties(String index) { 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(); GetMappingsResponse response = client().execute(GetMappingsAction.INSTANCE, request).actionGet();
Map<String, MappingMetadata> indexMappings = response.getMappings(); Map<String, MappingMetadata> indexMappings = response.getMappings();
assertNotNull(indexMappings); assertNotNull(indexMappings);

View file

@ -223,7 +223,7 @@ public class TransportStartDataFrameAnalyticsAction extends TransportMasterNodeA
); );
// Get start context // Get start context
getStartContext(request.getId(), task, startContextListener); getStartContext(request.getId(), task, startContextListener, request.masterNodeTimeout());
} }
private void estimateMemoryUsageAndUpdateMemoryTracker(StartContext startContext, ActionListener<StartContext> listener) { 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()); ParentTaskAssigningClient parentTaskClient = new ParentTaskAssigningClient(client, task.getParentTaskId());
@ -320,6 +320,7 @@ public class TransportStartDataFrameAnalyticsAction extends TransportMasterNodeA
.<StartContext>andThen( .<StartContext>andThen(
(l, startContext) -> MappingsMerger.mergeMappings( (l, startContext) -> MappingsMerger.mergeMappings(
parentTaskClient, parentTaskClient,
masterTimeout,
startContext.config.getHeaders(), startContext.config.getHeaders(),
startContext.config.getSource(), startContext.config.getSource(),
l.map(ignored -> startContext) 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.DataFrameAnalyticsDest;
import org.elasticsearch.xpack.core.ml.dataframe.analyses.RequiredField; import org.elasticsearch.xpack.core.ml.dataframe.analyses.RequiredField;
import org.elasticsearch.xpack.core.ml.utils.ExceptionsHelper; import org.elasticsearch.xpack.core.ml.utils.ExceptionsHelper;
import org.elasticsearch.xpack.ml.MachineLearning;
import java.time.Clock; import java.time.Clock;
import java.util.Arrays; import java.util.Arrays;
@ -147,6 +148,7 @@ public final class DestinationIndex {
final Settings settings = settings(settingsResponse, destIndexAllowedSettings); final Settings settings = settings(settingsResponse, destIndexAllowedSettings);
MappingsMerger.mergeMappings( MappingsMerger.mergeMappings(
client, client,
MachineLearning.HARD_CODED_MACHINE_LEARNING_MASTER_NODE_TIMEOUT,
config.getHeaders(), config.getHeaders(),
config.getSource(), config.getSource(),
delegate.delegateFailureAndWrap( 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.action.admin.indices.mapping.get.GetMappingsResponse;
import org.elasticsearch.client.internal.Client; import org.elasticsearch.client.internal.Client;
import org.elasticsearch.cluster.metadata.MappingMetadata; import org.elasticsearch.cluster.metadata.MappingMetadata;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.mapper.MapperService;
import org.elasticsearch.xpack.core.ClientHelper; import org.elasticsearch.xpack.core.ClientHelper;
import org.elasticsearch.xpack.core.ml.dataframe.DataFrameAnalyticsSource; import org.elasticsearch.xpack.core.ml.dataframe.DataFrameAnalyticsSource;
@ -34,6 +35,7 @@ public final class MappingsMerger {
public static void mergeMappings( public static void mergeMappings(
Client client, Client client,
TimeValue masterTimeout,
Map<String, String> headers, Map<String, String> headers,
DataFrameAnalyticsSource source, DataFrameAnalyticsSource source,
ActionListener<MappingMetadata> listener ActionListener<MappingMetadata> listener
@ -43,7 +45,7 @@ public final class MappingsMerger {
listener::onFailure listener::onFailure
); );
GetMappingsRequest getMappingsRequest = new GetMappingsRequest(); GetMappingsRequest getMappingsRequest = new GetMappingsRequest(masterTimeout);
getMappingsRequest.indices(source.getIndex()); getMappingsRequest.indices(source.getIndex());
ClientHelper.executeWithHeadersAsync(headers, ML_ORIGIN, client, GetMappingsAction.INSTANCE, getMappingsRequest, mappingsListener); 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.stats.StatsAccumulator;
import org.elasticsearch.xpack.core.ml.utils.ExceptionsHelper; import org.elasticsearch.xpack.core.ml.utils.ExceptionsHelper;
import org.elasticsearch.xpack.core.security.support.Exceptions; 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.categorization.GrokPatternCreator;
import org.elasticsearch.xpack.ml.job.persistence.InfluencersQueryBuilder.InfluencersQuery; import org.elasticsearch.xpack.ml.job.persistence.InfluencersQueryBuilder.InfluencersQuery;
import org.elasticsearch.xpack.ml.job.process.autodetect.params.AutodetectParams; import org.elasticsearch.xpack.ml.job.process.autodetect.params.AutodetectParams;
@ -392,7 +393,10 @@ public class JobResultsProvider {
addTermsMapping(indexMappings, indexName, termFields, listener); addTermsMapping(indexMappings, indexName, termFields, listener);
}, listener::onFailure); }, 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( executeAsyncWithOrigin(
client.threadPool().getThreadContext(), client.threadPool().getThreadContext(),
ML_ORIGIN, ML_ORIGIN,

View file

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

View file

@ -166,7 +166,14 @@ public class PutJobStateMachineTests extends ESTestCase {
return null; return null;
}).when(client).execute(eq(GetMappingsAction.INSTANCE), any(GetMappingsRequest.class), requestCaptor.capture()); }).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()); verify(client).execute(eq(GetMappingsAction.INSTANCE), any(GetMappingsRequest.class), any());
} }
@ -201,7 +208,14 @@ public class PutJobStateMachineTests extends ESTestCase {
return null; return null;
}).when(client).execute(eq(GetMappingsAction.INSTANCE), any(GetMappingsRequest.class), requestCaptor.capture()); }).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()); verify(client).execute(eq(GetMappingsAction.INSTANCE), any(GetMappingsRequest.class), any());
} }
@ -238,7 +252,14 @@ public class PutJobStateMachineTests extends ESTestCase {
return null; return null;
}).when(client).execute(eq(GetMappingsAction.INSTANCE), any(GetMappingsRequest.class), requestCaptor.capture()); }).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()); verify(client).execute(eq(GetMappingsAction.INSTANCE), any(GetMappingsRequest.class), any());
} }
@ -272,7 +293,14 @@ public class PutJobStateMachineTests extends ESTestCase {
return null; return null;
}).when(client).execute(eq(GetMappingsAction.INSTANCE), any(GetMappingsRequest.class), requestCaptor.capture()); }).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()); verify(client).execute(eq(GetMappingsAction.INSTANCE), any(GetMappingsRequest.class), any());
} }
@ -318,7 +346,14 @@ public class PutJobStateMachineTests extends ESTestCase {
return null; return null;
}).when(client).execute(eq(TransportPutMappingAction.TYPE), any(PutMappingRequest.class), requestCaptor2.capture()); }).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(GetMappingsAction.INSTANCE), any(GetMappingsRequest.class), any());
verify(client).execute(eq(TransportPutMappingAction.TYPE), any(PutMappingRequest.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( GetMappingsResponse getMappingsResponse = client().filterWithHeader(
Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user1", USERS_PASSWD)) 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"); assertExpectedMetadataFields(getMappingsResponse.getMappings(), "field1");
} }
{ {
GetMappingsResponse getMappingsResponse = client().filterWithHeader( GetMappingsResponse getMappingsResponse = client().filterWithHeader(
Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user2", USERS_PASSWD)) 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"); assertExpectedMetadataFields(getMappingsResponse.getMappings(), "field2");
} }
{ {
GetMappingsResponse getMappingsResponse = client().filterWithHeader( GetMappingsResponse getMappingsResponse = client().filterWithHeader(
Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user3", USERS_PASSWD)) 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"); assertExpectedMetadataFields(getMappingsResponse.getMappings(), "field1");
} }
{ {
GetMappingsResponse getMappingsResponse = client().filterWithHeader( GetMappingsResponse getMappingsResponse = client().filterWithHeader(
Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user4", USERS_PASSWD)) 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"); assertExpectedMetadataFields(getMappingsResponse.getMappings(), "field1", "field2");
} }
} }

View file

@ -166,7 +166,7 @@ public class KibanaUserRoleIntegTests extends NativeRealmIntegTestCase {
GetMappingsResponse response = client().filterWithHeader( GetMappingsResponse response = client().filterWithHeader(
singletonMap("Authorization", UsernamePasswordToken.basicAuthHeaderValue("kibana_user", USERS_PASSWD)) 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(); Map<String, MappingMetadata> mappingsMap = response.getMappings();
assertNotNull(mappingsMap); assertNotNull(mappingsMap);
assertNotNull(mappingsMap.get(index)); assertNotNull(mappingsMap.get(index));

View file

@ -172,7 +172,8 @@ public class HistoryTemplateHttpMappingsTests extends AbstractWatcherIntegration
// ensure that enabled is set to false // ensure that enabled is set to false
List<Boolean> indexed = new ArrayList<>(); 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()) { for (MappingMetadata mapping : mappingsResponse.getMappings().values()) {
Map<String, Object> docMapping = mapping.getSourceAsMap(); Map<String, Object> docMapping = mapping.getSourceAsMap();
if (abortAtInput) { if (abortAtInput) {

View file

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

View file

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