Skip to content

Commit

Permalink
Suppress CachedTimeThread in hot threads output (#35558)
Browse files Browse the repository at this point in the history
In #23175 we renamed `ThreadPool$EstimatedTimeThread` to
`ThreadPool$CachedTimeThread` but did not update the corresponding entry in
`HotThreads#isIdleThread`. This commit addresses this.
  • Loading branch information
DaveCTurner committed Nov 15, 2018
1 parent c9b4ef0 commit 928ab6a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {

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

final Matcher<String> 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:
Expand All @@ -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:
Expand Down

0 comments on commit 928ab6a

Please sign in to comment.