Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove flatSettings support from request classes #29560

Merged
merged 1 commit into from
Apr 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,6 @@ private static Request resize(ResizeRequest resizeRequest) throws IOException {

static Request clusterPutSettings(ClusterUpdateSettingsRequest clusterUpdateSettingsRequest) throws IOException {
Params parameters = Params.builder();
parameters.withFlatSettings(clusterUpdateSettingsRequest.flatSettings());
parameters.withTimeout(clusterUpdateSettingsRequest.timeout());
parameters.withMasterTimeout(clusterUpdateSettingsRequest.masterNodeTimeout());
HttpEntity entity = createEntity(clusterUpdateSettingsRequest, REQUEST_BODY_CONTENT_TYPE);
Expand Down Expand Up @@ -603,7 +602,6 @@ static Request indicesExist(GetIndexRequest request) {
params.withLocal(request.local());
params.withHuman(request.humanReadable());
params.withIndicesOptions(request.indicesOptions());
params.withFlatSettings(request.flatSettings());
params.withIncludeDefaults(request.includeDefaults());
return new Request(HttpHead.METHOD_NAME, endpoint, params.getParams(), null);
}
Expand All @@ -613,7 +611,6 @@ static Request indexPutSettings(UpdateSettingsRequest updateSettingsRequest) thr
parameters.withTimeout(updateSettingsRequest.timeout());
parameters.withMasterTimeout(updateSettingsRequest.masterNodeTimeout());
parameters.withIndicesOptions(updateSettingsRequest.indicesOptions());
parameters.withFlatSettings(updateSettingsRequest.flatSettings());
parameters.withPreserveExisting(updateSettingsRequest.isPreserveExisting());

String[] indices = updateSettingsRequest.indices() == null ? Strings.EMPTY_ARRAY : updateSettingsRequest.indices();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,6 @@ public void testIndicesExist() {
Map<String, String> expectedParams = new HashMap<>();
setRandomIndicesOptions(getIndexRequest::indicesOptions, getIndexRequest::indicesOptions, expectedParams);
setRandomLocal(getIndexRequest, expectedParams);
setRandomFlatSettings(getIndexRequest::flatSettings, expectedParams);
setRandomHumanReadable(getIndexRequest, expectedParams);
setRandomIncludeDefaults(getIndexRequest, expectedParams);

Expand Down Expand Up @@ -1292,7 +1291,6 @@ private static void resizeTest(ResizeType resizeType, CheckedFunction<ResizeRequ
public void testClusterPutSettings() throws IOException {
ClusterUpdateSettingsRequest request = new ClusterUpdateSettingsRequest();
Map<String, String> expectedParams = new HashMap<>();
setRandomFlatSettings(request::flatSettings, expectedParams);
setRandomMasterTimeout(request, expectedParams);
setRandomTimeout(request::timeout, AcknowledgedRequest.DEFAULT_ACK_TIMEOUT, expectedParams);

Expand Down Expand Up @@ -1344,7 +1342,6 @@ public void testIndexPutSettings() throws IOException {
String[] indices = randomBoolean() ? null : randomIndicesNames(0, 2);
UpdateSettingsRequest updateSettingsRequest = new UpdateSettingsRequest(indices);
Map<String, String> expectedParams = new HashMap<>();
setRandomFlatSettings(updateSettingsRequest::flatSettings, expectedParams);
setRandomMasterTimeout(updateSettingsRequest, expectedParams);
setRandomTimeout(updateSettingsRequest::timeout, AcknowledgedRequest.DEFAULT_ACK_TIMEOUT, expectedParams);
setRandomIndicesOptions(updateSettingsRequest::indicesOptions, updateSettingsRequest::indicesOptions, expectedParams);
Expand Down Expand Up @@ -1627,16 +1624,6 @@ private static void setRandomTimeout(Consumer<String> setter, TimeValue defaultT
}
}

private static void setRandomFlatSettings(Consumer<Boolean> setter, Map<String, String> expectedParams) {
if (randomBoolean()) {
boolean flatSettings = randomBoolean();
setter.accept(flatSettings);
if (flatSettings) {
expectedParams.put("flat_settings", String.valueOf(flatSettings));
}
}
}

private static void setRandomMasterTimeout(MasterNodeRequest<?> request, Map<String, String> expectedParams) {
if (randomBoolean()) {
String masterTimeout = randomTimeValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,6 @@ public void testClusterPutSettings() throws IOException {
request.masterNodeTimeout("1m"); // <2>
// end::put-settings-request-masterTimeout

// tag::put-settings-request-flat-settings
request.flatSettings(true); // <1>
// end::put-settings-request-flat-settings

// tag::put-settings-execute
ClusterUpdateSettingsResponse response = client.cluster().putSettings(request);
// end::put-settings-execute
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.client.ESRestHighLevelClientTestCase;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.ByteSizeUnit;
import org.elasticsearch.common.unit.ByteSizeValue;
Expand Down Expand Up @@ -114,8 +113,7 @@ public void testIndicesExist() throws IOException {
request.local(false); // <1>
request.humanReadable(true); // <2>
request.includeDefaults(false); // <3>
request.flatSettings(false); // <4>
request.indicesOptions(indicesOptions); // <5>
request.indicesOptions(indicesOptions); // <4>
// end::indices-exists-request-optionals

// tag::indices-exists-response
Expand Down Expand Up @@ -1433,9 +1431,6 @@ public void testIndexPutSettings() throws Exception {
// end::put-settings-settings-source
}

// tag::put-settings-request-flat-settings
request.flatSettings(true); // <1>
// end::put-settings-request-flat-settings
// tag::put-settings-request-preserveExisting
request.setPreserveExisting(false); // <1>
// end::put-settings-request-preserveExisting
Expand Down
7 changes: 0 additions & 7 deletions docs/java-rest/high-level/cluster/put_settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,6 @@ include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[put-settings-setti
==== Optional Arguments
The following arguments can optionally be provided:

["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[put-settings-request-flat-settings]
--------------------------------------------------
<1> Whether the updated settings returned in the `ClusterUpdateSettings` should
be in a flat format

["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests}/ClusterClientDocumentationIT.java[put-settings-request-timeout]
Expand Down
3 changes: 1 addition & 2 deletions docs/java-rest/high-level/indices/indices_exists.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[indices-exists-req
<1> Whether to return local information or retrieve the state from master node
<2> Return result in a format suitable for humans
<3> Whether to return all default setting for each of the indices
<4> Return settings in flat format
<5> Controls how unavailable indices are resolved and how wildcard expressions are expanded
<4> Controls how unavailable indices are resolved and how wildcard expressions are expanded

[[java-rest-high-indices-sync]]
==== Synchronous Execution
Expand Down
7 changes: 0 additions & 7 deletions docs/java-rest/high-level/indices/put_settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,6 @@ include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[put-settings-setti
==== Optional Arguments
The following arguments can optionally be provided:

["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[put-settings-request-flat-settings]
--------------------------------------------------
<1> Whether the updated settings returned in the `UpdateSettings` should
be in a flat format

["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[put-settings-request-preserveExisting]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ public class ClusterUpdateSettingsRequest extends AcknowledgedRequest<ClusterUpd
PARSER.declareObject((r, t) -> r.transientSettings = t, (p, c) -> Settings.fromXContent(p), TRANSIENT);
}

private boolean flatSettings = false;
private Settings transientSettings = EMPTY_SETTINGS;
private Settings persistentSettings = EMPTY_SETTINGS;

Expand All @@ -74,29 +73,6 @@ public ActionRequestValidationException validate() {
return validationException;
}

/**
* Sets the value of "flat_settings".
* Used only by the high-level REST client.
*
* @param flatSettings
* value of "flat_settings" flag to be set
* @return this request
*/
public ClusterUpdateSettingsRequest flatSettings(boolean flatSettings) {
this.flatSettings = flatSettings;
return this;
}

/**
* Return settings in flat format.
* Used only by the high-level REST client.
*
* @return <code>true</code> if settings need to be returned in flat format; <code>false</code> otherwise.
*/
public boolean flatSettings() {
return flatSettings;
}

public Settings transientSettings() {
return transientSettings;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ public static Feature fromId(byte id) {
private static final Feature[] DEFAULT_FEATURES = new Feature[] { Feature.ALIASES, Feature.MAPPINGS, Feature.SETTINGS };
private Feature[] features = DEFAULT_FEATURES;
private boolean humanReadable = false;
private transient boolean flatSettings = false;
private transient boolean includeDefaults = false;

public GetIndexRequest() {
Expand Down Expand Up @@ -118,28 +117,6 @@ public boolean humanReadable() {
return humanReadable;
}

/**
* Sets the value of "flat_settings".
* Used only by the high-level REST client.
*
* @param flatSettings value of "flat_settings" flag to be set
* @return this request
*/
public GetIndexRequest flatSettings(boolean flatSettings) {
this.flatSettings = flatSettings;
return this;
}

/**
* Return settings in flat format.
* Used only by the high-level REST client.
*
* @return <code>true</code> if settings need to be returned in flat format; <code>false</code> otherwise.
*/
public boolean flatSettings() {
return flatSettings;
}

/**
* Sets the value of "include_defaults".
* Used only by the high-level REST client.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ public class UpdateSettingsRequest extends AcknowledgedRequest<UpdateSettingsReq
private IndicesOptions indicesOptions = IndicesOptions.fromOptions(false, false, true, true);
private Settings settings = EMPTY_SETTINGS;
private boolean preserveExisting = false;
private boolean flatSettings = false;

public UpdateSettingsRequest() {
}
Expand All @@ -75,29 +74,6 @@ public UpdateSettingsRequest(Settings settings, String... indices) {
this.settings = settings;
}

/**
* Sets the value of "flat_settings".
* Used only by the high-level REST client.
*
* @param flatSettings
* value of "flat_settings" flag to be set
* @return this request
*/
public UpdateSettingsRequest flatSettings(boolean flatSettings) {
this.flatSettings = flatSettings;
return this;
}

/**
* Return settings in flat format.
* Used only by the high-level REST client.
*
* @return <code>true</code> if settings need to be returned in flat format; <code>false</code> otherwise.
*/
public boolean flatSettings() {
return flatSettings;
}

@Override
public ActionRequestValidationException validate() {
ActionRequestValidationException validationException = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ public static UpdateSettingsRequest createTestItem() {
request.timeout(randomTimeValue());
request.indicesOptions(IndicesOptions.fromOptions(randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean()));
request.setPreserveExisting(randomBoolean());
request.flatSettings(randomBoolean());
return request;
}

Expand All @@ -77,7 +76,6 @@ private static UpdateSettingsRequest copyRequest(UpdateSettingsRequest request)
result.timeout(request.timeout());
result.indicesOptions(request.indicesOptions());
result.setPreserveExisting(request.isPreserveExisting());
result.flatSettings(request.flatSettings());
return result;
}

Expand Down