Ejemplo n.º 1
0
  public void testIgnoreIdleThreads() throws ExecutionException, InterruptedException {

    // First time, don't ignore idle threads:
    NodesHotThreadsRequestBuilder builder = client().admin().cluster().prepareNodesHotThreads();
    builder.setIgnoreIdleThreads(false);
    builder.setThreads(Integer.MAX_VALUE);
    NodesHotThreadsResponse response = builder.execute().get();

    int totSizeAll = 0;
    for (NodeHotThreads node : response.getNodesMap().values()) {
      totSizeAll += node.getHotThreads().length();
    }

    // Second time, do ignore idle threads:
    builder = client().admin().cluster().prepareNodesHotThreads();
    builder.setThreads(Integer.MAX_VALUE);

    // Make sure default is true:
    assertEquals(true, builder.request().ignoreIdleThreads());
    response = builder.execute().get();

    int totSizeIgnoreIdle = 0;
    for (NodeHotThreads node : response.getNodesMap().values()) {
      totSizeIgnoreIdle += node.getHotThreads().length();
    }

    // The filtered stacks should be smaller than unfiltered ones:
    assertThat(totSizeIgnoreIdle, lessThan(totSizeAll));
  }
Ejemplo n.º 2
0
  public void testTimestampAndParams() throws ExecutionException, InterruptedException {

    NodesHotThreadsResponse response =
        client().admin().cluster().prepareNodesHotThreads().execute().get();

    for (NodeHotThreads node : response.getNodesMap().values()) {
      String result = node.getHotThreads();
      assertTrue(result.indexOf("Hot threads at") != -1);
      assertTrue(result.indexOf("interval=500ms") != -1);
      assertTrue(result.indexOf("busiestThreads=3") != -1);
      assertTrue(result.indexOf("ignoreIdleThreads=true") != -1);
    }
  }