Skip to content

Commit f53005e

Browse files
committed
Run cluster info requests on local node
1 parent 5efe216 commit f53005e

File tree

21 files changed

+90
-319
lines changed

21 files changed

+90
-319
lines changed

rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/indices.exists/10_basic.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,14 @@
1717
- is_true: ''
1818
---
1919
"Test indices.exists with local flag":
20+
- requires:
21+
test_runner_features: ["allowed_warnings"]
22+
2023
- do:
2124
indices.exists:
2225
index: test_index
2326
local: true
27+
allowed_warnings:
28+
- "the [?local] query parameter to this API has no effect, is now deprecated, and will be removed in a future version"
2429

2530
- is_false: ''

server/src/internalClusterTest/java/org/elasticsearch/cluster/SimpleClusterStateIT.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,6 @@ public void testLargeClusterStatePublishing() throws Exception {
266266
MappingMetadata mappingMetadata = client.admin()
267267
.indices()
268268
.prepareGetMappings(TEST_REQUEST_TIMEOUT, "test")
269-
.setLocal(true)
270269
.get()
271270
.getMappings()
272271
.get("test");

server/src/main/java/org/elasticsearch/action/admin/indices/get/GetIndexRequest.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,12 @@
1717
import org.elasticsearch.common.util.ArrayUtils;
1818
import org.elasticsearch.core.TimeValue;
1919
import org.elasticsearch.rest.RestRequest;
20-
import org.elasticsearch.tasks.CancellableTask;
21-
import org.elasticsearch.tasks.Task;
22-
import org.elasticsearch.tasks.TaskId;
2320

2421
import java.io.IOException;
2522
import java.util.ArrayList;
2623
import java.util.EnumSet;
2724
import java.util.List;
2825
import java.util.Locale;
29-
import java.util.Map;
3026
import java.util.Set;
3127

3228
/**
@@ -168,9 +164,4 @@ public void writeTo(StreamOutput out) throws IOException {
168164
out.writeBoolean(humanReadable);
169165
out.writeBoolean(includeDefaults);
170166
}
171-
172-
@Override
173-
public Task createTask(long id, String type, String action, TaskId parentTaskId, Map<String, String> headers) {
174-
return new CancellableTask(id, type, action, getDescription(), parentTaskId, headers);
175-
}
176167
}

server/src/main/java/org/elasticsearch/action/admin/indices/get/TransportGetIndexAction.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,7 @@ public TransportGetIndexAction(
6363
threadPool,
6464
actionFilters,
6565
GetIndexRequest::new,
66-
indexNameExpressionResolver,
67-
GetIndexResponse::new
66+
indexNameExpressionResolver
6867
);
6968
this.indicesService = indicesService;
7069
this.settingsFilter = settingsFilter;

server/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/GetMappingsRequest.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,8 @@
1313
import org.elasticsearch.action.support.master.info.ClusterInfoRequest;
1414
import org.elasticsearch.common.io.stream.StreamInput;
1515
import org.elasticsearch.core.TimeValue;
16-
import org.elasticsearch.tasks.CancellableTask;
17-
import org.elasticsearch.tasks.Task;
18-
import org.elasticsearch.tasks.TaskId;
1916

2017
import java.io.IOException;
21-
import java.util.Map;
2218

2319
public class GetMappingsRequest extends ClusterInfoRequest<GetMappingsRequest> {
2420

@@ -34,9 +30,4 @@ public GetMappingsRequest(StreamInput in) throws IOException {
3430
public ActionRequestValidationException validate() {
3531
return null;
3632
}
37-
38-
@Override
39-
public Task createTask(long id, String type, String action, TaskId parentTaskId, Map<String, String> headers) {
40-
return new CancellableTask(id, type, action, "", parentTaskId, headers);
41-
}
4233
}

server/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/GetMappingsResponse.java

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,13 @@
99

1010
package org.elasticsearch.action.admin.indices.mapping.get;
1111

12-
import org.elasticsearch.TransportVersions;
1312
import org.elasticsearch.action.ActionResponse;
1413
import org.elasticsearch.cluster.metadata.MappingMetadata;
1514
import org.elasticsearch.common.Strings;
1615
import org.elasticsearch.common.collect.Iterators;
17-
import org.elasticsearch.common.io.stream.StreamInput;
1816
import org.elasticsearch.common.io.stream.StreamOutput;
1917
import org.elasticsearch.common.xcontent.ChunkedToXContentObject;
20-
import org.elasticsearch.index.mapper.MapperService;
18+
import org.elasticsearch.core.UpdateForV10;
2119
import org.elasticsearch.xcontent.ParseField;
2220
import org.elasticsearch.xcontent.ToXContent;
2321

@@ -35,21 +33,6 @@ public GetMappingsResponse(Map<String, MappingMetadata> mappings) {
3533
this.mappings = mappings;
3634
}
3735

38-
GetMappingsResponse(StreamInput in) throws IOException {
39-
super(in);
40-
mappings = in.readImmutableMap(in.getTransportVersion().before(TransportVersions.V_8_0_0) ? i -> {
41-
int mappingCount = i.readVInt();
42-
assert mappingCount == 1 || mappingCount == 0 : "Expected 0 or 1 mappings but got " + mappingCount;
43-
if (mappingCount == 1) {
44-
String type = i.readString();
45-
assert MapperService.SINGLE_MAPPING_NAME.equals(type) : "Expected type [_doc] but got [" + type + "]";
46-
return new MappingMetadata(i);
47-
} else {
48-
return MappingMetadata.EMPTY_MAPPINGS;
49-
}
50-
} : i -> i.readBoolean() ? new MappingMetadata(i) : MappingMetadata.EMPTY_MAPPINGS);
51-
}
52-
5336
public Map<String, MappingMetadata> mappings() {
5437
return mappings;
5538
}
@@ -58,6 +41,11 @@ public Map<String, MappingMetadata> getMappings() {
5841
return mappings();
5942
}
6043

44+
/**
45+
* NB prior to 9.0 this was a TransportMasterNodeReadAction so for BwC we must remain able to write these responses until
46+
* we no longer need to support calling this action remotely.
47+
*/
48+
@UpdateForV10(owner = UpdateForV10.Owner.DATA_MANAGEMENT)
6149
@Override
6250
public void writeTo(StreamOutput out) throws IOException {
6351
MappingMetadata.writeMappingMetadata(out, mappings);

server/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/TransportGetMappingsAction.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ public TransportGetMappingsAction(
5050
threadPool,
5151
actionFilters,
5252
GetMappingsRequest::new,
53-
indexNameExpressionResolver,
54-
GetMappingsResponse::new
53+
indexNameExpressionResolver
5554
);
5655
this.indicesService = indicesService;
5756
}

server/src/main/java/org/elasticsearch/action/support/local/LocalClusterStateRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ protected LocalClusterStateRequest(StreamInput in) throws IOException {
5050
}
5151

5252
@Override
53-
public final void writeTo(StreamOutput out) throws IOException {
53+
public void writeTo(StreamOutput out) throws IOException {
5454
TransportAction.localOnly();
5555
}
5656

server/src/main/java/org/elasticsearch/action/support/master/info/ClusterInfoRequest.java

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,19 @@
1212
import org.elasticsearch.TransportVersions;
1313
import org.elasticsearch.action.IndicesRequest;
1414
import org.elasticsearch.action.support.IndicesOptions;
15-
import org.elasticsearch.action.support.master.MasterNodeReadRequest;
15+
import org.elasticsearch.action.support.local.LocalClusterStateRequest;
1616
import org.elasticsearch.common.Strings;
1717
import org.elasticsearch.common.io.stream.StreamInput;
18-
import org.elasticsearch.common.io.stream.StreamOutput;
1918
import org.elasticsearch.core.TimeValue;
19+
import org.elasticsearch.core.UpdateForV10;
20+
import org.elasticsearch.tasks.CancellableTask;
21+
import org.elasticsearch.tasks.Task;
22+
import org.elasticsearch.tasks.TaskId;
2023

2124
import java.io.IOException;
25+
import java.util.Map;
2226

23-
public abstract class ClusterInfoRequest<Request extends ClusterInfoRequest<Request>> extends MasterNodeReadRequest<Request>
27+
public abstract class ClusterInfoRequest<Request extends ClusterInfoRequest<Request>> extends LocalClusterStateRequest
2428
implements
2529
IndicesRequest.Replaceable {
2630

@@ -37,18 +41,11 @@ public ClusterInfoRequest(TimeValue masterTimeout, IndicesOptions indicesOptions
3741
this.indicesOptions = indicesOptions;
3842
}
3943

40-
@Deprecated(forRemoval = true)
41-
public ClusterInfoRequest() {
42-
super(TRAPPY_IMPLICIT_DEFAULT_MASTER_NODE_TIMEOUT);
43-
}
44-
45-
// So subclasses can override the default indices options, if needed
46-
@Deprecated(forRemoval = true)
47-
protected ClusterInfoRequest(IndicesOptions indicesOptions) {
48-
super(TRAPPY_IMPLICIT_DEFAULT_MASTER_NODE_TIMEOUT);
49-
this.indicesOptions = indicesOptions;
50-
}
51-
44+
/**
45+
* NB prior to 9.0 this was a TransportMasterNodeReadAction so for BwC we must remain able to read these requests until
46+
* we no longer need to support calling this action remotely.
47+
*/
48+
@UpdateForV10(owner = UpdateForV10.Owner.DATA_MANAGEMENT)
5249
public ClusterInfoRequest(StreamInput in) throws IOException {
5350
super(in);
5451
indices = in.readStringArray();
@@ -59,13 +56,8 @@ public ClusterInfoRequest(StreamInput in) throws IOException {
5956
}
6057

6158
@Override
62-
public void writeTo(StreamOutput out) throws IOException {
63-
super.writeTo(out);
64-
out.writeStringArray(indices);
65-
if (out.getTransportVersion().before(TransportVersions.V_8_0_0)) {
66-
out.writeStringArray(Strings.EMPTY_ARRAY);
67-
}
68-
indicesOptions.writeIndicesOptions(out);
59+
public Task createTask(long id, String type, String action, TaskId parentTaskId, Map<String, String> headers) {
60+
return new CancellableTask(id, type, action, getDescription(), parentTaskId, headers);
6961
}
7062

7163
@Override

server/src/main/java/org/elasticsearch/action/support/master/info/ClusterInfoRequestBuilder.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,17 @@
88
*/
99
package org.elasticsearch.action.support.master.info;
1010

11+
import org.elasticsearch.action.ActionRequestBuilder;
1112
import org.elasticsearch.action.ActionResponse;
1213
import org.elasticsearch.action.ActionType;
1314
import org.elasticsearch.action.support.IndicesOptions;
14-
import org.elasticsearch.action.support.master.MasterNodeReadOperationRequestBuilder;
1515
import org.elasticsearch.client.internal.ElasticsearchClient;
1616
import org.elasticsearch.common.util.ArrayUtils;
1717

1818
public abstract class ClusterInfoRequestBuilder<
1919
Request extends ClusterInfoRequest<Request>,
2020
Response extends ActionResponse,
21-
Builder extends ClusterInfoRequestBuilder<Request, Response, Builder>> extends MasterNodeReadOperationRequestBuilder<
22-
Request,
23-
Response,
24-
Builder> {
21+
Builder extends ClusterInfoRequestBuilder<Request, Response, Builder>> extends ActionRequestBuilder<Request, Response> {
2522

2623
protected ClusterInfoRequestBuilder(ElasticsearchClient client, ActionType<Response> action, Request request) {
2724
super(client, action, request);

0 commit comments

Comments
 (0)