@@ -584,10 +584,7 @@ private void allocateExistingUnassignedShards(RoutingAllocation allocation) {
584
584
/*
585
585
Use batch mode if enabled and there is no custom allocator set for Allocation service
586
586
*/
587
- Boolean batchModeEnabled = EXISTING_SHARDS_ALLOCATOR_BATCH_MODE .get (settings );
588
- if (batchModeEnabled
589
- && allocation .nodes ().getMinNodeVersion ().onOrAfter (Version .V_2_14_0 )
590
- && existingShardsAllocators .size () == 2 ) {
587
+ if (isBatchModeEnabled (allocation )) {
591
588
/*
592
589
If we do not have any custom allocator set then we will be using ShardsBatchGatewayAllocator
593
590
Currently AllocationService will not run any custom Allocator that implements allocateAllUnassignedShards
@@ -724,13 +721,24 @@ private AllocateUnassignedDecision explainUnassignedShardAllocation(ShardRouting
724
721
725
722
private ExistingShardsAllocator getAllocatorForShard (ShardRouting shardRouting , RoutingAllocation routingAllocation ) {
726
723
assert assertInitialized ();
727
- final String allocatorName = ExistingShardsAllocator .EXISTING_SHARDS_ALLOCATOR_SETTING .get (
728
- routingAllocation .metadata ().getIndexSafe (shardRouting .index ()).getSettings ()
729
- );
724
+ String allocatorName ;
725
+ if (isBatchModeEnabled (routingAllocation )) {
726
+ allocatorName = ShardsBatchGatewayAllocator .ALLOCATOR_NAME ;
727
+ } else {
728
+ allocatorName = ExistingShardsAllocator .EXISTING_SHARDS_ALLOCATOR_SETTING .get (
729
+ routingAllocation .metadata ().getIndexSafe (shardRouting .index ()).getSettings ()
730
+ );
731
+ }
730
732
final ExistingShardsAllocator existingShardsAllocator = existingShardsAllocators .get (allocatorName );
731
733
return existingShardsAllocator != null ? existingShardsAllocator : new NotFoundAllocator (allocatorName );
732
734
}
733
735
736
+ private boolean isBatchModeEnabled (RoutingAllocation routingAllocation ) {
737
+ return EXISTING_SHARDS_ALLOCATOR_BATCH_MODE .get (settings )
738
+ && routingAllocation .nodes ().getMinNodeVersion ().onOrAfter (Version .V_2_14_0 )
739
+ && existingShardsAllocators .size () == 2 ;
740
+ }
741
+
734
742
private boolean assertInitialized () {
735
743
assert existingShardsAllocators != null : "must have set allocators first" ;
736
744
return true ;
0 commit comments