@@ -151,6 +151,11 @@ public ClusterModule(
151151 this .deciderList = createAllocationDeciders (settings , clusterService .getClusterSettings (), clusterPlugins );
152152 this .allocationDeciders = new AllocationDeciders (deciderList );
153153 final BalancerSettings balancerSettings = new BalancerSettings (clusterService .getClusterSettings ());
154+ // I'm aware that the following is an anti-pattern and will implement as an SPI provider or plugin
155+ // if we decide to go ahead with this.
156+ final PartitionedClusterFactory partitionedClusterFactory = DiscoveryNode .isStateless (settings )
157+ ? new TieredPartitionedClusterFactory (balancerSettings , clusterService .getClusterSettings ())
158+ : new GlobalPartitionedClusterFactory (balancerSettings );
154159 var nodeAllocationStatsAndWeightsCalculator = new NodeAllocationStatsAndWeightsCalculator (
155160 writeLoadForecaster ,
156161 new GlobalPartitionedClusterFactory (balancerSettings )
@@ -159,6 +164,7 @@ public ClusterModule(
159164 settings ,
160165 clusterService .getClusterSettings (),
161166 balancerSettings ,
167+ partitionedClusterFactory ,
162168 threadPool ,
163169 clusterPlugins ,
164170 clusterService ,
@@ -448,6 +454,7 @@ private static ShardsAllocator createShardsAllocator(
448454 Settings settings ,
449455 ClusterSettings clusterSettings ,
450456 BalancerSettings balancerSettings ,
457+ PartitionedClusterFactory partitionedClusterFactory ,
451458 ThreadPool threadPool ,
452459 List <ClusterPlugin > clusterPlugins ,
453460 ClusterService clusterService ,
@@ -457,11 +464,6 @@ private static ShardsAllocator createShardsAllocator(
457464 NodeAllocationStatsAndWeightsCalculator nodeAllocationStatsAndWeightsCalculator
458465 ) {
459466 Map <String , Supplier <ShardsAllocator >> allocators = new HashMap <>();
460- // I'm aware that the following is an anti-pattern and will implement as an SPI provider or plugin
461- // if we decide to go ahead with this.
462- final PartitionedClusterFactory partitionedClusterFactory = DiscoveryNode .isStateless (settings )
463- ? new TieredPartitionedClusterFactory (balancerSettings , clusterSettings )
464- : new GlobalPartitionedClusterFactory (balancerSettings );
465467 allocators .put (
466468 BALANCED_ALLOCATOR ,
467469 () -> new BalancedShardsAllocator (balancerSettings , writeLoadForecaster , partitionedClusterFactory )
0 commit comments