@@ -305,46 +305,27 @@ public void testHeapUsageEstimateIsPresent() {
305
305
}
306
306
307
307
public void testNodeWriteLoadsArePresent () {
308
- // Disable write load decider to begin with
309
- setWriteLoadDeciderEnablement (WriteLoadConstraintSettings .WriteLoadDeciderStatus .DISABLED );
310
-
311
308
InternalClusterInfoService clusterInfoService = (InternalClusterInfoService ) getInstanceFromNode (ClusterInfoService .class );
309
+
310
+ // Force a ClusterInfo refresh to run collection of the node thread pool usage stats.
312
311
ClusterInfoServiceUtils .refresh (clusterInfoService );
313
312
Map <String , NodeUsageStatsForThreadPools > nodeThreadPoolStats = clusterInfoService .getClusterInfo ()
314
313
.getNodeUsageStatsForThreadPools ();
315
314
assertNotNull (nodeThreadPoolStats );
316
- /** Not collecting stats yet because allocation write load stats collection is disabled by default.
317
- * see {@link WriteLoadConstraintSettings.WRITE_LOAD_DECIDER_ENABLED_SETTING} */
318
- assertTrue (nodeThreadPoolStats .isEmpty ());
319
-
320
- // Enable collection for node write loads.
321
- setWriteLoadDeciderEnablement (
322
- randomBoolean ()
323
- ? WriteLoadConstraintSettings .WriteLoadDeciderStatus .ENABLED
324
- : WriteLoadConstraintSettings .WriteLoadDeciderStatus .LOW_THRESHOLD_ONLY
325
- );
326
- try {
327
- // Force a ClusterInfo refresh to run collection of the node thread pool usage stats.
328
- ClusterInfoServiceUtils .refresh (clusterInfoService );
329
- nodeThreadPoolStats = clusterInfoService .getClusterInfo ().getNodeUsageStatsForThreadPools ();
330
315
331
- /** Verify that each node has usage stats reported. */
332
- ClusterState state = getInstanceFromNode (ClusterService .class ).state ();
333
- assertEquals (state .nodes ().size (), nodeThreadPoolStats .size ());
334
- for (DiscoveryNode node : state .nodes ()) {
335
- assertTrue (nodeThreadPoolStats .containsKey (node .getId ()));
336
- NodeUsageStatsForThreadPools nodeUsageStatsForThreadPools = nodeThreadPoolStats .get (node .getId ());
337
- assertThat (nodeUsageStatsForThreadPools .nodeId (), equalTo (node .getId ()));
338
- NodeUsageStatsForThreadPools .ThreadPoolUsageStats writeThreadPoolStats = nodeUsageStatsForThreadPools
339
- .threadPoolUsageStatsMap ()
340
- .get (ThreadPool .Names .WRITE );
341
- assertNotNull (writeThreadPoolStats );
342
- assertThat (writeThreadPoolStats .totalThreadPoolThreads (), greaterThanOrEqualTo (0 ));
343
- assertThat (writeThreadPoolStats .averageThreadPoolUtilization (), greaterThanOrEqualTo (0.0f ));
344
- assertThat (writeThreadPoolStats .maxThreadPoolQueueLatencyMillis (), greaterThanOrEqualTo (0L ));
345
- }
346
- } finally {
347
- clearWriteLoadDeciderEnablementSetting ();
316
+ /** Verify that each node has usage stats reported. */
317
+ ClusterState state = getInstanceFromNode (ClusterService .class ).state ();
318
+ assertEquals (state .nodes ().size (), nodeThreadPoolStats .size ());
319
+ for (DiscoveryNode node : state .nodes ()) {
320
+ assertTrue (nodeThreadPoolStats .containsKey (node .getId ()));
321
+ NodeUsageStatsForThreadPools nodeUsageStatsForThreadPools = nodeThreadPoolStats .get (node .getId ());
322
+ assertThat (nodeUsageStatsForThreadPools .nodeId (), equalTo (node .getId ()));
323
+ NodeUsageStatsForThreadPools .ThreadPoolUsageStats writeThreadPoolStats = nodeUsageStatsForThreadPools .threadPoolUsageStatsMap ()
324
+ .get (ThreadPool .Names .WRITE );
325
+ assertNotNull (writeThreadPoolStats );
326
+ assertThat (writeThreadPoolStats .totalThreadPoolThreads (), greaterThanOrEqualTo (0 ));
327
+ assertThat (writeThreadPoolStats .averageThreadPoolUtilization (), greaterThanOrEqualTo (0.0f ));
328
+ assertThat (writeThreadPoolStats .maxThreadPoolQueueLatencyMillis (), greaterThanOrEqualTo (0L ));
348
329
}
349
330
}
350
331
@@ -361,10 +342,10 @@ public void testShardWriteLoadsArePresent() {
361
342
362
343
final InternalClusterInfoService clusterInfoService = (InternalClusterInfoService ) getInstanceFromNode (ClusterInfoService .class );
363
344
364
- // Explicitly disable write load decider
365
- setWriteLoadDeciderEnablement (WriteLoadConstraintSettings .WriteLoadDeciderStatus .DISABLED );
366
-
367
345
try {
346
+ // Explicitly disable write load decider
347
+ setWriteLoadDeciderEnablement (WriteLoadConstraintSettings .WriteLoadDeciderStatus .DISABLED );
348
+
368
349
// Stats should not be collected when the decider is disabled
369
350
{
370
351
ClusterInfoServiceUtils .refresh (clusterInfoService );
0 commit comments