Skip to content

Commit be1a0af

Browse files
committed
Suppress CachedTimeThread in hot threads output (#35558)
In #23175 we renamed `ThreadPool$EstimatedTimeThread` to `ThreadPool$CachedTimeThread` but did not update the corresponding entry in `HotThreads#isIdleThread`. This commit addresses this.
1 parent 97b40f0 commit be1a0af

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

server/src/main/java/org/elasticsearch/monitor/jvm/HotThreads.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ private static boolean isIdleThread(ThreadInfo threadInfo) {
113113
methodName.equals("select")) {
114114
return true;
115115
}
116-
if (className.equals("org.elasticsearch.threadpool.ThreadPool$EstimatedTimeThread") &&
116+
if (className.equals("org.elasticsearch.threadpool.ThreadPool$CachedTimeThread") &&
117117
methodName.equals("run")) {
118118
return true;
119119
}

server/src/test/java/org/elasticsearch/action/admin/HotThreadsIT.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.elasticsearch.action.admin.cluster.node.hotthreads.NodesHotThreadsResponse;
2626
import org.elasticsearch.common.unit.TimeValue;
2727
import org.elasticsearch.test.ESIntegTestCase;
28+
import org.hamcrest.Matcher;
2829

2930
import java.util.Map;
3031
import java.util.concurrent.CountDownLatch;
@@ -38,7 +39,9 @@
3839
import static org.hamcrest.CoreMatchers.equalTo;
3940
import static org.hamcrest.CoreMatchers.is;
4041
import static org.hamcrest.CoreMatchers.notNullValue;
42+
import static org.hamcrest.Matchers.containsString;
4143
import static org.hamcrest.Matchers.lessThan;
44+
import static org.hamcrest.Matchers.not;
4245

4346
public class HotThreadsIT extends ESIntegTestCase {
4447

@@ -135,9 +138,13 @@ public void testIgnoreIdleThreads() throws ExecutionException, InterruptedExcept
135138
builder.setThreads(Integer.MAX_VALUE);
136139
NodesHotThreadsResponse response = builder.execute().get();
137140

141+
final Matcher<String> containsCachedTimeThreadRunMethod
142+
= containsString("org.elasticsearch.threadpool.ThreadPool$CachedTimeThread.run");
143+
138144
int totSizeAll = 0;
139145
for (NodeHotThreads node : response.getNodesMap().values()) {
140146
totSizeAll += node.getHotThreads().length();
147+
assertThat(node.getHotThreads(), containsCachedTimeThreadRunMethod);
141148
}
142149

143150
// Second time, do ignore idle threads:
@@ -151,6 +158,7 @@ public void testIgnoreIdleThreads() throws ExecutionException, InterruptedExcept
151158
int totSizeIgnoreIdle = 0;
152159
for (NodeHotThreads node : response.getNodesMap().values()) {
153160
totSizeIgnoreIdle += node.getHotThreads().length();
161+
assertThat(node.getHotThreads(), not(containsCachedTimeThreadRunMethod));
154162
}
155163

156164
// The filtered stacks should be smaller than unfiltered ones:

0 commit comments

Comments
 (0)