org.elasticsearch.action.admin.cluster.node.stats.NodeStats类的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(16.7k)|赞(0)|评价(0)|浏览(127)

本文整理了Java中org.elasticsearch.action.admin.cluster.node.stats.NodeStats类的一些代码示例,展示了NodeStats类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。NodeStats类的具体详情如下:
包路径:org.elasticsearch.action.admin.cluster.node.stats.NodeStats
类名称:NodeStats

NodeStats介绍

[英]Node statistics (dynamic, changes depending on when created).
[中]节点统计信息(动态,根据创建时间而变化)。

代码示例

代码示例来源:origin: org.elasticsearch/elasticsearch

builder.field("name", getNode().getName());
builder.field("transport_address", getNode().getAddress().toString());
builder.field("host", getNode().getHostName());
builder.field("ip", getNode().getAddress());
for (DiscoveryNode.Role role : getNode().getRoles()) {
  builder.value(role.getRoleName());
if (!getNode().getAttributes().isEmpty()) {
  builder.startObject("attributes");
  for (Map.Entry<String, String> attrEntry : getNode().getAttributes().entrySet()) {
    builder.field(attrEntry.getKey(), attrEntry.getValue());
if (getIndices() != null) {
  getIndices().toXContent(builder, params);
if (getOs() != null) {
  getOs().toXContent(builder, params);
if (getProcess() != null) {
  getProcess().toXContent(builder, params);
if (getJvm() != null) {
  getJvm().toXContent(builder, params);
if (getThreadPool() != null) {
  getThreadPool().toXContent(builder, params);
if (getFs() != null) {

代码示例来源:origin: SonarSource/sonarqube

private static NodeInfo toNodeInfo(NodeStats stat) {
 String nodeName = stat.getNode().getName();
 NodeInfo info = new NodeInfo(nodeName);
 info.setHost(stat.getHostname());
 ProtobufSystemInfo.Section.Builder section = ProtobufSystemInfo.Section.newBuilder();
 section.setName("Search State");
 EsStateSection.toProtobuf(stat, section);
 info.addSection(section.build());
 
 return info;
}

代码示例来源:origin: SonarSource/sonarqube

public static void toProtobuf(NodeStats stats, ProtobufSystemInfo.Section.Builder protobuf) {
 setAttribute(protobuf, "CPU Usage (%)", stats.getProcess().getCpu().getPercent());
 setAttribute(protobuf, "Disk Available", byteCountToDisplaySize(stats.getFs().getTotal().getAvailable().getBytes()));
 setAttribute(protobuf, "Store Size", byteCountToDisplaySize(stats.getIndices().getStore().getSizeInBytes()));
 setAttribute(protobuf, "Open File Descriptors", stats.getProcess().getOpenFileDescriptors());
 setAttribute(protobuf, "Max File Descriptors", stats.getProcess().getMaxFileDescriptors());
 setAttribute(protobuf, "Spinning", stats.getFs().getTotal().getSpins());
 setAttribute(protobuf, "JVM Heap Usage", formatPercent(stats.getJvm().getMem().getHeapUsedPercent()));
 setAttribute(protobuf, "JVM Heap Used", byteCountToDisplaySize(stats.getJvm().getMem().getHeapUsed().getBytes()));
 setAttribute(protobuf, "JVM Heap Max", byteCountToDisplaySize(stats.getJvm().getMem().getHeapMax().getBytes()));
 setAttribute(protobuf, "JVM Non Heap Used", byteCountToDisplaySize(stats.getJvm().getMem().getNonHeapUsed().getBytes()));
 setAttribute(protobuf, "JVM Threads", stats.getJvm().getThreads().getCount());
 setAttribute(protobuf, "Field Data Memory", byteCountToDisplaySize(stats.getIndices().getFieldData().getMemorySizeInBytes()));
 setAttribute(protobuf, "Field Data Circuit Breaker Limit", byteCountToDisplaySize(stats.getBreaker().getStats(CircuitBreaker.FIELDDATA).getLimit()));
 setAttribute(protobuf, "Field Data Circuit Breaker Estimation", byteCountToDisplaySize(stats.getBreaker().getStats(CircuitBreaker.FIELDDATA).getEstimated()));
 setAttribute(protobuf, "Request Circuit Breaker Limit", byteCountToDisplaySize(stats.getBreaker().getStats(CircuitBreaker.REQUEST).getLimit()));
 setAttribute(protobuf, "Request Circuit Breaker Estimation", byteCountToDisplaySize(stats.getBreaker().getStats(CircuitBreaker.REQUEST).getEstimated()));
 setAttribute(protobuf, "Query Cache Memory", byteCountToDisplaySize(stats.getIndices().getQueryCache().getMemorySizeInBytes()));
 setAttribute(protobuf, "Request Cache Memory", byteCountToDisplaySize(stats.getIndices().getRequestCache().getMemorySizeInBytes()));
}

代码示例来源:origin: org.elasticsearch/elasticsearch

@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
  builder.startObject("nodes");
  for (NodeStats nodeStats : getNodes()) {
    builder.startObject(nodeStats.getNode().getId());
    builder.field("timestamp", nodeStats.getTimestamp());
    nodeStats.toXContent(builder, params);
    builder.endObject();
  }
  builder.endObject();
  return builder;
}

代码示例来源:origin: org.elasticsearch/elasticsearch

NodeInfo info = nodesInfo.getNodesMap().get(node.getId());
NodeStats stats = nodesStats.getNodesMap().get(node.getId());
JvmInfo jvmInfo = info == null ? null : info.getJvm();
JvmStats jvmStats = stats == null ? null : stats.getJvm();
FsInfo fsInfo = stats == null ? null : stats.getFs();
OsStats osStats = stats == null ? null : stats.getOs();
ProcessStats processStats = stats == null ? null : stats.getProcess();
NodeIndicesStats indicesStats = stats == null ? null : stats.getIndices();
table.addCell(node.getName());
CompletionStats completionStats = indicesStats == null ? null : stats.getIndices().getCompletion();
table.addCell(completionStats == null ? null : completionStats.getSize());
FieldDataStats fdStats = indicesStats == null ? null : stats.getIndices().getFieldData();
table.addCell(fdStats == null ? null : fdStats.getMemorySize());
table.addCell(fdStats == null ? null : fdStats.getEvictions());
table.addCell(refreshStats == null ? null : refreshStats.getListeners());
ScriptStats scriptStats = stats == null ? null : stats.getScriptStats();
table.addCell(scriptStats == null ? null : scriptStats.getCompilations());
table.addCell(scriptStats == null ? null : scriptStats.getCacheEvictions());

代码示例来源:origin: org.elasticsearch/elasticsearch

private Table buildTable(final RestRequest request, final NodesStatsResponse nodeStatses) {
    Table table = getTableWithHeader(request);

    for (NodeStats nodeStats: nodeStatses.getNodes()) {
      if (nodeStats.getIndices().getFieldData().getFields() != null) {
        for (ObjectLongCursor<String> cursor : nodeStats.getIndices().getFieldData().getFields()) {
          table.startRow();
          table.addCell(nodeStats.getNode().getId());
          table.addCell(nodeStats.getNode().getHostName());
          table.addCell(nodeStats.getNode().getHostAddress());
          table.addCell(nodeStats.getNode().getName());
          table.addCell(cursor.key);
          table.addCell(new ByteSizeValue(cursor.value));
          table.endRow();
        }
      }
    }

    return table;
  }
}

代码示例来源:origin: harbby/presto-connectors

@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
  if (!params.param("node_info_format", "default").equals("none")) {
    builder.field("name", getNode().name(), XContentBuilder.FieldCaseConversion.NONE);
    builder.field("transport_address", getNode().address().toString(), XContentBuilder.FieldCaseConversion.NONE);
    builder.field("host", getNode().getHostName(), XContentBuilder.FieldCaseConversion.NONE);
    builder.field("ip", getNode().getAddress(), XContentBuilder.FieldCaseConversion.NONE);
    if (!getNode().attributes().isEmpty()) {
      builder.startObject("attributes");
      for (Map.Entry<String, String> attr : getNode().attributes().entrySet()) {
        builder.field(attr.getKey(), attr.getValue(), XContentBuilder.FieldCaseConversion.NONE);
  if (getIndices() != null) {
    getIndices().toXContent(builder, params);
  if (getOs() != null) {
    getOs().toXContent(builder, params);
  if (getProcess() != null) {
    getProcess().toXContent(builder, params);
  if (getJvm() != null) {
    getJvm().toXContent(builder, params);
  if (getThreadPool() != null) {
    getThreadPool().toXContent(builder, params);
  if (getFs() != null) {
    getFs().toXContent(builder, params);

代码示例来源:origin: org.elasticsearch/elasticsearch

for (final ThreadPoolStats.Stats threadPoolStats : nodeStats.getThreadPool()) {
  candidates.add(threadPoolStats.getName());
final NodeInfo info = nodesInfo.getNodesMap().get(node.getId());
final NodeStats stats = nodesStats.getNodesMap().get(node.getId());
  poolThreadInfo = new HashMap<>();
  ThreadPoolStats threadPoolStats = stats.getThreadPool();
  for (ThreadPoolStats.Stats threadPoolStat : threadPoolStats) {
    poolThreadStats.put(threadPoolStat.getName(), threadPoolStat);
    for (ThreadPool.Info threadPoolInfo : info.getThreadPool()) {
      poolThreadInfo.put(threadPoolInfo.getName(), threadPoolInfo);
  table.addCell(node.getName());
  table.addCell(node.getId());
  table.addCell(node.getEphemeralId());
  table.addCell(info == null ? null : info.getProcess().getId());
  table.addCell(node.getHostName());
  table.addCell(node.getHostAddress());

代码示例来源:origin: harbby/presto-connectors

NodeInfo info = nodesInfo.getNodesMap().get(node.id());
NodeStats stats = nodesStats.getNodesMap().get(node.id());
JvmInfo jvmInfo = info == null ? null : info.getJvm();
JvmStats jvmStats = stats == null ? null : stats.getJvm();
FsInfo fsInfo = stats == null ? null : stats.getFs();
OsStats osStats = stats == null ? null : stats.getOs();
ProcessStats processStats = stats == null ? null : stats.getProcess();
NodeIndicesStats indicesStats = stats == null ? null : stats.getIndices();
table.addCell(node.name());
CompletionStats completionStats = indicesStats == null ? null : stats.getIndices().getCompletion();
table.addCell(completionStats == null ? null : completionStats.getSize());
FieldDataStats fdStats = indicesStats == null ? null : stats.getIndices().getFieldData();
table.addCell(fdStats == null ? null : fdStats.getMemorySize());
table.addCell(fdStats == null ? null : fdStats.getEvictions());
table.addCell(refreshStats == null ? null : refreshStats.getTotalTime());
ScriptStats scriptStats = stats == null ? null : stats.getScriptStats();
table.addCell(scriptStats == null ? null : scriptStats.getCompilations());
table.addCell(scriptStats == null ? null : scriptStats.getCacheEvictions());

代码示例来源:origin: org.elasticsearch/elasticsearch

ImmutableOpenMap.Builder<String, DiskUsage> newMostAvaiableUsages) {
for (NodeStats nodeStats : nodeStatsArray) {
  if (nodeStats.getFs() == null) {
    logger.warn("Unable to retrieve node FS stats for {}", nodeStats.getNode().getName());
  } else {
    FsInfo.Path leastAvailablePath = null;
    FsInfo.Path mostAvailablePath = null;
    for (FsInfo.Path info : nodeStats.getFs()) {
      if (leastAvailablePath == null) {
        assert mostAvailablePath == null;
    String nodeId = nodeStats.getNode().getId();
    String nodeName = nodeStats.getNode().getName();
    if (logger.isTraceEnabled()) {
      logger.trace("node: [{}], most available: total disk: {}," +

代码示例来源:origin: spinscale/elasticsearch-graphite-plugin

private void sendNodeStats() {
  sendNodeFsStats(nodeStats.getFs());
  sendNodeHttpStats(nodeStats.getHttp());
  sendNodeJvmStats(nodeStats.getJvm());
  sendNodeNetworkStats(nodeStats.getNetwork());
  sendNodeOsStats(nodeStats.getOs());
  sendNodeProcessStats(nodeStats.getProcess());
  sendNodeTransportStats(nodeStats.getTransport());
  sendNodeThreadPoolStats(nodeStats.getThreadPool());
}

代码示例来源:origin: org.elasticsearch/elasticsearch

ClusterStatsNodes(List<ClusterStatsNodeResponse> nodeResponses) {
  this.versions = new HashSet<>();
  this.fs = new FsInfo.Path();
  this.plugins = new HashSet<>();
  Set<InetAddress> seenAddresses = new HashSet<>(nodeResponses.size());
  List<NodeInfo> nodeInfos = new ArrayList<>(nodeResponses.size());
  List<NodeStats> nodeStats = new ArrayList<>(nodeResponses.size());
  for (ClusterStatsNodeResponse nodeResponse : nodeResponses) {
    nodeInfos.add(nodeResponse.nodeInfo());
    nodeStats.add(nodeResponse.nodeStats());
    this.versions.add(nodeResponse.nodeInfo().getVersion());
    this.plugins.addAll(nodeResponse.nodeInfo().getPlugins().getPluginInfos());
    // now do the stats that should be deduped by hardware (implemented by ip deduping)
    TransportAddress publishAddress =
        nodeResponse.nodeInfo().getTransport().address().publishAddress();
    final InetAddress inetAddress = publishAddress.address().getAddress();
    if (!seenAddresses.add(inetAddress)) {
      continue;
    }
    if (nodeResponse.nodeStats().getFs() != null) {
      this.fs.add(nodeResponse.nodeStats().getFs().getTotal());
    }
  }
  this.counts = new Counts(nodeInfos);
  this.os = new OsStats(nodeInfos, nodeStats);
  this.process = new ProcessStats(nodeStats);
  this.jvm = new JvmStats(nodeInfos, nodeStats);
  this.networkTypes = new NetworkTypes(nodeInfos);
}

代码示例来源:origin: harbby/presto-connectors

ObjectLongHashMap<String> fields = ns.getIndices().getFieldData().getFields();
nodesFields.put(ns, fields);
if (fields != null) {
table.addCell(ns.getNode().id());
table.addCell(ns.getNode().getHostName());
table.addCell(ns.getNode().getHostAddress());
table.addCell(ns.getNode().getName());
table.addCell(ns.getIndices().getFieldData().getMemorySize());
ObjectLongMap<String> fields = statsEntry.getValue();
for (String fieldName : fieldNames) {

代码示例来源:origin: harbby/presto-connectors

NodeInfo info = nodesInfo.getNodesMap().get(node.id());
NodeStats stats = nodesStats.getNodesMap().get(node.id());
table.startRow();
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());
  poolThreadInfo = new HashMap<>(14);
  ThreadPoolStats threadPoolStats = stats.getThreadPool();
  for (ThreadPoolStats.Stats threadPoolStat : threadPoolStats) {
    poolThreadStats.put(threadPoolStat.getName(), threadPoolStat);
    for (ThreadPool.Info threadPoolInfo : info.getThreadPool()) {
      poolThreadInfo.put(threadPoolInfo.getName(), threadPoolInfo);

代码示例来源:origin: harbby/presto-connectors

DiscoveryNode node = nodeStats.getNode();
int shardCount = allocs.getOrDefault(node.id(), 0);
ByteSizeValue total = nodeStats.getFs().getTotal().getTotal();
ByteSizeValue avail = nodeStats.getFs().getTotal().getAvailable();
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();

代码示例来源:origin: harbby/presto-connectors

static void fillDiskUsagePerNode(ESLogger logger, NodeStats[] nodeStatsArray, Map<String, DiskUsage> newLeastAvaiableUsages, Map<String, DiskUsage> newMostAvaiableUsages) {
  for (NodeStats nodeStats : nodeStatsArray) {
    if (nodeStats.getFs() == null) {
      logger.warn("Unable to retrieve node FS stats for {}", nodeStats.getNode().name());
    } else {
      FsInfo.Path leastAvailablePath = null;
      FsInfo.Path mostAvailablePath = null;
      for (FsInfo.Path info : nodeStats.getFs()) {
        if (leastAvailablePath == null) {
          assert mostAvailablePath == null;
      String nodeId = nodeStats.getNode().id();
      String nodeName = nodeStats.getNode().getName();
      if (logger.isTraceEnabled()) {
        logger.trace("node: [{}], most available: total disk: {}, available disk: {} / least available: total disk: {}, available disk: {}",

代码示例来源:origin: com.scireum/sirius-search

private Map<String, String> getNodesStats(NodesStatsResponse nodesStatsResponse) {
  Map<String, String> nodeStatsMap = new HashMap<>();
  for (NodeStats stat : nodesStatsResponse.getNodes()) {
    try (XContentBuilder nodesStatsBuilder = XContentFactory.jsonBuilder()) {
      nodesStatsBuilder.humanReadable(true).prettyPrint().startObject();
      stat.toXContent(nodesStatsBuilder, ToXContent.EMPTY_PARAMS);
      nodesStatsBuilder.endObject();
      nodeStatsMap.put(stat.getNode().getName(), nodesStatsBuilder.string());
    } catch (IOException e) {
      Exceptions.handle(e);
    }
  }
  return nodeStatsMap;
}

代码示例来源:origin: sirensolutions/siren-join

public void memStatus() throws IOException {
 NodeStats[] nodeStats = client.admin().cluster().prepareNodesStats()
  .setJvm(true).setIndices(true).setTransport(true)
  .execute().actionGet().getNodes();
 log("==== MEMORY ====");
 log("Committed heap size: [0]=" + nodeStats[0].getJvm().getMem().getHeapCommitted() + ", [1]=" + nodeStats[1].getJvm().getMem().getHeapCommitted());
 log("Used heap size: [0]=" + nodeStats[0].getJvm().getMem().getHeapUsed() + ", [1]=" + nodeStats[1].getJvm().getMem().getHeapUsed());
 log("FieldData cache size: [0]=" + nodeStats[0].getIndices().getFieldData().getMemorySize() + ", [1]=" + nodeStats[1].getIndices().getFieldData().getMemorySize());
 log("Query cache size: [0]=" + nodeStats[0].getIndices().getQueryCache().getMemorySize() + ", [1]=" + nodeStats[1].getIndices().getQueryCache().getMemorySize());
 log("");
 log("==== NETWORK ====");
 log("Transport: [0]=" + nodeStats[0].getTransport().toXContent(jsonBuilder(), ToXContent.EMPTY_PARAMS).string() + ", [1]=" + nodeStats[1].getTransport().toXContent(jsonBuilder(), ToXContent.EMPTY_PARAMS).string());
 log("");
}

代码示例来源:origin: org.elasticsearch/elasticsearch

long heapUsed = 0;
for (NodeInfo nodeInfo : nodeInfos) {
  versions.addTo(new JvmVersion(nodeInfo.getJvm()), 1);
  org.elasticsearch.monitor.jvm.JvmStats js = nodeStats.getJvm();
  if (js == null) {
    continue;

代码示例来源:origin: harbby/presto-connectors

@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
  builder.field("cluster_name", getClusterName().value());
  builder.startObject("nodes");
  for (NodeStats nodeStats : this) {
    builder.startObject(nodeStats.getNode().id(), XContentBuilder.FieldCaseConversion.NONE);
    builder.field("timestamp", nodeStats.getTimestamp());
    nodeStats.toXContent(builder, params);
    builder.endObject();
  }
  builder.endObject();
  return builder;
}

相关文章