-
Notifications
You must be signed in to change notification settings - Fork 25.6k
ILM: Add total_shards_per_node setting to searchable snapshot #112972
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
Changes from 5 commits
4b035ae
febc50d
7c18216
2ae4aa1
7ded0db
6304b1b
debe05b
776c8ee
e458d0c
a8bcc83
01679a4
15cbad0
92ba2bb
28e28ce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
pr: 112972 | ||
summary: "ILM: Add `total_shards_per_node` setting to searchable snapshot" | ||
area: ILM+SLM | ||
type: enhancement | ||
issues: | ||
- 112261 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ index>> prefixed with `partial-` to the frozen tier. In other phases, the action | |
|
||
In the frozen tier, the action will ignore the setting | ||
<<total-shards-per-node,`index.routing.allocation.total_shards_per_node`>>, if it was present in the original index, | ||
to account for the difference in the number of nodes between the frozen and the other tiers. | ||
to account for the difference in the number of nodes between the frozen and the other tiers. To set <<total-shards-per-node,`index.routing.allocation.total_shards_per_node`>> for searchable snapshots, set the `total_shards_per_node` option in ILM policy. | ||
|
||
|
||
WARNING: Don't include the `searchable_snapshot` action in both the hot and cold | ||
|
@@ -74,6 +74,9 @@ will be performed on the hot nodes. If using a `searchable_snapshot` action in t | |
force merge will be performed on whatever tier the index is *prior* to the `cold` phase (either | ||
`hot` or `warm`). | ||
|
||
`total_shards_per_node`:: | ||
The maximum number of shards (replicas and primaries) that will be allocated to a single node for the searchable snapshot index. Defaults to unbounded. | ||
|
||
[[ilm-searchable-snapshot-ex]] | ||
==== Examples | ||
//// | ||
|
@@ -98,7 +101,8 @@ PUT _ilm/policy/my_policy | |
"cold": { | ||
"actions": { | ||
"searchable_snapshot" : { | ||
"snapshot_repository" : "backing_repo" | ||
"snapshot_repository" : "backing_repo", | ||
"total_shards_per_node" : 2 | ||
|
||
} | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -32,6 +32,7 @@ | |||||
import java.util.List; | ||||||
import java.util.Objects; | ||||||
|
||||||
import static org.elasticsearch.TransportVersions.ILM_ADD_SEARCHABLE_SNAPSHOT_TOTAL_SHARDS_PER_NODE; | ||||||
import static org.elasticsearch.snapshots.SearchableSnapshotsSettings.SEARCHABLE_SNAPSHOTS_REPOSITORY_NAME_SETTING_KEY; | ||||||
import static org.elasticsearch.snapshots.SearchableSnapshotsSettings.SEARCHABLE_SNAPSHOTS_SNAPSHOT_NAME_SETTING_KEY; | ||||||
import static org.elasticsearch.snapshots.SearchableSnapshotsSettings.SEARCHABLE_SNAPSHOT_PARTIAL_SETTING_KEY; | ||||||
|
@@ -49,6 +50,7 @@ public class SearchableSnapshotAction implements LifecycleAction { | |||||
|
||||||
public static final ParseField SNAPSHOT_REPOSITORY = new ParseField("snapshot_repository"); | ||||||
public static final ParseField FORCE_MERGE_INDEX = new ParseField("force_merge_index"); | ||||||
public static final ParseField TOTAL_SHARDS_PER_NODE = new ParseField("total_shards_per_node"); | ||||||
public static final String CONDITIONAL_DATASTREAM_CHECK_KEY = BranchingStep.NAME + "-on-datastream-check"; | ||||||
public static final String CONDITIONAL_SKIP_ACTION_STEP = BranchingStep.NAME + "-check-prerequisites"; | ||||||
public static final String CONDITIONAL_SKIP_GENERATE_AND_CLEAN = BranchingStep.NAME + "-check-existing-snapshot"; | ||||||
|
@@ -58,12 +60,13 @@ public class SearchableSnapshotAction implements LifecycleAction { | |||||
|
||||||
private static final ConstructingObjectParser<SearchableSnapshotAction, Void> PARSER = new ConstructingObjectParser<>( | ||||||
NAME, | ||||||
a -> new SearchableSnapshotAction((String) a[0], a[1] == null || (boolean) a[1]) | ||||||
a -> new SearchableSnapshotAction((String) a[0], a[1] == null || (boolean) a[1], (Integer) a[2]) | ||||||
); | ||||||
|
||||||
static { | ||||||
PARSER.declareString(ConstructingObjectParser.constructorArg(), SNAPSHOT_REPOSITORY); | ||||||
PARSER.declareBoolean(ConstructingObjectParser.optionalConstructorArg(), FORCE_MERGE_INDEX); | ||||||
PARSER.declareInt(ConstructingObjectParser.optionalConstructorArg(), TOTAL_SHARDS_PER_NODE); | ||||||
} | ||||||
|
||||||
public static SearchableSnapshotAction parse(XContentParser parser) { | ||||||
|
@@ -72,22 +75,36 @@ public static SearchableSnapshotAction parse(XContentParser parser) { | |||||
|
||||||
private final String snapshotRepository; | ||||||
private final boolean forceMergeIndex; | ||||||
@Nullable | ||||||
private final Integer totalShardsPerNode; | ||||||
|
||||||
public SearchableSnapshotAction(String snapshotRepository, boolean forceMergeIndex) { | ||||||
public SearchableSnapshotAction(String snapshotRepository, boolean forceMergeIndex, @Nullable Integer totalShardsPerNode) { | ||||||
if (Strings.hasText(snapshotRepository) == false) { | ||||||
throw new IllegalArgumentException("the snapshot repository must be specified"); | ||||||
} | ||||||
this.snapshotRepository = snapshotRepository; | ||||||
this.forceMergeIndex = forceMergeIndex; | ||||||
|
||||||
if (totalShardsPerNode != null && totalShardsPerNode < -1) { | ||||||
|
if (totalShardsPerNode != null && totalShardsPerNode < -1) { | |
if (totalShardsPerNode != null && totalShardsPerNode < 1) { |
(since we want to disallow -1 and 0)
Outdated
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.
throw new IllegalArgumentException("[" + TOTAL_SHARDS_PER_NODE.getPreferredName() + "] must be >= -1"); | |
throw new IllegalArgumentException("[" + TOTAL_SHARDS_PER_NODE.getPreferredName() + "] must be >= 1"); |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -224,7 +224,7 @@ public static LifecyclePolicy randomTimeseriesLifecyclePolicy(@Nullable String l | |||||
frozenTime, | ||||||
Collections.singletonMap( | ||||||
SearchableSnapshotAction.NAME, | ||||||
new SearchableSnapshotAction(randomAlphaOfLength(10), randomBoolean()) | ||||||
new SearchableSnapshotAction(randomAlphaOfLength(10), randomBoolean(), randomIntBetween(-1, 100)) | ||||||
|
new SearchableSnapshotAction(randomAlphaOfLength(10), randomBoolean(), randomIntBetween(-1, 100)) | |
new SearchableSnapshotAction(randomAlphaOfLength(10), randomBoolean(), (randomBoolean() ? null : randomIntBetween(1, 100))) |
Uh oh!
There was an error while loading. Please reload this page.