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())); }
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(FIELDDATA); builder.humanReadableField(MEMORY_SIZE_IN_BYTES, MEMORY_SIZE, getMemorySize()); builder.field(EVICTIONS, getEvictions()); if (fields != null) { fields.toXContent(builder, FIELDS, MEMORY_SIZE_IN_BYTES, MEMORY_SIZE); } builder.endObject(); return builder; }
this.fieldData = new FieldDataStats(); this.queryCache = new QueryCacheStats(); this.completion = new CompletionStats(); fieldData.add(shardCommonStats.fieldData); queryCache.add(shardCommonStats.queryCache); completion.add(shardCommonStats.completion);
public static FieldDataStats readFieldDataStats(StreamInput in) throws IOException { FieldDataStats stats = new FieldDataStats(); stats.readFrom(in); return stats; }
private void sendFieldDataStats(String name, FieldDataStats fieldDataStats) { sendInt(name, "memorySizeInBytes", fieldDataStats.getMemorySizeInBytes()); sendInt(name, "evictions", fieldDataStats.getEvictions()); }
public FieldDataStats stats(String... fields) { ObjectLongHashMap<String> fieldTotals = null; if (fields != null && fields.length > 0) { fieldTotals = new ObjectLongHashMap<>(); for (Map.Entry<String, CounterMetric> entry : perFieldTotals.entrySet()) { if (Regex.simpleMatch(fields, entry.getKey())) { fieldTotals.put(entry.getKey(), entry.getValue().count()); } } } return new FieldDataStats(totalMetric.count(), evictionsMetric.count(), fieldTotals == null ? null : new FieldMemoryStats(fieldTotals)); }
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.field(Fields.COUNT, indexCount); shards.toXContent(builder, params); docs.toXContent(builder, params); store.toXContent(builder, params); fieldData.toXContent(builder, params); queryCache.toXContent(builder, params); completion.toXContent(builder, params); segments.toXContent(builder, params); return builder; }
ObjectLongHashMap<String> fields = ns.getIndices().getFieldData().getFields(); nodesFields.put(ns, fields); if (fields != null) { 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) {
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(FIELDDATA); builder.byteSizeField(MEMORY_SIZE_IN_BYTES, MEMORY_SIZE, memorySize); builder.field(EVICTIONS, getEvictions()); if (fields != null) { fields.toXContent(builder, FIELDS, MEMORY_SIZE_IN_BYTES, MEMORY_SIZE); } builder.endObject(); return builder; }
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; } }
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(""); }
private void updateCache(NodeIndicesStatsBean nodeIndicesStatsBean, NodeIndicesStats nodeIndicesStats) { nodeIndicesStatsBean.cacheFieldEvictions = nodeIndicesStats.getFieldData().getEvictions(); nodeIndicesStatsBean.cacheFieldSize = nodeIndicesStats.getFieldData().getMemorySizeInBytes(); nodeIndicesStatsBean.cacheFilterEvictions = nodeIndicesStats.getFilterCache().getEvictions(); nodeIndicesStatsBean.cacheFilterSize = nodeIndicesStats.getFilterCache().getMemorySizeInBytes(); }
break; case FieldData: fieldData = new FieldDataStats(); break; case Completion:
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.field(Fields.COUNT, indexCount); shards.toXContent(builder, params); docs.toXContent(builder, params); store.toXContent(builder, params); fieldData.toXContent(builder, params); queryCache.toXContent(builder, params); completion.toXContent(builder, params); segments.toXContent(builder, params); return builder; }
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(Fields.FIELDDATA); builder.byteSizeField(Fields.MEMORY_SIZE_IN_BYTES, Fields.MEMORY_SIZE, memorySize); builder.field(Fields.EVICTIONS, getEvictions()); if (fields != null) { builder.startObject(Fields.FIELDS); assert !fields.containsKey(null); final Object[] keys = fields.keys; final long[] values = fields.values; for (int i = 0; i < keys.length; i++) { if (keys[i] != null) { builder.startObject((String) keys[i], XContentBuilder.FieldCaseConversion.NONE); builder.byteSizeField(Fields.MEMORY_SIZE_IN_BYTES, Fields.MEMORY_SIZE, values[i]); builder.endObject(); } } builder.endObject(); } builder.endObject(); return builder; }
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; } }
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(""); }
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(FIELDDATA); builder.humanReadableField(MEMORY_SIZE_IN_BYTES, MEMORY_SIZE, getMemorySize()); builder.field(EVICTIONS, getEvictions()); if (fields != null) { fields.toXContent(builder, FIELDS, MEMORY_SIZE_IN_BYTES, MEMORY_SIZE); } builder.endObject(); return builder; }
/** * Utility method which computes total memory by adding * FieldData, PercolatorCache, Segments (memory, index writer, version map) */ public ByteSizeValue getTotalMemory() { long size = 0; if (this.getFieldData() != null) { size += this.getFieldData().getMemorySizeInBytes(); } if (this.getQueryCache() != null) { size += this.getQueryCache().getMemorySizeInBytes(); } if (this.getSegments() != null) { size += this.getSegments().getMemoryInBytes() + this.getSegments().getIndexWriterMemoryInBytes() + this.getSegments().getVersionMapMemoryInBytes(); } return new ByteSizeValue(size); }
fieldData = new FieldDataStats(); fieldData.add(stats.getFieldData()); fieldData.add(stats.getFieldData());