@@ -305,46 +305,27 @@ public void testHeapUsageEstimateIsPresent() {
305305 }
306306
307307 public void testNodeWriteLoadsArePresent () {
308- // Disable write load decider to begin with
309- setWriteLoadDeciderEnablement (WriteLoadConstraintSettings .WriteLoadDeciderStatus .DISABLED );
310-
311308 InternalClusterInfoService clusterInfoService = (InternalClusterInfoService ) getInstanceFromNode (ClusterInfoService .class );
309+
310+ // Force a ClusterInfo refresh to run collection of the node thread pool usage stats.
312311 ClusterInfoServiceUtils .refresh (clusterInfoService );
313312 Map <String , NodeUsageStatsForThreadPools > nodeThreadPoolStats = clusterInfoService .getClusterInfo ()
314313 .getNodeUsageStatsForThreadPools ();
315314 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 ();
330315
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 ));
348329 }
349330 }
350331
@@ -361,10 +342,10 @@ public void testShardWriteLoadsArePresent() {
361342
362343 final InternalClusterInfoService clusterInfoService = (InternalClusterInfoService ) getInstanceFromNode (ClusterInfoService .class );
363344
364- // Explicitly disable write load decider
365- setWriteLoadDeciderEnablement (WriteLoadConstraintSettings .WriteLoadDeciderStatus .DISABLED );
366-
367345 try {
346+ // Explicitly disable write load decider
347+ setWriteLoadDeciderEnablement (WriteLoadConstraintSettings .WriteLoadDeciderStatus .DISABLED );
348+
368349 // Stats should not be collected when the decider is disabled
369350 {
370351 ClusterInfoServiceUtils .refresh (clusterInfoService );
0 commit comments