Default copy settings to true and deprecate on the REST layer (#30598)
This commit defaults the copy_settings REST parameter to the shrink and split APIs to true, and deprecates the parameter.
This commit is contained in:
parent
33cba44d0a
commit
d68c44b76c
|
@ -642,7 +642,12 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
|
|||
|
||||
ResizeRequest resizeRequest = new ResizeRequest("target", "source");
|
||||
resizeRequest.setResizeType(ResizeType.SHRINK);
|
||||
Settings targetSettings = Settings.builder().put("index.number_of_shards", 2).put("index.number_of_replicas", 0).build();
|
||||
Settings targetSettings =
|
||||
Settings.builder()
|
||||
.put("index.number_of_shards", 2)
|
||||
.put("index.number_of_replicas", 0)
|
||||
.putNull("index.routing.allocation.require._name")
|
||||
.build();
|
||||
resizeRequest.setTargetIndex(new CreateIndexRequest("target").settings(targetSettings).alias(new Alias("alias")));
|
||||
ResizeResponse resizeResponse = highLevelClient().indices().shrink(resizeRequest);
|
||||
assertTrue(resizeResponse.isAcknowledged());
|
||||
|
|
|
@ -1305,7 +1305,8 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
|
|||
// end::shrink-index-request-waitForActiveShards
|
||||
// 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>
|
||||
|
|
|
@ -45,8 +45,8 @@ returns a response, as an `ActiveShardCount`
|
|||
--------------------------------------------------
|
||||
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[shrink-index-request-settings]
|
||||
--------------------------------------------------
|
||||
<1> The settings to apply to the target index, which include the number of
|
||||
shards to create for it
|
||||
<1> The number of shards on the target of the shrink index request
|
||||
<2> Remove the allocation requirement copied from the source index
|
||||
|
||||
["source","java",subs="attributes,callouts,macros"]
|
||||
--------------------------------------------------
|
||||
|
|
|
@ -62,7 +62,7 @@ the following request:
|
|||
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
POST my_source_index/_shrink/my_target_index?copy_settings=true
|
||||
POST my_source_index/_shrink/my_target_index
|
||||
{
|
||||
"settings": {
|
||||
"index.routing.allocation.require._name": null, <1>
|
||||
|
@ -106,7 +106,7 @@ and accepts `settings` and `aliases` parameters for the target index:
|
|||
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
POST my_source_index/_shrink/my_target_index?copy_settings=true
|
||||
POST my_source_index/_shrink/my_target_index
|
||||
{
|
||||
"settings": {
|
||||
"index.number_of_replicas": 1,
|
||||
|
@ -130,16 +130,6 @@ POST my_source_index/_shrink/my_target_index?copy_settings=true
|
|||
|
||||
NOTE: Mappings may not be specified in the `_shrink` request.
|
||||
|
||||
NOTE: By default, with the exception of `index.analysis`, `index.similarity`,
|
||||
and `index.sort` settings, index settings on the source index are not copied
|
||||
during a shrink operation. With the exception of non-copyable settings, settings
|
||||
from the source index can be copied to the target index by adding the URL
|
||||
parameter `copy_settings=true` to the request. Note that `copy_settings` can not
|
||||
be set to `false`. The parameter `copy_settings` will be removed in 8.0.0
|
||||
|
||||
deprecated[6.4.0, not copying settings is deprecated, copying settings will be
|
||||
the default behavior in 7.x]
|
||||
|
||||
[float]
|
||||
=== Monitoring the shrink process
|
||||
|
||||
|
|
|
@ -123,7 +123,7 @@ the following request:
|
|||
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
POST my_source_index/_split/my_target_index?copy_settings=true
|
||||
POST my_source_index/_split/my_target_index
|
||||
{
|
||||
"settings": {
|
||||
"index.number_of_shards": 2
|
||||
|
@ -158,7 +158,7 @@ and accepts `settings` and `aliases` parameters for the target index:
|
|||
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
POST my_source_index/_split/my_target_index?copy_settings=true
|
||||
POST my_source_index/_split/my_target_index
|
||||
{
|
||||
"settings": {
|
||||
"index.number_of_shards": 5 <1>
|
||||
|
@ -177,16 +177,6 @@ POST my_source_index/_split/my_target_index?copy_settings=true
|
|||
|
||||
NOTE: Mappings may not be specified in the `_split` request.
|
||||
|
||||
NOTE: By default, with the exception of `index.analysis`, `index.similarity`,
|
||||
and `index.sort` settings, index settings on the source index are not copied
|
||||
during a split operation. With the exception of non-copyable settings, settings
|
||||
from the source index can be copied to the target index by adding the URL
|
||||
parameter `copy_settings=true` to the request. Note that `copy_settings` can not
|
||||
be set to `false`. The parameter `copy_settings` will be removed in 8.0.0
|
||||
|
||||
deprecated[6.4.0, not copying settings is deprecated, copying settings will be
|
||||
the default behavior in 7.x]
|
||||
|
||||
[float]
|
||||
=== Monitoring the split process
|
||||
|
||||
|
|
|
@ -65,3 +65,13 @@ deprecated in 6.3.0 and now removed in 7.0.0.
|
|||
In the past, `fields` could be provided either as a parameter, or as part of the request
|
||||
body. Specifying `fields` in the request body as opposed to a parameter was deprecated
|
||||
in 6.4.0, and is now unsupported in 7.0.0.
|
||||
|
||||
==== `copy_settings` is deprecated on shrink and split APIs
|
||||
|
||||
Versions of Elasticsearch prior to 6.4.0 did not copy index settings on shrink
|
||||
and split operations. Starting with Elasticsearch 7.0.0, the default behavior
|
||||
will be for such settings to be copied on such operations. To enable users in
|
||||
6.4.0 to transition in 6.4.0 to the default behavior in 7.0.0, the
|
||||
`copy_settings` parameter was added on the REST layer. As this behavior will be
|
||||
the only behavior in 8.0.0, this parameter is deprecated in 7.0.0 for removal in
|
||||
8.0.0.
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
---
|
||||
"Shrink index via API":
|
||||
- skip:
|
||||
version: " - 6.3.99"
|
||||
reason: expects warnings that pre-6.4.0 will not send
|
||||
version: " - 6.9.99"
|
||||
reason: expects warnings that pre-7.0.0 will not send
|
||||
features: "warnings"
|
||||
# creates an index with one document solely allocated on the master node
|
||||
# and shrinks it into a new index with a single shard
|
||||
|
@ -67,8 +67,6 @@
|
|||
body:
|
||||
settings:
|
||||
index.number_of_replicas: 0
|
||||
warnings:
|
||||
- "resize operations without copying settings is deprecated; set parameter [copy_settings] to [true] for future default behavior"
|
||||
|
||||
- do:
|
||||
cluster.health:
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
---
|
||||
"Shrink index ignores target template mapping":
|
||||
- skip:
|
||||
version: " - 6.3.99"
|
||||
reason: expects warnings that pre-6.4.0 will not send
|
||||
version: " - 6.9.99"
|
||||
reason: expects warnings that pre-7.0.0 will not send
|
||||
features: "warnings"
|
||||
|
||||
- do:
|
||||
|
@ -71,8 +71,6 @@
|
|||
body:
|
||||
settings:
|
||||
index.number_of_replicas: 0
|
||||
warnings:
|
||||
- "resize operations without copying settings is deprecated; set parameter [copy_settings] to [true] for future default behavior"
|
||||
|
||||
- do:
|
||||
cluster.health:
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
---
|
||||
"Copy settings during shrink index":
|
||||
- skip:
|
||||
version: " - 6.3.99"
|
||||
reason: expects warnings that pre-6.4.0 will not send
|
||||
version: " - 6.9.99"
|
||||
reason: expects warnings that pre-7.0.0 will not send
|
||||
features: "warnings"
|
||||
|
||||
- do:
|
||||
|
@ -48,6 +48,8 @@
|
|||
settings:
|
||||
index.number_of_replicas: 0
|
||||
index.merge.scheduler.max_thread_count: 2
|
||||
warnings:
|
||||
- "parameter [copy_settings] is deprecated and will be removed in 8.0.0"
|
||||
|
||||
- do:
|
||||
cluster.health:
|
||||
|
@ -63,19 +65,17 @@
|
|||
- match: { copy-settings-target.settings.index.blocks.write: "true" }
|
||||
- match: { copy-settings-target.settings.index.routing.allocation.include._id: $master }
|
||||
|
||||
# now we do a actual shrink and do not copy settings (by default)
|
||||
# now we do a actual shrink and copy settings (by default)
|
||||
- do:
|
||||
indices.shrink:
|
||||
index: "source"
|
||||
target: "no-copy-settings-target"
|
||||
target: "default-copy-settings-target"
|
||||
wait_for_active_shards: 1
|
||||
master_timeout: 10s
|
||||
body:
|
||||
settings:
|
||||
index.number_of_replicas: 0
|
||||
index.merge.scheduler.max_thread_count: 2
|
||||
warnings:
|
||||
- "resize operations without copying settings is deprecated; set parameter [copy_settings] to [true] for future default behavior"
|
||||
|
||||
- do:
|
||||
cluster.health:
|
||||
|
@ -83,13 +83,13 @@
|
|||
|
||||
- do:
|
||||
indices.get_settings:
|
||||
index: "no-copy-settings-target"
|
||||
index: "default-copy-settings-target"
|
||||
|
||||
# only the request setting should be copied
|
||||
- is_false: no-copy-settings-target.settings.index.merge.scheduler.max_merge_count
|
||||
- match: { no-copy-settings-target.settings.index.merge.scheduler.max_thread_count: "2" }
|
||||
- is_false: no-copy-settings-target.settings.index.blocks.write
|
||||
- is_false: no-copy-settings-target.settings.index.routing.allocation.include._id
|
||||
# settings should be copied
|
||||
- match: { default-copy-settings-target.settings.index.merge.scheduler.max_merge_count: "4" }
|
||||
- match: { default-copy-settings-target.settings.index.merge.scheduler.max_thread_count: "2" }
|
||||
- match: { default-copy-settings-target.settings.index.blocks.write: "true" }
|
||||
- match: { default-copy-settings-target.settings.index.routing.allocation.include._id: $master }
|
||||
|
||||
# now we do a actual shrink and try to set no copy settings
|
||||
- do:
|
||||
|
|
|
@ -33,8 +33,8 @@ setup:
|
|||
---
|
||||
"Split index via API":
|
||||
- skip:
|
||||
version: " - 6.3.99"
|
||||
reason: expects warnings that pre-6.4.0 will not send
|
||||
version: " - 6.9.99"
|
||||
reason: pre-7.0.0 will send warnings
|
||||
features: "warnings"
|
||||
|
||||
# make it read-only
|
||||
|
@ -61,8 +61,6 @@ setup:
|
|||
settings:
|
||||
index.number_of_replicas: 0
|
||||
index.number_of_shards: 4
|
||||
warnings:
|
||||
- "resize operations without copying settings is deprecated; set parameter [copy_settings] to [true] for future default behavior"
|
||||
|
||||
- do:
|
||||
cluster.health:
|
||||
|
@ -108,8 +106,7 @@ setup:
|
|||
"Split from 1 to N":
|
||||
- skip:
|
||||
version: " - 6.99.99"
|
||||
reason: Automatic preparation for splitting was added in 7.0.0
|
||||
features: "warnings"
|
||||
reason: automatic preparation for splitting was added in 7.0.0
|
||||
- do:
|
||||
indices.create:
|
||||
index: source_one_shard
|
||||
|
@ -163,8 +160,6 @@ setup:
|
|||
settings:
|
||||
index.number_of_replicas: 0
|
||||
index.number_of_shards: 5
|
||||
warnings:
|
||||
- "resize operations without copying settings is deprecated; set parameter [copy_settings] to [true] for future default behavior"
|
||||
|
||||
- do:
|
||||
cluster.health:
|
||||
|
@ -205,13 +200,11 @@ setup:
|
|||
- match: { _id: "3" }
|
||||
- match: { _source: { foo: "hello world 3" } }
|
||||
|
||||
|
||||
|
||||
---
|
||||
"Create illegal split indices":
|
||||
- skip:
|
||||
version: " - 6.3.99"
|
||||
reason: expects warnings that pre-6.4.0 will not send
|
||||
version: " - 6.9.99"
|
||||
reason: pre-7.0.0 will send warnings
|
||||
features: "warnings"
|
||||
|
||||
# try to do an illegal split with number_of_routing_shards set
|
||||
|
@ -227,8 +220,6 @@ setup:
|
|||
index.number_of_replicas: 0
|
||||
index.number_of_shards: 4
|
||||
index.number_of_routing_shards: 8
|
||||
warnings:
|
||||
- "resize operations without copying settings is deprecated; set parameter [copy_settings] to [true] for future default behavior"
|
||||
|
||||
# try to do an illegal split with illegal number_of_shards
|
||||
- do:
|
||||
|
@ -242,5 +233,3 @@ setup:
|
|||
settings:
|
||||
index.number_of_replicas: 0
|
||||
index.number_of_shards: 6
|
||||
warnings:
|
||||
- "resize operations without copying settings is deprecated; set parameter [copy_settings] to [true] for future default behavior"
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
---
|
||||
"Split index ignores target template mapping":
|
||||
- skip:
|
||||
version: " - 6.3.99"
|
||||
reason: expects warnings that pre-6.4.0 will not send
|
||||
version: " - 6.9.99"
|
||||
reason: pre-7.0.0 will send warnings
|
||||
features: "warnings"
|
||||
|
||||
# create index
|
||||
|
@ -65,8 +65,6 @@
|
|||
settings:
|
||||
index.number_of_shards: 2
|
||||
index.number_of_replicas: 0
|
||||
warnings:
|
||||
- "resize operations without copying settings is deprecated; set parameter [copy_settings] to [true] for future default behavior"
|
||||
|
||||
- do:
|
||||
cluster.health:
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
---
|
||||
"Copy settings during split index":
|
||||
- skip:
|
||||
version: " - 6.3.99"
|
||||
reason: expects warnings that pre-6.4.0 will not send
|
||||
version: " - 6.9.99"
|
||||
reason: expects warnings that pre-7.0.0 will not send
|
||||
features: "warnings"
|
||||
|
||||
- do:
|
||||
|
@ -50,6 +50,9 @@
|
|||
index.number_of_replicas: 0
|
||||
index.number_of_shards: 2
|
||||
index.merge.scheduler.max_thread_count: 2
|
||||
warnings:
|
||||
- "parameter [copy_settings] is deprecated and will be removed in 8.0.0"
|
||||
|
||||
|
||||
- do:
|
||||
cluster.health:
|
||||
|
@ -65,11 +68,11 @@
|
|||
- match: { copy-settings-target.settings.index.blocks.write: "true" }
|
||||
- match: { copy-settings-target.settings.index.routing.allocation.include._id: $master }
|
||||
|
||||
# now we do a actual shrink and do not copy settings (by default)
|
||||
# now we do a actual shrink and copy settings (by default)
|
||||
- do:
|
||||
indices.split:
|
||||
index: "source"
|
||||
target: "no-copy-settings-target"
|
||||
target: "default-copy-settings-target"
|
||||
wait_for_active_shards: 1
|
||||
master_timeout: 10s
|
||||
body:
|
||||
|
@ -77,8 +80,6 @@
|
|||
index.number_of_replicas: 0
|
||||
index.number_of_shards: 2
|
||||
index.merge.scheduler.max_thread_count: 2
|
||||
warnings:
|
||||
- "resize operations without copying settings is deprecated; set parameter [copy_settings] to [true] for future default behavior"
|
||||
|
||||
- do:
|
||||
cluster.health:
|
||||
|
@ -86,13 +87,13 @@
|
|||
|
||||
- do:
|
||||
indices.get_settings:
|
||||
index: "no-copy-settings-target"
|
||||
index: "default-copy-settings-target"
|
||||
|
||||
# only the request setting should be copied
|
||||
- is_false: no-copy-settings-target.settings.index.merge.scheduler.max_merge_count
|
||||
- match: { no-copy-settings-target.settings.index.merge.scheduler.max_thread_count: "2" }
|
||||
- is_false: no-copy-settings-target.settings.index.blocks.write
|
||||
- is_false: no-copy-settings-target.settings.index.routing.allocation.include._id
|
||||
# settings should be copied
|
||||
- match: { default-copy-settings-target.settings.index.merge.scheduler.max_merge_count: "4" }
|
||||
- match: { default-copy-settings-target.settings.index.merge.scheduler.max_thread_count: "2" }
|
||||
- match: { default-copy-settings-target.settings.index.blocks.write: "true" }
|
||||
- match: { default-copy-settings-target.settings.index.routing.allocation.include._id: $master }
|
||||
|
||||
- do:
|
||||
catch: /illegal_argument_exception/
|
||||
|
|
|
@ -56,7 +56,7 @@ public class ResizeRequest extends AcknowledgedRequest<ResizeRequest> implements
|
|||
private CreateIndexRequest targetIndexRequest;
|
||||
private String sourceIndex;
|
||||
private ResizeType type = ResizeType.SHRINK;
|
||||
private Boolean copySettings;
|
||||
private Boolean copySettings = true;
|
||||
|
||||
ResizeRequest() {}
|
||||
|
||||
|
|
|
@ -51,18 +51,16 @@ public abstract class RestResizeHandler extends BaseRestHandler {
|
|||
final Boolean copySettings;
|
||||
if (rawCopySettings == null) {
|
||||
copySettings = resizeRequest.getCopySettings();
|
||||
} else if (rawCopySettings.isEmpty()) {
|
||||
copySettings = true;
|
||||
} else {
|
||||
copySettings = Booleans.parseBoolean(rawCopySettings);
|
||||
if (copySettings == false) {
|
||||
throw new IllegalArgumentException("parameter [copy_settings] can not be explicitly set to [false]");
|
||||
if (rawCopySettings.isEmpty()) {
|
||||
copySettings = true;
|
||||
} else {
|
||||
copySettings = Booleans.parseBoolean(rawCopySettings);
|
||||
if (copySettings == false) {
|
||||
throw new IllegalArgumentException("parameter [copy_settings] can not be explicitly set to [false]");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (copySettings == null) {
|
||||
deprecationLogger.deprecated(
|
||||
"resize operations without copying settings is deprecated; "
|
||||
+ "set parameter [copy_settings] to [true] for future default behavior");
|
||||
deprecationLogger.deprecated("parameter [copy_settings] is deprecated and will be removed in 8.0.0");
|
||||
}
|
||||
resizeRequest.setCopySettings(copySettings);
|
||||
request.applyContentParser(resizeRequest::fromXContent);
|
||||
|
|
|
@ -113,9 +113,11 @@ public class ShrinkIndexIT extends ESIntegTestCase {
|
|||
ensureGreen();
|
||||
// now merge source into a 4 shard index
|
||||
assertAcked(client().admin().indices().prepareResizeIndex("source", "first_shrink")
|
||||
.setSettings(Settings.builder()
|
||||
.put("index.number_of_replicas", 0)
|
||||
.put("index.number_of_shards", shardSplits[1]).build()).get());
|
||||
.setSettings(Settings.builder()
|
||||
.put("index.number_of_replicas", 0)
|
||||
.put("index.number_of_shards", shardSplits[1])
|
||||
.putNull("index.blocks.write")
|
||||
.build()).get());
|
||||
ensureGreen();
|
||||
assertHitCount(client().prepareSearch("first_shrink").setSize(100).setQuery(new TermsQueryBuilder("foo", "bar")).get(), 20);
|
||||
|
||||
|
@ -135,9 +137,12 @@ public class ShrinkIndexIT extends ESIntegTestCase {
|
|||
ensureGreen();
|
||||
// now merge source into a 2 shard index
|
||||
assertAcked(client().admin().indices().prepareResizeIndex("first_shrink", "second_shrink")
|
||||
.setSettings(Settings.builder()
|
||||
.put("index.number_of_replicas", 0)
|
||||
.put("index.number_of_shards", shardSplits[2]).build()).get());
|
||||
.setSettings(Settings.builder()
|
||||
.put("index.number_of_replicas", 0)
|
||||
.put("index.number_of_shards", shardSplits[2])
|
||||
.putNull("index.blocks.write")
|
||||
.putNull("index.routing.allocation.require._name")
|
||||
.build()).get());
|
||||
ensureGreen();
|
||||
assertHitCount(client().prepareSearch("second_shrink").setSize(100).setQuery(new TermsQueryBuilder("foo", "bar")).get(), 20);
|
||||
// let it be allocated anywhere and bump replicas
|
||||
|
@ -272,8 +277,14 @@ public class ShrinkIndexIT extends ESIntegTestCase {
|
|||
|
||||
// now merge source into a single shard index
|
||||
final boolean createWithReplicas = randomBoolean();
|
||||
assertAcked(client().admin().indices().prepareResizeIndex("source", "target")
|
||||
.setSettings(Settings.builder().put("index.number_of_replicas", createWithReplicas ? 1 : 0).build()).get());
|
||||
assertAcked(
|
||||
client().admin().indices().prepareResizeIndex("source", "target")
|
||||
.setSettings(
|
||||
Settings.builder()
|
||||
.put("index.number_of_replicas", createWithReplicas ? 1 : 0)
|
||||
.putNull("index.blocks.write")
|
||||
.putNull("index.routing.allocation.require._name")
|
||||
.build()).get());
|
||||
ensureGreen();
|
||||
|
||||
// resolve true merge node - this is not always the node we required as all shards may be on another node
|
||||
|
@ -444,19 +455,20 @@ public class ShrinkIndexIT extends ESIntegTestCase {
|
|||
|
||||
// check that index sort cannot be set on the target index
|
||||
IllegalArgumentException exc = expectThrows(IllegalArgumentException.class,
|
||||
() -> client().admin().indices().prepareResizeIndex("source", "target")
|
||||
.setSettings(Settings.builder()
|
||||
.put("index.number_of_replicas", 0)
|
||||
.put("index.number_of_shards", "2")
|
||||
.put("index.sort.field", "foo")
|
||||
.build()).get());
|
||||
() -> client().admin().indices().prepareResizeIndex("source", "target")
|
||||
.setSettings(Settings.builder()
|
||||
.put("index.number_of_replicas", 0)
|
||||
.put("index.number_of_shards", "2")
|
||||
.put("index.sort.field", "foo")
|
||||
.build()).get());
|
||||
assertThat(exc.getMessage(), containsString("can't override index sort when resizing an index"));
|
||||
|
||||
// check that the index sort order of `source` is correctly applied to the `target`
|
||||
assertAcked(client().admin().indices().prepareResizeIndex("source", "target")
|
||||
.setSettings(Settings.builder()
|
||||
.put("index.number_of_replicas", 0)
|
||||
.put("index.number_of_shards", "2").build()).get());
|
||||
.setSettings(Settings.builder()
|
||||
.put("index.number_of_replicas", 0)
|
||||
.put("index.number_of_shards", "2")
|
||||
.putNull("index.blocks.write").build()).get());
|
||||
ensureGreen();
|
||||
flushAndRefresh();
|
||||
GetSettingsResponse settingsResponse =
|
||||
|
|
|
@ -193,8 +193,9 @@ public class SplitIndexIT extends ESIntegTestCase {
|
|||
.put("index.blocks.write", true)).get();
|
||||
ensureGreen();
|
||||
Settings.Builder firstSplitSettingsBuilder = Settings.builder()
|
||||
.put("index.number_of_replicas", 0)
|
||||
.put("index.number_of_shards", firstSplitShards);
|
||||
.put("index.number_of_replicas", 0)
|
||||
.put("index.number_of_shards", firstSplitShards)
|
||||
.putNull("index.blocks.write");
|
||||
if (sourceShards == 1 && useRoutingPartition == false && randomBoolean()) { // try to set it if we have a source index with 1 shard
|
||||
firstSplitSettingsBuilder.put("index.number_of_routing_shards", secondSplitShards);
|
||||
}
|
||||
|
@ -225,10 +226,12 @@ public class SplitIndexIT extends ESIntegTestCase {
|
|||
ensureGreen();
|
||||
// now split source into a new index
|
||||
assertAcked(client().admin().indices().prepareResizeIndex("first_split", "second_split")
|
||||
.setResizeType(ResizeType.SPLIT)
|
||||
.setSettings(Settings.builder()
|
||||
.put("index.number_of_replicas", 0)
|
||||
.put("index.number_of_shards", secondSplitShards).build()).get());
|
||||
.setResizeType(ResizeType.SPLIT)
|
||||
.setSettings(Settings.builder()
|
||||
.put("index.number_of_replicas", 0)
|
||||
.put("index.number_of_shards", secondSplitShards)
|
||||
.putNull("index.blocks.write")
|
||||
.build()).get());
|
||||
ensureGreen();
|
||||
assertHitCount(client().prepareSearch("second_split").setSize(100).setQuery(new TermsQueryBuilder("foo", "bar")).get(), numDocs);
|
||||
// let it be allocated anywhere and bump replicas
|
||||
|
@ -340,7 +343,11 @@ public class SplitIndexIT extends ESIntegTestCase {
|
|||
|
||||
// now split source into target
|
||||
final Settings splitSettings =
|
||||
Settings.builder().put("index.number_of_replicas", 0).put("index.number_of_shards", numberOfTargetShards).build();
|
||||
Settings.builder()
|
||||
.put("index.number_of_replicas", 0)
|
||||
.put("index.number_of_shards", numberOfTargetShards)
|
||||
.putNull("index.blocks.write")
|
||||
.build();
|
||||
assertAcked(client().admin().indices().prepareResizeIndex("source", "target")
|
||||
.setResizeType(ResizeType.SPLIT)
|
||||
.setSettings(splitSettings).get());
|
||||
|
@ -396,8 +403,10 @@ public class SplitIndexIT extends ESIntegTestCase {
|
|||
assertAcked(client().admin().indices().prepareResizeIndex("source", "target")
|
||||
.setResizeType(ResizeType.SPLIT)
|
||||
.setSettings(Settings.builder()
|
||||
.put("index.number_of_replicas", createWithReplicas ? 1 : 0)
|
||||
.put("index.number_of_shards", 2).build()).get());
|
||||
.put("index.number_of_replicas", createWithReplicas ? 1 : 0)
|
||||
.put("index.number_of_shards", 2)
|
||||
.putNull("index.blocks.write")
|
||||
.build()).get());
|
||||
ensureGreen();
|
||||
|
||||
final ClusterState state = client().admin().cluster().prepareState().get().getState();
|
||||
|
@ -507,10 +516,12 @@ public class SplitIndexIT extends ESIntegTestCase {
|
|||
|
||||
// check that the index sort order of `source` is correctly applied to the `target`
|
||||
assertAcked(client().admin().indices().prepareResizeIndex("source", "target")
|
||||
.setResizeType(ResizeType.SPLIT)
|
||||
.setSettings(Settings.builder()
|
||||
.put("index.number_of_replicas", 0)
|
||||
.put("index.number_of_shards", 4).build()).get());
|
||||
.setResizeType(ResizeType.SPLIT)
|
||||
.setSettings(Settings.builder()
|
||||
.put("index.number_of_replicas", 0)
|
||||
.put("index.number_of_shards", 4)
|
||||
.putNull("index.blocks.write")
|
||||
.build()).get());
|
||||
ensureGreen();
|
||||
flushAndRefresh();
|
||||
GetSettingsResponse settingsResponse =
|
||||
|
|
|
@ -70,10 +70,8 @@ public class RestResizeHandlerTests extends ESTestCase {
|
|||
assertThat(e, hasToString(containsString("parameter [copy_settings] can not be explicitly set to [false]")));
|
||||
} else {
|
||||
handler.prepareRequest(request, mock(NodeClient.class));
|
||||
if (copySettings == null) {
|
||||
assertWarnings(
|
||||
"resize operations without copying settings is deprecated; "
|
||||
+ "set parameter [copy_settings] to [true] for future default behavior");
|
||||
if ("".equals(copySettings) || "true".equals(copySettings)) {
|
||||
assertWarnings("parameter [copy_settings] is deprecated and will be removed in 8.0.0");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -108,10 +108,11 @@ public class PartitionedRoutingIT extends ESIntegTestCase {
|
|||
|
||||
logger.info("--> shrinking index [" + previousIndex + "] to [" + index + "]");
|
||||
client().admin().indices().prepareResizeIndex(previousIndex, index)
|
||||
.setSettings(Settings.builder()
|
||||
.put("index.number_of_shards", currentShards)
|
||||
.put("index.number_of_replicas", numberOfReplicas())
|
||||
.build()).get();
|
||||
.setSettings(Settings.builder()
|
||||
.put("index.number_of_shards", currentShards)
|
||||
.put("index.number_of_replicas", numberOfReplicas())
|
||||
.putNull("index.routing.allocation.require._name")
|
||||
.build()).get();
|
||||
ensureGreen();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue