-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Rollover add max_primary_shard_docs condition #80981
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
martijnvg
merged 28 commits into
elastic:master
from
weizijun:rollover-add-max_shard_docs
Feb 8, 2022
Merged
Changes from 26 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
d1c4ed7
rollover add max_shard_docs condition
weizijun 3cea0d7
fixup
weizijun ed8fc6e
rollover add max_shard_docs condition
weizijun e8ad38f
rollover add max_shard_docs condition
weizijun 7e7b33b
fixup
weizijun 2939d24
spotless
weizijun 4d6f241
Merge branch 'upstream/master' into rollover-add-max_shard_docs
weizijun 24cc5cd
fix exception
weizijun d86f1f8
rename
weizijun aca6b68
rename
weizijun e60b76e
remove file
weizijun d77fd75
fix
weizijun e9282d0
improve
weizijun a529b47
improve
weizijun 67c358e
revert HLRC code
weizijun 9baff6c
revert HLRC code
weizijun 36ff8b3
revert HLRC code
weizijun 936f557
bwc
weizijun 0b374d5
fixup
weizijun e849807
fixup
weizijun f3de95a
Merge branch 'master' into rollover-add-max_shard_docs
elasticmachine af982a3
spotless
weizijun 037621a
Merge branch 'master' into rollover-add-max_shard_docs
elasticmachine 8396f2b
change version from 8.1.0 to 8.2.0
weizijun 69ee711
add change log
weizijun ae9786a
Merge branch 'upstream/master' into rollover-add-max_shard_docs
weizijun 764ce75
comment
weizijun 7facb5a
Merge branch 'master' into rollover-add-max_shard_docs
elasticmachine 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 hidden or 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,5 @@ | ||
| pr: 80981 | ||
| summary: Rollover add max_primary_shard_docs condition | ||
| area: ILM+SLM | ||
| type: enhancement | ||
| issues: [] |
This file contains hidden or 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 hidden or 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
59 changes: 59 additions & 0 deletions
59
...yamlRestTest/resources/rest-api-spec/test/indices.rollover/25_max_shard_doc_condition.yml
This file contains hidden or 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,59 @@ | ||
| --- | ||
| "Rollover with max_primary_shard_docs condition": | ||
| - skip: | ||
| version: " - 8.1.99" | ||
| reason: introduced in 8.2.0 | ||
|
|
||
| # create index with alias and replica | ||
| - do: | ||
| indices.create: | ||
| index: logs-1 | ||
| wait_for_active_shards: 1 | ||
| body: | ||
| settings: | ||
| index: | ||
| number_of_shards: 1 | ||
| number_of_replicas: 0 | ||
| aliases: | ||
| logs_search: {} | ||
|
|
||
| # index first document and wait for refresh | ||
| - do: | ||
| index: | ||
| index: logs-1 | ||
| id: "1" | ||
| body: { "foo": "hello world" } | ||
| refresh: true | ||
|
|
||
| # perform alias rollover with no result | ||
| - do: | ||
| indices.rollover: | ||
| alias: "logs_search" | ||
| wait_for_active_shards: 1 | ||
| body: | ||
| conditions: | ||
| max_primary_shard_docs: 2 | ||
|
|
||
| - match: { conditions: { "[max_primary_shard_docs: 2]": false } } | ||
| - match: { rolled_over: false } | ||
|
|
||
| # index second document and wait for refresh | ||
| - do: | ||
| index: | ||
| index: logs-1 | ||
| id: "2" | ||
| body: { "foo": "hello world" } | ||
| refresh: true | ||
|
|
||
| # perform alias rollover | ||
| - do: | ||
| indices.rollover: | ||
| alias: "logs_search" | ||
| wait_for_active_shards: 1 | ||
| body: | ||
| conditions: | ||
| max_primary_shard_docs: 2 | ||
|
|
||
| - match: { conditions: { "[max_primary_shard_docs: 2]": true } } | ||
| - match: { rolled_over: true } | ||
|
|
This file contains hidden or 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 hidden or 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
64 changes: 64 additions & 0 deletions
64
...in/java/org/elasticsearch/action/admin/indices/rollover/MaxPrimaryShardDocsCondition.java
This file contains hidden or 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,64 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
| * in compliance with, at your election, the Elastic License 2.0 or the Server | ||
| * Side Public License, v 1. | ||
| */ | ||
|
|
||
| package org.elasticsearch.action.admin.indices.rollover; | ||
|
|
||
| import org.elasticsearch.Version; | ||
| import org.elasticsearch.common.io.stream.StreamInput; | ||
| import org.elasticsearch.common.io.stream.StreamOutput; | ||
| import org.elasticsearch.xcontent.XContentBuilder; | ||
| import org.elasticsearch.xcontent.XContentParser; | ||
|
|
||
| import java.io.IOException; | ||
|
|
||
| public class MaxPrimaryShardDocsCondition extends Condition<Long> { | ||
| public static final String NAME = "max_primary_shard_docs"; | ||
|
|
||
| public MaxPrimaryShardDocsCondition(Long value) { | ||
| super(NAME); | ||
| this.value = value; | ||
| } | ||
|
|
||
| public MaxPrimaryShardDocsCondition(StreamInput in) throws IOException { | ||
| super(NAME); | ||
| this.value = in.readLong(); | ||
| } | ||
|
|
||
| @Override | ||
| public Result evaluate(Stats stats) { | ||
| return new Result(this, this.value <= stats.maxPrimaryShardDocs()); | ||
| } | ||
|
|
||
| @Override | ||
| public String getWriteableName() { | ||
| return NAME; | ||
| } | ||
|
|
||
| @Override | ||
| public void writeTo(StreamOutput out) throws IOException { | ||
| out.writeLong(value); | ||
| } | ||
|
|
||
| @Override | ||
| public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { | ||
| return builder.field(NAME, value); | ||
| } | ||
|
|
||
| public static MaxPrimaryShardDocsCondition fromXContent(XContentParser parser) throws IOException { | ||
| if (parser.nextToken() == XContentParser.Token.VALUE_NUMBER) { | ||
| return new MaxPrimaryShardDocsCondition(parser.longValue()); | ||
| } else { | ||
| throw new IllegalArgumentException("invalid token: " + parser.currentToken()); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| boolean includedInVersion(Version version) { | ||
| return version.onOrAfter(Version.V_8_2_0); | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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.
Uh oh!
There was an error while loading. Please reload this page.