|
8 | 8 |
|
9 | 9 | package org.elasticsearch.client;
|
10 | 10 |
|
| 11 | +import org.apache.http.client.methods.HttpGet; |
11 | 12 | import org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryRequest;
|
12 | 13 | import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotRequest;
|
13 | 14 | import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse;
|
|
35 | 36 |
|
36 | 37 | import java.io.IOException;
|
37 | 38 | import java.util.List;
|
| 39 | +import java.util.Map; |
| 40 | +import java.util.concurrent.TimeUnit; |
38 | 41 |
|
| 42 | +import static org.elasticsearch.common.xcontent.support.XContentMapValues.extractValue; |
39 | 43 | import static org.hamcrest.Matchers.aMapWithSize;
|
40 | 44 | import static org.hamcrest.Matchers.emptyOrNullString;
|
41 | 45 | import static org.hamcrest.Matchers.equalTo;
|
@@ -125,6 +129,35 @@ public void testCacheStats() throws Exception {
|
125 | 129 | assertThat(response.getHits().getHits()[0].getSourceAsMap(), aMapWithSize(2));
|
126 | 130 | }
|
127 | 131 |
|
| 132 | + { |
| 133 | + assertBusy(() -> { |
| 134 | + final Response response = client().performRequest(new Request(HttpGet.METHOD_NAME, "/_nodes/stats/thread_pool")); |
| 135 | + assertThat(response.getStatusLine().getStatusCode(), equalTo(RestStatus.OK.getStatus())); |
| 136 | + |
| 137 | + @SuppressWarnings("unchecked") |
| 138 | + final Map<String, Object> nodes = (Map<String, Object>) extractValue(responseAsMap(response), "nodes"); |
| 139 | + assertThat(nodes, notNullValue()); |
| 140 | + |
| 141 | + for (String node : nodes.keySet()) { |
| 142 | + @SuppressWarnings("unchecked") |
| 143 | + final Map<String, Object> threadPools = |
| 144 | + (Map<String, Object>) extractValue((Map<String, Object>) nodes.get(node), "thread_pool"); |
| 145 | + assertNotNull("No thread pools on node " + node, threadPools); |
| 146 | + |
| 147 | + @SuppressWarnings("unchecked") |
| 148 | + final Map<String, Object> threadPoolStats = |
| 149 | + (Map<String, Object>) threadPools.get("searchable_snapshots_cache_fetch_async"); |
| 150 | + assertNotNull("No thread pools stats on node " + node, threadPoolStats); |
| 151 | + |
| 152 | + final Number active = (Number) extractValue(threadPoolStats, "active"); |
| 153 | + assertThat(node + " has still active tasks", active, equalTo(0)); |
| 154 | + |
| 155 | + final Number queue = (Number) extractValue(threadPoolStats, "queue"); |
| 156 | + assertThat(node + " has still enqueued tasks", queue, equalTo(0)); |
| 157 | + } |
| 158 | + }, 30L, TimeUnit.SECONDS); |
| 159 | + } |
| 160 | + |
128 | 161 | {
|
129 | 162 | final CachesStatsRequest request = new CachesStatsRequest();
|
130 | 163 | final CachesStatsResponse response = execute(request, client::cacheStats, client::cacheStatsAsync);
|
|
0 commit comments