org.elasticsearch.action.admin.cluster.node.stats.NodesStatsResponse Java Examples
The following examples show how to use
org.elasticsearch.action.admin.cluster.node.stats.NodesStatsResponse.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MockInternalClusterInfoService.java From crate with Apache License 2.0 | 6 votes |
@Override protected CountDownLatch updateNodeStats(ActionListener<NodesStatsResponse> listener) { return super.updateNodeStats(new ActionListener<>() { @Override public void onResponse(NodesStatsResponse nodesStatsResponse) { ImmutableOpenMap.Builder<String, DiskUsage> leastAvailableUsagesBuilder = ImmutableOpenMap.builder(); ImmutableOpenMap.Builder<String, DiskUsage> mostAvailableUsagesBuilder = ImmutableOpenMap.builder(); fillDiskUsagePerNode( LOGGER, adjustNodesStats(nodesStatsResponse.getNodes()), leastAvailableUsagesBuilder, mostAvailableUsagesBuilder ); leastAvailableSpaceUsages = leastAvailableUsagesBuilder.build(); mostAvailableSpaceUsages = mostAvailableUsagesBuilder.build(); } @Override public void onFailure(Exception e) { } }); }
Example #2
Source File: SystemMonitorTarget.java From fess with Apache License 2.0 | 6 votes |
private void appendElasticsearchStats(final StringBuilder buf) { String stats = null; try { final FessEsClient esClient = ComponentUtil.getFessEsClient(); final NodesStatsResponse response = esClient.admin().cluster().prepareNodesStats().all().execute().actionGet(10000L); final XContentBuilder builder = XContentFactory.jsonBuilder(); builder.startObject(); response.toXContent(builder, ToXContent.EMPTY_PARAMS); builder.endObject(); builder.flush(); try (OutputStream out = builder.getOutputStream()) { stats = ((ByteArrayOutputStream) out).toString(Constants.UTF_8); } } catch (final Exception e) { logger.debug("Failed to access Elasticsearch stats.", e); } buf.append("\"elasticsearch\":").append(stats).append(','); }
Example #3
Source File: ElasticsearchQueryStoreTest.java From foxtrot with Apache License 2.0 | 6 votes |
@Test @Ignore public void testEsNodesStats() throws FoxtrotException, ExecutionException, InterruptedException { List<Document> documents = Lists.newArrayList(); for (int i = 0; i < 10; i++) { documents.add(createDummyDocument()); } doReturn(documents).when(dataStore) .saveAll(any(Table.class), anyListOf(Document.class)); queryStore.save(TestUtils.TEST_TABLE_NAME, documents); elasticsearchConnection.refresh(ElasticsearchUtils.getIndices(TestUtils.TEST_TABLE_NAME)); NodesStatsResponse clusterHealth = queryStore.getNodeStats(); assertNotNull(clusterHealth); assertEquals(1, clusterHealth.getNodesMap() .size()); }
Example #4
Source File: ElasticsearchQueryStore.java From foxtrot with Apache License 2.0 | 6 votes |
@Override public NodesStatsResponse getNodeStats() throws ExecutionException, InterruptedException { NodesStatsRequest nodesStatsRequest = new NodesStatsRequest(); nodesStatsRequest.clear() .jvm(true) .os(true) .fs(true) .indices(true) .process(true) .breaker(true); return connection.getClient() .admin() .cluster() .nodesStats(nodesStatsRequest) .actionGet(); }
Example #5
Source File: RestFielddataAction.java From Elasticsearch with Apache License 2.0 | 6 votes |
@Override protected void doRequest(final RestRequest request, final RestChannel channel, final Client client) { final NodesStatsRequest nodesStatsRequest = new NodesStatsRequest("data:true"); nodesStatsRequest.clear(); nodesStatsRequest.indices(true); String[] fields = request.paramAsStringArray("fields", null); nodesStatsRequest.indices().fieldDataFields(fields == null ? new String[] {"*"} : fields); client.admin().cluster().nodesStats(nodesStatsRequest, new RestResponseListener<NodesStatsResponse>(channel) { @Override public RestResponse buildResponse(NodesStatsResponse nodeStatses) throws Exception { return RestTable.buildResponse(buildTable(request, nodeStatses), channel); } }); }
Example #6
Source File: CircuitBreakerTest.java From siren-join with GNU Affero General Public License v3.0 | 6 votes |
@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)); }
Example #7
Source File: CircuitBreakerTest.java From siren-join with GNU Affero General Public License v3.0 | 6 votes |
@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)); }
Example #8
Source File: ElasticSearchService.java From sakai with Educational Community License v2.0 | 5 votes |
protected NodesStatsResponse getNodesStats() { final NodesInfoResponse nodesInfoResponse = client.admin().cluster().nodesInfo(new NodesInfoRequest()).actionGet(); final String[] nodes = new String[nodesInfoResponse.getNodes().length]; int i = 0; for (NodeInfo nodeInfo : nodesInfoResponse.getNodes()) { nodes[i++] = nodeInfo.getNode().getName(); } return client.admin().cluster().nodesStats(new NodesStatsRequest(nodes)).actionGet(); }
Example #9
Source File: InternalClusterInfoService.java From crate with Apache License 2.0 | 5 votes |
/** * Retrieve the latest nodes stats, calling the listener when complete * @return a latch that can be used to wait for the nodes stats to complete if desired */ protected CountDownLatch updateNodeStats(final ActionListener<NodesStatsResponse> listener) { final CountDownLatch latch = new CountDownLatch(1); ObjectContainer<DiscoveryNode> allDataNodes = this.clusterService.state().getNodes().getDataNodes().values(); final NodesStatsRequest nodesStatsRequest = new NodesStatsRequest(allDataNodes.toArray(DiscoveryNode.class)); nodesStatsRequest.timeout(fetchTimeout); client.admin().cluster().nodesStats(nodesStatsRequest, new LatchedActionListener<>(listener, latch)); return latch; }
Example #10
Source File: ElasticSearchService.java From sakai with Educational Community License v2.0 | 5 votes |
protected NodesStatsResponse getNodesStats() { final NodesInfoResponse nodesInfoResponse = client.admin().cluster().nodesInfo(new NodesInfoRequest()).actionGet(); final String[] nodes = new String[nodesInfoResponse.getNodes().length]; int i = 0; for (NodeInfo nodeInfo : nodesInfoResponse.getNodes()) { nodes[i++] = nodeInfo.getNode().getName(); } return client.admin().cluster().nodesStats(new NodesStatsRequest(nodes)).actionGet(); }
Example #11
Source File: ElasticSearchService.java From sakai with Educational Community License v2.0 | 5 votes |
@Override public List<SearchStatus> getSearchStatus() { final List<SearchStatus> indexBuilderStatuses = Lists.newArrayList(); forEachRegisteredIndexBuilder(i -> indexBuilderStatuses.add(i.getSearchStatus())); final NodesStatsResponse nodesStatsResponse = getNodesStats(); return indexBuilderStatuses .stream() .map(s -> newSearchStatusWrapper(s, nodesStatsResponse)) .collect(Collectors.toList()); }
Example #12
Source File: ClusterHealthResource.java From foxtrot with Apache License 2.0 | 5 votes |
@GET @Timed @Path("/nodestats") @ApiOperation("getNodeStat") public NodesStatsResponse getNodeStat() throws ExecutionException, InterruptedException { return queryStore.getNodeStats(); }
Example #13
Source File: ElasticsearchTransportClient.java From Raigad with Apache License 2.0 | 5 votes |
public static NodesStatsResponse getNodesStatsResponse(IConfiguration config) { try { return ElasticsearchTransportClient.instance(config).getNodeStatsRequestBuilder().execute().actionGet(); } catch (Exception e) { logger.error(e.getMessage(), e); } return null; }
Example #14
Source File: ElasticSearchService.java From sakai with Educational Community License v2.0 | 5 votes |
@Override public List<SearchStatus> getSearchStatus() { final List<SearchStatus> indexBuilderStatuses = Lists.newArrayList(); forEachRegisteredIndexBuilder(i -> indexBuilderStatuses.add(i.getSearchStatus())); final NodesStatsResponse nodesStatsResponse = getNodesStats(); return indexBuilderStatuses .stream() .map(s -> newSearchStatusWrapper(s, nodesStatsResponse)) .collect(Collectors.toList()); }
Example #15
Source File: Elasticsearch5SearchIndexTest.java From vertexium with Apache License 2.0 | 5 votes |
private long getNumQueries() { NodesStatsResponse nodeStats = NodesStatsAction.INSTANCE.newRequestBuilder(elasticsearchResource.getClient()).get(); List<NodeStats> nodes = nodeStats.getNodes(); assertEquals(1, nodes.size()); SearchStats searchStats = nodes.get(0).getIndices().getSearch(); return searchStats.getTotal().getQueryCount(); }
Example #16
Source File: Elasticsearch7SearchIndexTest.java From vertexium with Apache License 2.0 | 5 votes |
private long getNumQueries() { NodesStatsResponse nodeStats = new NodesStatsRequestBuilder(elasticsearchResource.getClient(), NodesStatsAction.INSTANCE).get(); List<NodeStats> nodes = nodeStats.getNodes(); assertEquals(1, nodes.size()); SearchStats searchStats = nodes.get(0).getIndices().getSearch(); return searchStats.getTotal().getQueryCount(); }
Example #17
Source File: TransportNodePrometheusMetricsAction.java From elasticsearch-prometheus-exporter with Apache License 2.0 | 5 votes |
protected NodePrometheusMetricsResponse buildResponse(ClusterHealthResponse clusterHealth, NodesStatsResponse nodesStats, @Nullable IndicesStatsResponse indicesStats, @Nullable ClusterStateResponse clusterStateResponse) { NodePrometheusMetricsResponse response = new NodePrometheusMetricsResponse(clusterHealth, nodesStats.getNodes().get(0), indicesStats, clusterStateResponse, settings, clusterSettings); if (logger.isTraceEnabled()) { logger.trace("Return response: [{}]", response); } return response; }
Example #18
Source File: TransportNodePrometheusMetricsAction.java From elasticsearch-prometheus-exporter with Apache License 2.0 | 5 votes |
@Override public void onResponse(NodesStatsResponse nodeStats) { nodesStatsResponse = nodeStats; if (isPrometheusIndices) { client.admin().indices().stats(indicesStatsRequest, indicesStatsResponseActionListener); } else { indicesStatsResponseActionListener.onResponse(null); } }
Example #19
Source File: InternalClusterInfoService.java From Elasticsearch with Apache License 2.0 | 5 votes |
/** * Retrieve the latest nodes stats, calling the listener when complete * @return a latch that can be used to wait for the nodes stats to complete if desired */ protected CountDownLatch updateNodeStats(final ActionListener<NodesStatsResponse> listener) { final CountDownLatch latch = new CountDownLatch(1); final NodesStatsRequest nodesStatsRequest = new NodesStatsRequest("data:true"); nodesStatsRequest.clear(); nodesStatsRequest.fs(true); nodesStatsRequest.timeout(fetchTimeout); transportNodesStatsAction.execute(nodesStatsRequest, new LatchedActionListener<>(listener, latch)); return latch; }
Example #20
Source File: RestThreadPoolAction.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public void doRequest(final RestRequest request, final RestChannel channel, final Client client) { final ClusterStateRequest clusterStateRequest = new ClusterStateRequest(); clusterStateRequest.clear().nodes(true); clusterStateRequest.local(request.paramAsBoolean("local", clusterStateRequest.local())); clusterStateRequest.masterNodeTimeout(request.paramAsTime("master_timeout", clusterStateRequest.masterNodeTimeout())); client.admin().cluster().state(clusterStateRequest, new RestActionListener<ClusterStateResponse>(channel) { @Override public void processResponse(final ClusterStateResponse clusterStateResponse) { NodesInfoRequest nodesInfoRequest = new NodesInfoRequest(); nodesInfoRequest.clear().process(true).threadPool(true); client.admin().cluster().nodesInfo(nodesInfoRequest, new RestActionListener<NodesInfoResponse>(channel) { @Override public void processResponse(final NodesInfoResponse nodesInfoResponse) { NodesStatsRequest nodesStatsRequest = new NodesStatsRequest(); nodesStatsRequest.clear().threadPool(true); client.admin().cluster().nodesStats(nodesStatsRequest, new RestResponseListener<NodesStatsResponse>(channel) { @Override public RestResponse buildResponse(NodesStatsResponse nodesStatsResponse) throws Exception { return RestTable.buildResponse(buildTable(request, clusterStateResponse, nodesInfoResponse, nodesStatsResponse), channel); } }); } }); } }); }
Example #21
Source File: RestNodesAction.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public void doRequest(final RestRequest request, final RestChannel channel, final Client client) { final ClusterStateRequest clusterStateRequest = new ClusterStateRequest(); clusterStateRequest.clear().nodes(true); clusterStateRequest.local(request.paramAsBoolean("local", clusterStateRequest.local())); clusterStateRequest.masterNodeTimeout(request.paramAsTime("master_timeout", clusterStateRequest.masterNodeTimeout())); client.admin().cluster().state(clusterStateRequest, new RestActionListener<ClusterStateResponse>(channel) { @Override public void processResponse(final ClusterStateResponse clusterStateResponse) { NodesInfoRequest nodesInfoRequest = new NodesInfoRequest(); nodesInfoRequest.clear().jvm(true).os(true).process(true); client.admin().cluster().nodesInfo(nodesInfoRequest, new RestActionListener<NodesInfoResponse>(channel) { @Override public void processResponse(final NodesInfoResponse nodesInfoResponse) { NodesStatsRequest nodesStatsRequest = new NodesStatsRequest(); nodesStatsRequest.clear().jvm(true).os(true).fs(true).indices(true).process(true).script(true); client.admin().cluster().nodesStats(nodesStatsRequest, new RestResponseListener<NodesStatsResponse>(channel) { @Override public RestResponse buildResponse(NodesStatsResponse nodesStatsResponse) throws Exception { return RestTable.buildResponse(buildTable(request, clusterStateResponse, nodesInfoResponse, nodesStatsResponse), channel); } }); } }); } }); }
Example #22
Source File: RestNodeAttrsAction.java From Elasticsearch with Apache License 2.0 | 5 votes |
private Table buildTable(RestRequest req, ClusterStateResponse state, NodesInfoResponse nodesInfo, NodesStatsResponse nodesStats) { boolean fullId = req.paramAsBoolean("full_id", false); DiscoveryNodes nodes = state.getState().nodes(); Table table = getTableWithHeader(req); for (DiscoveryNode node : nodes) { NodeInfo info = nodesInfo.getNodesMap().get(node.id()); ImmutableMap<String, String> attrs = node.getAttributes(); for(String att : attrs.keySet()) { table.startRow(); table.addCell(node.name()); table.addCell(fullId ? node.id() : Strings.substring(node.getId(), 0, 4)); table.addCell(info == null ? null : info.getProcess().getId()); table.addCell(node.getHostName()); table.addCell(node.getHostAddress()); if (node.address() instanceof InetSocketTransportAddress) { table.addCell(((InetSocketTransportAddress) node.address()).address().getPort()); } else { table.addCell("-"); } table.addCell(att); table.addCell(attrs.containsKey(att) ? attrs.get(att) : null); table.endRow(); } } return table; }
Example #23
Source File: RestNodeAttrsAction.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public void doRequest(final RestRequest request, final RestChannel channel, final Client client) { final ClusterStateRequest clusterStateRequest = new ClusterStateRequest(); clusterStateRequest.clear().nodes(true); clusterStateRequest.local(request.paramAsBoolean("local", clusterStateRequest.local())); clusterStateRequest.masterNodeTimeout(request.paramAsTime("master_timeout", clusterStateRequest.masterNodeTimeout())); client.admin().cluster().state(clusterStateRequest, new RestActionListener<ClusterStateResponse>(channel) { @Override public void processResponse(final ClusterStateResponse clusterStateResponse) { NodesInfoRequest nodesInfoRequest = new NodesInfoRequest(); nodesInfoRequest.clear().jvm(false).os(false).process(true); client.admin().cluster().nodesInfo(nodesInfoRequest, new RestActionListener<NodesInfoResponse>(channel) { @Override public void processResponse(final NodesInfoResponse nodesInfoResponse) { NodesStatsRequest nodesStatsRequest = new NodesStatsRequest(); nodesStatsRequest.clear().jvm(false).os(false).fs(false).indices(false).process(false); client.admin().cluster().nodesStats(nodesStatsRequest, new RestResponseListener<NodesStatsResponse>(channel) { @Override public RestResponse buildResponse(NodesStatsResponse nodesStatsResponse) throws Exception { return RestTable.buildResponse(buildTable(request, clusterStateResponse, nodesInfoResponse, nodesStatsResponse), channel); } }); } }); } }); }
Example #24
Source File: ThreadPoolStatsMonitor.java From Raigad with Apache License 2.0 | 4 votes |
@Override public void execute() throws Exception { // If Elasticsearch is started then only start the monitoring if (!ElasticsearchProcessMonitor.isElasticsearchRunning()) { String exceptionMsg = "Elasticsearch is not yet started, check back again later"; logger.info(exceptionMsg); return; } ThreadPoolStatsBean threadPoolStatsBean = new ThreadPoolStatsBean(); try { NodesStatsResponse nodesStatsResponse = ElasticsearchTransportClient.getNodesStatsResponse(config); NodeStats nodeStats = null; List<NodeStats> nodeStatsList = nodesStatsResponse.getNodes(); if (nodeStatsList.size() > 0) { nodeStats = nodeStatsList.get(0); } if (nodeStats == null) { logger.info("Thread pool stats are not available (node stats is not available)"); return; } ThreadPoolStats threadPoolStats = nodeStats.getThreadPool(); if (threadPoolStats == null) { logger.info("Thread pool stats are not available"); return; } Iterator<ThreadPoolStats.Stats> threadPoolStatsIterator = threadPoolStats.iterator(); while (threadPoolStatsIterator.hasNext()) { ThreadPoolStats.Stats stat = threadPoolStatsIterator.next(); if (stat.getName().equals("index")) { threadPoolStatsBean.indexThreads = stat.getThreads(); threadPoolStatsBean.indexQueue = stat.getQueue(); threadPoolStatsBean.indexActive = stat.getActive(); threadPoolStatsBean.indexRejected = stat.getRejected(); threadPoolStatsBean.indexLargest = stat.getLargest(); threadPoolStatsBean.indexCompleted = stat.getCompleted(); } else if (stat.getName().equals("get")) { threadPoolStatsBean.getThreads = stat.getThreads(); threadPoolStatsBean.getQueue = stat.getQueue(); threadPoolStatsBean.getActive = stat.getActive(); threadPoolStatsBean.getRejected = stat.getRejected(); threadPoolStatsBean.getLargest = stat.getLargest(); threadPoolStatsBean.getCompleted = stat.getCompleted(); } else if (stat.getName().equals("search")) { threadPoolStatsBean.searchThreads = stat.getThreads(); threadPoolStatsBean.searchQueue = stat.getQueue(); threadPoolStatsBean.searchActive = stat.getActive(); threadPoolStatsBean.searchRejected = stat.getRejected(); threadPoolStatsBean.searchLargest = stat.getLargest(); threadPoolStatsBean.searchCompleted = stat.getCompleted(); } else if (stat.getName().equals("bulk")) { threadPoolStatsBean.bulkThreads = stat.getThreads(); threadPoolStatsBean.bulkQueue = stat.getQueue(); threadPoolStatsBean.bulkActive = stat.getActive(); threadPoolStatsBean.bulkRejected = stat.getRejected(); threadPoolStatsBean.bulkLargest = stat.getLargest(); threadPoolStatsBean.bulkCompleted = stat.getCompleted(); } } } catch (Exception e) { logger.warn("Failed to load thread pool stats data", e); } tpStatsReporter.threadPoolBean.set(threadPoolStatsBean); }
Example #25
Source File: FsStatsMonitor.java From Raigad with Apache License 2.0 | 4 votes |
@Override public void execute() throws Exception { // Only start monitoring if Elasticsearch is started if (!ElasticsearchProcessMonitor.isElasticsearchRunning()) { String exceptionMsg = "Elasticsearch is not yet started, check back again later"; logger.info(exceptionMsg); return; } FsStatsBean fsStatsBean = new FsStatsBean(); try { NodesStatsResponse nodesStatsResponse = ElasticsearchTransportClient.getNodesStatsResponse(config); NodeStats nodeStats = null; List<NodeStats> nodeStatsList = nodesStatsResponse.getNodes(); if (nodeStatsList.size() > 0) { nodeStats = nodeStatsList.get(0); } if (nodeStats == null) { logger.info("File system info is not available (node stats are not available)"); return; } FsInfo fsInfo = nodeStats.getFs(); if (fsInfo == null) { logger.info("File system info is not available"); return; } fsStatsBean.total = fsInfo.getTotal().getTotal().getBytes(); fsStatsBean.free = fsInfo.getTotal().getFree().getBytes(); fsStatsBean.available = fsInfo.getTotal().getAvailable().getBytes(); fsStatsBean.availableDiskPercent = (fsStatsBean.available * 100) / fsStatsBean.total; } catch (Exception e) { logger.warn("Failed to load file system stats data", e); } fsStatsReporter.fsStatsBean.set(fsStatsBean); }
Example #26
Source File: RestAllocationAction.java From Elasticsearch with Apache License 2.0 | 4 votes |
private Table buildTable(RestRequest request, final ClusterStateResponse state, final NodesStatsResponse stats) { final ObjectIntScatterMap<String> allocs = new ObjectIntScatterMap<>(); for (ShardRouting shard : state.getState().routingTable().allShards()) { String nodeId = "UNASSIGNED"; if (shard.assignedToNode()) { nodeId = shard.currentNodeId(); } allocs.addTo(nodeId, 1); } Table table = getTableWithHeader(request); for (NodeStats nodeStats : stats.getNodes()) { DiscoveryNode node = nodeStats.getNode(); int shardCount = allocs.getOrDefault(node.id(), 0); ByteSizeValue total = nodeStats.getFs().getTotal().getTotal(); ByteSizeValue avail = nodeStats.getFs().getTotal().getAvailable(); //if we don't know how much we use (non data nodes), it means 0 long used = 0; short diskPercent = -1; if (total.bytes() > 0) { used = total.bytes() - avail.bytes(); if (used >= 0 && avail.bytes() >= 0) { diskPercent = (short) (used * 100 / (used + avail.bytes())); } } table.startRow(); table.addCell(shardCount); table.addCell(nodeStats.getIndices().getStore().getSize()); table.addCell(used < 0 ? null : new ByteSizeValue(used)); table.addCell(avail.bytes() < 0 ? null : avail); table.addCell(total.bytes() < 0 ? null : total); table.addCell(diskPercent < 0 ? null : diskPercent); table.addCell(node.getHostName()); table.addCell(node.getHostAddress()); table.addCell(node.name()); table.endRow(); } final String UNASSIGNED = "UNASSIGNED"; if (allocs.containsKey(UNASSIGNED)) { table.startRow(); table.addCell(allocs.get(UNASSIGNED)); table.addCell(null); table.addCell(null); table.addCell(null); table.addCell(null); table.addCell(null); table.addCell(null); table.addCell(null); table.addCell(UNASSIGNED); table.endRow(); } return table; }
Example #27
Source File: RestNodesStatsAction.java From Elasticsearch with Apache License 2.0 | 4 votes |
@Override public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { String[] nodesIds = Strings.splitStringByCommaToArray(request.param("nodeId")); Set<String> metrics = Strings.splitStringByCommaToSet(request.param("metric", "_all")); NodesStatsRequest nodesStatsRequest = new NodesStatsRequest(nodesIds); nodesStatsRequest.timeout(request.param("timeout")); if (metrics.size() == 1 && metrics.contains("_all")) { nodesStatsRequest.all(); nodesStatsRequest.indices(CommonStatsFlags.ALL); } else { nodesStatsRequest.clear(); nodesStatsRequest.os(metrics.contains("os")); nodesStatsRequest.jvm(metrics.contains("jvm")); nodesStatsRequest.threadPool(metrics.contains("thread_pool")); nodesStatsRequest.fs(metrics.contains("fs")); nodesStatsRequest.transport(metrics.contains("transport")); nodesStatsRequest.http(metrics.contains("http")); nodesStatsRequest.indices(metrics.contains("indices")); nodesStatsRequest.process(metrics.contains("process")); nodesStatsRequest.breaker(metrics.contains("breaker")); nodesStatsRequest.script(metrics.contains("script")); // check for index specific metrics if (metrics.contains("indices")) { Set<String> indexMetrics = Strings.splitStringByCommaToSet(request.param("indexMetric", "_all")); if (indexMetrics.size() == 1 && indexMetrics.contains("_all")) { nodesStatsRequest.indices(CommonStatsFlags.ALL); } else { CommonStatsFlags flags = new CommonStatsFlags(); for (Flag flag : CommonStatsFlags.Flag.values()) { flags.set(flag, indexMetrics.contains(flag.getRestName())); } nodesStatsRequest.indices(flags); } } } if (nodesStatsRequest.indices().isSet(Flag.FieldData) && (request.hasParam("fields") || request.hasParam("fielddata_fields"))) { nodesStatsRequest.indices().fieldDataFields(request.paramAsStringArray("fielddata_fields", request.paramAsStringArray("fields", null))); } if (nodesStatsRequest.indices().isSet(Flag.Completion) && (request.hasParam("fields") || request.hasParam("completion_fields"))) { nodesStatsRequest.indices().completionDataFields(request.paramAsStringArray("completion_fields", request.paramAsStringArray("fields", null))); } if (nodesStatsRequest.indices().isSet(Flag.Search) && (request.hasParam("groups"))) { nodesStatsRequest.indices().groups(request.paramAsStringArray("groups", null)); } if (nodesStatsRequest.indices().isSet(Flag.Indexing) && (request.hasParam("types"))) { nodesStatsRequest.indices().types(request.paramAsStringArray("types", null)); } client.admin().cluster().nodesStats(nodesStatsRequest, new RestToXContentListener<NodesStatsResponse>(channel)); }
Example #28
Source File: ElasticSearchService.java From sakai with Educational Community License v2.0 | 4 votes |
protected SearchStatus newSearchStatusWrapper(SearchStatus toWrap, NodesStatsResponse nodesStatsResponse) { return new SearchStatus() { @Override public String getLastLoad() { return toWrap.getLastLoad(); } @Override public String getLoadTime() { return toWrap.getLoadTime(); } @Override public String getCurrentWorker() { return getNodeName(); } @Override public String getCurrentWorkerETC() { return getNodeName(); } @Override public List getWorkerNodes() { List<Object[]> workers = new ArrayList(); for (NodeStats nodeStat : nodesStatsResponse.getNodes()) { if (nodeStat.getNode().isDataNode()) { workers.add(new Object[]{nodeStat.getNode().getName() + "(" + nodeStat.getHostname() + ")", null, // No way to get a meaningful "start" time per node, so now just set a null Date. // Historically used an index builder starttime, which was always meaningless in this // context since it's always going to refer to the local node. And we now have // multiple index builders, so it's doubly meaningless. Historical comment below // hints at same problem with the results of 'getStatus()' //TODO will show same status for each node, need to deal with that getStatus()}); } } return workers; } @Override public String getNDocuments() { return toWrap.getNDocuments(); } @Override public String getPDocuments() { return toWrap.getPDocuments(); } }; }
Example #29
Source File: AbstractClient.java From Elasticsearch with Apache License 2.0 | 4 votes |
@Override public void nodesStats(final NodesStatsRequest request, final ActionListener<NodesStatsResponse> listener) { execute(NodesStatsAction.INSTANCE, request, listener); }
Example #30
Source File: AbstractClient.java From Elasticsearch with Apache License 2.0 | 4 votes |
@Override public ActionFuture<NodesStatsResponse> nodesStats(final NodesStatsRequest request) { return execute(NodesStatsAction.INSTANCE, request); }