99package org .elasticsearch .cluster .routing .allocation .decider ;
1010
1111import org .elasticsearch .Version ;
12- import org .elasticsearch .action .ActionListener ;
1312import org .elasticsearch .cluster .ClusterState ;
1413import org .elasticsearch .cluster .ESAllocationTestCase ;
15- import org .elasticsearch .cluster .EmptyClusterInfoService ;
16- import org .elasticsearch .cluster .TestShardRoutingRoleStrategies ;
1714import org .elasticsearch .cluster .metadata .IndexMetadata ;
1815import org .elasticsearch .cluster .metadata .Metadata ;
1916import org .elasticsearch .cluster .metadata .NodesShutdownMetadata ;
2623import org .elasticsearch .cluster .routing .RoutingNodesHelper ;
2724import org .elasticsearch .cluster .routing .ShardRouting ;
2825import org .elasticsearch .cluster .routing .UnassignedInfo ;
29- import org .elasticsearch .cluster .routing .allocation .AllocationService ;
3026import org .elasticsearch .cluster .routing .allocation .RoutingAllocation ;
31- import org .elasticsearch .cluster .routing .allocation .allocator .BalancedShardsAllocator ;
3227import org .elasticsearch .common .settings .ClusterSettings ;
33- import org .elasticsearch .common .settings .Settings ;
3428import org .elasticsearch .core .TimeValue ;
3529import org .elasticsearch .index .shard .ShardId ;
36- import org .elasticsearch .snapshots .EmptySnapshotsInfoService ;
37- import org .elasticsearch .test .gateway .TestGatewayAllocator ;
3830
3931import java .util .Arrays ;
4032import java .util .Collections ;
@@ -58,14 +50,6 @@ public class NodeShutdownAllocationDeciderTests extends ESAllocationTestCase {
5850 private final AllocationDeciders allocationDeciders = new AllocationDeciders (
5951 Arrays .asList (decider , new SameShardAllocationDecider (clusterSettings ), new ReplicaAfterPrimaryActiveAllocationDecider ())
6052 );
61- private final AllocationService service = new AllocationService (
62- allocationDeciders ,
63- new TestGatewayAllocator (),
64- new BalancedShardsAllocator (Settings .EMPTY ),
65- EmptyClusterInfoService .INSTANCE ,
66- EmptySnapshotsInfoService .INSTANCE ,
67- TestShardRoutingRoleStrategies .DEFAULT_ROLE_ONLY
68- );
6953
7054 private final String idxName = "test-idx" ;
7155 private final String idxUuid = "test-idx-uuid" ;
@@ -80,10 +64,7 @@ public class NodeShutdownAllocationDeciderTests extends ESAllocationTestCase {
8064 );
8165
8266 public void testCanAllocateShardsToRestartingNode () {
83- ClusterState state = prepareState (
84- service .reroute (ClusterState .EMPTY_STATE , "initial state" , ActionListener .noop ()),
85- SingleNodeShutdownMetadata .Type .RESTART
86- );
67+ ClusterState state = prepareState (ClusterState .EMPTY_STATE , SingleNodeShutdownMetadata .Type .RESTART );
8768 RoutingAllocation allocation = new RoutingAllocation (allocationDeciders , state , null , null , 0 );
8869 RoutingNode routingNode = RoutingNodesHelper .routingNode (DATA_NODE .getId (), DATA_NODE , shard );
8970 allocation .debugDecision (true );
@@ -98,7 +79,7 @@ public void testCanAllocateShardsToRestartingNode() {
9879
9980 public void testCannotAllocateShardsToRemovingNode () {
10081 for (SingleNodeShutdownMetadata .Type type : REMOVE_SHUTDOWN_TYPES ) {
101- ClusterState state = prepareState (service . reroute ( ClusterState .EMPTY_STATE , "initial state" , ActionListener . noop ()) , type );
82+ ClusterState state = prepareState (ClusterState .EMPTY_STATE , type );
10283 RoutingAllocation allocation = new RoutingAllocation (allocationDeciders , state , null , null , 0 );
10384 RoutingNode routingNode = RoutingNodesHelper .routingNode (DATA_NODE .getId (), DATA_NODE , shard );
10485 allocation .debugDecision (true );
@@ -110,10 +91,7 @@ public void testCannotAllocateShardsToRemovingNode() {
11091 }
11192
11293 public void testShardsCanRemainOnRestartingNode () {
113- ClusterState state = prepareState (
114- service .reroute (ClusterState .EMPTY_STATE , "initial state" , ActionListener .noop ()),
115- SingleNodeShutdownMetadata .Type .RESTART
116- );
94+ ClusterState state = prepareState (ClusterState .EMPTY_STATE , SingleNodeShutdownMetadata .Type .RESTART );
11795 RoutingAllocation allocation = new RoutingAllocation (allocationDeciders , state , null , null , 0 );
11896 RoutingNode routingNode = RoutingNodesHelper .routingNode (DATA_NODE .getId (), DATA_NODE , shard );
11997 allocation .debugDecision (true );
@@ -128,7 +106,7 @@ public void testShardsCanRemainOnRestartingNode() {
128106
129107 public void testShardsCannotRemainOnRemovingNode () {
130108 for (SingleNodeShutdownMetadata .Type type : REMOVE_SHUTDOWN_TYPES ) {
131- ClusterState state = prepareState (service . reroute ( ClusterState .EMPTY_STATE , "initial state" , ActionListener . noop ()) , type );
109+ ClusterState state = prepareState (ClusterState .EMPTY_STATE , type );
132110 RoutingAllocation allocation = new RoutingAllocation (allocationDeciders , state , null , null , 0 );
133111 RoutingNode routingNode = RoutingNodesHelper .routingNode (DATA_NODE .getId (), DATA_NODE , shard );
134112 allocation .debugDecision (true );
@@ -144,10 +122,7 @@ public void testShardsCannotRemainOnRemovingNode() {
144122 }
145123
146124 public void testCanAutoExpandToRestartingNode () {
147- ClusterState state = prepareState (
148- service .reroute (ClusterState .EMPTY_STATE , "initial state" , ActionListener .noop ()),
149- SingleNodeShutdownMetadata .Type .RESTART
150- );
125+ ClusterState state = prepareState (ClusterState .EMPTY_STATE , SingleNodeShutdownMetadata .Type .RESTART );
151126 RoutingAllocation allocation = new RoutingAllocation (allocationDeciders , state , null , null , 0 );
152127 allocation .debugDecision (true );
153128
@@ -160,9 +135,7 @@ public void testCanAutoExpandToRestartingNode() {
160135 }
161136
162137 public void testCanAutoExpandToNodeIfNoNodesShuttingDown () {
163- ClusterState state = service .reroute (ClusterState .EMPTY_STATE , "initial state" , ActionListener .noop ());
164-
165- RoutingAllocation allocation = new RoutingAllocation (allocationDeciders , state , null , null , 0 );
138+ RoutingAllocation allocation = new RoutingAllocation (allocationDeciders , ClusterState .EMPTY_STATE , null , null , 0 );
166139 allocation .debugDecision (true );
167140
168141 Decision decision = decider .shouldAutoExpandToNode (indexMetadata , DATA_NODE , allocation );
@@ -172,11 +145,7 @@ public void testCanAutoExpandToNodeIfNoNodesShuttingDown() {
172145
173146 public void testCanAutoExpandToNodeThatIsNotShuttingDown () {
174147 for (SingleNodeShutdownMetadata .Type type : REMOVE_SHUTDOWN_TYPES ) {
175- ClusterState state = prepareState (
176- service .reroute (ClusterState .EMPTY_STATE , "initial state" , ActionListener .noop ()),
177- type ,
178- "other-node-id"
179- );
148+ ClusterState state = prepareState (ClusterState .EMPTY_STATE , type , "other-node-id" );
180149
181150 RoutingAllocation allocation = new RoutingAllocation (allocationDeciders , state , null , null , 0 );
182151 allocation .debugDecision (true );
@@ -189,7 +158,7 @@ public void testCanAutoExpandToNodeThatIsNotShuttingDown() {
189158
190159 public void testCannotAutoExpandToRemovingNode () {
191160 for (SingleNodeShutdownMetadata .Type type : REMOVE_SHUTDOWN_TYPES ) {
192- ClusterState state = prepareState (service . reroute ( ClusterState .EMPTY_STATE , "initial state" , ActionListener . noop ()) , type );
161+ ClusterState state = prepareState (ClusterState .EMPTY_STATE , type );
193162 RoutingAllocation allocation = new RoutingAllocation (allocationDeciders , state , null , null , 0 );
194163 allocation .debugDecision (true );
195164
0 commit comments