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.
Signed-off-by: Poojita Raj <poojiraj@amazon.com>
- Loading branch information
1 parent
9d22b92
commit 7f7df45
Showing
6 changed files
with
151 additions
and
173 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
55 changes: 55 additions & 0 deletions
55
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,55 @@ | ||
/* | ||
* 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. | ||
*/ | ||
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
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.