forked from opensearch-project/OpenSearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Segment Replication] Prioritize replica shard movement during shard …
…relocation (opensearch-project#8875) * add shard movement strategy setting Signed-off-by: Poojita Raj <poojiraj@amazon.com> * add tests Signed-off-by: Poojita Raj <poojiraj@amazon.com> * add changelog Signed-off-by: Poojita Raj <poojiraj@amazon.com> * Add NodeVersionAllocationDecider check Signed-off-by: Poojita Raj <poojiraj@amazon.com> * refactoring Signed-off-by: Poojita Raj <poojiraj@amazon.com> * add annotation + refactor Signed-off-by: Poojita Raj <poojiraj@amazon.com> --------- Signed-off-by: Poojita Raj <poojiraj@amazon.com>
- Loading branch information
1 parent
1d28fac
commit c6e4bcd
Showing
11 changed files
with
491 additions
and
91 deletions.
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
57 changes: 57 additions & 0 deletions
57
server/src/main/java/org/opensearch/cluster/routing/ShardMovementStrategy.java
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,57 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.cluster.routing; | ||
|
||
import org.opensearch.cluster.routing.allocation.allocator.BalancedShardsAllocator; | ||
|
||
import java.util.Locale; | ||
|
||
/** | ||
* ShardMovementStrategy defines the order in which shard movement occurs. | ||
* | ||
* ShardMovementStrategy values or rather their string representation to be used with | ||
* {@link BalancedShardsAllocator#SHARD_MOVEMENT_STRATEGY_SETTING} via cluster settings. | ||
* | ||
* @opensearch.internal | ||
*/ | ||
public enum ShardMovementStrategy { | ||
/** | ||
* default behavior in which order of shard movement doesn't matter. | ||
*/ | ||
NO_PREFERENCE, | ||
|
||
/** | ||
* primary shards are moved first | ||
*/ | ||
PRIMARY_FIRST, | ||
|
||
/** | ||
* replica shards are moved first | ||
*/ | ||
REPLICA_FIRST; | ||
|
||
public static ShardMovementStrategy parse(String strValue) { | ||
if (strValue == null) { | ||
return null; | ||
} else { | ||
strValue = strValue.toUpperCase(Locale.ROOT); | ||
try { | ||
return ShardMovementStrategy.valueOf(strValue); | ||
} catch (IllegalArgumentException e) { | ||
throw new IllegalArgumentException("Illegal allocation.shard_movement_strategy value [" + strValue + "]"); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return name().toLowerCase(Locale.ROOT); | ||
} | ||
|
||
} |
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.