forked from opensearch-project/OpenSearch
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor BalancedAllocator.Balancer to LocalShardsBalancer (opensearc…
…h-project#4761) * Refactor BalancedAllocator.Balancer to LocalShardsBalancer Signed-off-by: Kunal Kotwani <kkotwani@amazon.com> * Deprecate Balancer to maintain BWC Signed-off-by: Kunal Kotwani <kkotwani@amazon.com> Signed-off-by: Kunal Kotwani <kkotwani@amazon.com>
- Loading branch information
1 parent
6ac0c7c
commit 1d65485
Showing
7 changed files
with
1,083 additions
and
942 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
967 changes: 31 additions & 936 deletions
967
...ain/java/org/opensearch/cluster/routing/allocation/allocator/BalancedShardsAllocator.java
Large diffs are not rendered by default.
Oops, something went wrong.
967 changes: 967 additions & 0 deletions
967
...rc/main/java/org/opensearch/cluster/routing/allocation/allocator/LocalShardsBalancer.java
Large diffs are not rendered by default.
Oops, something went wrong.
75 changes: 75 additions & 0 deletions
75
server/src/main/java/org/opensearch/cluster/routing/allocation/allocator/ShardsBalancer.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,75 @@ | ||
/* | ||
* 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.allocation.allocator; | ||
|
||
import org.opensearch.cluster.routing.ShardRouting; | ||
import org.opensearch.cluster.routing.allocation.AllocateUnassignedDecision; | ||
import org.opensearch.cluster.routing.allocation.MoveDecision; | ||
|
||
/** | ||
* <p> | ||
* A {@link ShardsBalancer} helps the {@link BalancedShardsAllocator} to perform allocation and balancing | ||
* operations on the cluster. | ||
* </p> | ||
* | ||
* @opensearch.internal | ||
*/ | ||
public abstract class ShardsBalancer { | ||
|
||
/** | ||
* Performs allocation of unassigned shards on nodes within the cluster. | ||
*/ | ||
abstract void allocateUnassigned(); | ||
|
||
/** | ||
* Moves shards that cannot be allocated to a node anymore. | ||
*/ | ||
abstract void moveShards(); | ||
|
||
/** | ||
* Balances the nodes on the cluster model. | ||
*/ | ||
abstract void balance(); | ||
|
||
/** | ||
* Make a decision for allocating an unassigned shard. | ||
* @param shardRouting the shard for which the decision has to be made | ||
* @return the allocation decision | ||
*/ | ||
abstract AllocateUnassignedDecision decideAllocateUnassigned(ShardRouting shardRouting); | ||
|
||
/** | ||
* Makes a decision on whether to move a started shard to another node. | ||
* @param shardRouting the shard for which the decision has to be made | ||
* @return a move decision for the shard | ||
*/ | ||
abstract MoveDecision decideMove(ShardRouting shardRouting); | ||
|
||
/** | ||
* Makes a decision about moving a single shard to a different node to form a more | ||
* optimally balanced cluster. | ||
* @param shardRouting the shard for which the move decision has to be made | ||
* @return a move decision for the shard | ||
*/ | ||
abstract MoveDecision decideRebalance(ShardRouting shardRouting); | ||
|
||
/** | ||
* Returns the average of shards per node for the given index | ||
*/ | ||
public float avgShardsPerNode() { | ||
return Float.MAX_VALUE; | ||
} | ||
|
||
/** | ||
* Returns the global average of shards per node | ||
*/ | ||
public float avgShardsPerNode(String index) { | ||
return Float.MAX_VALUE; | ||
} | ||
} |
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