Java Code Examples for org.elasticsearch.action.admin.cluster.node.stats.NodesStatsResponse#getNodes()
The following examples show how to use
org.elasticsearch.action.admin.cluster.node.stats.NodesStatsResponse#getNodes() .
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: 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 2
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 3
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 4
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 5
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 6
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 7
Source File: JvmStatsMonitor.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; } JvmStatsBean jvmStatsBean = new JvmStatsBean(); 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("JVM stats is not available (node stats is not available)"); return; } JvmStats jvmStats = nodeStats.getJvm(); if (jvmStats == null) { logger.info("JVM stats is not available"); return; } //Heap jvmStatsBean.heapCommittedInBytes = jvmStats.getMem().getHeapCommitted().getMb(); jvmStatsBean.heapMaxInBytes = jvmStats.getMem().getHeapMax().getMb(); jvmStatsBean.heapUsedInBytes = jvmStats.getMem().getHeapUsed().getMb(); jvmStatsBean.heapUsedPercent = jvmStats.getMem().getHeapUsedPercent(); jvmStatsBean.nonHeapCommittedInBytes = jvmStats.getMem().getNonHeapCommitted().getMb(); jvmStatsBean.nonHeapUsedInBytes = jvmStats.getMem().getNonHeapUsed().getMb(); Iterator<JvmStats.MemoryPool> memoryPoolIterator = jvmStats.getMem().iterator(); while (memoryPoolIterator.hasNext()) { JvmStats.MemoryPool memoryPoolStats = memoryPoolIterator.next(); if (memoryPoolStats.getName().equalsIgnoreCase(GC_YOUNG_TAG)) { jvmStatsBean.youngMaxInBytes = memoryPoolStats.getMax().getBytes(); jvmStatsBean.youngUsedInBytes = memoryPoolStats.getUsed().getBytes(); jvmStatsBean.youngPeakUsedInBytes = memoryPoolStats.getPeakUsed().getBytes(); jvmStatsBean.youngPeakMaxInBytes = memoryPoolStats.getPeakMax().getBytes(); } else if (memoryPoolStats.getName().equalsIgnoreCase(GC_SURVIVOR_TAG)) { jvmStatsBean.survivorMaxInBytes = memoryPoolStats.getMax().getBytes(); jvmStatsBean.survivorUsedInBytes = memoryPoolStats.getUsed().getBytes(); jvmStatsBean.survivorPeakUsedInBytes = memoryPoolStats.getPeakUsed().getBytes(); jvmStatsBean.survivorPeakMaxInBytes = memoryPoolStats.getPeakMax().getBytes(); } else if (memoryPoolStats.getName().equalsIgnoreCase(GC_OLD_TAG)) { jvmStatsBean.oldMaxInBytes = memoryPoolStats.getMax().getBytes(); jvmStatsBean.oldUsedInBytes = memoryPoolStats.getUsed().getBytes(); jvmStatsBean.oldPeakUsedInBytes = memoryPoolStats.getPeakUsed().getBytes(); jvmStatsBean.oldPeakMaxInBytes = memoryPoolStats.getPeakMax().getBytes(); } } //Threads jvmStatsBean.threadCount = jvmStats.getThreads().getCount(); jvmStatsBean.threadPeakCount = jvmStats.getThreads().getPeakCount(); jvmStatsBean.uptimeHours = jvmStats.getUptime().getHours(); //GC for (JvmStats.GarbageCollector garbageCollector : jvmStats.getGc().getCollectors()) { if (garbageCollector.getName().equalsIgnoreCase(GC_YOUNG_TAG)) { jvmStatsBean.youngCollectionCount = garbageCollector.getCollectionCount(); jvmStatsBean.youngCollectionTimeInMillis = garbageCollector.getCollectionTime().getMillis(); } else if (garbageCollector.getName().equalsIgnoreCase(GC_OLD_TAG)) { jvmStatsBean.oldCollectionCount = garbageCollector.getCollectionCount(); jvmStatsBean.oldCollectionTimeInMillis = garbageCollector.getCollectionTime().getMillis(); } } } catch (Exception e) { logger.warn("Failed to load JVM stats data", e); } jvmStatsReporter.jvmStatsBean.set(jvmStatsBean); }
Example 8
Source File: ProcessStatsMonitor.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; } ProcessStatsBean processStatsBean = new ProcessStatsBean(); 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("Process stats are not available (node stats is not available)"); return; } ProcessStats processStats = nodeStats.getProcess(); if (processStats == null) { logger.info("Process stats are not available"); return; } //Memory processStatsBean.totalVirtualInBytes = processStats.getMem().getTotalVirtual().getBytes(); //CPU processStatsBean.cpuPercent = processStats.getCpu().getPercent(); processStatsBean.totalInMillis = processStats.getCpu().getTotal().getMillis(); //Open file descriptors processStatsBean.openFileDescriptors = processStats.getOpenFileDescriptors(); //Timestamp processStatsBean.cpuTimestamp = processStats.getTimestamp(); } catch (Exception e) { logger.warn("Failed to load process stats data", e); } processStatsReporter.processStatsBean.set(processStatsBean); }
Example 9
Source File: NodeIndicesStatsMonitor.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; } NodeIndicesStatsBean nodeIndicesStatsBean = new NodeIndicesStatsBean(); 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("Node indices stats is not available (node stats is not available)"); return; } NodeIndicesStats nodeIndicesStats = nodeStats.getIndices(); if (nodeIndicesStats == null) { logger.info("Node indices stats is not available"); return; } updateStoreDocs(nodeIndicesStatsBean, nodeIndicesStats); updateRefreshFlush(nodeIndicesStatsBean, nodeIndicesStats); updateMerge(nodeIndicesStatsBean, nodeIndicesStats); updateCache(nodeIndicesStatsBean, nodeIndicesStats); updateSearch(nodeIndicesStatsBean, nodeIndicesStats); updateGet(nodeIndicesStatsBean, nodeIndicesStats); updateIndexing(nodeIndicesStatsBean, nodeIndicesStats); } catch (Exception e) { logger.warn("Failed to load indices stats data", e); } nodeIndicesStatsReporter.nodeIndicesStatsBean.set(nodeIndicesStatsBean); }
Example 10
Source File: HttpStatsMonitor.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; } HttpStatsBean httpStatsBean = new HttpStatsBean(); 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("HTTP stats is not available (node stats are not available)"); return; } HttpStats httpStats = nodeStats.getHttp(); if (httpStats == null) { logger.info("HTTP stats is not available"); return; } httpStatsBean.serverOpen = httpStats.getServerOpen(); httpStatsBean.totalOpen = httpStats.getTotalOpen(); } catch (Exception e) { logger.warn("Failed to load HTTP stats data", e); } httpStatsReporter.httpStatsBean.set(httpStatsBean); }
Example 11
Source File: AllCircuitBreakerStatsMonitor.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; } AllCircuitBreakerStatsBean allCircuitBreakerStatsBean = new AllCircuitBreakerStatsBean(); 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("Circuit breaker stats is not available (node stats is not available)"); return; } AllCircuitBreakerStats allCircuitBreakerStats = nodeStats.getBreaker(); if (allCircuitBreakerStats == null) { logger.info("Circuit breaker stats is not available"); return; } CircuitBreakerStats[] circuitBreakerStats = allCircuitBreakerStats.getAllStats(); if (circuitBreakerStats == null || circuitBreakerStats.length == 0) { logger.info("Circuit breaker stats is not available (stats are empty)"); return; } for (CircuitBreakerStats circuitBreakerStat : circuitBreakerStats) { if (CircuitBreaker.FIELDDATA.equals(circuitBreakerStat.getName())) { allCircuitBreakerStatsBean.fieldDataEstimatedSizeInBytes = circuitBreakerStat.getEstimated(); allCircuitBreakerStatsBean.fieldDataLimitMaximumSizeInBytes = circuitBreakerStat.getLimit(); allCircuitBreakerStatsBean.fieldDataOverhead = circuitBreakerStat.getOverhead(); allCircuitBreakerStatsBean.fieldDataTrippedCount = circuitBreakerStat.getTrippedCount(); } if (CircuitBreaker.REQUEST.equals(circuitBreakerStat.getName())) { allCircuitBreakerStatsBean.requestEstimatedSizeInBytes = circuitBreakerStat.getEstimated(); allCircuitBreakerStatsBean.requestLimitMaximumSizeInBytes = circuitBreakerStat.getLimit(); allCircuitBreakerStatsBean.requestOverhead = circuitBreakerStat.getOverhead(); allCircuitBreakerStatsBean.requestTrippedCount = circuitBreakerStat.getTrippedCount(); } } } catch (Exception e) { logger.warn("Failed to load circuit breaker stats data", e); } allCircuitBreakerStatsReporter.allCircuitBreakerStatsBean.set(allCircuitBreakerStatsBean); }
Example 12
Source File: TransportStatsMonitor.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; } TransportStatsBean transportStatsBean = new TransportStatsBean(); 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("Transport stats are not available (node stats is not available)"); return; } TransportStats transportStats = nodeStats.getTransport(); if (transportStats == null) { logger.info("Transport stats are not available"); return; } transportStatsBean.serverOpen = transportStats.getServerOpen(); transportStatsBean.rxCount = transportStats.getRxCount(); transportStatsBean.rxSize = transportStats.getRxSize().getBytes(); transportStatsBean.rxSizeDelta = transportStats.getRxSize().getBytes() - transportStatsBean.rxSize; transportStatsBean.txCount = transportStats.getTxCount(); transportStatsBean.txSize = transportStats.getTxSize().getBytes(); transportStatsBean.txSizeDelta = transportStats.getTxSize().getBytes() - transportStatsBean.txSize; } catch (Exception e) { logger.warn("Failed to load transport stats data", e); } transportStatsReporter.transportStatsBean.set(transportStatsBean); }
Example 13
Source File: OsStatsMonitor.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; } OsStatsBean osStatsBean = new OsStatsBean(); 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("OS stats is not available (node stats is not available)"); return; } OsStats osStats = nodeStats.getOs(); if (osStats == null) { logger.info("OS stats is not available"); return; } //Memory osStatsBean.freeInBytes = osStats.getMem().getFree().getBytes(); osStatsBean.usedInBytes = osStats.getMem().getUsed().getBytes(); osStatsBean.actualFreeInBytes = osStats.getMem().getFree().getBytes(); osStatsBean.actualUsedInBytes = osStats.getMem().getUsed().getBytes(); osStatsBean.freePercent = osStats.getMem().getFreePercent(); osStatsBean.usedPercent = osStats.getMem().getUsedPercent(); //CPU osStatsBean.cpuSys = osStats.getCpu().getPercent(); osStatsBean.cpuUser = 0; osStatsBean.cpuIdle = 0; osStatsBean.cpuStolen = 0; //Swap osStatsBean.swapFreeInBytes = osStats.getSwap().getFree().getBytes(); osStatsBean.swapUsedInBytes = osStats.getSwap().getUsed().getBytes(); //Uptime osStatsBean.uptimeInMillis = 0; //Timestamp osStatsBean.osTimestamp = osStats.getTimestamp(); } catch (Exception e) { logger.warn("Failed to load OS stats data", e); } osStatsReporter.osStatsBean.set(osStatsBean); }
Example 14
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 15
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 16
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(); } }; }