Skip to content

Commit acfc91f

Browse files
committed
Remove flatSettings support from request classes (#29560)
As part of adding support for new API to the high-level REST client, we added support for the `flat_settings` parameter to some of our request classes. We added documentation that such flag is only ever read by the high-level REST client, but the truth is that it doesn't do anything given that settings are always parsed back into a `Settings` object, no matter whether they are returned in a flat format or not. It was a mistake to add support for this flag in the context of the high-level REST client, hence this commit removes it.
1 parent 688854d commit acfc91f

File tree

11 files changed

+2
-115
lines changed

11 files changed

+2
-115
lines changed

client/rest-high-level/src/main/java/org/elasticsearch/client/Request.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,6 @@ private static Request resize(ResizeRequest resizeRequest) throws IOException {
581581

582582
static Request clusterPutSettings(ClusterUpdateSettingsRequest clusterUpdateSettingsRequest) throws IOException {
583583
Params parameters = Params.builder();
584-
parameters.withFlatSettings(clusterUpdateSettingsRequest.flatSettings());
585584
parameters.withTimeout(clusterUpdateSettingsRequest.timeout());
586585
parameters.withMasterTimeout(clusterUpdateSettingsRequest.masterNodeTimeout());
587586
HttpEntity entity = createEntity(clusterUpdateSettingsRequest, REQUEST_BODY_CONTENT_TYPE);
@@ -612,7 +611,6 @@ static Request indicesExist(GetIndexRequest request) {
612611
params.withLocal(request.local());
613612
params.withHuman(request.humanReadable());
614613
params.withIndicesOptions(request.indicesOptions());
615-
params.withFlatSettings(request.flatSettings());
616614
params.withIncludeDefaults(request.includeDefaults());
617615
return new Request(HttpHead.METHOD_NAME, endpoint, params.getParams(), null);
618616
}
@@ -622,7 +620,6 @@ static Request indexPutSettings(UpdateSettingsRequest updateSettingsRequest) thr
622620
parameters.withTimeout(updateSettingsRequest.timeout());
623621
parameters.withMasterTimeout(updateSettingsRequest.masterNodeTimeout());
624622
parameters.withIndicesOptions(updateSettingsRequest.indicesOptions());
625-
parameters.withFlatSettings(updateSettingsRequest.flatSettings());
626623
parameters.withPreserveExisting(updateSettingsRequest.isPreserveExisting());
627624

628625
String[] indices = updateSettingsRequest.indices() == null ? Strings.EMPTY_ARRAY : updateSettingsRequest.indices();

client/rest-high-level/src/test/java/org/elasticsearch/client/RequestTests.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,6 @@ public void testIndicesExist() {
280280
Map<String, String> expectedParams = new HashMap<>();
281281
setRandomIndicesOptions(getIndexRequest::indicesOptions, getIndexRequest::indicesOptions, expectedParams);
282282
setRandomLocal(getIndexRequest, expectedParams);
283-
setRandomFlatSettings(getIndexRequest::flatSettings, expectedParams);
284283
setRandomHumanReadable(getIndexRequest, expectedParams);
285284
setRandomIncludeDefaults(getIndexRequest, expectedParams);
286285

@@ -1322,7 +1321,6 @@ private static void resizeTest(ResizeType resizeType, CheckedFunction<ResizeRequ
13221321
public void testClusterPutSettings() throws IOException {
13231322
ClusterUpdateSettingsRequest request = new ClusterUpdateSettingsRequest();
13241323
Map<String, String> expectedParams = new HashMap<>();
1325-
setRandomFlatSettings(request::flatSettings, expectedParams);
13261324
setRandomMasterTimeout(request, expectedParams);
13271325
setRandomTimeout(request::timeout, AcknowledgedRequest.DEFAULT_ACK_TIMEOUT, expectedParams);
13281326

@@ -1375,7 +1373,6 @@ public void testIndexPutSettings() throws IOException {
13751373
String[] indices = randomBoolean() ? null : randomIndicesNames(0, 2);
13761374
UpdateSettingsRequest updateSettingsRequest = new UpdateSettingsRequest(indices);
13771375
Map<String, String> expectedParams = new HashMap<>();
1378-
setRandomFlatSettings(updateSettingsRequest::flatSettings, expectedParams);
13791376
setRandomMasterTimeout(updateSettingsRequest, expectedParams);
13801377
setRandomTimeout(updateSettingsRequest::timeout, AcknowledgedRequest.DEFAULT_ACK_TIMEOUT, expectedParams);
13811378
setRandomIndicesOptions(updateSettingsRequest::indicesOptions, updateSettingsRequest::indicesOptions, expectedParams);
@@ -1658,16 +1655,6 @@ private static void setRandomTimeout(Consumer<String> setter, TimeValue defaultT
16581655
}
16591656
}
16601657

1661-
private static void setRandomFlatSettings(Consumer<Boolean> setter, Map<String, String> expectedParams) {
1662-
if (randomBoolean()) {
1663-
boolean flatSettings = randomBoolean();
1664-
setter.accept(flatSettings);
1665-
if (flatSettings) {
1666-
expectedParams.put("flat_settings", String.valueOf(flatSettings));
1667-
}
1668-
}
1669-
}
1670-
16711658
private static void setRandomMasterTimeout(MasterNodeRequest<?> request, Map<String, String> expectedParams) {
16721659
if (randomBoolean()) {
16731660
String masterTimeout = randomTimeValue();

client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/ClusterClientDocumentationIT.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,6 @@ public void testClusterPutSettings() throws IOException {
124124
request.masterNodeTimeout("1m"); // <2>
125125
// end::put-settings-request-masterTimeout
126126

127-
// tag::put-settings-request-flat-settings
128-
request.flatSettings(true); // <1>
129-
// end::put-settings-request-flat-settings
130-
131127
// tag::put-settings-execute
132128
ClusterUpdateSettingsResponse response = client.cluster().putSettings(request);
133129
// end::put-settings-execute

client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/IndicesClientDocumentationIT.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@
5858
import org.elasticsearch.action.support.IndicesOptions;
5959
import org.elasticsearch.client.ESRestHighLevelClientTestCase;
6060
import org.elasticsearch.client.RestHighLevelClient;
61-
import org.elasticsearch.cluster.metadata.IndexMetaData;
6261
import org.elasticsearch.common.settings.Settings;
6362
import org.elasticsearch.common.unit.ByteSizeUnit;
6463
import org.elasticsearch.common.unit.ByteSizeValue;
@@ -114,8 +113,7 @@ public void testIndicesExist() throws IOException {
114113
request.local(false); // <1>
115114
request.humanReadable(true); // <2>
116115
request.includeDefaults(false); // <3>
117-
request.flatSettings(false); // <4>
118-
request.indicesOptions(indicesOptions); // <5>
116+
request.indicesOptions(indicesOptions); // <4>
119117
// end::indices-exists-request-optionals
120118

121119
// tag::indices-exists-response
@@ -1433,9 +1431,6 @@ public void testIndexPutSettings() throws Exception {
14331431
// end::put-settings-settings-source
14341432
}
14351433

1436-
// tag::put-settings-request-flat-settings
1437-
request.flatSettings(true); // <1>
1438-
// end::put-settings-request-flat-settings
14391434
// tag::put-settings-request-preserveExisting
14401435
request.setPreserveExisting(false); // <1>
14411436
// end::put-settings-request-preserveExisting

docs/java-rest/high-level/cluster/put_settings.asciidoc

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,6 @@ include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[put-settings-setti
5454
==== Optional Arguments
5555
The following arguments can optionally be provided:
5656

57-
["source","java",subs="attributes,callouts,macros"]
58-
--------------------------------------------------
59-
include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[put-settings-request-flat-settings]
60-
--------------------------------------------------
61-
<1> Whether the updated settings returned in the `ClusterUpdateSettings` should
62-
be in a flat format
63-
6457
["source","java",subs="attributes,callouts,macros"]
6558
--------------------------------------------------
6659
include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[put-settings-request-timeout]

docs/java-rest/high-level/indices/indices_exists.asciidoc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[indices-exists-req
2323
<1> Whether to return local information or retrieve the state from master node
2424
<2> Return result in a format suitable for humans
2525
<3> Whether to return all default setting for each of the indices
26-
<4> Return settings in flat format
27-
<5> Controls how unavailable indices are resolved and how wildcard expressions are expanded
26+
<4> Controls how unavailable indices are resolved and how wildcard expressions are expanded
2827

2928
[[java-rest-high-indices-sync]]
3029
==== Synchronous Execution

docs/java-rest/high-level/indices/put_settings.asciidoc

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,6 @@ include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[put-settings-setti
5555
==== Optional Arguments
5656
The following arguments can optionally be provided:
5757

58-
["source","java",subs="attributes,callouts,macros"]
59-
--------------------------------------------------
60-
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[put-settings-request-flat-settings]
61-
--------------------------------------------------
62-
<1> Whether the updated settings returned in the `UpdateSettings` should
63-
be in a flat format
64-
6558
["source","java",subs="attributes,callouts,macros"]
6659
--------------------------------------------------
6760
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[put-settings-request-preserveExisting]

server/src/main/java/org/elasticsearch/action/admin/cluster/settings/ClusterUpdateSettingsRequest.java

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ public class ClusterUpdateSettingsRequest extends AcknowledgedRequest<ClusterUpd
5858
PARSER.declareObject((r, t) -> r.transientSettings = t, (p, c) -> Settings.fromXContent(p), TRANSIENT);
5959
}
6060

61-
private boolean flatSettings = false;
6261
private Settings transientSettings = EMPTY_SETTINGS;
6362
private Settings persistentSettings = EMPTY_SETTINGS;
6463

@@ -74,29 +73,6 @@ public ActionRequestValidationException validate() {
7473
return validationException;
7574
}
7675

77-
/**
78-
* Sets the value of "flat_settings".
79-
* Used only by the high-level REST client.
80-
*
81-
* @param flatSettings
82-
* value of "flat_settings" flag to be set
83-
* @return this request
84-
*/
85-
public ClusterUpdateSettingsRequest flatSettings(boolean flatSettings) {
86-
this.flatSettings = flatSettings;
87-
return this;
88-
}
89-
90-
/**
91-
* Return settings in flat format.
92-
* Used only by the high-level REST client.
93-
*
94-
* @return <code>true</code> if settings need to be returned in flat format; <code>false</code> otherwise.
95-
*/
96-
public boolean flatSettings() {
97-
return flatSettings;
98-
}
99-
10076
public Settings transientSettings() {
10177
return transientSettings;
10278
}

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

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ public static Feature fromId(byte id) {
6666
private static final Feature[] DEFAULT_FEATURES = new Feature[] { Feature.ALIASES, Feature.MAPPINGS, Feature.SETTINGS };
6767
private Feature[] features = DEFAULT_FEATURES;
6868
private boolean humanReadable = false;
69-
private transient boolean flatSettings = false;
7069
private transient boolean includeDefaults = false;
7170

7271
public GetIndexRequest features(Feature... features) {
@@ -104,28 +103,6 @@ public boolean humanReadable() {
104103
return humanReadable;
105104
}
106105

107-
/**
108-
* Sets the value of "flat_settings".
109-
* Used only by the high-level REST client.
110-
*
111-
* @param flatSettings value of "flat_settings" flag to be set
112-
* @return this request
113-
*/
114-
public GetIndexRequest flatSettings(boolean flatSettings) {
115-
this.flatSettings = flatSettings;
116-
return this;
117-
}
118-
119-
/**
120-
* Return settings in flat format.
121-
* Used only by the high-level REST client.
122-
*
123-
* @return <code>true</code> if settings need to be returned in flat format; <code>false</code> otherwise.
124-
*/
125-
public boolean flatSettings() {
126-
return flatSettings;
127-
}
128-
129106
/**
130107
* Sets the value of "include_defaults".
131108
* Used only by the high-level REST client.

server/src/main/java/org/elasticsearch/action/admin/indices/settings/put/UpdateSettingsRequest.java

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ public class UpdateSettingsRequest extends AcknowledgedRequest<UpdateSettingsReq
5555
private IndicesOptions indicesOptions = IndicesOptions.fromOptions(false, false, true, true);
5656
private Settings settings = EMPTY_SETTINGS;
5757
private boolean preserveExisting = false;
58-
private boolean flatSettings = false;
5958

6059
public UpdateSettingsRequest() {
6160
}
@@ -75,29 +74,6 @@ public UpdateSettingsRequest(Settings settings, String... indices) {
7574
this.settings = settings;
7675
}
7776

78-
/**
79-
* Sets the value of "flat_settings".
80-
* Used only by the high-level REST client.
81-
*
82-
* @param flatSettings
83-
* value of "flat_settings" flag to be set
84-
* @return this request
85-
*/
86-
public UpdateSettingsRequest flatSettings(boolean flatSettings) {
87-
this.flatSettings = flatSettings;
88-
return this;
89-
}
90-
91-
/**
92-
* Return settings in flat format.
93-
* Used only by the high-level REST client.
94-
*
95-
* @return <code>true</code> if settings need to be returned in flat format; <code>false</code> otherwise.
96-
*/
97-
public boolean flatSettings() {
98-
return flatSettings;
99-
}
100-
10177
@Override
10278
public ActionRequestValidationException validate() {
10379
ActionRequestValidationException validationException = null;

0 commit comments

Comments
 (0)