Skip to content
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

Switch to ShardsBatchGatewayAllocator in batch enabled mode for shard… #14107

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -584,10 +584,7 @@
/*
Use batch mode if enabled and there is no custom allocator set for Allocation service
*/
Boolean batchModeEnabled = EXISTING_SHARDS_ALLOCATOR_BATCH_MODE.get(settings);
if (batchModeEnabled
&& allocation.nodes().getMinNodeVersion().onOrAfter(Version.V_2_14_0)
&& existingShardsAllocators.size() == 2) {
if (isBatchModeEnabled(allocation)) {
/*
If we do not have any custom allocator set then we will be using ShardsBatchGatewayAllocator
Currently AllocationService will not run any custom Allocator that implements allocateAllUnassignedShards
Expand Down Expand Up @@ -724,13 +721,24 @@

private ExistingShardsAllocator getAllocatorForShard(ShardRouting shardRouting, RoutingAllocation routingAllocation) {
assert assertInitialized();
final String allocatorName = ExistingShardsAllocator.EXISTING_SHARDS_ALLOCATOR_SETTING.get(
routingAllocation.metadata().getIndexSafe(shardRouting.index()).getSettings()
);
String allocatorName;
if (isBatchModeEnabled(routingAllocation)) {
allocatorName = ShardsBatchGatewayAllocator.ALLOCATOR_NAME;

Check warning on line 726 in server/src/main/java/org/opensearch/cluster/routing/allocation/AllocationService.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/opensearch/cluster/routing/allocation/AllocationService.java#L726

Added line #L726 was not covered by tests
} else {
allocatorName = ExistingShardsAllocator.EXISTING_SHARDS_ALLOCATOR_SETTING.get(
routingAllocation.metadata().getIndexSafe(shardRouting.index()).getSettings()
);
}
final ExistingShardsAllocator existingShardsAllocator = existingShardsAllocators.get(allocatorName);
SwethaGuptha marked this conversation as resolved.
Show resolved Hide resolved
return existingShardsAllocator != null ? existingShardsAllocator : new NotFoundAllocator(allocatorName);
}

private boolean isBatchModeEnabled(RoutingAllocation routingAllocation) {
return EXISTING_SHARDS_ALLOCATOR_BATCH_MODE.get(settings)
&& routingAllocation.nodes().getMinNodeVersion().onOrAfter(Version.V_2_14_0)
&& existingShardsAllocators.size() == 2;
SwethaGuptha marked this conversation as resolved.
Show resolved Hide resolved
}

private boolean assertInitialized() {
assert existingShardsAllocators != null : "must have set allocators first";
return true;
Expand Down
Loading