From bb2b6508dfe5c72a43d56228d82fcf7f7bb085b0 Mon Sep 17 00:00:00 2001 From: David Turner Date: Wed, 14 Nov 2018 17:49:00 +0000 Subject: [PATCH] Suppress CachedTimeThread in hot threads output In #23175 we renamed `ThreadPool$EstimatedTimeThread` to `ThreadPool$CachedTimeThread` but did not update the corresponding entry in `HotThreads#isIdleThread`. This commit addresses this. --- .../java/org/elasticsearch/monitor/jvm/HotThreads.java | 2 +- .../java/org/elasticsearch/action/admin/HotThreadsIT.java | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/server/src/main/java/org/elasticsearch/monitor/jvm/HotThreads.java b/server/src/main/java/org/elasticsearch/monitor/jvm/HotThreads.java index 7e00aaa7cd99c..9d7571c6eefc9 100644 --- a/server/src/main/java/org/elasticsearch/monitor/jvm/HotThreads.java +++ b/server/src/main/java/org/elasticsearch/monitor/jvm/HotThreads.java @@ -113,7 +113,7 @@ private static boolean isIdleThread(ThreadInfo threadInfo) { methodName.equals("select")) { return true; } - if (className.equals("org.elasticsearch.threadpool.ThreadPool$EstimatedTimeThread") && + if (className.equals("org.elasticsearch.threadpool.ThreadPool$CachedTimeThread") && methodName.equals("run")) { return true; } diff --git a/server/src/test/java/org/elasticsearch/action/admin/HotThreadsIT.java b/server/src/test/java/org/elasticsearch/action/admin/HotThreadsIT.java index 5d51253882173..9f5d40c6709f0 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/HotThreadsIT.java +++ b/server/src/test/java/org/elasticsearch/action/admin/HotThreadsIT.java @@ -25,6 +25,7 @@ import org.elasticsearch.action.admin.cluster.node.hotthreads.NodesHotThreadsResponse; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.test.ESIntegTestCase; +import org.hamcrest.Matcher; import java.util.Map; import java.util.concurrent.CountDownLatch; @@ -38,7 +39,9 @@ import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.notNullValue; +import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.lessThan; +import static org.hamcrest.Matchers.not; public class HotThreadsIT extends ESIntegTestCase { @@ -135,9 +138,13 @@ public void testIgnoreIdleThreads() throws ExecutionException, InterruptedExcept builder.setThreads(Integer.MAX_VALUE); NodesHotThreadsResponse response = builder.execute().get(); + final Matcher containsCachedTimeThreadRunMethod + = containsString("org.elasticsearch.threadpool.ThreadPool$CachedTimeThread.run"); + int totSizeAll = 0; for (NodeHotThreads node : response.getNodesMap().values()) { totSizeAll += node.getHotThreads().length(); + assertThat(node.getHotThreads(), containsCachedTimeThreadRunMethod); } // Second time, do ignore idle threads: @@ -151,6 +158,7 @@ public void testIgnoreIdleThreads() throws ExecutionException, InterruptedExcept int totSizeIgnoreIdle = 0; for (NodeHotThreads node : response.getNodesMap().values()) { totSizeIgnoreIdle += node.getHotThreads().length(); + assertThat(node.getHotThreads(), not(containsCachedTimeThreadRunMethod)); } // The filtered stacks should be smaller than unfiltered ones: