@@ -179,13 +179,14 @@ public void testNodeValidatorWithHealthyResources() {
179
179
when (cpu .getPercent ()).thenReturn ((short ) 50 );
180
180
when (jvm .getHeapUsedPercent ()).thenReturn ((short ) 60 );
181
181
ThreadPoolStats stats = new ThreadPoolStats (
182
- Arrays .asList (new ThreadPoolStats .Stats (
183
- ThreadPool .Names .FORCE_MERGE , 1 , 0 , 0 , 0 , 1 , 0 , 0
184
- ))
182
+ Arrays .asList (new ThreadPoolStats .Stats (ThreadPool .Names .FORCE_MERGE , 1 , 0 , 0 , 0 , 1 , 0 , 0 ))
185
183
);
186
184
when (threadPool .stats ()).thenReturn (stats );
187
185
188
- AutoForceMergeManager autoForceMergeManager = clusterSetupWithNode (getConfiguredClusterSettings (true , true , Collections .emptyMap ()), getNodeWithRoles (DATA_NODE_1 , Set .of (DiscoveryNodeRole .DATA_ROLE )));
186
+ AutoForceMergeManager autoForceMergeManager = clusterSetupWithNode (
187
+ getConfiguredClusterSettings (true , true , Collections .emptyMap ()),
188
+ getNodeWithRoles (DATA_NODE_1 , Set .of (DiscoveryNodeRole .DATA_ROLE ))
189
+ );
189
190
autoForceMergeManager .start ();
190
191
assertTrue (autoForceMergeManager .getNodeValidator ().validate ().isAllowed ());
191
192
autoForceMergeManager .close ();
@@ -195,13 +196,14 @@ public void testNodeValidatorWithFeatureSwitch() {
195
196
when (cpu .getPercent ()).thenReturn ((short ) 50 );
196
197
when (jvm .getHeapUsedPercent ()).thenReturn ((short ) 60 );
197
198
ThreadPoolStats stats = new ThreadPoolStats (
198
- Arrays .asList (new ThreadPoolStats .Stats (
199
- ThreadPool .Names .FORCE_MERGE , 1 , 0 , 0 , 0 , 1 , 0 , 0
200
- ))
199
+ Arrays .asList (new ThreadPoolStats .Stats (ThreadPool .Names .FORCE_MERGE , 1 , 0 , 0 , 0 , 1 , 0 , 0 ))
201
200
);
202
201
when (threadPool .stats ()).thenReturn (stats );
203
202
Settings settings = getConfiguredClusterSettings (false , false , Collections .emptyMap ());
204
- AutoForceMergeManager autoForceMergeManager = clusterSetupWithNode (settings , getNodeWithRoles (DATA_NODE_1 , Set .of (DiscoveryNodeRole .DATA_ROLE )));
203
+ AutoForceMergeManager autoForceMergeManager = clusterSetupWithNode (
204
+ settings ,
205
+ getNodeWithRoles (DATA_NODE_1 , Set .of (DiscoveryNodeRole .DATA_ROLE ))
206
+ );
205
207
autoForceMergeManager .start ();
206
208
assertFalse (autoForceMergeManager .getConfigurationValidator ().validate ().isAllowed ());
207
209
assertNotEquals (Lifecycle .State .STARTED , ResourceTrackerProvider .resourceTrackers .cpuFiveMinute .lifecycleState ());
@@ -249,22 +251,28 @@ public void testNodeValidatorWithHighCPU() {
249
251
public void testNodeValidatorWithHighDiskUsage () {
250
252
when (cpu .getPercent ()).thenReturn ((short ) 50 );
251
253
when (disk .getAvailable ()).thenReturn (new ByteSizeValue (5 ));
252
- AutoForceMergeManager autoForceMergeManager = clusterSetupWithNode (getConfiguredClusterSettings (true , true , Collections .emptyMap ()), getNodeWithRoles (DATA_NODE_1 , Set .of (DiscoveryNodeRole .DATA_ROLE )));
254
+ AutoForceMergeManager autoForceMergeManager = clusterSetupWithNode (
255
+ getConfiguredClusterSettings (true , true , Collections .emptyMap ()),
256
+ getNodeWithRoles (DATA_NODE_1 , Set .of (DiscoveryNodeRole .DATA_ROLE ))
257
+ );
253
258
autoForceMergeManager .start ();
254
259
assertFalse (autoForceMergeManager .getNodeValidator ().validate ().isAllowed ());
255
260
autoForceMergeManager .close ();
256
261
}
257
262
258
263
public void testNodeValidatorWithHighJVMUsage () {
259
264
when (cpu .getPercent ()).thenReturn ((short ) 50 );
260
- AutoForceMergeManager autoForceMergeManager = clusterSetupWithNode (getConfiguredClusterSettings (true , true , Collections .emptyMap ()), getNodeWithRoles (DATA_NODE_1 , Set .of (DiscoveryNodeRole .DATA_ROLE )));
265
+ AutoForceMergeManager autoForceMergeManager = clusterSetupWithNode (
266
+ getConfiguredClusterSettings (true , true , Collections .emptyMap ()),
267
+ getNodeWithRoles (DATA_NODE_1 , Set .of (DiscoveryNodeRole .DATA_ROLE ))
268
+ );
261
269
autoForceMergeManager .start ();
262
270
when (jvm .getHeapUsedPercent ()).thenReturn ((short ) 90 );
263
271
assertFalse (autoForceMergeManager .getNodeValidator ().validate ().isAllowed ());
264
- for (int i = 0 ; i < 10 ; i ++)
272
+ for (int i = 0 ; i < 10 ; i ++)
265
273
ResourceTrackerProvider .resourceTrackers .jvmOneMinute .recordUsage (90 );
266
274
assertFalse (autoForceMergeManager .getNodeValidator ().validate ().isAllowed ());
267
- for (int i = 0 ; i < 10 ; i ++)
275
+ for (int i = 0 ; i < 10 ; i ++)
268
276
ResourceTrackerProvider .resourceTrackers .jvmFiveMinute .recordUsage (90 );
269
277
assertFalse (autoForceMergeManager .getNodeValidator ().validate ().isAllowed ());
270
278
autoForceMergeManager .close ();
@@ -274,12 +282,13 @@ public void testNodeValidatorWithInsufficientForceMergeThreads() {
274
282
when (cpu .getPercent ()).thenReturn ((short ) 50 );
275
283
when (jvm .getHeapUsedPercent ()).thenReturn ((short ) 50 );
276
284
ThreadPoolStats stats = new ThreadPoolStats (
277
- Arrays .asList (new ThreadPoolStats .Stats (
278
- ThreadPool .Names .FORCE_MERGE , 1 , 1 , 1 , 0 , 1 , 0 , -1
279
- ))
285
+ Arrays .asList (new ThreadPoolStats .Stats (ThreadPool .Names .FORCE_MERGE , 1 , 1 , 1 , 0 , 1 , 0 , -1 ))
280
286
);
281
287
when (threadPool .stats ()).thenReturn (stats );
282
- AutoForceMergeManager autoForceMergeManager = clusterSetupWithNode (getConfiguredClusterSettings (true , true , Collections .emptyMap ()), getNodeWithRoles (DATA_NODE_1 , Set .of (DiscoveryNodeRole .DATA_ROLE )));
288
+ AutoForceMergeManager autoForceMergeManager = clusterSetupWithNode (
289
+ getConfiguredClusterSettings (true , true , Collections .emptyMap ()),
290
+ getNodeWithRoles (DATA_NODE_1 , Set .of (DiscoveryNodeRole .DATA_ROLE ))
291
+ );
283
292
autoForceMergeManager .start ();
284
293
assertFalse (autoForceMergeManager .getNodeValidator ().validate ().isAllowed ());
285
294
ThreadPoolStats emptyStats = new ThreadPoolStats (Collections .emptyList ());
@@ -553,12 +562,7 @@ private AutoForceMergeManager clusterSetupWithNode(Settings settings, DiscoveryN
553
562
when (clusterService .getSettings ()).thenReturn (settings );
554
563
when (clusterService .localNode ()).thenReturn (node );
555
564
556
- return new AutoForceMergeManager (
557
- threadPool ,
558
- monitorService ,
559
- indicesService ,
560
- clusterService
561
- );
565
+ return new AutoForceMergeManager (threadPool , monitorService , indicesService , clusterService );
562
566
}
563
567
564
568
private IndexShard getShard (String indexName , TranslogStats translogStats , Integer segmentCount ) {
0 commit comments