-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Add max_shard_size parameter for Shrink API #5229
Merged
dblock
merged 10 commits into
opensearch-project:main
from
gaobinlong:add_shrink_parameter
Nov 30, 2022
Merged
Changes from 3 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
5ef329a
Add max_shard_size parameter for Shrink API
gaobinlong 88a5528
add change log
gaobinlong 2bad9ff
fix yaml test failed
gaobinlong 81bca05
merge main
gaobinlong 7fbca43
optimize the code
gaobinlong 31f728a
Merge remote-tracking branch 'upstream/main' into add_shrink_parameter
gaobinlong 98fe8c1
fix test failed
gaobinlong a1214a6
merge main
gaobinlong 2c0ad77
optimize changelog & code
gaobinlong c1240cb
Merge remote-tracking branch 'upstream/main' into add_shrink_parameter
gaobinlong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,6 +79,7 @@ | |
import org.opensearch.common.xcontent.XContentType; | ||
import org.opensearch.test.OpenSearchTestCase; | ||
import org.junit.Assert; | ||
import org.opensearch.common.unit.ByteSizeValue; | ||
|
||
import java.io.IOException; | ||
import java.util.Arrays; | ||
|
@@ -702,6 +703,9 @@ private void resizeTest(ResizeType resizeType, CheckedFunction<ResizeRequest, Re | |
if (resizeType == ResizeType.SPLIT) { | ||
resizeRequest.setSettings(Settings.builder().put("index.number_of_shards", 2).build()); | ||
} | ||
if (resizeType == ResizeType.SHRINK) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: add |
||
resizeRequest.setMaxShardSize(new ByteSizeValue(randomIntBetween(1, 1000))); | ||
} | ||
|
||
Request request = function.apply(resizeRequest); | ||
Assert.assertEquals(HttpPut.METHOD_NAME, request.getMethod()); | ||
|
82 changes: 82 additions & 0 deletions
82
rest-api-spec/src/main/resources/rest-api-spec/test/indices.shrink/40_max_shard_size.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
--- | ||
"Shrink index with max_shard_size": | ||
# shrink index with max_shard_size parameter, which is used to generate an optimum | ||
# number_of_shards for the target index. | ||
|
||
- skip: | ||
version: " - 2.9.99" | ||
reason: "only available in 3.0+" | ||
features: allowed_warnings | ||
|
||
- do: | ||
nodes.info: | ||
node_id: data:true | ||
- set: | ||
nodes._arbitrary_key_: node_id | ||
|
||
- do: | ||
indices.create: | ||
index: source | ||
wait_for_active_shards: 1 | ||
body: | ||
settings: | ||
# ensure everything is allocated on the same data node | ||
index.routing.allocation.include._id: $node_id | ||
index.number_of_shards: 3 | ||
index.number_of_replicas: 0 | ||
- do: | ||
index: | ||
index: source | ||
id: "1" | ||
body: { "foo": "hello world" } | ||
|
||
- do: | ||
get: | ||
index: source | ||
id: "1" | ||
|
||
- match: { _index: source } | ||
- match: { _id: "1" } | ||
- match: { _source: { foo: "hello world" } } | ||
|
||
# make it read-only | ||
- do: | ||
indices.put_settings: | ||
index: source | ||
body: | ||
index.blocks.write: true | ||
index.number_of_replicas: 0 | ||
|
||
- do: | ||
cluster.health: | ||
wait_for_status: green | ||
index: source | ||
|
||
# shrink with max_shard_size | ||
- do: | ||
allowed_warnings: | ||
- "Parameter [master_timeout] is deprecated and will be removed in 3.0. To support inclusive language, please use [cluster_manager_timeout] instead." | ||
indices.shrink: | ||
index: "source" | ||
target: "new_shrunken_index" | ||
wait_for_active_shards: 1 | ||
master_timeout: 10s | ||
body: | ||
settings: | ||
index.number_of_replicas: 0 | ||
max_shard_size: "10gb" | ||
|
||
- do: | ||
cluster.health: | ||
wait_for_status: green | ||
|
||
- do: | ||
get: | ||
index: "new_shrunken_index" | ||
id: "1" | ||
|
||
- do: | ||
indices.get_settings: | ||
index: "new_shrunken_index" | ||
|
||
- match: { new_shrunken_index.settings.index.number_of_shards: "1" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lowercase shrink