Java Code Examples for org.elasticsearch.common.xcontent.XContentBuilder#byteSizeField()
The following examples show how to use
org.elasticsearch.common.xcontent.XContentBuilder#byteSizeField() .
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: ClusterStatsNodes.java From Elasticsearch with Apache License 2.0 | 6 votes |
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.timeValueField(Fields.MAX_UPTIME_IN_MILLIS, Fields.MAX_UPTIME, maxUptime); builder.startArray(Fields.VERSIONS); for (ObjectIntCursor<JvmVersion> v : versions) { builder.startObject(); builder.field(Fields.VERSION, v.key.version); builder.field(Fields.VM_NAME, v.key.vmName); builder.field(Fields.VM_VERSION, v.key.vmVersion); builder.field(Fields.VM_VENDOR, v.key.vmVendor); builder.field(Fields.COUNT, v.value); builder.endObject(); } builder.endArray(); builder.startObject(Fields.MEM); builder.byteSizeField(Fields.HEAP_USED_IN_BYTES, Fields.HEAP_USED, heapUsed); builder.byteSizeField(Fields.HEAP_MAX_IN_BYTES, Fields.HEAP_MAX, heapMax); builder.endObject(); builder.field(Fields.THREADS, threads); return builder; }
Example 2
Source File: ClusterStatsNodes.java From Elasticsearch with Apache License 2.0 | 6 votes |
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.field(Fields.AVAILABLE_PROCESSORS, availableProcessors); builder.field(Fields.ALLOCATED_PROCESSORS, allocatedProcessors); builder.startObject(Fields.MEM); builder.byteSizeField(Fields.TOTAL_IN_BYTES, Fields.TOTAL, availableMemory); builder.endObject(); builder.startArray(Fields.NAMES); for (ObjectIntCursor<String> name : names) { builder.startObject(); builder.field(Fields.NAME, name.key); builder.field(Fields.COUNT, name.value); builder.endObject(); } builder.endArray(); return builder; }
Example 3
Source File: SegmentsStats.java From Elasticsearch with Apache License 2.0 | 6 votes |
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(Fields.SEGMENTS); builder.field(Fields.COUNT, count); builder.byteSizeField(Fields.MEMORY_IN_BYTES, Fields.MEMORY, memoryInBytes); builder.byteSizeField(Fields.TERMS_MEMORY_IN_BYTES, Fields.TERMS_MEMORY, termsMemoryInBytes); builder.byteSizeField(Fields.STORED_FIELDS_MEMORY_IN_BYTES, Fields.STORED_FIELDS_MEMORY, storedFieldsMemoryInBytes); builder.byteSizeField(Fields.TERM_VECTORS_MEMORY_IN_BYTES, Fields.TERM_VECTORS_MEMORY, termVectorsMemoryInBytes); builder.byteSizeField(Fields.NORMS_MEMORY_IN_BYTES, Fields.NORMS_MEMORY, normsMemoryInBytes); builder.byteSizeField(Fields.DOC_VALUES_MEMORY_IN_BYTES, Fields.DOC_VALUES_MEMORY, docValuesMemoryInBytes); builder.byteSizeField(Fields.INDEX_WRITER_MEMORY_IN_BYTES, Fields.INDEX_WRITER_MEMORY, indexWriterMemoryInBytes); builder.byteSizeField(Fields.INDEX_WRITER_MAX_MEMORY_IN_BYTES, Fields.INDEX_WRITER_MAX_MEMORY, indexWriterMaxMemoryInBytes); builder.byteSizeField(Fields.VERSION_MAP_MEMORY_IN_BYTES, Fields.VERSION_MAP_MEMORY, versionMapMemoryInBytes); builder.byteSizeField(Fields.FIXED_BIT_SET_MEMORY_IN_BYTES, Fields.FIXED_BIT_SET, bitsetMemoryInBytes); builder.endObject(); return builder; }
Example 4
Source File: MergeStats.java From Elasticsearch with Apache License 2.0 | 6 votes |
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(Fields.MERGES); builder.field(Fields.CURRENT, current); builder.field(Fields.CURRENT_DOCS, currentNumDocs); builder.byteSizeField(Fields.CURRENT_SIZE_IN_BYTES, Fields.CURRENT_SIZE, currentSizeInBytes); builder.field(Fields.TOTAL, total); builder.timeValueField(Fields.TOTAL_TIME_IN_MILLIS, Fields.TOTAL_TIME, totalTimeInMillis); builder.field(Fields.TOTAL_DOCS, totalNumDocs); builder.byteSizeField(Fields.TOTAL_SIZE_IN_BYTES, Fields.TOTAL_SIZE, totalSizeInBytes); builder.timeValueField(Fields.TOTAL_STOPPED_TIME_IN_MILLIS, Fields.TOTAL_STOPPED_TIME, totalStoppedTimeInMillis); builder.timeValueField(Fields.TOTAL_THROTTLED_TIME_IN_MILLIS, Fields.TOTAL_THROTTLED_TIME, totalThrottledTimeInMillis); builder.byteSizeField(Fields.TOTAL_THROTTLE_BYTES_PER_SEC_IN_BYTES, Fields.TOTAL_THROTTLE_BYTES_PER_SEC, totalBytesPerSecAutoThrottle); builder.endObject(); return builder; }
Example 5
Source File: ProcessStats.java From Elasticsearch with Apache License 2.0 | 6 votes |
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(Fields.PROCESS); builder.field(Fields.TIMESTAMP, timestamp); builder.field(Fields.OPEN_FILE_DESCRIPTORS, openFileDescriptors); builder.field(Fields.MAX_FILE_DESCRIPTORS, maxFileDescriptors); if (cpu != null) { builder.startObject(Fields.CPU); builder.field(Fields.PERCENT, cpu.percent); builder.timeValueField(Fields.TOTAL_IN_MILLIS, Fields.TOTAL, cpu.total); builder.endObject(); } if (mem != null) { builder.startObject(Fields.MEM); builder.byteSizeField(Fields.TOTAL_VIRTUAL_IN_BYTES, Fields.TOTAL_VIRTUAL, mem.totalVirtual); builder.endObject(); } builder.endObject(); return builder; }
Example 6
Source File: SnapshotStats.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException { builder.startObject(Fields.STATS); builder.field(Fields.NUMBER_OF_FILES, getNumberOfFiles()); builder.field(Fields.PROCESSED_FILES, getProcessedFiles()); builder.byteSizeField(Fields.TOTAL_SIZE_IN_BYTES, Fields.TOTAL_SIZE, getTotalSize()); builder.byteSizeField(Fields.PROCESSED_SIZE_IN_BYTES, Fields.PROCESSED_SIZE, getProcessedSize()); builder.field(Fields.START_TIME_IN_MILLIS, getStartTime()); builder.timeValueField(Fields.TIME_IN_MILLIS, Fields.TIME, getTime()); builder.endObject(); return builder; }
Example 7
Source File: IndicesSegmentResponse.java From Elasticsearch with Apache License 2.0 | 5 votes |
static void toXContent(XContentBuilder builder, Accountable tree) throws IOException { builder.startObject(); builder.field(Fields.DESCRIPTION, tree.toString()); builder.byteSizeField(Fields.SIZE_IN_BYTES, Fields.SIZE, new ByteSizeValue(tree.ramBytesUsed())); Collection<Accountable> children = tree.getChildResources(); if (children.isEmpty() == false) { builder.startArray(Fields.CHILDREN); for (Accountable child : children) { toXContent(builder, child); } builder.endArray(); } builder.endObject(); }
Example 8
Source File: FsInfo.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(); if (path != null) { builder.field(Fields.PATH, path, XContentBuilder.FieldCaseConversion.NONE); } if (mount != null) { builder.field(Fields.MOUNT, mount, XContentBuilder.FieldCaseConversion.NONE); } if (type != null) { builder.field(Fields.TYPE, type, XContentBuilder.FieldCaseConversion.NONE); } if (total != -1) { builder.byteSizeField(Fields.TOTAL_IN_BYTES, Fields.TOTAL, total); } if (free != -1) { builder.byteSizeField(Fields.FREE_IN_BYTES, Fields.FREE, free); } if (available != -1) { builder.byteSizeField(Fields.AVAILABLE_IN_BYTES, Fields.AVAILABLE, available); } if (spins != null) { builder.field(Fields.SPINS, spins.toString()); } builder.endObject(); return builder; }
Example 9
Source File: OsStats.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(Fields.OS); builder.field(Fields.TIMESTAMP, getTimestamp()); if (getCpuPercent() != null) { builder.field(Fields.PERCENT, getCpuPercent()); } builder.field(Fields.LOAD_AVERAGE, getLoadAverage()); if (mem != null) { builder.startObject(Fields.MEM); builder.byteSizeField(Fields.TOTAL_IN_BYTES, Fields.TOTAL, mem.getTotal()); builder.byteSizeField(Fields.FREE_IN_BYTES, Fields.FREE, mem.getFree()); builder.byteSizeField(Fields.USED_IN_BYTES, Fields.USED, mem.getUsed()); builder.field(Fields.FREE_PERCENT, mem.getFreePercent()); builder.field(Fields.USED_PERCENT, mem.getUsedPercent()); builder.endObject(); } if (swap != null) { builder.startObject(Fields.SWAP); builder.byteSizeField(Fields.TOTAL_IN_BYTES, Fields.TOTAL, swap.getTotal()); builder.byteSizeField(Fields.FREE_IN_BYTES, Fields.FREE, swap.getFree()); builder.byteSizeField(Fields.USED_IN_BYTES, Fields.USED, swap.getUsed()); builder.endObject(); } builder.endObject(); return builder; }
Example 10
Source File: JvmInfo.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(Fields.JVM); builder.field(Fields.PID, pid); builder.field(Fields.VERSION, version); builder.field(Fields.VM_NAME, vmName); builder.field(Fields.VM_VERSION, vmVersion); builder.field(Fields.VM_VENDOR, vmVendor); builder.dateValueField(Fields.START_TIME_IN_MILLIS, Fields.START_TIME, startTime); builder.startObject(Fields.MEM); builder.byteSizeField(Fields.HEAP_INIT_IN_BYTES, Fields.HEAP_INIT, mem.heapInit); builder.byteSizeField(Fields.HEAP_MAX_IN_BYTES, Fields.HEAP_MAX, mem.heapMax); builder.byteSizeField(Fields.NON_HEAP_INIT_IN_BYTES, Fields.NON_HEAP_INIT, mem.nonHeapInit); builder.byteSizeField(Fields.NON_HEAP_MAX_IN_BYTES, Fields.NON_HEAP_MAX, mem.nonHeapMax); builder.byteSizeField(Fields.DIRECT_MAX_IN_BYTES, Fields.DIRECT_MAX, mem.directMemoryMax); builder.endObject(); builder.field(Fields.GC_COLLECTORS, gcCollectors); builder.field(Fields.MEMORY_POOLS, memoryPools); if (useCompressedOops != null) { builder.field(Fields.USING_COMPRESSED_OOPS, useCompressedOops); } builder.endObject(); return builder; }
Example 11
Source File: TransportStats.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(Fields.TRANSPORT); builder.field(Fields.SERVER_OPEN, serverOpen); builder.field(Fields.RX_COUNT, rxCount); builder.byteSizeField(Fields.RX_SIZE_IN_BYTES, Fields.RX_SIZE, rxSize); builder.field(Fields.TX_COUNT, txCount); builder.byteSizeField(Fields.TX_SIZE_IN_BYTES, Fields.TX_SIZE, txSize); builder.endObject(); return builder; }
Example 12
Source File: StoreStats.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(Fields.STORE); builder.byteSizeField(Fields.SIZE_IN_BYTES, Fields.SIZE, sizeInBytes); builder.timeValueField(Fields.THROTTLE_TIME_IN_MILLIS, Fields.THROTTLE_TIME, throttleTime()); builder.endObject(); return builder; }
Example 13
Source File: TranslogStats.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(Fields.TRANSLOG); builder.field(Fields.OPERATIONS, numberOfOperations); builder.byteSizeField(Fields.SIZE_IN_BYTES, Fields.SIZE, translogSizeInBytes); builder.endObject(); return builder; }
Example 14
Source File: QueryCacheStats.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException { builder.startObject(Fields.QUERY_CACHE); builder.byteSizeField(Fields.MEMORY_SIZE_IN_BYTES, Fields.MEMORY_SIZE, ramBytesUsed); builder.field(Fields.TOTAL_COUNT, getTotalCount()); builder.field(Fields.HIT_COUNT, getHitCount()); builder.field(Fields.MISS_COUNT, getMissCount()); builder.field(Fields.CACHE_SIZE, getCacheSize()); builder.field(Fields.CACHE_COUNT, getCacheCount()); builder.field(Fields.EVICTIONS, getEvictions()); builder.endObject(); return builder; }
Example 15
Source File: RequestCacheStats.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(Fields.REQUEST_CACHE_STATS); builder.byteSizeField(Fields.MEMORY_SIZE_IN_BYTES, Fields.MEMORY_SIZE, memorySize); builder.field(Fields.EVICTIONS, getEvictions()); builder.field(Fields.HIT_COUNT, getHitCount()); builder.field(Fields.MISS_COUNT, getMissCount()); builder.endObject(); return builder; }
Example 16
Source File: HttpInfo.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(Fields.HTTP); builder.array(Fields.BOUND_ADDRESS, (Object[]) address.boundAddresses()); builder.field(Fields.PUBLISH_ADDRESS, address.publishAddress().toString()); builder.byteSizeField(Fields.MAX_CONTENT_LENGTH_IN_BYTES, Fields.MAX_CONTENT_LENGTH, maxContentLength); builder.endObject(); return builder; }
Example 17
Source File: JvmStats.java From Elasticsearch with Apache License 2.0 | 4 votes |
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(Fields.JVM); builder.field(Fields.TIMESTAMP, timestamp); builder.timeValueField(Fields.UPTIME_IN_MILLIS, Fields.UPTIME, uptime); if (mem != null) { builder.startObject(Fields.MEM); builder.byteSizeField(Fields.HEAP_USED_IN_BYTES, Fields.HEAP_USED, mem.heapUsed); if (mem.getHeapUsedPercent() >= 0) { builder.field(Fields.HEAP_USED_PERCENT, mem.getHeapUsedPercent()); } builder.byteSizeField(Fields.HEAP_COMMITTED_IN_BYTES, Fields.HEAP_COMMITTED, mem.heapCommitted); builder.byteSizeField(Fields.HEAP_MAX_IN_BYTES, Fields.HEAP_MAX, mem.heapMax); builder.byteSizeField(Fields.NON_HEAP_USED_IN_BYTES, Fields.NON_HEAP_USED, mem.nonHeapUsed); builder.byteSizeField(Fields.NON_HEAP_COMMITTED_IN_BYTES, Fields.NON_HEAP_COMMITTED, mem.nonHeapCommitted); builder.startObject(Fields.POOLS); for (MemoryPool pool : mem) { builder.startObject(pool.getName(), XContentBuilder.FieldCaseConversion.NONE); builder.byteSizeField(Fields.USED_IN_BYTES, Fields.USED, pool.used); builder.byteSizeField(Fields.MAX_IN_BYTES, Fields.MAX, pool.max); builder.byteSizeField(Fields.PEAK_USED_IN_BYTES, Fields.PEAK_USED, pool.peakUsed); builder.byteSizeField(Fields.PEAK_MAX_IN_BYTES, Fields.PEAK_MAX, pool.peakMax); builder.endObject(); } builder.endObject(); builder.endObject(); } if (threads != null) { builder.startObject(Fields.THREADS); builder.field(Fields.COUNT, threads.getCount()); builder.field(Fields.PEAK_COUNT, threads.getPeakCount()); builder.endObject(); } if (gc != null) { builder.startObject(Fields.GC); builder.startObject(Fields.COLLECTORS); for (GarbageCollector collector : gc) { builder.startObject(collector.getName(), XContentBuilder.FieldCaseConversion.NONE); builder.field(Fields.COLLECTION_COUNT, collector.getCollectionCount()); builder.timeValueField(Fields.COLLECTION_TIME_IN_MILLIS, Fields.COLLECTION_TIME, collector.collectionTime); builder.endObject(); } builder.endObject(); builder.endObject(); } if (bufferPools != null) { builder.startObject(Fields.BUFFER_POOLS); for (BufferPool bufferPool : bufferPools) { builder.startObject(bufferPool.getName(), XContentBuilder.FieldCaseConversion.NONE); builder.field(Fields.COUNT, bufferPool.getCount()); builder.byteSizeField(Fields.USED_IN_BYTES, Fields.USED, bufferPool.used); builder.byteSizeField(Fields.TOTAL_CAPACITY_IN_BYTES, Fields.TOTAL_CAPACITY, bufferPool.totalCapacity); builder.endObject(); } builder.endObject(); } if (classes != null) { builder.startObject(Fields.CLASSES); builder.field(Fields.CURRENT_LOADED_COUNT, classes.getLoadedClassCount()); builder.field(Fields.TOTAL_LOADED_COUNT, classes.getTotalLoadedClassCount()); builder.field(Fields.TOTAL_UNLOADED_COUNT, classes.getUnloadedClassCount()); builder.endObject(); } builder.endObject(); return builder; }
Example 18
Source File: UpgradeStatusResponse.java From Elasticsearch with Apache License 2.0 | 4 votes |
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.byteSizeField(Fields.SIZE_IN_BYTES, Fields.SIZE, getTotalBytes()); builder.byteSizeField(Fields.SIZE_TO_UPGRADE_IN_BYTES, Fields.SIZE_TO_UPGRADE, getToUpgradeBytes()); builder.byteSizeField(Fields.SIZE_TO_UPGRADE_ANCIENT_IN_BYTES, Fields.SIZE_TO_UPGRADE_ANCIENT, getToUpgradeBytesAncient()); String level = params.param("level", "indices"); boolean outputShards = "shards".equals(level); boolean outputIndices = "indices".equals(level) || outputShards; if (outputIndices) { builder.startObject(Fields.INDICES); for (IndexUpgradeStatus indexUpgradeStatus : getIndices().values()) { builder.startObject(indexUpgradeStatus.getIndex(), XContentBuilder.FieldCaseConversion.NONE); builder.byteSizeField(Fields.SIZE_IN_BYTES, Fields.SIZE, indexUpgradeStatus.getTotalBytes()); builder.byteSizeField(Fields.SIZE_TO_UPGRADE_IN_BYTES, Fields.SIZE_TO_UPGRADE, indexUpgradeStatus.getToUpgradeBytes()); builder.byteSizeField(Fields.SIZE_TO_UPGRADE_ANCIENT_IN_BYTES, Fields.SIZE_TO_UPGRADE_ANCIENT, indexUpgradeStatus.getToUpgradeBytesAncient()); if (outputShards) { builder.startObject(Fields.SHARDS); for (IndexShardUpgradeStatus indexShardUpgradeStatus : indexUpgradeStatus) { builder.startArray(Integer.toString(indexShardUpgradeStatus.getShardId().id())); for (ShardUpgradeStatus shardUpgradeStatus : indexShardUpgradeStatus) { builder.startObject(); builder.byteSizeField(Fields.SIZE_IN_BYTES, Fields.SIZE, getTotalBytes()); builder.byteSizeField(Fields.SIZE_TO_UPGRADE_IN_BYTES, Fields.SIZE_TO_UPGRADE, getToUpgradeBytes()); builder.byteSizeField(Fields.SIZE_TO_UPGRADE_ANCIENT_IN_BYTES, Fields.SIZE_TO_UPGRADE_ANCIENT, getToUpgradeBytesAncient()); builder.startObject(Fields.ROUTING); builder.field(Fields.STATE, shardUpgradeStatus.getShardRouting().state()); builder.field(Fields.PRIMARY, shardUpgradeStatus.getShardRouting().primary()); builder.field(Fields.NODE, shardUpgradeStatus.getShardRouting().currentNodeId()); if (shardUpgradeStatus.getShardRouting().relocatingNodeId() != null) { builder.field(Fields.RELOCATING_NODE, shardUpgradeStatus.getShardRouting().relocatingNodeId()); } builder.endObject(); builder.endObject(); } builder.endArray(); } builder.endObject(); } builder.endObject(); } builder.endObject(); } return builder; }
Example 19
Source File: IndicesSegmentResponse.java From Elasticsearch with Apache License 2.0 | 4 votes |
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(Fields.INDICES); for (IndexSegments indexSegments : getIndices().values()) { builder.startObject(indexSegments.getIndex(), XContentBuilder.FieldCaseConversion.NONE); builder.startObject(Fields.SHARDS); for (IndexShardSegments indexSegment : indexSegments) { builder.startArray(Integer.toString(indexSegment.getShardId().id())); for (ShardSegments shardSegments : indexSegment) { builder.startObject(); builder.startObject(Fields.ROUTING); builder.field(Fields.STATE, shardSegments.getShardRouting().state()); builder.field(Fields.PRIMARY, shardSegments.getShardRouting().primary()); builder.field(Fields.NODE, shardSegments.getShardRouting().currentNodeId()); if (shardSegments.getShardRouting().relocatingNodeId() != null) { builder.field(Fields.RELOCATING_NODE, shardSegments.getShardRouting().relocatingNodeId()); } builder.endObject(); builder.field(Fields.NUM_COMMITTED_SEGMENTS, shardSegments.getNumberOfCommitted()); builder.field(Fields.NUM_SEARCH_SEGMENTS, shardSegments.getNumberOfSearch()); builder.startObject(Fields.SEGMENTS); for (Segment segment : shardSegments) { builder.startObject(segment.getName()); builder.field(Fields.GENERATION, segment.getGeneration()); builder.field(Fields.NUM_DOCS, segment.getNumDocs()); builder.field(Fields.DELETED_DOCS, segment.getDeletedDocs()); builder.byteSizeField(Fields.SIZE_IN_BYTES, Fields.SIZE, segment.getSizeInBytes()); builder.byteSizeField(Fields.MEMORY_IN_BYTES, Fields.MEMORY, segment.getMemoryInBytes()); builder.field(Fields.COMMITTED, segment.isCommitted()); builder.field(Fields.SEARCH, segment.isSearch()); if (segment.getVersion() != null) { builder.field(Fields.VERSION, segment.getVersion()); } if (segment.isCompound() != null) { builder.field(Fields.COMPOUND, segment.isCompound()); } if (segment.getMergeId() != null) { builder.field(Fields.MERGE_ID, segment.getMergeId()); } if (segment.ramTree != null) { builder.startArray(Fields.RAM_TREE); for (Accountable child : segment.ramTree.getChildResources()) { toXContent(builder, child); } builder.endArray(); } builder.endObject(); } builder.endObject(); builder.endObject(); } builder.endArray(); } builder.endObject(); builder.endObject(); } builder.endObject(); return builder; }
Example 20
Source File: JvmInfo.java From elasticsearch-helper with Apache License 2.0 | 4 votes |
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(Fields.JVM); builder.field(Fields.TIMESTAMP, stats.timestamp); builder.dateValueField(Fields.START_TIME_IN_MILLIS, Fields.START_TIME, startTime); builder.timeValueField(Fields.UPTIME_IN_MILLIS, Fields.UPTIME, stats.uptime); builder.field(Fields.PID, pid); builder.field(Fields.VERSION, version); builder.field(Fields.VM_NAME, vmName); builder.field(Fields.VM_VERSION, vmVersion); builder.field(Fields.VM_VENDOR, vmVendor); if (stats.threads != null) { builder.startObject(Fields.THREADS); builder.field(Fields.COUNT, stats.threads.getCount()); builder.field(Fields.PEAK_COUNT, stats.threads.getPeakCount()); builder.endObject(); } builder.field(Fields.MEMORY_POOLS, memoryPools); if (stats.mem != null) { builder.startObject(Fields.MEM); builder.startObject(Fields.POOLS); for (MemoryPool pool : stats.mem) { builder.startObject(pool.getName(), XContentBuilder.FieldCaseConversion.NONE); builder.byteSizeField(Fields.USED_IN_BYTES, Fields.USED, pool.used); builder.byteSizeField(Fields.MAX_IN_BYTES, Fields.MAX, pool.max); builder.byteSizeField(Fields.PEAK_USED_IN_BYTES, Fields.PEAK_USED, pool.peakUsed); builder.byteSizeField(Fields.PEAK_MAX_IN_BYTES, Fields.PEAK_MAX, pool.peakMax); builder.endObject(); } builder.endObject(); if (stats.mem.getHeapUsedPercent() >= 0) { builder.field(Fields.HEAP_USED_PERCENT, stats.mem.getHeapUsedPercent()); } builder.byteSizeField(Fields.HEAP_INIT_IN_BYTES, Fields.HEAP_INIT, stats.mem.heapInit); builder.byteSizeField(Fields.HEAP_USED_IN_BYTES, Fields.HEAP_USED, stats.mem.heapUsed); builder.byteSizeField(Fields.HEAP_COMMITTED_IN_BYTES, Fields.HEAP_COMMITTED, stats.mem.heapCommitted); builder.byteSizeField(Fields.HEAP_MAX_IN_BYTES, Fields.HEAP_MAX, stats.mem.heapMax); builder.byteSizeField(Fields.NON_HEAP_INIT_IN_BYTES, Fields.NON_HEAP_INIT, stats.mem.nonHeapInit); builder.byteSizeField(Fields.NON_HEAP_USED_IN_BYTES, Fields.NON_HEAP_USED, stats.mem.nonHeapUsed); builder.byteSizeField(Fields.NON_HEAP_COMMITTED_IN_BYTES, Fields.NON_HEAP_COMMITTED, stats.mem.nonHeapCommitted); builder.byteSizeField(Fields.NON_HEAP_MAX_IN_BYTES, Fields.NON_HEAP_MAX, stats.mem.nonHeapMax); builder.byteSizeField(Fields.DIRECT_MAX_IN_BYTES, Fields.DIRECT_MAX, stats.mem.directMemoryMax); builder.endObject(); } builder.field(Fields.GC_COLLECTORS, gcCollectors); if (stats.gc != null) { builder.startObject(Fields.GC); builder.startObject(Fields.COLLECTORS); for (GarbageCollector collector : stats.gc) { builder.startObject(collector.getName(), XContentBuilder.FieldCaseConversion.NONE); builder.field(Fields.COLLECTION_COUNT, collector.getCollectionCount()); builder.timeValueField(Fields.COLLECTION_TIME_IN_MILLIS, Fields.COLLECTION_TIME, collector.collectionTime); builder.endObject(); } builder.endObject(); builder.endObject(); } if (stats.bufferPools != null) { builder.startObject(Fields.BUFFER_POOLS); for (BufferPool bufferPool : stats.bufferPools) { builder.startObject(bufferPool.getName(), XContentBuilder.FieldCaseConversion.NONE); builder.field(Fields.COUNT, bufferPool.getCount()); builder.byteSizeField(Fields.USED_IN_BYTES, Fields.USED, bufferPool.used); builder.byteSizeField(Fields.TOTAL_CAPACITY_IN_BYTES, Fields.TOTAL_CAPACITY, bufferPool.totalCapacity); builder.endObject(); } builder.endObject(); } if (stats.classes != null) { builder.startObject(Fields.CLASSES); builder.field(Fields.CURRENT_LOADED_COUNT, stats.classes.getLoadedClassCount()); builder.field(Fields.TOTAL_LOADED_COUNT, stats.classes.getTotalLoadedClassCount()); builder.field(Fields.TOTAL_UNLOADED_COUNT, stats.classes.getUnloadedClassCount()); builder.endObject(); } builder.endObject(); return builder; }