Skip to content

Allow setting of copy_settings in the HLRC #39752

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

Merged
merged 8 commits into from
Mar 8, 2019
Merged
Show file tree
Hide file tree
Changes from 6 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 @@ -342,6 +342,7 @@ private static Request resize(ResizeRequest resizeRequest) throws IOException {
params.withTimeout(resizeRequest.timeout());
params.withMasterTimeout(resizeRequest.masterNodeTimeout());
params.withWaitForActiveShards(resizeRequest.getTargetIndexRequest().waitForActiveShards(), ActiveShardCount.DEFAULT);
params.withCopySettings(resizeRequest.getCopySettings());

request.setEntity(RequestConverters.createEntity(resizeRequest, RequestConverters.REQUEST_BODY_CONTENT_TYPE));
return request;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -909,6 +909,17 @@ Params withWaitForActiveShards(ActiveShardCount activeShardCount) {
return withWaitForActiveShards(activeShardCount, ActiveShardCount.DEFAULT);
}

/**
* @deprecated <code>copy_settings</code> can not be set to false. If unset, behaves as <code>false</code> and won't copy settings.
*/
@Deprecated
Params withCopySettings(Boolean setCopySettings) {
if (setCopySettings != null) {
return putParam("copy_settings", setCopySettings.toString());
}
return this;
}

Params withIndicesOptions(IndicesOptions indicesOptions) {
if (indicesOptions != null) {
withIgnoreUnavailable(indicesOptions.ignoreUnavailable());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,12 @@ private void resizeTest(ResizeType resizeType, CheckedFunction<ResizeRequest, Re
ResizeRequest resizeRequest = new ResizeRequest(indices[0], indices[1]);
resizeRequest.setResizeType(resizeType);
Map<String, String> expectedParams = new HashMap<>();

if (randomBoolean()) {
resizeRequest.setCopySettings(Boolean.TRUE);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
resizeRequest.setCopySettings(Boolean.TRUE);
resizeRequest.setCopySettings(true);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in b20c245

expectedParams.put("copy_settings", "true");
}

RequestConvertersTests.setRandomMasterTimeout(resizeRequest, expectedParams);
RequestConvertersTests.setRandomTimeout(resizeRequest::timeout, resizeRequest.timeout(), expectedParams);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1683,9 +1683,13 @@ public void testShrinkIndex() throws Exception {
request.setWaitForActiveShards(2); // <1>
request.setWaitForActiveShards(ActiveShardCount.DEFAULT); // <2>
// end::shrink-index-request-waitForActiveShards
// tag::shrink-index-request-copySettings
request.setCopySettings(Boolean.TRUE); // <1>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true is more natural

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in de8ca18

// end::shrink-index-request-copySettings
// tag::shrink-index-request-settings
request.getTargetIndexRequest().settings(Settings.builder()
.put("index.number_of_shards", 2)); // <1>
.put("index.number_of_shards", 2) // <1>
.putNull("index.routing.allocation.require._name")); // <2>
// end::shrink-index-request-settings
// tag::shrink-index-request-aliases
request.getTargetIndexRequest().alias(new Alias("target_alias")); // <1>
Expand Down
9 changes: 9 additions & 0 deletions docs/java-rest/high-level/indices/shrink_index.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,21 @@ returns a response, as an `int`
<2> The number of active shard copies to wait for before the shrink index API
returns a response, as an `ActiveShardCount`

["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests-file}[{api}-request-copySettings]
--------------------------------------------------
<1> Use `Boolean.TRUE` to copy the settings from the source index to the target
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use true

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in de8ca18

index. This cannot be `Boolean.FALSE`. If this method is not used, default behavior is not to copy.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe false?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in de8ca18

This parameter will be removed in 8.0.0.

["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests-file}[{api}-request-settings]
--------------------------------------------------
<1> The settings to apply to the target index, which include the number of
shards to create for it
<2> Remove the allocation requirement copied from the source index

["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
Expand Down