public Collection<NodeInfo> load() { NodesStatsResponse nodesStats = esClient.prepareNodesStats() .setFs(true) .setProcess(true) .setJvm(true) .setIndices(true) .setBreaker(true) .get(); List<NodeInfo> result = new ArrayList<>(); nodesStats.getNodes().forEach(nodeStat -> result.add(toNodeInfo(nodeStat))); return result; }
private boolean isBulkProcessorAvailable() { NodesStatsResponse response = client.admin().cluster().prepareNodesStats().setThreadPool(true).get(); for (NodeStats nodeStats : response.getNodes()) { Iterator<Stats> iterator = nodeStats.getThreadPool().iterator(); while (iterator.hasNext()) { Stats stats = iterator.next(); if ("bulk".equals(stats.getName())) { int queue = stats.getQueue(); logger.trace("bulkQueueSize [{}] - queue [{}] - availability [{}]", bulkQueueSize, queue, 1 - (queue / bulkQueueSize)); return 1 - (queue / bulkQueueSize) > 0.1; } } } return true; }
private void completeNodeAttributes(ProtobufSystemInfo.Section.Builder protobuf) { NodesStatsResponse nodesStats = esClient.prepareNodesStats() .setFs(true) .setProcess(true) .setJvm(true) .setIndices(true) .setBreaker(true) .get(); if (!nodesStats.getNodes().isEmpty()) { NodeStats stats = nodesStats.getNodes().get(0); toProtobuf(stats, protobuf); } }
@Test public void trace_logs() { logTester.setLevel(LoggerLevel.TRACE); es.client().prepareNodesStats().get(); assertThat(logTester.logs()).hasSize(1); }
@Test public void stats() { es.client().prepareNodesStats().get(); }
@Test public void get_with_string_timeout_is_not_yet_implemented() { thrown.expect(IllegalStateException.class); thrown.expectMessage("Not yet implemented"); es.client().prepareNodesStats(FakeIndexDefinition.INDEX).get("1"); }
@Test public void get_with_time_value_timeout_is_not_yet_implemented() { thrown.expect(IllegalStateException.class); thrown.expectMessage("Not yet implemented"); es.client().prepareNodesStats(FakeIndexDefinition.INDEX).get(TimeValue.timeValueMinutes(1)); }
@Override public String getNodesStats() { return client.admin().cluster().prepareNodesStats().get().toString(); }
public Map<String, NodeStats> getNodesStats() throws Exception { NodesStatsResponse nodesStats = esClient.admin().cluster().prepareNodesStats().all().get(); return nodesStats.getNodesMap(); }
/** * Prints current memory stats as info logging. */ public void logMemoryStats() { logger.info("memory: {}", Strings.toString(client().admin().cluster().prepareNodesStats().clear().setJvm(true).get(), true, true)); }
public Collection<NodeInfo> load() { NodesStatsResponse nodesStats = esClient.prepareNodesStats() .setFs(true) .setProcess(true) .setJvm(true) .setIndices(true) .setBreaker(true) .get(); List<NodeInfo> result = new ArrayList<>(); nodesStats.getNodes().forEach(nodeStat -> result.add(toNodeInfo(nodeStat))); return result; }
private void completeNodeAttributes(ProtobufSystemInfo.Section.Builder protobuf) { NodesStatsResponse nodesStats = esClient.prepareNodesStats() .setFs(true) .setProcess(true) .setJvm(true) .setIndices(true) .setBreaker(true) .get(); if (!nodesStats.getNodes().isEmpty()) { NodeStats stats = nodesStats.getNodes().get(0); toProtobuf(stats, protobuf); } }
private long getNumQueries() { Client client = elasticsearchResource.getRunner().client(); NodesStatsResponse nodeStats = NodesStatsAction.INSTANCE.newRequestBuilder(client).get(); List<NodeStats> nodes = nodeStats.getNodes(); assertEquals(1, nodes.size()); SearchStats searchStats = nodes.get(0).getIndices().getSearch(); return searchStats.getTotal().getQueryCount(); }
ClusterStatsResponse clusterStatsResponse = index.getClient().admin().cluster().prepareClusterStats().get(); NodesInfoResponse nodesInfoResponse = index.getClient().admin().cluster().prepareNodesInfo().get(); NodesStatsResponse nodesStatsResponse = index.getClient().admin().cluster().prepareNodesStats().get(); ClusterStateResponse clusterStateResponse = index.getClient().admin().cluster().prepareState().get(); IndicesStatsResponse indicesStatsResponse = index.getClient().admin().indices().prepareStats().all().get();
@Test public void testCircuitBreakerOnCoordinator() throws Exception { // Update circuit breaker settings Settings settings = settingsBuilder() .put(HierarchyCircuitBreakerService.REQUEST_CIRCUIT_BREAKER_LIMIT_SETTING, "60b") .build(); assertAcked(client().admin().cluster().prepareUpdateSettings().setTransientSettings(settings)); SearchRequestBuilder searchRequest = new CoordinateSearchRequestBuilder(client()).setIndices("index1").setQuery( QueryBuilders.filterJoin("foreign_key").indices("index2").types("type").path("id").query( boolQuery().filter(termQuery("tag", "aaa")) ).termsEncoding(TermsByQueryRequest.TermsEncoding.LONG) ); assertFailures(searchRequest, RestStatus.INTERNAL_SERVER_ERROR, containsString("Data too large, data for [<terms_set>] would be larger than limit of [60/60b]")); NodesStatsResponse stats = client().admin().cluster().prepareNodesStats().setBreaker(true).get(); int breaks = 0; for (NodeStats stat : stats.getNodes()) { CircuitBreakerStats breakerStats = stat.getBreaker().getStats(CircuitBreaker.REQUEST); breaks += breakerStats.getTrippedCount(); } assertThat(breaks, greaterThanOrEqualTo(1)); }
@Test public void testCircuitBreakerOnShard() throws Exception { // Update circuit breaker settings Settings settings = settingsBuilder() .put(HierarchyCircuitBreakerService.REQUEST_CIRCUIT_BREAKER_LIMIT_SETTING, "8b") .build(); assertAcked(client().admin().cluster().prepareUpdateSettings().setTransientSettings(settings)); SearchRequestBuilder searchRequest = new CoordinateSearchRequestBuilder(client()).setIndices("index1").setQuery( QueryBuilders.filterJoin("foreign_key").indices("index2").types("type").path("id").query( boolQuery().filter(termQuery("tag", "aaa")) ).termsEncoding(TermsByQueryRequest.TermsEncoding.LONG) ); assertFailures(searchRequest, RestStatus.INTERNAL_SERVER_ERROR, containsString("Data too large, data for [<terms_set>] would be larger than limit of [8/8b]")); NodesStatsResponse stats = client().admin().cluster().prepareNodesStats().setBreaker(true).get(); int breaks = 0; for (NodeStats stat : stats.getNodes()) { CircuitBreakerStats breakerStats = stat.getBreaker().getStats(CircuitBreaker.REQUEST); breaks += breakerStats.getTrippedCount(); } assertThat(breaks, greaterThanOrEqualTo(1)); }