Skip to content

Commit 592a7fa

Browse files
committed
Removing List.removeAll from LocalShardsBalancer to filter remote search shard from relocation decision
Signed-off-by: RS146BIJAY <[email protected]>
1 parent f9512db commit 592a7fa

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

server/src/main/java/org/opensearch/cluster/routing/allocation/allocator/LocalShardsBalancer.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -781,12 +781,14 @@ void allocateUnassigned() {
781781
*/
782782
ShardRouting[] unassignedShards = unassigned.drain();
783783
List<ShardRouting> allUnassignedShards = Arrays.stream(unassignedShards).collect(Collectors.toList());
784-
List<ShardRouting> localUnassignedShards = allUnassignedShards.stream()
785-
.filter(shard -> RoutingPool.LOCAL_ONLY.equals(RoutingPool.getShardPool(shard, allocation)))
784+
List<ShardRouting> nonLocalUnassignedShards = allUnassignedShards.stream()
785+
.filter(shard -> !RoutingPool.LOCAL_ONLY.equals(RoutingPool.getShardPool(shard, allocation)))
786786
.collect(Collectors.toList());
787-
allUnassignedShards.removeAll(localUnassignedShards);
788-
allUnassignedShards.forEach(shard -> routingNodes.unassigned().add(shard));
789-
unassignedShards = localUnassignedShards.toArray(new ShardRouting[0]);
787+
788+
nonLocalUnassignedShards.forEach(shard -> routingNodes.unassigned().add(shard));
789+
unassignedShards = allUnassignedShards.stream()
790+
.filter(shard -> RoutingPool.LOCAL_ONLY.equals(RoutingPool.getShardPool(shard, allocation)))
791+
.toArray(ShardRouting[]::new);
790792
ShardRouting[] primary = unassignedShards;
791793
ShardRouting[] secondary = new ShardRouting[primary.length];
792794
int secondaryLength = 0;

0 commit comments

Comments
 (0)