mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-09 14:35:04 +00:00
Merge pull request #20327 from javanna/enhancement/stats_writeable
NodeStats classes to implement Writeable rather then Streamable
This commit is contained in:
commit
0d21d9ff6e
@ -211,30 +211,16 @@ public class NodeStats extends BaseNodeResponse implements ToXContent {
|
|||||||
if (in.readBoolean()) {
|
if (in.readBoolean()) {
|
||||||
indices = NodeIndicesStats.readIndicesStats(in);
|
indices = NodeIndicesStats.readIndicesStats(in);
|
||||||
}
|
}
|
||||||
if (in.readBoolean()) {
|
os = in.readOptionalWriteable(OsStats::new);
|
||||||
os = new OsStats(in);
|
process = in.readOptionalWriteable(ProcessStats::new);
|
||||||
}
|
jvm = in.readOptionalWriteable(JvmStats::new);
|
||||||
if (in.readBoolean()) {
|
threadPool = in.readOptionalWriteable(ThreadPoolStats::new);
|
||||||
process = ProcessStats.readProcessStats(in);
|
fs = in.readOptionalWriteable(FsInfo::new);
|
||||||
}
|
transport = in.readOptionalWriteable(TransportStats::new);
|
||||||
if (in.readBoolean()) {
|
http = in.readOptionalWriteable(HttpStats::new);
|
||||||
jvm = JvmStats.readJvmStats(in);
|
breaker = in.readOptionalWriteable(AllCircuitBreakerStats::new);
|
||||||
}
|
scriptStats = in.readOptionalWriteable(ScriptStats::new);
|
||||||
if (in.readBoolean()) {
|
discoveryStats = in.readOptionalWriteable(DiscoveryStats::new);
|
||||||
threadPool = ThreadPoolStats.readThreadPoolStats(in);
|
|
||||||
}
|
|
||||||
if (in.readBoolean()) {
|
|
||||||
fs = new FsInfo(in);
|
|
||||||
}
|
|
||||||
if (in.readBoolean()) {
|
|
||||||
transport = TransportStats.readTransportStats(in);
|
|
||||||
}
|
|
||||||
if (in.readBoolean()) {
|
|
||||||
http = HttpStats.readHttpStats(in);
|
|
||||||
}
|
|
||||||
breaker = AllCircuitBreakerStats.readOptionalAllCircuitBreakerStats(in);
|
|
||||||
scriptStats = in.readOptionalStreamable(ScriptStats::new);
|
|
||||||
discoveryStats = in.readOptionalStreamable(() -> new DiscoveryStats(null));
|
|
||||||
ingestStats = in.readOptionalWriteable(IngestStats::new);
|
ingestStats = in.readOptionalWriteable(IngestStats::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,51 +234,16 @@ public class NodeStats extends BaseNodeResponse implements ToXContent {
|
|||||||
out.writeBoolean(true);
|
out.writeBoolean(true);
|
||||||
indices.writeTo(out);
|
indices.writeTo(out);
|
||||||
}
|
}
|
||||||
if (os == null) {
|
out.writeOptionalWriteable(os);
|
||||||
out.writeBoolean(false);
|
out.writeOptionalWriteable(process);
|
||||||
} else {
|
out.writeOptionalWriteable(jvm);
|
||||||
out.writeBoolean(true);
|
out.writeOptionalWriteable(threadPool);
|
||||||
os.writeTo(out);
|
out.writeOptionalWriteable(fs);
|
||||||
}
|
out.writeOptionalWriteable(transport);
|
||||||
if (process == null) {
|
out.writeOptionalWriteable(http);
|
||||||
out.writeBoolean(false);
|
out.writeOptionalWriteable(breaker);
|
||||||
} else {
|
out.writeOptionalWriteable(scriptStats);
|
||||||
out.writeBoolean(true);
|
out.writeOptionalWriteable(discoveryStats);
|
||||||
process.writeTo(out);
|
|
||||||
}
|
|
||||||
if (jvm == null) {
|
|
||||||
out.writeBoolean(false);
|
|
||||||
} else {
|
|
||||||
out.writeBoolean(true);
|
|
||||||
jvm.writeTo(out);
|
|
||||||
}
|
|
||||||
if (threadPool == null) {
|
|
||||||
out.writeBoolean(false);
|
|
||||||
} else {
|
|
||||||
out.writeBoolean(true);
|
|
||||||
threadPool.writeTo(out);
|
|
||||||
}
|
|
||||||
if (fs == null) {
|
|
||||||
out.writeBoolean(false);
|
|
||||||
} else {
|
|
||||||
out.writeBoolean(true);
|
|
||||||
fs.writeTo(out);
|
|
||||||
}
|
|
||||||
if (transport == null) {
|
|
||||||
out.writeBoolean(false);
|
|
||||||
} else {
|
|
||||||
out.writeBoolean(true);
|
|
||||||
transport.writeTo(out);
|
|
||||||
}
|
|
||||||
if (http == null) {
|
|
||||||
out.writeBoolean(false);
|
|
||||||
} else {
|
|
||||||
out.writeBoolean(true);
|
|
||||||
http.writeTo(out);
|
|
||||||
}
|
|
||||||
out.writeOptionalStreamable(breaker);
|
|
||||||
out.writeOptionalStreamable(scriptStats);
|
|
||||||
out.writeOptionalStreamable(discoveryStats);
|
|
||||||
out.writeOptionalWriteable(ingestStats);
|
out.writeOptionalWriteable(ingestStats);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -318,11 +269,9 @@ public class NodeStats extends BaseNodeResponse implements ToXContent {
|
|||||||
builder.endObject();
|
builder.endObject();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getIndices() != null) {
|
if (getIndices() != null) {
|
||||||
getIndices().toXContent(builder, params);
|
getIndices().toXContent(builder, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getOs() != null) {
|
if (getOs() != null) {
|
||||||
getOs().toXContent(builder, params);
|
getOs().toXContent(builder, params);
|
||||||
}
|
}
|
||||||
@ -350,15 +299,12 @@ public class NodeStats extends BaseNodeResponse implements ToXContent {
|
|||||||
if (getScriptStats() != null) {
|
if (getScriptStats() != null) {
|
||||||
getScriptStats().toXContent(builder, params);
|
getScriptStats().toXContent(builder, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getDiscoveryStats() != null) {
|
if (getDiscoveryStats() != null) {
|
||||||
getDiscoveryStats().toXContent(builder, params);
|
getDiscoveryStats().toXContent(builder, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getIngestStats() != null) {
|
if (getIngestStats() != null) {
|
||||||
getIngestStats().toXContent(builder, params);
|
getIngestStats().toXContent(builder, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -268,7 +268,7 @@ public class NodesStatsRequest extends BaseNodesRequest<NodesStatsRequest> {
|
|||||||
@Override
|
@Override
|
||||||
public void readFrom(StreamInput in) throws IOException {
|
public void readFrom(StreamInput in) throws IOException {
|
||||||
super.readFrom(in);
|
super.readFrom(in);
|
||||||
indices = CommonStatsFlags.readCommonStatsFlags(in);
|
indices = new CommonStatsFlags(in);
|
||||||
os = in.readBoolean();
|
os = in.readBoolean();
|
||||||
process = in.readBoolean();
|
process = in.readBoolean();
|
||||||
jvm = in.readBoolean();
|
jvm = in.readBoolean();
|
||||||
@ -298,5 +298,4 @@ public class NodesStatsRequest extends BaseNodesRequest<NodesStatsRequest> {
|
|||||||
out.writeBoolean(discovery);
|
out.writeBoolean(discovery);
|
||||||
out.writeBoolean(ingest);
|
out.writeBoolean(ingest);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ public class ClusterStatsNodes implements ToXContent {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (nodeResponse.nodeStats().getFs() != null) {
|
if (nodeResponse.nodeStats().getFs() != null) {
|
||||||
this.fs.add(nodeResponse.nodeStats().getFs().total());
|
this.fs.add(nodeResponse.nodeStats().getFs().getTotal());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.counts = new Counts(nodeInfos);
|
this.counts = new Counts(nodeInfos);
|
||||||
|
@ -22,7 +22,7 @@ package org.elasticsearch.action.admin.indices.stats;
|
|||||||
import org.elasticsearch.common.Nullable;
|
import org.elasticsearch.common.Nullable;
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||||
import org.elasticsearch.common.io.stream.Streamable;
|
import org.elasticsearch.common.io.stream.Writeable;
|
||||||
import org.elasticsearch.common.unit.ByteSizeValue;
|
import org.elasticsearch.common.unit.ByteSizeValue;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContent;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
@ -32,13 +32,13 @@ import org.elasticsearch.index.engine.SegmentsStats;
|
|||||||
import org.elasticsearch.index.fielddata.FieldDataStats;
|
import org.elasticsearch.index.fielddata.FieldDataStats;
|
||||||
import org.elasticsearch.index.flush.FlushStats;
|
import org.elasticsearch.index.flush.FlushStats;
|
||||||
import org.elasticsearch.index.get.GetStats;
|
import org.elasticsearch.index.get.GetStats;
|
||||||
import org.elasticsearch.index.shard.IndexingStats;
|
|
||||||
import org.elasticsearch.index.merge.MergeStats;
|
import org.elasticsearch.index.merge.MergeStats;
|
||||||
import org.elasticsearch.index.recovery.RecoveryStats;
|
import org.elasticsearch.index.recovery.RecoveryStats;
|
||||||
import org.elasticsearch.index.refresh.RefreshStats;
|
import org.elasticsearch.index.refresh.RefreshStats;
|
||||||
import org.elasticsearch.index.search.stats.SearchStats;
|
import org.elasticsearch.index.search.stats.SearchStats;
|
||||||
import org.elasticsearch.index.shard.DocsStats;
|
import org.elasticsearch.index.shard.DocsStats;
|
||||||
import org.elasticsearch.index.shard.IndexShard;
|
import org.elasticsearch.index.shard.IndexShard;
|
||||||
|
import org.elasticsearch.index.shard.IndexingStats;
|
||||||
import org.elasticsearch.index.store.StoreStats;
|
import org.elasticsearch.index.store.StoreStats;
|
||||||
import org.elasticsearch.index.translog.TranslogStats;
|
import org.elasticsearch.index.translog.TranslogStats;
|
||||||
import org.elasticsearch.index.warmer.WarmerStats;
|
import org.elasticsearch.index.warmer.WarmerStats;
|
||||||
@ -47,9 +47,55 @@ import org.elasticsearch.search.suggest.completion.CompletionStats;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
public class CommonStats implements Writeable, ToXContent {
|
||||||
*/
|
|
||||||
public class CommonStats implements Streamable, ToXContent {
|
@Nullable
|
||||||
|
public DocsStats docs;
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public StoreStats store;
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public IndexingStats indexing;
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public GetStats get;
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public SearchStats search;
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public MergeStats merge;
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public RefreshStats refresh;
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public FlushStats flush;
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public WarmerStats warmer;
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public QueryCacheStats queryCache;
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public FieldDataStats fieldData;
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public CompletionStats completion;
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public SegmentsStats segments;
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public TranslogStats translog;
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public RequestCacheStats requestCache;
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public RecoveryStats recoveryStats;
|
||||||
|
|
||||||
public CommonStats() {
|
public CommonStats() {
|
||||||
this(CommonStatsFlags.NONE);
|
this(CommonStatsFlags.NONE);
|
||||||
@ -117,11 +163,8 @@ public class CommonStats implements Streamable, ToXContent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public CommonStats(IndicesQueryCache indicesQueryCache, IndexShard indexShard, CommonStatsFlags flags) {
|
public CommonStats(IndicesQueryCache indicesQueryCache, IndexShard indexShard, CommonStatsFlags flags) {
|
||||||
|
|
||||||
CommonStatsFlags.Flag[] setFlags = flags.getFlags();
|
CommonStatsFlags.Flag[] setFlags = flags.getFlags();
|
||||||
|
|
||||||
for (CommonStatsFlags.Flag flag : setFlags) {
|
for (CommonStatsFlags.Flag flag : setFlags) {
|
||||||
switch (flag) {
|
switch (flag) {
|
||||||
case Docs:
|
case Docs:
|
||||||
@ -181,53 +224,135 @@ public class CommonStats implements Streamable, ToXContent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
public CommonStats(StreamInput in) throws IOException {
|
||||||
public DocsStats docs;
|
if (in.readBoolean()) {
|
||||||
|
docs = DocsStats.readDocStats(in);
|
||||||
|
}
|
||||||
|
if (in.readBoolean()) {
|
||||||
|
store = StoreStats.readStoreStats(in);
|
||||||
|
}
|
||||||
|
if (in.readBoolean()) {
|
||||||
|
indexing = IndexingStats.readIndexingStats(in);
|
||||||
|
}
|
||||||
|
if (in.readBoolean()) {
|
||||||
|
get = GetStats.readGetStats(in);
|
||||||
|
}
|
||||||
|
if (in.readBoolean()) {
|
||||||
|
search = SearchStats.readSearchStats(in);
|
||||||
|
}
|
||||||
|
if (in.readBoolean()) {
|
||||||
|
merge = MergeStats.readMergeStats(in);
|
||||||
|
}
|
||||||
|
if (in.readBoolean()) {
|
||||||
|
refresh = RefreshStats.readRefreshStats(in);
|
||||||
|
}
|
||||||
|
if (in.readBoolean()) {
|
||||||
|
flush = FlushStats.readFlushStats(in);
|
||||||
|
}
|
||||||
|
if (in.readBoolean()) {
|
||||||
|
warmer = WarmerStats.readWarmerStats(in);
|
||||||
|
}
|
||||||
|
if (in.readBoolean()) {
|
||||||
|
queryCache = QueryCacheStats.readQueryCacheStats(in);
|
||||||
|
}
|
||||||
|
if (in.readBoolean()) {
|
||||||
|
fieldData = FieldDataStats.readFieldDataStats(in);
|
||||||
|
}
|
||||||
|
if (in.readBoolean()) {
|
||||||
|
completion = CompletionStats.readCompletionStats(in);
|
||||||
|
}
|
||||||
|
if (in.readBoolean()) {
|
||||||
|
segments = SegmentsStats.readSegmentsStats(in);
|
||||||
|
}
|
||||||
|
translog = in.readOptionalStreamable(TranslogStats::new);
|
||||||
|
requestCache = in.readOptionalStreamable(RequestCacheStats::new);
|
||||||
|
recoveryStats = in.readOptionalStreamable(RecoveryStats::new);
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Override
|
||||||
public StoreStats store;
|
public void writeTo(StreamOutput out) throws IOException {
|
||||||
|
if (docs == null) {
|
||||||
@Nullable
|
out.writeBoolean(false);
|
||||||
public IndexingStats indexing;
|
} else {
|
||||||
|
out.writeBoolean(true);
|
||||||
@Nullable
|
docs.writeTo(out);
|
||||||
public GetStats get;
|
}
|
||||||
|
if (store == null) {
|
||||||
@Nullable
|
out.writeBoolean(false);
|
||||||
public SearchStats search;
|
} else {
|
||||||
|
out.writeBoolean(true);
|
||||||
@Nullable
|
store.writeTo(out);
|
||||||
public MergeStats merge;
|
}
|
||||||
|
if (indexing == null) {
|
||||||
@Nullable
|
out.writeBoolean(false);
|
||||||
public RefreshStats refresh;
|
} else {
|
||||||
|
out.writeBoolean(true);
|
||||||
@Nullable
|
indexing.writeTo(out);
|
||||||
public FlushStats flush;
|
}
|
||||||
|
if (get == null) {
|
||||||
@Nullable
|
out.writeBoolean(false);
|
||||||
public WarmerStats warmer;
|
} else {
|
||||||
|
out.writeBoolean(true);
|
||||||
@Nullable
|
get.writeTo(out);
|
||||||
public QueryCacheStats queryCache;
|
}
|
||||||
|
if (search == null) {
|
||||||
@Nullable
|
out.writeBoolean(false);
|
||||||
public FieldDataStats fieldData;
|
} else {
|
||||||
|
out.writeBoolean(true);
|
||||||
@Nullable
|
search.writeTo(out);
|
||||||
public CompletionStats completion;
|
}
|
||||||
|
if (merge == null) {
|
||||||
@Nullable
|
out.writeBoolean(false);
|
||||||
public SegmentsStats segments;
|
} else {
|
||||||
|
out.writeBoolean(true);
|
||||||
@Nullable
|
merge.writeTo(out);
|
||||||
public TranslogStats translog;
|
}
|
||||||
|
if (refresh == null) {
|
||||||
@Nullable
|
out.writeBoolean(false);
|
||||||
public RequestCacheStats requestCache;
|
} else {
|
||||||
|
out.writeBoolean(true);
|
||||||
@Nullable
|
refresh.writeTo(out);
|
||||||
public RecoveryStats recoveryStats;
|
}
|
||||||
|
if (flush == null) {
|
||||||
|
out.writeBoolean(false);
|
||||||
|
} else {
|
||||||
|
out.writeBoolean(true);
|
||||||
|
flush.writeTo(out);
|
||||||
|
}
|
||||||
|
if (warmer == null) {
|
||||||
|
out.writeBoolean(false);
|
||||||
|
} else {
|
||||||
|
out.writeBoolean(true);
|
||||||
|
warmer.writeTo(out);
|
||||||
|
}
|
||||||
|
if (queryCache == null) {
|
||||||
|
out.writeBoolean(false);
|
||||||
|
} else {
|
||||||
|
out.writeBoolean(true);
|
||||||
|
queryCache.writeTo(out);
|
||||||
|
}
|
||||||
|
if (fieldData == null) {
|
||||||
|
out.writeBoolean(false);
|
||||||
|
} else {
|
||||||
|
out.writeBoolean(true);
|
||||||
|
fieldData.writeTo(out);
|
||||||
|
}
|
||||||
|
if (completion == null) {
|
||||||
|
out.writeBoolean(false);
|
||||||
|
} else {
|
||||||
|
out.writeBoolean(true);
|
||||||
|
completion.writeTo(out);
|
||||||
|
}
|
||||||
|
if (segments == null) {
|
||||||
|
out.writeBoolean(false);
|
||||||
|
} else {
|
||||||
|
out.writeBoolean(true);
|
||||||
|
segments.writeTo(out);
|
||||||
|
}
|
||||||
|
out.writeOptionalStreamable(translog);
|
||||||
|
out.writeOptionalStreamable(requestCache);
|
||||||
|
out.writeOptionalStreamable(recoveryStats);
|
||||||
|
}
|
||||||
|
|
||||||
public void add(CommonStats stats) {
|
public void add(CommonStats stats) {
|
||||||
if (docs == null) {
|
if (docs == null) {
|
||||||
@ -441,12 +566,6 @@ public class CommonStats implements Streamable, ToXContent {
|
|||||||
return recoveryStats;
|
return recoveryStats;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CommonStats readCommonStats(StreamInput in) throws IOException {
|
|
||||||
CommonStats stats = new CommonStats();
|
|
||||||
stats.readFrom(in);
|
|
||||||
return stats;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility method which computes total memory by adding
|
* Utility method which computes total memory by adding
|
||||||
* FieldData, PercolatorCache, Segments (memory, index writer, version map)
|
* FieldData, PercolatorCache, Segments (memory, index writer, version map)
|
||||||
@ -468,137 +587,6 @@ public class CommonStats implements Streamable, ToXContent {
|
|||||||
return new ByteSizeValue(size);
|
return new ByteSizeValue(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void readFrom(StreamInput in) throws IOException {
|
|
||||||
if (in.readBoolean()) {
|
|
||||||
docs = DocsStats.readDocStats(in);
|
|
||||||
}
|
|
||||||
if (in.readBoolean()) {
|
|
||||||
store = StoreStats.readStoreStats(in);
|
|
||||||
}
|
|
||||||
if (in.readBoolean()) {
|
|
||||||
indexing = IndexingStats.readIndexingStats(in);
|
|
||||||
}
|
|
||||||
if (in.readBoolean()) {
|
|
||||||
get = GetStats.readGetStats(in);
|
|
||||||
}
|
|
||||||
if (in.readBoolean()) {
|
|
||||||
search = SearchStats.readSearchStats(in);
|
|
||||||
}
|
|
||||||
if (in.readBoolean()) {
|
|
||||||
merge = MergeStats.readMergeStats(in);
|
|
||||||
}
|
|
||||||
if (in.readBoolean()) {
|
|
||||||
refresh = RefreshStats.readRefreshStats(in);
|
|
||||||
}
|
|
||||||
if (in.readBoolean()) {
|
|
||||||
flush = FlushStats.readFlushStats(in);
|
|
||||||
}
|
|
||||||
if (in.readBoolean()) {
|
|
||||||
warmer = WarmerStats.readWarmerStats(in);
|
|
||||||
}
|
|
||||||
if (in.readBoolean()) {
|
|
||||||
queryCache = QueryCacheStats.readQueryCacheStats(in);
|
|
||||||
}
|
|
||||||
if (in.readBoolean()) {
|
|
||||||
fieldData = FieldDataStats.readFieldDataStats(in);
|
|
||||||
}
|
|
||||||
if (in.readBoolean()) {
|
|
||||||
completion = CompletionStats.readCompletionStats(in);
|
|
||||||
}
|
|
||||||
if (in.readBoolean()) {
|
|
||||||
segments = SegmentsStats.readSegmentsStats(in);
|
|
||||||
}
|
|
||||||
translog = in.readOptionalStreamable(TranslogStats::new);
|
|
||||||
requestCache = in.readOptionalStreamable(RequestCacheStats::new);
|
|
||||||
recoveryStats = in.readOptionalStreamable(RecoveryStats::new);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeTo(StreamOutput out) throws IOException {
|
|
||||||
if (docs == null) {
|
|
||||||
out.writeBoolean(false);
|
|
||||||
} else {
|
|
||||||
out.writeBoolean(true);
|
|
||||||
docs.writeTo(out);
|
|
||||||
}
|
|
||||||
if (store == null) {
|
|
||||||
out.writeBoolean(false);
|
|
||||||
} else {
|
|
||||||
out.writeBoolean(true);
|
|
||||||
store.writeTo(out);
|
|
||||||
}
|
|
||||||
if (indexing == null) {
|
|
||||||
out.writeBoolean(false);
|
|
||||||
} else {
|
|
||||||
out.writeBoolean(true);
|
|
||||||
indexing.writeTo(out);
|
|
||||||
}
|
|
||||||
if (get == null) {
|
|
||||||
out.writeBoolean(false);
|
|
||||||
} else {
|
|
||||||
out.writeBoolean(true);
|
|
||||||
get.writeTo(out);
|
|
||||||
}
|
|
||||||
if (search == null) {
|
|
||||||
out.writeBoolean(false);
|
|
||||||
} else {
|
|
||||||
out.writeBoolean(true);
|
|
||||||
search.writeTo(out);
|
|
||||||
}
|
|
||||||
if (merge == null) {
|
|
||||||
out.writeBoolean(false);
|
|
||||||
} else {
|
|
||||||
out.writeBoolean(true);
|
|
||||||
merge.writeTo(out);
|
|
||||||
}
|
|
||||||
if (refresh == null) {
|
|
||||||
out.writeBoolean(false);
|
|
||||||
} else {
|
|
||||||
out.writeBoolean(true);
|
|
||||||
refresh.writeTo(out);
|
|
||||||
}
|
|
||||||
if (flush == null) {
|
|
||||||
out.writeBoolean(false);
|
|
||||||
} else {
|
|
||||||
out.writeBoolean(true);
|
|
||||||
flush.writeTo(out);
|
|
||||||
}
|
|
||||||
if (warmer == null) {
|
|
||||||
out.writeBoolean(false);
|
|
||||||
} else {
|
|
||||||
out.writeBoolean(true);
|
|
||||||
warmer.writeTo(out);
|
|
||||||
}
|
|
||||||
if (queryCache == null) {
|
|
||||||
out.writeBoolean(false);
|
|
||||||
} else {
|
|
||||||
out.writeBoolean(true);
|
|
||||||
queryCache.writeTo(out);
|
|
||||||
}
|
|
||||||
if (fieldData == null) {
|
|
||||||
out.writeBoolean(false);
|
|
||||||
} else {
|
|
||||||
out.writeBoolean(true);
|
|
||||||
fieldData.writeTo(out);
|
|
||||||
}
|
|
||||||
if (completion == null) {
|
|
||||||
out.writeBoolean(false);
|
|
||||||
} else {
|
|
||||||
out.writeBoolean(true);
|
|
||||||
completion.writeTo(out);
|
|
||||||
}
|
|
||||||
if (segments == null) {
|
|
||||||
out.writeBoolean(false);
|
|
||||||
} else {
|
|
||||||
out.writeBoolean(true);
|
|
||||||
segments.writeTo(out);
|
|
||||||
}
|
|
||||||
out.writeOptionalStreamable(translog);
|
|
||||||
out.writeOptionalStreamable(requestCache);
|
|
||||||
out.writeOptionalStreamable(recoveryStats);
|
|
||||||
}
|
|
||||||
|
|
||||||
// note, requires a wrapping object
|
// note, requires a wrapping object
|
||||||
@Override
|
@Override
|
||||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||||
|
@ -19,17 +19,15 @@
|
|||||||
|
|
||||||
package org.elasticsearch.action.admin.indices.stats;
|
package org.elasticsearch.action.admin.indices.stats;
|
||||||
|
|
||||||
import org.elasticsearch.Version;
|
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||||
import org.elasticsearch.common.io.stream.Streamable;
|
import org.elasticsearch.common.io.stream.Writeable;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
|
|
||||||
/**
|
public class CommonStatsFlags implements Writeable, Cloneable {
|
||||||
*/
|
|
||||||
public class CommonStatsFlags implements Streamable, Cloneable {
|
|
||||||
|
|
||||||
public static final CommonStatsFlags ALL = new CommonStatsFlags().all();
|
public static final CommonStatsFlags ALL = new CommonStatsFlags().all();
|
||||||
public static final CommonStatsFlags NONE = new CommonStatsFlags().clear();
|
public static final CommonStatsFlags NONE = new CommonStatsFlags().clear();
|
||||||
@ -41,19 +39,45 @@ public class CommonStatsFlags implements Streamable, Cloneable {
|
|||||||
private String[] completionDataFields = null;
|
private String[] completionDataFields = null;
|
||||||
private boolean includeSegmentFileSizes = false;
|
private boolean includeSegmentFileSizes = false;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param flags flags to set. If no flags are supplied, default flags will be set.
|
* @param flags flags to set. If no flags are supplied, default flags will be set.
|
||||||
*/
|
*/
|
||||||
public CommonStatsFlags(Flag... flags) {
|
public CommonStatsFlags(Flag... flags) {
|
||||||
if (flags.length > 0) {
|
if (flags.length > 0) {
|
||||||
clear();
|
clear();
|
||||||
for (Flag f : flags) {
|
Collections.addAll(this.flags, flags);
|
||||||
this.flags.add(f);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CommonStatsFlags(StreamInput in) throws IOException {
|
||||||
|
final long longFlags = in.readLong();
|
||||||
|
flags.clear();
|
||||||
|
for (Flag flag : Flag.values()) {
|
||||||
|
if ((longFlags & (1 << flag.ordinal())) != 0) {
|
||||||
|
flags.add(flag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
types = in.readStringArray();
|
||||||
|
groups = in.readStringArray();
|
||||||
|
fieldDataFields = in.readStringArray();
|
||||||
|
completionDataFields = in.readStringArray();
|
||||||
|
includeSegmentFileSizes = in.readBoolean();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeTo(StreamOutput out) throws IOException {
|
||||||
|
long longFlags = 0;
|
||||||
|
for (Flag flag : flags) {
|
||||||
|
longFlags |= (1 << flag.ordinal());
|
||||||
|
}
|
||||||
|
out.writeLong(longFlags);
|
||||||
|
|
||||||
|
out.writeStringArrayNullable(types);
|
||||||
|
out.writeStringArrayNullable(groups);
|
||||||
|
out.writeStringArrayNullable(fieldDataFields);
|
||||||
|
out.writeStringArrayNullable(completionDataFields);
|
||||||
|
out.writeBoolean(includeSegmentFileSizes);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets all flags to return all stats.
|
* Sets all flags to return all stats.
|
||||||
@ -162,7 +186,6 @@ public class CommonStatsFlags implements Streamable, Cloneable {
|
|||||||
flags.add(flag);
|
flags.add(flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public CommonStatsFlags set(Flag flag, boolean add) {
|
public CommonStatsFlags set(Flag flag, boolean add) {
|
||||||
if (add) {
|
if (add) {
|
||||||
set(flag);
|
set(flag);
|
||||||
@ -172,49 +195,6 @@ public class CommonStatsFlags implements Streamable, Cloneable {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CommonStatsFlags readCommonStatsFlags(StreamInput in) throws IOException {
|
|
||||||
CommonStatsFlags flags = new CommonStatsFlags();
|
|
||||||
flags.readFrom(in);
|
|
||||||
return flags;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeTo(StreamOutput out) throws IOException {
|
|
||||||
long longFlags = 0;
|
|
||||||
for (Flag flag : flags) {
|
|
||||||
longFlags |= (1 << flag.ordinal());
|
|
||||||
}
|
|
||||||
out.writeLong(longFlags);
|
|
||||||
|
|
||||||
out.writeStringArrayNullable(types);
|
|
||||||
out.writeStringArrayNullable(groups);
|
|
||||||
out.writeStringArrayNullable(fieldDataFields);
|
|
||||||
out.writeStringArrayNullable(completionDataFields);
|
|
||||||
if (out.getVersion().onOrAfter(Version.V_5_0_0_alpha1)) {
|
|
||||||
out.writeBoolean(includeSegmentFileSizes);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void readFrom(StreamInput in) throws IOException {
|
|
||||||
final long longFlags = in.readLong();
|
|
||||||
flags.clear();
|
|
||||||
for (Flag flag : Flag.values()) {
|
|
||||||
if ((longFlags & (1 << flag.ordinal())) != 0) {
|
|
||||||
flags.add(flag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
types = in.readStringArray();
|
|
||||||
groups = in.readStringArray();
|
|
||||||
fieldDataFields = in.readStringArray();
|
|
||||||
completionDataFields = in.readStringArray();
|
|
||||||
if (in.getVersion().onOrAfter(Version.V_5_0_0_alpha1)) {
|
|
||||||
includeSegmentFileSizes = in.readBoolean();
|
|
||||||
} else {
|
|
||||||
includeSegmentFileSizes = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommonStatsFlags clone() {
|
public CommonStatsFlags clone() {
|
||||||
try {
|
try {
|
||||||
@ -226,7 +206,7 @@ public class CommonStatsFlags implements Streamable, Cloneable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static enum Flag {
|
public enum Flag {
|
||||||
// Do not change the order of these flags we use
|
// Do not change the order of these flags we use
|
||||||
// the ordinal for encoding! Only append to the end!
|
// the ordinal for encoding! Only append to the end!
|
||||||
Store("store"),
|
Store("store"),
|
||||||
@ -247,7 +227,6 @@ public class CommonStatsFlags implements Streamable, Cloneable {
|
|||||||
RequestCache("request_cache"),
|
RequestCache("request_cache"),
|
||||||
Recovery("recovery");
|
Recovery("recovery");
|
||||||
|
|
||||||
|
|
||||||
private final String restName;
|
private final String restName;
|
||||||
|
|
||||||
Flag(String restName) {
|
Flag(String restName) {
|
||||||
@ -257,6 +236,5 @@ public class CommonStatsFlags implements Streamable, Cloneable {
|
|||||||
public String getRestName() {
|
public String getRestName() {
|
||||||
return restName;
|
return restName;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -274,6 +274,6 @@ public class IndicesStatsRequest extends BroadcastRequest<IndicesStatsRequest> {
|
|||||||
@Override
|
@Override
|
||||||
public void readFrom(StreamInput in) throws IOException {
|
public void readFrom(StreamInput in) throws IOException {
|
||||||
super.readFrom(in);
|
super.readFrom(in);
|
||||||
flags = CommonStatsFlags.readCommonStatsFlags(in);
|
flags = new CommonStatsFlags(in);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,7 @@ public class ShardStats implements Streamable, ToXContent {
|
|||||||
@Override
|
@Override
|
||||||
public void readFrom(StreamInput in) throws IOException {
|
public void readFrom(StreamInput in) throws IOException {
|
||||||
shardRouting = new ShardRouting(in);
|
shardRouting = new ShardRouting(in);
|
||||||
commonStats = CommonStats.readCommonStats(in);
|
commonStats = new CommonStats(in);
|
||||||
commitStats = CommitStats.readOptionalCommitStatsFrom(in);
|
commitStats = CommitStats.readOptionalCommitStatsFrom(in);
|
||||||
statePath = in.readString();
|
statePath = in.readString();
|
||||||
dataPath = in.readString();
|
dataPath = in.readString();
|
||||||
|
@ -22,26 +22,34 @@ package org.elasticsearch.discovery;
|
|||||||
import org.elasticsearch.common.Nullable;
|
import org.elasticsearch.common.Nullable;
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||||
import org.elasticsearch.common.io.stream.Streamable;
|
import org.elasticsearch.common.io.stream.Writeable;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContent;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.discovery.zen.publish.PendingClusterStateStats;
|
import org.elasticsearch.discovery.zen.publish.PendingClusterStateStats;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class DiscoveryStats implements Streamable, ToXContent {
|
public class DiscoveryStats implements Writeable, ToXContent {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private PendingClusterStateStats queueStats;
|
private final PendingClusterStateStats queueStats;
|
||||||
|
|
||||||
public DiscoveryStats(PendingClusterStateStats queueStats) {
|
public DiscoveryStats(PendingClusterStateStats queueStats) {
|
||||||
this.queueStats = queueStats;
|
this.queueStats = queueStats;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DiscoveryStats(StreamInput in) throws IOException {
|
||||||
|
queueStats = in.readOptionalWriteable(PendingClusterStateStats::new);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeTo(StreamOutput out) throws IOException {
|
||||||
|
out.writeOptionalWriteable(queueStats);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||||
builder.startObject(Fields.DISCOVERY);
|
builder.startObject(Fields.DISCOVERY);
|
||||||
|
|
||||||
if (queueStats != null ){
|
if (queueStats != null ){
|
||||||
queueStats.toXContent(builder, params);
|
queueStats.toXContent(builder, params);
|
||||||
}
|
}
|
||||||
@ -49,24 +57,6 @@ public class DiscoveryStats implements Streamable, ToXContent {
|
|||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void readFrom(StreamInput in) throws IOException {
|
|
||||||
if (in.readBoolean()) {
|
|
||||||
queueStats = new PendingClusterStateStats();
|
|
||||||
queueStats.readFrom(in);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeTo(StreamOutput out) throws IOException {
|
|
||||||
if (queueStats != null ) {
|
|
||||||
out.writeBoolean(true);
|
|
||||||
queueStats.writeTo(out);
|
|
||||||
}else{
|
|
||||||
out.writeBoolean(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static final class Fields {
|
static final class Fields {
|
||||||
static final String DISCOVERY = "discovery";
|
static final String DISCOVERY = "discovery";
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,7 @@ import org.elasticsearch.discovery.BlockingClusterStatePublishResponseHandler;
|
|||||||
import org.elasticsearch.discovery.Discovery;
|
import org.elasticsearch.discovery.Discovery;
|
||||||
import org.elasticsearch.discovery.DiscoverySettings;
|
import org.elasticsearch.discovery.DiscoverySettings;
|
||||||
import org.elasticsearch.discovery.DiscoveryStats;
|
import org.elasticsearch.discovery.DiscoveryStats;
|
||||||
|
import org.elasticsearch.discovery.zen.publish.PendingClusterStateStats;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@ -281,7 +282,7 @@ public class LocalDiscovery extends AbstractLifecycleComponent implements Discov
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DiscoveryStats stats() {
|
public DiscoveryStats stats() {
|
||||||
return new DiscoveryStats(null);
|
return new DiscoveryStats((PendingClusterStateStats)null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -21,7 +21,7 @@ package org.elasticsearch.discovery.zen.publish;
|
|||||||
|
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||||
import org.elasticsearch.common.io.stream.Streamable;
|
import org.elasticsearch.common.io.stream.Writeable;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContent;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
|
|
||||||
@ -30,15 +30,11 @@ import java.io.IOException;
|
|||||||
/**
|
/**
|
||||||
* Class encapsulating stats about the PendingClusterStatsQueue
|
* Class encapsulating stats about the PendingClusterStatsQueue
|
||||||
*/
|
*/
|
||||||
public class PendingClusterStateStats implements Streamable, ToXContent {
|
public class PendingClusterStateStats implements Writeable, ToXContent {
|
||||||
|
|
||||||
private int total;
|
private final int total;
|
||||||
private int pending;
|
private final int pending;
|
||||||
private int committed;
|
private final int committed;
|
||||||
|
|
||||||
public PendingClusterStateStats() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public PendingClusterStateStats(int total, int pending, int committed) {
|
public PendingClusterStateStats(int total, int pending, int committed) {
|
||||||
this.total = total;
|
this.total = total;
|
||||||
@ -46,6 +42,19 @@ public class PendingClusterStateStats implements Streamable, ToXContent {
|
|||||||
this.committed = committed;
|
this.committed = committed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PendingClusterStateStats(StreamInput in) throws IOException {
|
||||||
|
total = in.readVInt();
|
||||||
|
pending = in.readVInt();
|
||||||
|
committed = in.readVInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeTo(StreamOutput out) throws IOException {
|
||||||
|
out.writeVInt(total);
|
||||||
|
out.writeVInt(pending);
|
||||||
|
out.writeVInt(committed);
|
||||||
|
}
|
||||||
|
|
||||||
public int getCommitted() {
|
public int getCommitted() {
|
||||||
return committed;
|
return committed;
|
||||||
}
|
}
|
||||||
@ -68,20 +77,6 @@ public class PendingClusterStateStats implements Streamable, ToXContent {
|
|||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void readFrom(StreamInput in) throws IOException {
|
|
||||||
total = in.readVInt();
|
|
||||||
pending = in.readVInt();
|
|
||||||
committed = in.readVInt();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeTo(StreamOutput out) throws IOException {
|
|
||||||
out.writeVInt(total);
|
|
||||||
out.writeVInt(pending);
|
|
||||||
out.writeVInt(committed);
|
|
||||||
}
|
|
||||||
|
|
||||||
static final class Fields {
|
static final class Fields {
|
||||||
static final String QUEUE = "cluster_state_queue";
|
static final String QUEUE = "cluster_state_queue";
|
||||||
static final String TOTAL = "total";
|
static final String TOTAL = "total";
|
||||||
|
@ -21,42 +21,23 @@ package org.elasticsearch.http;
|
|||||||
|
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||||
import org.elasticsearch.common.io.stream.Streamable;
|
import org.elasticsearch.common.io.stream.Writeable;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContent;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class HttpStats implements Streamable, ToXContent {
|
public class HttpStats implements Writeable, ToXContent {
|
||||||
|
|
||||||
private long serverOpen;
|
private final long serverOpen;
|
||||||
private long totalOpen;
|
private final long totalOpen;
|
||||||
|
|
||||||
HttpStats() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public HttpStats(long serverOpen, long totalOpen) {
|
public HttpStats(long serverOpen, long totalOpen) {
|
||||||
this.serverOpen = serverOpen;
|
this.serverOpen = serverOpen;
|
||||||
this.totalOpen = totalOpen;
|
this.totalOpen = totalOpen;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getServerOpen() {
|
public HttpStats(StreamInput in) throws IOException {
|
||||||
return this.serverOpen;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getTotalOpen() {
|
|
||||||
return this.totalOpen;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HttpStats readHttpStats(StreamInput in) throws IOException {
|
|
||||||
HttpStats stats = new HttpStats();
|
|
||||||
stats.readFrom(in);
|
|
||||||
return stats;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void readFrom(StreamInput in) throws IOException {
|
|
||||||
serverOpen = in.readVLong();
|
serverOpen = in.readVLong();
|
||||||
totalOpen = in.readVLong();
|
totalOpen = in.readVLong();
|
||||||
}
|
}
|
||||||
@ -67,6 +48,14 @@ public class HttpStats implements Streamable, ToXContent {
|
|||||||
out.writeVLong(totalOpen);
|
out.writeVLong(totalOpen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getServerOpen() {
|
||||||
|
return this.serverOpen;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getTotalOpen() {
|
||||||
|
return this.totalOpen;
|
||||||
|
}
|
||||||
|
|
||||||
static final class Fields {
|
static final class Fields {
|
||||||
static final String HTTP = "http";
|
static final String HTTP = "http";
|
||||||
static final String CURRENT_OPEN = "current_open";
|
static final String CURRENT_OPEN = "current_open";
|
||||||
|
@ -35,12 +35,12 @@ import org.elasticsearch.index.engine.SegmentsStats;
|
|||||||
import org.elasticsearch.index.fielddata.FieldDataStats;
|
import org.elasticsearch.index.fielddata.FieldDataStats;
|
||||||
import org.elasticsearch.index.flush.FlushStats;
|
import org.elasticsearch.index.flush.FlushStats;
|
||||||
import org.elasticsearch.index.get.GetStats;
|
import org.elasticsearch.index.get.GetStats;
|
||||||
import org.elasticsearch.index.shard.IndexingStats;
|
|
||||||
import org.elasticsearch.index.merge.MergeStats;
|
import org.elasticsearch.index.merge.MergeStats;
|
||||||
import org.elasticsearch.index.recovery.RecoveryStats;
|
import org.elasticsearch.index.recovery.RecoveryStats;
|
||||||
import org.elasticsearch.index.refresh.RefreshStats;
|
import org.elasticsearch.index.refresh.RefreshStats;
|
||||||
import org.elasticsearch.index.search.stats.SearchStats;
|
import org.elasticsearch.index.search.stats.SearchStats;
|
||||||
import org.elasticsearch.index.shard.DocsStats;
|
import org.elasticsearch.index.shard.DocsStats;
|
||||||
|
import org.elasticsearch.index.shard.IndexingStats;
|
||||||
import org.elasticsearch.index.store.StoreStats;
|
import org.elasticsearch.index.store.StoreStats;
|
||||||
import org.elasticsearch.search.suggest.completion.CompletionStats;
|
import org.elasticsearch.search.suggest.completion.CompletionStats;
|
||||||
|
|
||||||
@ -154,7 +154,7 @@ public class NodeIndicesStats implements Streamable, ToXContent {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readFrom(StreamInput in) throws IOException {
|
public void readFrom(StreamInput in) throws IOException {
|
||||||
stats = CommonStats.readCommonStats(in);
|
stats = new CommonStats(in);
|
||||||
if (in.readBoolean()) {
|
if (in.readBoolean()) {
|
||||||
int entries = in.readVInt();
|
int entries = in.readVInt();
|
||||||
statsByShard = new HashMap<>();
|
statsByShard = new HashMap<>();
|
||||||
|
@ -21,7 +21,7 @@ package org.elasticsearch.indices.breaker;
|
|||||||
|
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||||
import org.elasticsearch.common.io.stream.Streamable;
|
import org.elasticsearch.common.io.stream.Writeable;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContent;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
|
|
||||||
@ -30,18 +30,23 @@ import java.io.IOException;
|
|||||||
/**
|
/**
|
||||||
* Stats class encapsulating all of the different circuit breaker stats
|
* Stats class encapsulating all of the different circuit breaker stats
|
||||||
*/
|
*/
|
||||||
public class AllCircuitBreakerStats implements Streamable, ToXContent {
|
public class AllCircuitBreakerStats implements Writeable, ToXContent {
|
||||||
|
|
||||||
private CircuitBreakerStats[] allStats = new CircuitBreakerStats[0];
|
private final CircuitBreakerStats[] allStats;
|
||||||
|
|
||||||
public AllCircuitBreakerStats() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public AllCircuitBreakerStats(CircuitBreakerStats[] allStats) {
|
public AllCircuitBreakerStats(CircuitBreakerStats[] allStats) {
|
||||||
this.allStats = allStats;
|
this.allStats = allStats;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AllCircuitBreakerStats(StreamInput in) throws IOException {
|
||||||
|
allStats = in.readArray(CircuitBreakerStats::new, CircuitBreakerStats[]::new);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeTo(StreamOutput out) throws IOException {
|
||||||
|
out.writeArray(allStats);
|
||||||
|
}
|
||||||
|
|
||||||
public CircuitBreakerStats[] getAllStats() {
|
public CircuitBreakerStats[] getAllStats() {
|
||||||
return this.allStats;
|
return this.allStats;
|
||||||
}
|
}
|
||||||
@ -55,33 +60,6 @@ public class AllCircuitBreakerStats implements Streamable, ToXContent {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AllCircuitBreakerStats readOptionalAllCircuitBreakerStats(StreamInput in) throws IOException {
|
|
||||||
AllCircuitBreakerStats stats = in.readOptionalStreamable(AllCircuitBreakerStats::new);
|
|
||||||
return stats;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void readFrom(StreamInput in) throws IOException {
|
|
||||||
int statCount = in.readVInt();
|
|
||||||
CircuitBreakerStats[] newStats = new CircuitBreakerStats[statCount];
|
|
||||||
for (int i = 0; i < statCount; i++) {
|
|
||||||
CircuitBreakerStats stats = new CircuitBreakerStats();
|
|
||||||
stats.readFrom(in);
|
|
||||||
newStats[i] = stats;
|
|
||||||
}
|
|
||||||
allStats = newStats;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeTo(StreamOutput out) throws IOException {
|
|
||||||
out.writeVInt(allStats.length);
|
|
||||||
for (CircuitBreakerStats stats : allStats) {
|
|
||||||
if (stats != null) {
|
|
||||||
stats.writeTo(out);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||||
builder.startObject(Fields.BREAKERS);
|
builder.startObject(Fields.BREAKERS);
|
||||||
|
@ -21,7 +21,7 @@ package org.elasticsearch.indices.breaker;
|
|||||||
|
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||||
import org.elasticsearch.common.io.stream.Streamable;
|
import org.elasticsearch.common.io.stream.Writeable;
|
||||||
import org.elasticsearch.common.unit.ByteSizeValue;
|
import org.elasticsearch.common.unit.ByteSizeValue;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContent;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
@ -32,17 +32,13 @@ import java.util.Locale;
|
|||||||
/**
|
/**
|
||||||
* Class encapsulating stats about the circuit breaker
|
* Class encapsulating stats about the circuit breaker
|
||||||
*/
|
*/
|
||||||
public class CircuitBreakerStats implements Streamable, ToXContent {
|
public class CircuitBreakerStats implements Writeable, ToXContent {
|
||||||
|
|
||||||
private String name;
|
private final String name;
|
||||||
private long limit;
|
private final long limit;
|
||||||
private long estimated;
|
private final long estimated;
|
||||||
private long trippedCount;
|
private final long trippedCount;
|
||||||
private double overhead;
|
private final double overhead;
|
||||||
|
|
||||||
CircuitBreakerStats() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public CircuitBreakerStats(String name, long limit, long estimated, double overhead, long trippedCount) {
|
public CircuitBreakerStats(String name, long limit, long estimated, double overhead, long trippedCount) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
@ -52,6 +48,23 @@ public class CircuitBreakerStats implements Streamable, ToXContent {
|
|||||||
this.overhead = overhead;
|
this.overhead = overhead;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CircuitBreakerStats(StreamInput in) throws IOException {
|
||||||
|
limit = in.readLong();
|
||||||
|
estimated = in.readLong();
|
||||||
|
overhead = in.readDouble();
|
||||||
|
this.trippedCount = in.readLong();
|
||||||
|
this.name = in.readString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeTo(StreamOutput out) throws IOException {
|
||||||
|
out.writeLong(limit);
|
||||||
|
out.writeLong(estimated);
|
||||||
|
out.writeDouble(overhead);
|
||||||
|
out.writeLong(trippedCount);
|
||||||
|
out.writeString(name);
|
||||||
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
@ -72,30 +85,6 @@ public class CircuitBreakerStats implements Streamable, ToXContent {
|
|||||||
return this.overhead;
|
return this.overhead;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CircuitBreakerStats readOptionalCircuitBreakerStats(StreamInput in) throws IOException {
|
|
||||||
CircuitBreakerStats stats = in.readOptionalStreamable(CircuitBreakerStats::new);
|
|
||||||
return stats;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void readFrom(StreamInput in) throws IOException {
|
|
||||||
// limit is the maximum from the old circuit breaker stats for backwards compatibility
|
|
||||||
limit = in.readLong();
|
|
||||||
estimated = in.readLong();
|
|
||||||
overhead = in.readDouble();
|
|
||||||
this.trippedCount = in.readLong();
|
|
||||||
this.name = in.readString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeTo(StreamOutput out) throws IOException {
|
|
||||||
out.writeLong(limit);
|
|
||||||
out.writeLong(estimated);
|
|
||||||
out.writeDouble(overhead);
|
|
||||||
out.writeLong(trippedCount);
|
|
||||||
out.writeString(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||||
builder.startObject(name.toLowerCase(Locale.ROOT));
|
builder.startObject(name.toLowerCase(Locale.ROOT));
|
||||||
|
@ -386,6 +386,30 @@ public class FsInfo implements Iterable<FsInfo.Path>, Writeable, ToXContent {
|
|||||||
out.writeLong(totalWriteKilobytes);
|
out.writeLong(totalWriteKilobytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DeviceStats[] getDevicesStats() {
|
||||||
|
return devicesStats;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getTotalOperations() {
|
||||||
|
return totalOperations;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getTotalReadOperations() {
|
||||||
|
return totalReadOperations;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getTotalWriteOperations() {
|
||||||
|
return totalWriteOperations;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getTotalReadKilobytes() {
|
||||||
|
return totalReadKilobytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getTotalWriteKilobytes() {
|
||||||
|
return totalWriteKilobytes;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||||
if (devicesStats.length > 0) {
|
if (devicesStats.length > 0) {
|
||||||
@ -410,16 +434,16 @@ public class FsInfo implements Iterable<FsInfo.Path>, Writeable, ToXContent {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final long timestamp;
|
private final long timestamp;
|
||||||
final Path[] paths;
|
private final Path[] paths;
|
||||||
final IoStats ioStats;
|
private final IoStats ioStats;
|
||||||
Path total;
|
private final Path total;
|
||||||
|
|
||||||
public FsInfo(long timestamp, IoStats ioStats, Path[] paths) {
|
public FsInfo(long timestamp, IoStats ioStats, Path[] paths) {
|
||||||
this.timestamp = timestamp;
|
this.timestamp = timestamp;
|
||||||
this.ioStats = ioStats;
|
this.ioStats = ioStats;
|
||||||
this.paths = paths;
|
this.paths = paths;
|
||||||
this.total = null;
|
this.total = total();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -432,6 +456,7 @@ public class FsInfo implements Iterable<FsInfo.Path>, Writeable, ToXContent {
|
|||||||
for (int i = 0; i < paths.length; i++) {
|
for (int i = 0; i < paths.length; i++) {
|
||||||
paths[i] = new Path(in);
|
paths[i] = new Path(in);
|
||||||
}
|
}
|
||||||
|
this.total = total();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -445,13 +470,10 @@ public class FsInfo implements Iterable<FsInfo.Path>, Writeable, ToXContent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Path getTotal() {
|
public Path getTotal() {
|
||||||
return total();
|
return total;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Path total() {
|
private Path total() {
|
||||||
if (total != null) {
|
|
||||||
return total;
|
|
||||||
}
|
|
||||||
Path res = new Path();
|
Path res = new Path();
|
||||||
Set<String> seenDevices = new HashSet<>(paths.length);
|
Set<String> seenDevices = new HashSet<>(paths.length);
|
||||||
for (Path subPath : paths) {
|
for (Path subPath : paths) {
|
||||||
@ -462,7 +484,6 @@ public class FsInfo implements Iterable<FsInfo.Path>, Writeable, ToXContent {
|
|||||||
}
|
}
|
||||||
res.add(subPath);
|
res.add(subPath);
|
||||||
}
|
}
|
||||||
total = res;
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -506,5 +527,4 @@ public class FsInfo implements Iterable<FsInfo.Path>, Writeable, ToXContent {
|
|||||||
static final String TOTAL = "total";
|
static final String TOTAL = "total";
|
||||||
static final String IO_STATS = "io_stats";
|
static final String IO_STATS = "io_stats";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ package org.elasticsearch.monitor.jvm;
|
|||||||
|
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||||
import org.elasticsearch.common.io.stream.Streamable;
|
import org.elasticsearch.common.io.stream.Writeable;
|
||||||
import org.elasticsearch.common.unit.ByteSizeValue;
|
import org.elasticsearch.common.unit.ByteSizeValue;
|
||||||
import org.elasticsearch.common.unit.TimeValue;
|
import org.elasticsearch.common.unit.TimeValue;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContent;
|
||||||
@ -39,14 +39,12 @@ import java.lang.management.RuntimeMXBean;
|
|||||||
import java.lang.management.ThreadMXBean;
|
import java.lang.management.ThreadMXBean;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
public class JvmStats implements Writeable, ToXContent {
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class JvmStats implements Streamable, ToXContent {
|
|
||||||
|
|
||||||
private static final RuntimeMXBean runtimeMXBean;
|
private static final RuntimeMXBean runtimeMXBean;
|
||||||
private static final MemoryMXBean memoryMXBean;
|
private static final MemoryMXBean memoryMXBean;
|
||||||
@ -61,21 +59,17 @@ public class JvmStats implements Streamable, ToXContent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static JvmStats jvmStats() {
|
public static JvmStats jvmStats() {
|
||||||
JvmStats stats = new JvmStats(System.currentTimeMillis(), runtimeMXBean.getUptime());
|
|
||||||
stats.mem = new Mem();
|
|
||||||
MemoryUsage memUsage = memoryMXBean.getHeapMemoryUsage();
|
MemoryUsage memUsage = memoryMXBean.getHeapMemoryUsage();
|
||||||
stats.mem.heapUsed = memUsage.getUsed() < 0 ? 0 : memUsage.getUsed();
|
long heapUsed = memUsage.getUsed() < 0 ? 0 : memUsage.getUsed();
|
||||||
stats.mem.heapCommitted = memUsage.getCommitted() < 0 ? 0 : memUsage.getCommitted();
|
long heapCommitted = memUsage.getCommitted() < 0 ? 0 : memUsage.getCommitted();
|
||||||
stats.mem.heapMax = memUsage.getMax() < 0 ? 0 : memUsage.getMax();
|
long heapMax = memUsage.getMax() < 0 ? 0 : memUsage.getMax();
|
||||||
memUsage = memoryMXBean.getNonHeapMemoryUsage();
|
memUsage = memoryMXBean.getNonHeapMemoryUsage();
|
||||||
stats.mem.nonHeapUsed = memUsage.getUsed() < 0 ? 0 : memUsage.getUsed();
|
long nonHeapUsed = memUsage.getUsed() < 0 ? 0 : memUsage.getUsed();
|
||||||
stats.mem.nonHeapCommitted = memUsage.getCommitted() < 0 ? 0 : memUsage.getCommitted();
|
long nonHeapCommitted = memUsage.getCommitted() < 0 ? 0 : memUsage.getCommitted();
|
||||||
|
|
||||||
List<MemoryPoolMXBean> memoryPoolMXBeans = ManagementFactory.getMemoryPoolMXBeans();
|
List<MemoryPoolMXBean> memoryPoolMXBeans = ManagementFactory.getMemoryPoolMXBeans();
|
||||||
List<MemoryPool> pools = new ArrayList<>();
|
List<MemoryPool> pools = new ArrayList<>();
|
||||||
for (int i = 0; i < memoryPoolMXBeans.size(); i++) {
|
for (MemoryPoolMXBean memoryPoolMXBean : memoryPoolMXBeans) {
|
||||||
try {
|
try {
|
||||||
MemoryPoolMXBean memoryPoolMXBean = memoryPoolMXBeans.get(i);
|
|
||||||
MemoryUsage usage = memoryPoolMXBean.getUsage();
|
MemoryUsage usage = memoryPoolMXBean.getUsage();
|
||||||
MemoryUsage peakUsage = memoryPoolMXBean.getPeakUsage();
|
MemoryUsage peakUsage = memoryPoolMXBean.getPeakUsage();
|
||||||
String name = GcNames.getByMemoryPoolName(memoryPoolMXBean.getName(), null);
|
String name = GcNames.getByMemoryPoolName(memoryPoolMXBean.getName(), null);
|
||||||
@ -94,55 +88,74 @@ public class JvmStats implements Streamable, ToXContent {
|
|||||||
* we just omit the pool in that case!*/
|
* we just omit the pool in that case!*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stats.mem.pools = pools.toArray(new MemoryPool[pools.size()]);
|
Mem mem = new Mem(heapCommitted, heapUsed, heapMax, nonHeapCommitted, nonHeapUsed, Collections.unmodifiableList(pools));
|
||||||
|
Threads threads = new Threads(threadMXBean.getThreadCount(), threadMXBean.getPeakThreadCount());
|
||||||
stats.threads = new Threads();
|
|
||||||
stats.threads.count = threadMXBean.getThreadCount();
|
|
||||||
stats.threads.peakCount = threadMXBean.getPeakThreadCount();
|
|
||||||
|
|
||||||
List<GarbageCollectorMXBean> gcMxBeans = ManagementFactory.getGarbageCollectorMXBeans();
|
List<GarbageCollectorMXBean> gcMxBeans = ManagementFactory.getGarbageCollectorMXBeans();
|
||||||
stats.gc = new GarbageCollectors();
|
GarbageCollector[] collectors = new GarbageCollector[gcMxBeans.size()];
|
||||||
stats.gc.collectors = new GarbageCollector[gcMxBeans.size()];
|
for (int i = 0; i < collectors.length; i++) {
|
||||||
for (int i = 0; i < stats.gc.collectors.length; i++) {
|
|
||||||
GarbageCollectorMXBean gcMxBean = gcMxBeans.get(i);
|
GarbageCollectorMXBean gcMxBean = gcMxBeans.get(i);
|
||||||
stats.gc.collectors[i] = new GarbageCollector();
|
collectors[i] = new GarbageCollector(GcNames.getByGcName(gcMxBean.getName(), gcMxBean.getName()),
|
||||||
stats.gc.collectors[i].name = GcNames.getByGcName(gcMxBean.getName(), gcMxBean.getName());
|
gcMxBean.getCollectionCount(), gcMxBean.getCollectionTime());
|
||||||
stats.gc.collectors[i].collectionCount = gcMxBean.getCollectionCount();
|
|
||||||
stats.gc.collectors[i].collectionTime = gcMxBean.getCollectionTime();
|
|
||||||
}
|
}
|
||||||
|
GarbageCollectors garbageCollectors = new GarbageCollectors(collectors);
|
||||||
|
List<BufferPool> bufferPoolsList = Collections.emptyList();
|
||||||
try {
|
try {
|
||||||
List<BufferPoolMXBean> bufferPools = ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class);
|
List<BufferPoolMXBean> bufferPools = ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class);
|
||||||
stats.bufferPools = new ArrayList<>(bufferPools.size());
|
bufferPoolsList = new ArrayList<>(bufferPools.size());
|
||||||
for (BufferPoolMXBean bufferPool : bufferPools) {
|
for (BufferPoolMXBean bufferPool : bufferPools) {
|
||||||
stats.bufferPools.add(new BufferPool(bufferPool.getName(), bufferPool.getCount(), bufferPool.getTotalCapacity(), bufferPool.getMemoryUsed()));
|
bufferPoolsList.add(new BufferPool(bufferPool.getName(), bufferPool.getCount(),
|
||||||
|
bufferPool.getTotalCapacity(), bufferPool.getMemoryUsed()));
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// buffer pools are not available
|
// buffer pools are not available
|
||||||
}
|
}
|
||||||
|
|
||||||
stats.classes = new Classes();
|
Classes classes = new Classes(classLoadingMXBean.getLoadedClassCount(), classLoadingMXBean.getTotalLoadedClassCount(),
|
||||||
stats.classes.loadedClassCount = classLoadingMXBean.getLoadedClassCount();
|
classLoadingMXBean.getUnloadedClassCount());
|
||||||
stats.classes.totalLoadedClassCount = classLoadingMXBean.getTotalLoadedClassCount();
|
|
||||||
stats.classes.unloadedClassCount = classLoadingMXBean.getUnloadedClassCount();
|
|
||||||
|
|
||||||
return stats;
|
return new JvmStats(System.currentTimeMillis(), runtimeMXBean.getUptime(), mem, threads,
|
||||||
|
garbageCollectors, bufferPoolsList, classes);
|
||||||
}
|
}
|
||||||
|
|
||||||
long timestamp = -1;
|
private final long timestamp;
|
||||||
long uptime;
|
private final long uptime;
|
||||||
Mem mem;
|
private final Mem mem;
|
||||||
Threads threads;
|
private final Threads threads;
|
||||||
GarbageCollectors gc;
|
private final GarbageCollectors gc;
|
||||||
List<BufferPool> bufferPools;
|
private final List<BufferPool> bufferPools;
|
||||||
Classes classes;
|
private final Classes classes;
|
||||||
|
|
||||||
private JvmStats() {
|
public JvmStats(long timestamp, long uptime, Mem mem, Threads threads, GarbageCollectors gc,
|
||||||
}
|
List<BufferPool> bufferPools, Classes classes) {
|
||||||
|
|
||||||
public JvmStats(long timestamp, long uptime) {
|
|
||||||
this.timestamp = timestamp;
|
this.timestamp = timestamp;
|
||||||
this.uptime = uptime;
|
this.uptime = uptime;
|
||||||
|
this.mem = mem;
|
||||||
|
this.threads = threads;
|
||||||
|
this.gc = gc;
|
||||||
|
this.bufferPools = bufferPools;
|
||||||
|
this.classes = classes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public JvmStats(StreamInput in) throws IOException {
|
||||||
|
timestamp = in.readVLong();
|
||||||
|
uptime = in.readVLong();
|
||||||
|
mem = new Mem(in);
|
||||||
|
threads = new Threads(in);
|
||||||
|
gc = new GarbageCollectors(in);
|
||||||
|
bufferPools = in.readList(BufferPool::new);
|
||||||
|
classes = new Classes(in);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeTo(StreamOutput out) throws IOException {
|
||||||
|
out.writeVLong(timestamp);
|
||||||
|
out.writeVLong(uptime);
|
||||||
|
mem.writeTo(out);
|
||||||
|
threads.writeTo(out);
|
||||||
|
gc.writeTo(out);
|
||||||
|
out.writeList(bufferPools);
|
||||||
|
classes.writeTo(out);
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getTimestamp() {
|
public long getTimestamp() {
|
||||||
@ -178,53 +191,50 @@ public class JvmStats implements Streamable, ToXContent {
|
|||||||
builder.startObject(Fields.JVM);
|
builder.startObject(Fields.JVM);
|
||||||
builder.field(Fields.TIMESTAMP, timestamp);
|
builder.field(Fields.TIMESTAMP, timestamp);
|
||||||
builder.timeValueField(Fields.UPTIME_IN_MILLIS, Fields.UPTIME, uptime);
|
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);
|
builder.startObject(Fields.MEM);
|
||||||
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);
|
builder.byteSizeField(Fields.HEAP_USED_IN_BYTES, Fields.HEAP_USED, mem.heapUsed);
|
||||||
for (MemoryPool pool : mem) {
|
if (mem.getHeapUsedPercent() >= 0) {
|
||||||
builder.startObject(pool.getName());
|
builder.field(Fields.HEAP_USED_PERCENT, mem.getHeapUsedPercent());
|
||||||
builder.byteSizeField(Fields.USED_IN_BYTES, Fields.USED, pool.used);
|
}
|
||||||
builder.byteSizeField(Fields.MAX_IN_BYTES, Fields.MAX, pool.max);
|
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.byteSizeField(Fields.PEAK_USED_IN_BYTES, Fields.PEAK_USED, pool.peakUsed);
|
builder.startObject(Fields.POOLS);
|
||||||
builder.byteSizeField(Fields.PEAK_MAX_IN_BYTES, Fields.PEAK_MAX, pool.peakMax);
|
for (MemoryPool pool : mem) {
|
||||||
|
builder.startObject(pool.getName());
|
||||||
|
builder.byteSizeField(Fields.USED_IN_BYTES, Fields.USED, pool.used);
|
||||||
|
builder.byteSizeField(Fields.MAX_IN_BYTES, Fields.MAX, pool.max);
|
||||||
|
|
||||||
builder.endObject();
|
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.endObject();
|
||||||
builder.startObject(Fields.THREADS);
|
|
||||||
builder.field(Fields.COUNT, threads.getCount());
|
builder.endObject();
|
||||||
builder.field(Fields.PEAK_COUNT, threads.getPeakCount());
|
|
||||||
|
builder.startObject(Fields.THREADS);
|
||||||
|
builder.field(Fields.COUNT, threads.getCount());
|
||||||
|
builder.field(Fields.PEAK_COUNT, threads.getPeakCount());
|
||||||
|
builder.endObject();
|
||||||
|
|
||||||
|
builder.startObject(Fields.GC);
|
||||||
|
|
||||||
|
builder.startObject(Fields.COLLECTORS);
|
||||||
|
for (GarbageCollector collector : gc) {
|
||||||
|
builder.startObject(collector.getName());
|
||||||
|
builder.field(Fields.COLLECTION_COUNT, collector.getCollectionCount());
|
||||||
|
builder.timeValueField(Fields.COLLECTION_TIME_IN_MILLIS, Fields.COLLECTION_TIME, collector.collectionTime);
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
}
|
}
|
||||||
if (gc != null) {
|
builder.endObject();
|
||||||
builder.startObject(Fields.GC);
|
|
||||||
|
|
||||||
builder.startObject(Fields.COLLECTORS);
|
builder.endObject();
|
||||||
for (GarbageCollector collector : gc) {
|
|
||||||
builder.startObject(collector.getName());
|
|
||||||
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) {
|
if (bufferPools != null) {
|
||||||
builder.startObject(Fields.BUFFER_POOLS);
|
builder.startObject(Fields.BUFFER_POOLS);
|
||||||
@ -238,13 +248,11 @@ public class JvmStats implements Streamable, ToXContent {
|
|||||||
builder.endObject();
|
builder.endObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (classes != null) {
|
builder.startObject(Fields.CLASSES);
|
||||||
builder.startObject(Fields.CLASSES);
|
builder.field(Fields.CURRENT_LOADED_COUNT, classes.getLoadedClassCount());
|
||||||
builder.field(Fields.CURRENT_LOADED_COUNT, classes.getLoadedClassCount());
|
builder.field(Fields.TOTAL_LOADED_COUNT, classes.getTotalLoadedClassCount());
|
||||||
builder.field(Fields.TOTAL_LOADED_COUNT, classes.getTotalLoadedClassCount());
|
builder.field(Fields.TOTAL_UNLOADED_COUNT, classes.getUnloadedClassCount());
|
||||||
builder.field(Fields.TOTAL_UNLOADED_COUNT, classes.getUnloadedClassCount());
|
builder.endObject();
|
||||||
builder.endObject();
|
|
||||||
}
|
|
||||||
|
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
return builder;
|
return builder;
|
||||||
@ -291,7 +299,6 @@ public class JvmStats implements Streamable, ToXContent {
|
|||||||
static final String COLLECTION_TIME_IN_MILLIS = "collection_time_in_millis";
|
static final String COLLECTION_TIME_IN_MILLIS = "collection_time_in_millis";
|
||||||
|
|
||||||
static final String BUFFER_POOLS = "buffer_pools";
|
static final String BUFFER_POOLS = "buffer_pools";
|
||||||
static final String NAME = "name";
|
|
||||||
static final String TOTAL_CAPACITY = "total_capacity";
|
static final String TOTAL_CAPACITY = "total_capacity";
|
||||||
static final String TOTAL_CAPACITY_IN_BYTES = "total_capacity_in_bytes";
|
static final String TOTAL_CAPACITY_IN_BYTES = "total_capacity_in_bytes";
|
||||||
|
|
||||||
@ -301,80 +308,21 @@ public class JvmStats implements Streamable, ToXContent {
|
|||||||
static final String TOTAL_UNLOADED_COUNT = "total_unloaded_count";
|
static final String TOTAL_UNLOADED_COUNT = "total_unloaded_count";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class GarbageCollectors implements Writeable, Iterable<GarbageCollector> {
|
||||||
|
|
||||||
public static JvmStats readJvmStats(StreamInput in) throws IOException {
|
private final GarbageCollector[] collectors;
|
||||||
JvmStats jvmStats = new JvmStats();
|
|
||||||
jvmStats.readFrom(in);
|
|
||||||
return jvmStats;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
public GarbageCollectors(GarbageCollector[] collectors) {
|
||||||
public void readFrom(StreamInput in) throws IOException {
|
this.collectors = collectors;
|
||||||
timestamp = in.readVLong();
|
|
||||||
uptime = in.readVLong();
|
|
||||||
|
|
||||||
mem = Mem.readMem(in);
|
|
||||||
threads = Threads.readThreads(in);
|
|
||||||
gc = GarbageCollectors.readGarbageCollectors(in);
|
|
||||||
|
|
||||||
if (in.readBoolean()) {
|
|
||||||
int size = in.readVInt();
|
|
||||||
bufferPools = new ArrayList<>(size);
|
|
||||||
for (int i = 0; i < size; i++) {
|
|
||||||
BufferPool bufferPool = new BufferPool();
|
|
||||||
bufferPool.readFrom(in);
|
|
||||||
bufferPools.add(bufferPool);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeTo(StreamOutput out) throws IOException {
|
|
||||||
out.writeVLong(timestamp);
|
|
||||||
out.writeVLong(uptime);
|
|
||||||
|
|
||||||
mem.writeTo(out);
|
|
||||||
threads.writeTo(out);
|
|
||||||
gc.writeTo(out);
|
|
||||||
|
|
||||||
if (bufferPools == null) {
|
|
||||||
out.writeBoolean(false);
|
|
||||||
} else {
|
|
||||||
out.writeBoolean(true);
|
|
||||||
out.writeVInt(bufferPools.size());
|
|
||||||
for (BufferPool bufferPool : bufferPools) {
|
|
||||||
bufferPool.writeTo(out);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class GarbageCollectors implements Streamable, Iterable<GarbageCollector> {
|
|
||||||
|
|
||||||
GarbageCollector[] collectors;
|
|
||||||
|
|
||||||
GarbageCollectors() {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GarbageCollectors readGarbageCollectors(StreamInput in) throws IOException {
|
public GarbageCollectors(StreamInput in) throws IOException {
|
||||||
GarbageCollectors collectors = new GarbageCollectors();
|
collectors = in.readArray(GarbageCollector::new, GarbageCollector[]::new);
|
||||||
collectors.readFrom(in);
|
|
||||||
return collectors;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void readFrom(StreamInput in) throws IOException {
|
|
||||||
collectors = new GarbageCollector[in.readVInt()];
|
|
||||||
for (int i = 0; i < collectors.length; i++) {
|
|
||||||
collectors[i] = GarbageCollector.readGarbageCollector(in);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeTo(StreamOutput out) throws IOException {
|
public void writeTo(StreamOutput out) throws IOException {
|
||||||
out.writeVInt(collectors.length);
|
out.writeArray(collectors);
|
||||||
for (GarbageCollector gc : collectors) {
|
|
||||||
gc.writeTo(out);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public GarbageCollector[] getCollectors() {
|
public GarbageCollector[] getCollectors() {
|
||||||
@ -387,23 +335,19 @@ public class JvmStats implements Streamable, ToXContent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class GarbageCollector implements Streamable {
|
public static class GarbageCollector implements Writeable {
|
||||||
|
|
||||||
String name;
|
private final String name;
|
||||||
long collectionCount;
|
private final long collectionCount;
|
||||||
long collectionTime;
|
private final long collectionTime;
|
||||||
|
|
||||||
GarbageCollector() {
|
public GarbageCollector(String name, long collectionCount, long collectionTime) {
|
||||||
|
this.name = name;
|
||||||
|
this.collectionCount = collectionCount;
|
||||||
|
this.collectionTime = collectionTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GarbageCollector readGarbageCollector(StreamInput in) throws IOException {
|
public GarbageCollector(StreamInput in) throws IOException {
|
||||||
GarbageCollector gc = new GarbageCollector();
|
|
||||||
gc.readFrom(in);
|
|
||||||
return gc;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void readFrom(StreamInput in) throws IOException {
|
|
||||||
name = in.readString();
|
name = in.readString();
|
||||||
collectionCount = in.readVLong();
|
collectionCount = in.readVLong();
|
||||||
collectionTime = in.readVLong();
|
collectionTime = in.readVLong();
|
||||||
@ -429,30 +373,17 @@ public class JvmStats implements Streamable, ToXContent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Threads implements Streamable {
|
public static class Threads implements Writeable {
|
||||||
|
|
||||||
int count;
|
private final int count;
|
||||||
int peakCount;
|
private final int peakCount;
|
||||||
|
|
||||||
Threads() {
|
public Threads(int count, int peakCount) {
|
||||||
|
this.count = count;
|
||||||
|
this.peakCount = peakCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCount() {
|
public Threads(StreamInput in) throws IOException {
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPeakCount() {
|
|
||||||
return peakCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Threads readThreads(StreamInput in) throws IOException {
|
|
||||||
Threads threads = new Threads();
|
|
||||||
threads.readFrom(in);
|
|
||||||
return threads;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void readFrom(StreamInput in) throws IOException {
|
|
||||||
count = in.readVInt();
|
count = in.readVInt();
|
||||||
peakCount = in.readVInt();
|
peakCount = in.readVInt();
|
||||||
}
|
}
|
||||||
@ -462,20 +393,23 @@ public class JvmStats implements Streamable, ToXContent {
|
|||||||
out.writeVInt(count);
|
out.writeVInt(count);
|
||||||
out.writeVInt(peakCount);
|
out.writeVInt(peakCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getCount() {
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPeakCount() {
|
||||||
|
return peakCount;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class MemoryPool implements Streamable {
|
public static class MemoryPool implements Writeable {
|
||||||
|
|
||||||
String name;
|
private final String name;
|
||||||
long used;
|
private final long used;
|
||||||
long max;
|
private final long max;
|
||||||
|
private final long peakUsed;
|
||||||
long peakUsed;
|
private final long peakMax;
|
||||||
long peakMax;
|
|
||||||
|
|
||||||
MemoryPool() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public MemoryPool(String name, long used, long max, long peakUsed, long peakMax) {
|
public MemoryPool(String name, long used, long max, long peakUsed, long peakMax) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
@ -485,10 +419,21 @@ public class JvmStats implements Streamable, ToXContent {
|
|||||||
this.peakMax = peakMax;
|
this.peakMax = peakMax;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MemoryPool readMemoryPool(StreamInput in) throws IOException {
|
public MemoryPool(StreamInput in) throws IOException {
|
||||||
MemoryPool pool = new MemoryPool();
|
name = in.readString();
|
||||||
pool.readFrom(in);
|
used = in.readVLong();
|
||||||
return pool;
|
max = in.readVLong();
|
||||||
|
peakUsed = in.readVLong();
|
||||||
|
peakMax = in.readVLong();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeTo(StreamOutput out) throws IOException {
|
||||||
|
out.writeString(name);
|
||||||
|
out.writeVLong(used);
|
||||||
|
out.writeVLong(max);
|
||||||
|
out.writeVLong(peakUsed);
|
||||||
|
out.writeVLong(peakMax);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
@ -510,61 +455,33 @@ public class JvmStats implements Streamable, ToXContent {
|
|||||||
public ByteSizeValue getPeakMax() {
|
public ByteSizeValue getPeakMax() {
|
||||||
return new ByteSizeValue(peakMax);
|
return new ByteSizeValue(peakMax);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void readFrom(StreamInput in) throws IOException {
|
|
||||||
name = in.readString();
|
|
||||||
used = in.readVLong();
|
|
||||||
max = in.readVLong();
|
|
||||||
peakUsed = in.readVLong();
|
|
||||||
peakMax = in.readVLong();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeTo(StreamOutput out) throws IOException {
|
|
||||||
out.writeString(name);
|
|
||||||
out.writeVLong(used);
|
|
||||||
out.writeVLong(max);
|
|
||||||
out.writeVLong(peakUsed);
|
|
||||||
out.writeVLong(peakMax);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Mem implements Streamable, Iterable<MemoryPool> {
|
public static class Mem implements Writeable, Iterable<MemoryPool> {
|
||||||
|
|
||||||
long heapCommitted;
|
private final long heapCommitted;
|
||||||
long heapUsed;
|
private final long heapUsed;
|
||||||
long heapMax;
|
private final long heapMax;
|
||||||
long nonHeapCommitted;
|
private final long nonHeapCommitted;
|
||||||
long nonHeapUsed;
|
private final long nonHeapUsed;
|
||||||
|
private final List<MemoryPool> pools;
|
||||||
|
|
||||||
MemoryPool[] pools = new MemoryPool[0];
|
public Mem(long heapCommitted, long heapUsed, long heapMax, long nonHeapCommitted, long nonHeapUsed, List<MemoryPool> pools) {
|
||||||
|
this.heapCommitted = heapCommitted;
|
||||||
Mem() {
|
this.heapUsed = heapUsed;
|
||||||
|
this.heapMax = heapMax;
|
||||||
|
this.nonHeapCommitted = nonHeapCommitted;
|
||||||
|
this.nonHeapUsed = nonHeapUsed;
|
||||||
|
this.pools = pools;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Mem readMem(StreamInput in) throws IOException {
|
public Mem(StreamInput in) throws IOException {
|
||||||
Mem mem = new Mem();
|
|
||||||
mem.readFrom(in);
|
|
||||||
return mem;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Iterator<MemoryPool> iterator() {
|
|
||||||
return Arrays.stream(pools).iterator();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void readFrom(StreamInput in) throws IOException {
|
|
||||||
heapCommitted = in.readVLong();
|
heapCommitted = in.readVLong();
|
||||||
heapUsed = in.readVLong();
|
heapUsed = in.readVLong();
|
||||||
nonHeapCommitted = in.readVLong();
|
nonHeapCommitted = in.readVLong();
|
||||||
nonHeapUsed = in.readVLong();
|
nonHeapUsed = in.readVLong();
|
||||||
heapMax = in.readVLong();
|
heapMax = in.readVLong();
|
||||||
pools = new MemoryPool[in.readVInt()];
|
pools = in.readList(MemoryPool::new);
|
||||||
for (int i = 0; i < pools.length; i++) {
|
|
||||||
pools[i] = MemoryPool.readMemoryPool(in);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -574,10 +491,12 @@ public class JvmStats implements Streamable, ToXContent {
|
|||||||
out.writeVLong(nonHeapCommitted);
|
out.writeVLong(nonHeapCommitted);
|
||||||
out.writeVLong(nonHeapUsed);
|
out.writeVLong(nonHeapUsed);
|
||||||
out.writeVLong(heapMax);
|
out.writeVLong(heapMax);
|
||||||
out.writeVInt(pools.length);
|
out.writeList(pools);
|
||||||
for (MemoryPool pool : pools) {
|
}
|
||||||
pool.writeTo(out);
|
|
||||||
}
|
@Override
|
||||||
|
public Iterator<MemoryPool> iterator() {
|
||||||
|
return pools.iterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ByteSizeValue getHeapCommitted() {
|
public ByteSizeValue getHeapCommitted() {
|
||||||
@ -614,15 +533,12 @@ public class JvmStats implements Streamable, ToXContent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class BufferPool implements Streamable {
|
public static class BufferPool implements Writeable {
|
||||||
|
|
||||||
String name;
|
private final String name;
|
||||||
long count;
|
private final long count;
|
||||||
long totalCapacity;
|
private final long totalCapacity;
|
||||||
long used;
|
private final long used;
|
||||||
|
|
||||||
BufferPool() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public BufferPool(String name, long count, long totalCapacity, long used) {
|
public BufferPool(String name, long count, long totalCapacity, long used) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
@ -631,6 +547,21 @@ public class JvmStats implements Streamable, ToXContent {
|
|||||||
this.used = used;
|
this.used = used;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BufferPool(StreamInput in) throws IOException {
|
||||||
|
name = in.readString();
|
||||||
|
count = in.readLong();
|
||||||
|
totalCapacity = in.readLong();
|
||||||
|
used = in.readLong();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeTo(StreamOutput out) throws IOException {
|
||||||
|
out.writeString(name);
|
||||||
|
out.writeLong(count);
|
||||||
|
out.writeLong(totalCapacity);
|
||||||
|
out.writeLong(used);
|
||||||
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
@ -646,32 +577,13 @@ public class JvmStats implements Streamable, ToXContent {
|
|||||||
public ByteSizeValue getUsed() {
|
public ByteSizeValue getUsed() {
|
||||||
return new ByteSizeValue(used);
|
return new ByteSizeValue(used);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void readFrom(StreamInput in) throws IOException {
|
|
||||||
name = in.readString();
|
|
||||||
count = in.readLong();
|
|
||||||
totalCapacity = in.readLong();
|
|
||||||
used = in.readLong();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeTo(StreamOutput out) throws IOException {
|
|
||||||
out.writeString(name);
|
|
||||||
out.writeLong(count);
|
|
||||||
out.writeLong(totalCapacity);
|
|
||||||
out.writeLong(used);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Classes implements Streamable {
|
public static class Classes implements Writeable {
|
||||||
|
|
||||||
long loadedClassCount;
|
private final long loadedClassCount;
|
||||||
long totalLoadedClassCount;
|
private final long totalLoadedClassCount;
|
||||||
long unloadedClassCount;
|
private final long unloadedClassCount;
|
||||||
|
|
||||||
Classes() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public Classes(long loadedClassCount, long totalLoadedClassCount, long unloadedClassCount) {
|
public Classes(long loadedClassCount, long totalLoadedClassCount, long unloadedClassCount) {
|
||||||
this.loadedClassCount = loadedClassCount;
|
this.loadedClassCount = loadedClassCount;
|
||||||
@ -679,6 +591,19 @@ public class JvmStats implements Streamable, ToXContent {
|
|||||||
this.unloadedClassCount = unloadedClassCount;
|
this.unloadedClassCount = unloadedClassCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Classes(StreamInput in) throws IOException {
|
||||||
|
loadedClassCount = in.readLong();
|
||||||
|
totalLoadedClassCount = in.readLong();
|
||||||
|
unloadedClassCount = in.readLong();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeTo(StreamOutput out) throws IOException {
|
||||||
|
out.writeLong(loadedClassCount);
|
||||||
|
out.writeLong(totalLoadedClassCount);
|
||||||
|
out.writeLong(unloadedClassCount);
|
||||||
|
}
|
||||||
|
|
||||||
public long getLoadedClassCount() {
|
public long getLoadedClassCount() {
|
||||||
return loadedClassCount;
|
return loadedClassCount;
|
||||||
}
|
}
|
||||||
@ -690,19 +615,5 @@ public class JvmStats implements Streamable, ToXContent {
|
|||||||
public long getUnloadedClassCount() {
|
public long getUnloadedClassCount() {
|
||||||
return unloadedClassCount;
|
return unloadedClassCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void readFrom(StreamInput in) throws IOException {
|
|
||||||
loadedClassCount = in.readLong();
|
|
||||||
totalLoadedClassCount = in.readLong();
|
|
||||||
unloadedClassCount = in.readLong();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeTo(StreamOutput out) throws IOException {
|
|
||||||
out.writeLong(loadedClassCount);
|
|
||||||
out.writeLong(totalLoadedClassCount);
|
|
||||||
out.writeLong(unloadedClassCount);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -131,21 +131,9 @@ public class ProcessProbe {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ProcessStats processStats() {
|
public ProcessStats processStats() {
|
||||||
ProcessStats stats = new ProcessStats();
|
ProcessStats.Cpu cpu = new ProcessStats.Cpu(getProcessCpuPercent(), getProcessCpuTotalTime());
|
||||||
stats.timestamp = System.currentTimeMillis();
|
ProcessStats.Mem mem = new ProcessStats.Mem(getTotalVirtualMemorySize());
|
||||||
stats.openFileDescriptors = getOpenFileDescriptorCount();
|
return new ProcessStats(System.currentTimeMillis(), getOpenFileDescriptorCount(), getMaxFileDescriptorCount(), cpu, mem);
|
||||||
stats.maxFileDescriptors = getMaxFileDescriptorCount();
|
|
||||||
|
|
||||||
ProcessStats.Cpu cpu = new ProcessStats.Cpu();
|
|
||||||
cpu.percent = getProcessCpuPercent();
|
|
||||||
cpu.total = getProcessCpuTotalTime();
|
|
||||||
stats.cpu = cpu;
|
|
||||||
|
|
||||||
ProcessStats.Mem mem = new ProcessStats.Mem();
|
|
||||||
mem.totalVirtual = getTotalVirtualMemorySize();
|
|
||||||
stats.mem = mem;
|
|
||||||
|
|
||||||
return stats;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -21,7 +21,7 @@ package org.elasticsearch.monitor.process;
|
|||||||
|
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||||
import org.elasticsearch.common.io.stream.Streamable;
|
import org.elasticsearch.common.io.stream.Writeable;
|
||||||
import org.elasticsearch.common.unit.ByteSizeValue;
|
import org.elasticsearch.common.unit.ByteSizeValue;
|
||||||
import org.elasticsearch.common.unit.TimeValue;
|
import org.elasticsearch.common.unit.TimeValue;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContent;
|
||||||
@ -29,18 +29,37 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class ProcessStats implements Streamable, ToXContent {
|
public class ProcessStats implements Writeable, ToXContent {
|
||||||
|
|
||||||
long timestamp = -1;
|
private final long timestamp;
|
||||||
|
private final long openFileDescriptors;
|
||||||
|
private final long maxFileDescriptors;
|
||||||
|
private final Cpu cpu;
|
||||||
|
private final Mem mem;
|
||||||
|
|
||||||
long openFileDescriptors = -1;
|
public ProcessStats(long timestamp, long openFileDescriptors, long maxFileDescriptors, Cpu cpu, Mem mem) {
|
||||||
long maxFileDescriptors = -1;
|
this.timestamp = timestamp;
|
||||||
|
this.openFileDescriptors = openFileDescriptors;
|
||||||
|
this.maxFileDescriptors = maxFileDescriptors;
|
||||||
|
this.cpu = cpu;
|
||||||
|
this.mem = mem;
|
||||||
|
}
|
||||||
|
|
||||||
Cpu cpu = null;
|
public ProcessStats(StreamInput in) throws IOException {
|
||||||
|
timestamp = in.readVLong();
|
||||||
|
openFileDescriptors = in.readLong();
|
||||||
|
maxFileDescriptors = in.readLong();
|
||||||
|
cpu = in.readOptionalWriteable(Cpu::new);
|
||||||
|
mem = in.readOptionalWriteable(Mem::new);
|
||||||
|
}
|
||||||
|
|
||||||
Mem mem = null;
|
@Override
|
||||||
|
public void writeTo(StreamOutput out) throws IOException {
|
||||||
ProcessStats() {
|
out.writeVLong(timestamp);
|
||||||
|
out.writeLong(openFileDescriptors);
|
||||||
|
out.writeLong(maxFileDescriptors);
|
||||||
|
out.writeOptionalWriteable(cpu);
|
||||||
|
out.writeOptionalWriteable(mem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getTimestamp() {
|
public long getTimestamp() {
|
||||||
@ -100,59 +119,15 @@ public class ProcessStats implements Streamable, ToXContent {
|
|||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ProcessStats readProcessStats(StreamInput in) throws IOException {
|
public static class Mem implements Writeable {
|
||||||
ProcessStats stats = new ProcessStats();
|
|
||||||
stats.readFrom(in);
|
|
||||||
return stats;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
private final long totalVirtual;
|
||||||
public void readFrom(StreamInput in) throws IOException {
|
|
||||||
timestamp = in.readVLong();
|
|
||||||
openFileDescriptors = in.readLong();
|
|
||||||
maxFileDescriptors = in.readLong();
|
|
||||||
if (in.readBoolean()) {
|
|
||||||
cpu = Cpu.readCpu(in);
|
|
||||||
}
|
|
||||||
if (in.readBoolean()) {
|
|
||||||
mem = Mem.readMem(in);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
public Mem(long totalVirtual) {
|
||||||
public void writeTo(StreamOutput out) throws IOException {
|
this.totalVirtual = totalVirtual;
|
||||||
out.writeVLong(timestamp);
|
|
||||||
out.writeLong(openFileDescriptors);
|
|
||||||
out.writeLong(maxFileDescriptors);
|
|
||||||
if (cpu == null) {
|
|
||||||
out.writeBoolean(false);
|
|
||||||
} else {
|
|
||||||
out.writeBoolean(true);
|
|
||||||
cpu.writeTo(out);
|
|
||||||
}
|
|
||||||
if (mem == null) {
|
|
||||||
out.writeBoolean(false);
|
|
||||||
} else {
|
|
||||||
out.writeBoolean(true);
|
|
||||||
mem.writeTo(out);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Mem implements Streamable {
|
|
||||||
|
|
||||||
long totalVirtual = -1;
|
|
||||||
|
|
||||||
Mem() {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Mem readMem(StreamInput in) throws IOException {
|
public Mem(StreamInput in) throws IOException {
|
||||||
Mem mem = new Mem();
|
|
||||||
mem.readFrom(in);
|
|
||||||
return mem;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void readFrom(StreamInput in) throws IOException {
|
|
||||||
totalVirtual = in.readLong();
|
totalVirtual = in.readLong();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,23 +141,17 @@ public class ProcessStats implements Streamable, ToXContent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Cpu implements Streamable {
|
public static class Cpu implements Writeable {
|
||||||
|
|
||||||
short percent = -1;
|
private final short percent;
|
||||||
long total = -1;
|
private final long total;
|
||||||
|
|
||||||
Cpu() {
|
|
||||||
|
|
||||||
|
public Cpu(short percent, long total) {
|
||||||
|
this.percent = percent;
|
||||||
|
this.total = total;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Cpu readCpu(StreamInput in) throws IOException {
|
public Cpu(StreamInput in) throws IOException {
|
||||||
Cpu cpu = new Cpu();
|
|
||||||
cpu.readFrom(in);
|
|
||||||
return cpu;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void readFrom(StreamInput in) throws IOException {
|
|
||||||
percent = in.readShort();
|
percent = in.readShort();
|
||||||
total = in.readLong();
|
total = in.readLong();
|
||||||
}
|
}
|
||||||
|
@ -21,39 +21,22 @@ package org.elasticsearch.script;
|
|||||||
|
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||||
import org.elasticsearch.common.io.stream.Streamable;
|
import org.elasticsearch.common.io.stream.Writeable;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContent;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class ScriptStats implements Streamable, ToXContent {
|
public class ScriptStats implements Writeable, ToXContent {
|
||||||
private long compilations;
|
private final long compilations;
|
||||||
private long cacheEvictions;
|
private final long cacheEvictions;
|
||||||
|
|
||||||
public ScriptStats() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public ScriptStats(long compilations, long cacheEvictions) {
|
public ScriptStats(long compilations, long cacheEvictions) {
|
||||||
this.compilations = compilations;
|
this.compilations = compilations;
|
||||||
this.cacheEvictions = cacheEvictions;
|
this.cacheEvictions = cacheEvictions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void add(ScriptStats stats) {
|
public ScriptStats(StreamInput in) throws IOException {
|
||||||
this.compilations += stats.compilations;
|
|
||||||
this.cacheEvictions += stats.cacheEvictions;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getCompilations() {
|
|
||||||
return compilations;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getCacheEvictions() {
|
|
||||||
return cacheEvictions;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void readFrom(StreamInput in) throws IOException {
|
|
||||||
compilations = in.readVLong();
|
compilations = in.readVLong();
|
||||||
cacheEvictions = in.readVLong();
|
cacheEvictions = in.readVLong();
|
||||||
}
|
}
|
||||||
@ -64,6 +47,14 @@ public class ScriptStats implements Streamable, ToXContent {
|
|||||||
out.writeVLong(cacheEvictions);
|
out.writeVLong(cacheEvictions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getCompilations() {
|
||||||
|
return compilations;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getCacheEvictions() {
|
||||||
|
return cacheEvictions;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||||
builder.startObject(Fields.SCRIPT_STATS);
|
builder.startObject(Fields.SCRIPT_STATS);
|
||||||
|
@ -21,33 +21,26 @@ package org.elasticsearch.threadpool;
|
|||||||
|
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||||
import org.elasticsearch.common.io.stream.Streamable;
|
import org.elasticsearch.common.io.stream.Writeable;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContent;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
public class ThreadPoolStats implements Writeable, ToXContent, Iterable<ThreadPoolStats.Stats> {
|
||||||
*/
|
|
||||||
public class ThreadPoolStats implements Streamable, ToXContent, Iterable<ThreadPoolStats.Stats> {
|
|
||||||
|
|
||||||
public static class Stats implements Streamable, ToXContent, Comparable<Stats> {
|
public static class Stats implements Writeable, ToXContent, Comparable<Stats> {
|
||||||
|
|
||||||
private String name;
|
private final String name;
|
||||||
private int threads;
|
private final int threads;
|
||||||
private int queue;
|
private final int queue;
|
||||||
private int active;
|
private final int active;
|
||||||
private long rejected;
|
private final long rejected;
|
||||||
private int largest;
|
private final int largest;
|
||||||
private long completed;
|
private final long completed;
|
||||||
|
|
||||||
Stats() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public Stats(String name, int threads, int queue, int active, long rejected, int largest, long completed) {
|
public Stats(String name, int threads, int queue, int active, long rejected, int largest, long completed) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
@ -59,6 +52,27 @@ public class ThreadPoolStats implements Streamable, ToXContent, Iterable<ThreadP
|
|||||||
this.completed = completed;
|
this.completed = completed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Stats(StreamInput in) throws IOException {
|
||||||
|
name = in.readString();
|
||||||
|
threads = in.readInt();
|
||||||
|
queue = in.readInt();
|
||||||
|
active = in.readInt();
|
||||||
|
rejected = in.readLong();
|
||||||
|
largest = in.readInt();
|
||||||
|
completed = in.readLong();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeTo(StreamOutput out) throws IOException {
|
||||||
|
out.writeString(name);
|
||||||
|
out.writeInt(threads);
|
||||||
|
out.writeInt(queue);
|
||||||
|
out.writeInt(active);
|
||||||
|
out.writeLong(rejected);
|
||||||
|
out.writeInt(largest);
|
||||||
|
out.writeLong(completed);
|
||||||
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
@ -87,28 +101,6 @@ public class ThreadPoolStats implements Streamable, ToXContent, Iterable<ThreadP
|
|||||||
return this.completed;
|
return this.completed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void readFrom(StreamInput in) throws IOException {
|
|
||||||
name = in.readString();
|
|
||||||
threads = in.readInt();
|
|
||||||
queue = in.readInt();
|
|
||||||
active = in.readInt();
|
|
||||||
rejected = in.readLong();
|
|
||||||
largest = in.readInt();
|
|
||||||
completed = in.readLong();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeTo(StreamOutput out) throws IOException {
|
|
||||||
out.writeString(name);
|
|
||||||
out.writeInt(threads);
|
|
||||||
out.writeInt(queue);
|
|
||||||
out.writeInt(active);
|
|
||||||
out.writeLong(rejected);
|
|
||||||
out.writeInt(largest);
|
|
||||||
out.writeLong(completed);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||||
builder.startObject(name);
|
builder.startObject(name);
|
||||||
@ -154,43 +146,23 @@ public class ThreadPoolStats implements Streamable, ToXContent, Iterable<ThreadP
|
|||||||
|
|
||||||
private List<Stats> stats;
|
private List<Stats> stats;
|
||||||
|
|
||||||
ThreadPoolStats() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public ThreadPoolStats(List<Stats> stats) {
|
public ThreadPoolStats(List<Stats> stats) {
|
||||||
Collections.sort(stats);
|
Collections.sort(stats);
|
||||||
this.stats = stats;
|
this.stats = stats;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public ThreadPoolStats(StreamInput in) throws IOException {
|
||||||
public Iterator<Stats> iterator() {
|
stats = in.readList(Stats::new);
|
||||||
return stats.iterator();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ThreadPoolStats readThreadPoolStats(StreamInput in) throws IOException {
|
|
||||||
ThreadPoolStats stats = new ThreadPoolStats();
|
|
||||||
stats.readFrom(in);
|
|
||||||
return stats;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void readFrom(StreamInput in) throws IOException {
|
|
||||||
int size = in.readVInt();
|
|
||||||
stats = new ArrayList<>(size);
|
|
||||||
for (int i = 0; i < size; i++) {
|
|
||||||
Stats stats1 = new Stats();
|
|
||||||
stats1.readFrom(in);
|
|
||||||
stats.add(stats1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeTo(StreamOutput out) throws IOException {
|
public void writeTo(StreamOutput out) throws IOException {
|
||||||
out.writeVInt(stats.size());
|
out.writeList(stats);
|
||||||
for (Stats stat : stats) {
|
}
|
||||||
stat.writeTo(out);
|
|
||||||
}
|
@Override
|
||||||
|
public Iterator<Stats> iterator() {
|
||||||
|
return stats.iterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
static final class Fields {
|
static final class Fields {
|
||||||
|
@ -21,24 +21,20 @@ package org.elasticsearch.transport;
|
|||||||
|
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||||
import org.elasticsearch.common.io.stream.Streamable;
|
import org.elasticsearch.common.io.stream.Writeable;
|
||||||
import org.elasticsearch.common.unit.ByteSizeValue;
|
import org.elasticsearch.common.unit.ByteSizeValue;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContent;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class TransportStats implements Streamable, ToXContent {
|
public class TransportStats implements Writeable, ToXContent {
|
||||||
|
|
||||||
private long serverOpen;
|
private final long serverOpen;
|
||||||
private long rxCount;
|
private final long rxCount;
|
||||||
private long rxSize;
|
private final long rxSize;
|
||||||
private long txCount;
|
private final long txCount;
|
||||||
private long txSize;
|
private final long txSize;
|
||||||
|
|
||||||
TransportStats() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public TransportStats(long serverOpen, long rxCount, long rxSize, long txCount, long txSize) {
|
public TransportStats(long serverOpen, long rxCount, long rxSize, long txCount, long txSize) {
|
||||||
this.serverOpen = serverOpen;
|
this.serverOpen = serverOpen;
|
||||||
@ -48,6 +44,23 @@ public class TransportStats implements Streamable, ToXContent {
|
|||||||
this.txSize = txSize;
|
this.txSize = txSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TransportStats(StreamInput in) throws IOException {
|
||||||
|
serverOpen = in.readVLong();
|
||||||
|
rxCount = in.readVLong();
|
||||||
|
rxSize = in.readVLong();
|
||||||
|
txCount = in.readVLong();
|
||||||
|
txSize = in.readVLong();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeTo(StreamOutput out) throws IOException {
|
||||||
|
out.writeVLong(serverOpen);
|
||||||
|
out.writeVLong(rxCount);
|
||||||
|
out.writeVLong(rxSize);
|
||||||
|
out.writeVLong(txCount);
|
||||||
|
out.writeVLong(txSize);
|
||||||
|
}
|
||||||
|
|
||||||
public long serverOpen() {
|
public long serverOpen() {
|
||||||
return this.serverOpen;
|
return this.serverOpen;
|
||||||
}
|
}
|
||||||
@ -88,30 +101,6 @@ public class TransportStats implements Streamable, ToXContent {
|
|||||||
return txSize();
|
return txSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TransportStats readTransportStats(StreamInput in) throws IOException {
|
|
||||||
TransportStats stats = new TransportStats();
|
|
||||||
stats.readFrom(in);
|
|
||||||
return stats;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void readFrom(StreamInput in) throws IOException {
|
|
||||||
serverOpen = in.readVLong();
|
|
||||||
rxCount = in.readVLong();
|
|
||||||
rxSize = in.readVLong();
|
|
||||||
txCount = in.readVLong();
|
|
||||||
txSize = in.readVLong();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeTo(StreamOutput out) throws IOException {
|
|
||||||
out.writeVLong(serverOpen);
|
|
||||||
out.writeVLong(rxCount);
|
|
||||||
out.writeVLong(rxSize);
|
|
||||||
out.writeVLong(txCount);
|
|
||||||
out.writeVLong(txSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||||
builder.startObject(Fields.TRANSPORT);
|
builder.startObject(Fields.TRANSPORT);
|
||||||
|
@ -0,0 +1,364 @@
|
|||||||
|
/*
|
||||||
|
* Licensed to Elasticsearch under one or more contributor
|
||||||
|
* license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright
|
||||||
|
* ownership. Elasticsearch licenses this file to you under
|
||||||
|
* the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
* not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.elasticsearch.action.admin.cluster.node.stats;
|
||||||
|
|
||||||
|
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||||
|
import org.elasticsearch.common.io.stream.BytesStreamOutput;
|
||||||
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
|
import org.elasticsearch.common.transport.LocalTransportAddress;
|
||||||
|
import org.elasticsearch.discovery.DiscoveryStats;
|
||||||
|
import org.elasticsearch.discovery.zen.publish.PendingClusterStateStats;
|
||||||
|
import org.elasticsearch.http.HttpStats;
|
||||||
|
import org.elasticsearch.indices.breaker.AllCircuitBreakerStats;
|
||||||
|
import org.elasticsearch.indices.breaker.CircuitBreakerStats;
|
||||||
|
import org.elasticsearch.ingest.IngestStats;
|
||||||
|
import org.elasticsearch.monitor.fs.FsInfo;
|
||||||
|
import org.elasticsearch.monitor.jvm.JvmStats;
|
||||||
|
import org.elasticsearch.monitor.os.OsStats;
|
||||||
|
import org.elasticsearch.monitor.process.ProcessStats;
|
||||||
|
import org.elasticsearch.script.ScriptStats;
|
||||||
|
import org.elasticsearch.test.ESTestCase;
|
||||||
|
import org.elasticsearch.test.VersionUtils;
|
||||||
|
import org.elasticsearch.threadpool.ThreadPoolStats;
|
||||||
|
import org.elasticsearch.transport.TransportStats;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static java.util.Collections.emptyMap;
|
||||||
|
import static java.util.Collections.emptySet;
|
||||||
|
|
||||||
|
public class NodeStatsTests extends ESTestCase {
|
||||||
|
|
||||||
|
public void testSerialization() throws IOException {
|
||||||
|
NodeStats nodeStats = createNodeStats();
|
||||||
|
try (BytesStreamOutput out = new BytesStreamOutput()) {
|
||||||
|
nodeStats.writeTo(out);
|
||||||
|
try (StreamInput in = out.bytes().streamInput()) {
|
||||||
|
NodeStats deserializedNodeStats = NodeStats.readNodeStats(in);
|
||||||
|
assertEquals(nodeStats.getNode(), deserializedNodeStats.getNode());
|
||||||
|
assertEquals(nodeStats.getTimestamp(), deserializedNodeStats.getTimestamp());
|
||||||
|
if (nodeStats.getOs() == null) {
|
||||||
|
assertNull(deserializedNodeStats.getOs());
|
||||||
|
} else {
|
||||||
|
assertEquals(nodeStats.getOs().getTimestamp(), deserializedNodeStats.getOs().getTimestamp());
|
||||||
|
assertEquals(nodeStats.getOs().getSwap().getFree(), deserializedNodeStats.getOs().getSwap().getFree());
|
||||||
|
assertEquals(nodeStats.getOs().getSwap().getTotal(), deserializedNodeStats.getOs().getSwap().getTotal());
|
||||||
|
assertEquals(nodeStats.getOs().getSwap().getUsed(), deserializedNodeStats.getOs().getSwap().getUsed());
|
||||||
|
assertEquals(nodeStats.getOs().getMem().getFree(), deserializedNodeStats.getOs().getMem().getFree());
|
||||||
|
assertEquals(nodeStats.getOs().getMem().getTotal(), deserializedNodeStats.getOs().getMem().getTotal());
|
||||||
|
assertEquals(nodeStats.getOs().getMem().getUsed(), deserializedNodeStats.getOs().getMem().getUsed());
|
||||||
|
assertEquals(nodeStats.getOs().getMem().getFreePercent(), deserializedNodeStats.getOs().getMem().getFreePercent());
|
||||||
|
assertEquals(nodeStats.getOs().getMem().getUsedPercent(), deserializedNodeStats.getOs().getMem().getUsedPercent());
|
||||||
|
assertEquals(nodeStats.getOs().getCpu().getPercent(), deserializedNodeStats.getOs().getCpu().getPercent());
|
||||||
|
assertArrayEquals(nodeStats.getOs().getCpu().getLoadAverage(),
|
||||||
|
deserializedNodeStats.getOs().getCpu().getLoadAverage(), 0);
|
||||||
|
}
|
||||||
|
if (nodeStats.getProcess() == null) {
|
||||||
|
assertNull(deserializedNodeStats.getProcess());
|
||||||
|
} else {
|
||||||
|
assertEquals(nodeStats.getProcess().getTimestamp(), deserializedNodeStats.getProcess().getTimestamp());
|
||||||
|
assertEquals(nodeStats.getProcess().getCpu().getTotal(), deserializedNodeStats.getProcess().getCpu().getTotal());
|
||||||
|
assertEquals(nodeStats.getProcess().getCpu().getPercent(), deserializedNodeStats.getProcess().getCpu().getPercent());
|
||||||
|
assertEquals(nodeStats.getProcess().getMem().getTotalVirtual(),
|
||||||
|
deserializedNodeStats.getProcess().getMem().getTotalVirtual());
|
||||||
|
assertEquals(nodeStats.getProcess().getMaxFileDescriptors(),
|
||||||
|
deserializedNodeStats.getProcess().getMaxFileDescriptors());
|
||||||
|
assertEquals(nodeStats.getProcess().getOpenFileDescriptors(),
|
||||||
|
deserializedNodeStats.getProcess().getOpenFileDescriptors());
|
||||||
|
}
|
||||||
|
JvmStats jvm = nodeStats.getJvm();
|
||||||
|
JvmStats deserializedJvm = deserializedNodeStats.getJvm();
|
||||||
|
if (jvm == null) {
|
||||||
|
assertNull(deserializedJvm);
|
||||||
|
} else {
|
||||||
|
JvmStats.Mem mem = jvm.getMem();
|
||||||
|
JvmStats.Mem deserializedMem = deserializedJvm.getMem();
|
||||||
|
assertEquals(jvm.getTimestamp(), deserializedJvm.getTimestamp());
|
||||||
|
assertEquals(mem.getHeapUsedPercent(), deserializedMem.getHeapUsedPercent());
|
||||||
|
assertEquals(mem.getHeapUsed(), deserializedMem.getHeapUsed());
|
||||||
|
assertEquals(mem.getHeapCommitted(), deserializedMem.getHeapCommitted());
|
||||||
|
assertEquals(mem.getNonHeapCommitted(), deserializedMem.getNonHeapCommitted());
|
||||||
|
assertEquals(mem.getNonHeapUsed(), deserializedMem.getNonHeapUsed());
|
||||||
|
assertEquals(mem.getHeapMax(), deserializedMem.getHeapMax());
|
||||||
|
JvmStats.Classes classes = jvm.getClasses();
|
||||||
|
assertEquals(classes.getLoadedClassCount(), deserializedJvm.getClasses().getLoadedClassCount());
|
||||||
|
assertEquals(classes.getTotalLoadedClassCount(), deserializedJvm.getClasses().getTotalLoadedClassCount());
|
||||||
|
assertEquals(classes.getUnloadedClassCount(), deserializedJvm.getClasses().getUnloadedClassCount());
|
||||||
|
assertEquals(jvm.getGc().getCollectors().length, deserializedJvm.getGc().getCollectors().length);
|
||||||
|
for (int i = 0; i < jvm.getGc().getCollectors().length; i++) {
|
||||||
|
JvmStats.GarbageCollector garbageCollector = jvm.getGc().getCollectors()[i];
|
||||||
|
JvmStats.GarbageCollector deserializedGarbageCollector = deserializedJvm.getGc().getCollectors()[i];
|
||||||
|
assertEquals(garbageCollector.getName(), deserializedGarbageCollector.getName());
|
||||||
|
assertEquals(garbageCollector.getCollectionCount(), deserializedGarbageCollector.getCollectionCount());
|
||||||
|
assertEquals(garbageCollector.getCollectionTime(), deserializedGarbageCollector.getCollectionTime());
|
||||||
|
}
|
||||||
|
assertEquals(jvm.getThreads().getCount(), deserializedJvm.getThreads().getCount());
|
||||||
|
assertEquals(jvm.getThreads().getPeakCount(), deserializedJvm.getThreads().getPeakCount());
|
||||||
|
assertEquals(jvm.getUptime(), deserializedJvm.getUptime());
|
||||||
|
if (jvm.getBufferPools() == null) {
|
||||||
|
assertNull(deserializedJvm.getBufferPools());
|
||||||
|
} else {
|
||||||
|
assertEquals(jvm.getBufferPools().size(), deserializedJvm.getBufferPools().size());
|
||||||
|
for (int i = 0; i < jvm.getBufferPools().size(); i++) {
|
||||||
|
JvmStats.BufferPool bufferPool = jvm.getBufferPools().get(i);
|
||||||
|
JvmStats.BufferPool deserializedBufferPool = deserializedJvm.getBufferPools().get(i);
|
||||||
|
assertEquals(bufferPool.getName(), deserializedBufferPool.getName());
|
||||||
|
assertEquals(bufferPool.getCount(), deserializedBufferPool.getCount());
|
||||||
|
assertEquals(bufferPool.getTotalCapacity(), deserializedBufferPool.getTotalCapacity());
|
||||||
|
assertEquals(bufferPool.getUsed(), deserializedBufferPool.getUsed());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (nodeStats.getThreadPool() == null) {
|
||||||
|
assertNull(deserializedNodeStats.getThreadPool());
|
||||||
|
} else {
|
||||||
|
Iterator<ThreadPoolStats.Stats> threadPoolIterator = nodeStats.getThreadPool().iterator();
|
||||||
|
Iterator<ThreadPoolStats.Stats> deserializedThreadPoolIterator = deserializedNodeStats.getThreadPool().iterator();
|
||||||
|
while (threadPoolIterator.hasNext()) {
|
||||||
|
ThreadPoolStats.Stats stats = threadPoolIterator.next();
|
||||||
|
ThreadPoolStats.Stats deserializedStats = deserializedThreadPoolIterator.next();
|
||||||
|
assertEquals(stats.getName(), deserializedStats.getName());
|
||||||
|
assertEquals(stats.getThreads(), deserializedStats.getThreads());
|
||||||
|
assertEquals(stats.getActive(), deserializedStats.getActive());
|
||||||
|
assertEquals(stats.getLargest(), deserializedStats.getLargest());
|
||||||
|
assertEquals(stats.getCompleted(), deserializedStats.getCompleted());
|
||||||
|
assertEquals(stats.getQueue(), deserializedStats.getQueue());
|
||||||
|
assertEquals(stats.getRejected(), deserializedStats.getRejected());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FsInfo fs = nodeStats.getFs();
|
||||||
|
FsInfo deserializedFs = deserializedNodeStats.getFs();
|
||||||
|
if (fs == null) {
|
||||||
|
assertNull(deserializedFs);
|
||||||
|
} else {
|
||||||
|
assertEquals(fs.getTimestamp(), deserializedFs.getTimestamp());
|
||||||
|
assertEquals(fs.getTotal().getAvailable(), deserializedFs.getTotal().getAvailable());
|
||||||
|
assertEquals(fs.getTotal().getTotal(), deserializedFs.getTotal().getTotal());
|
||||||
|
assertEquals(fs.getTotal().getFree(), deserializedFs.getTotal().getFree());
|
||||||
|
assertEquals(fs.getTotal().getMount(), deserializedFs.getTotal().getMount());
|
||||||
|
assertEquals(fs.getTotal().getPath(), deserializedFs.getTotal().getPath());
|
||||||
|
assertEquals(fs.getTotal().getSpins(), deserializedFs.getTotal().getSpins());
|
||||||
|
assertEquals(fs.getTotal().getType(), deserializedFs.getTotal().getType());
|
||||||
|
FsInfo.IoStats ioStats = fs.getIoStats();
|
||||||
|
FsInfo.IoStats deserializedIoStats = deserializedFs.getIoStats();
|
||||||
|
assertEquals(ioStats.getTotalOperations(), deserializedIoStats.getTotalOperations());
|
||||||
|
assertEquals(ioStats.getTotalReadKilobytes(), deserializedIoStats.getTotalReadKilobytes());
|
||||||
|
assertEquals(ioStats.getTotalReadOperations(), deserializedIoStats.getTotalReadOperations());
|
||||||
|
assertEquals(ioStats.getTotalWriteKilobytes(), deserializedIoStats.getTotalWriteKilobytes());
|
||||||
|
assertEquals(ioStats.getTotalWriteOperations(), deserializedIoStats.getTotalWriteOperations());
|
||||||
|
assertEquals(ioStats.getDevicesStats().length, deserializedIoStats.getDevicesStats().length);
|
||||||
|
for (int i = 0; i < ioStats.getDevicesStats().length; i++) {
|
||||||
|
FsInfo.DeviceStats deviceStats = ioStats.getDevicesStats()[i];
|
||||||
|
FsInfo.DeviceStats deserializedDeviceStats = deserializedIoStats.getDevicesStats()[i];
|
||||||
|
assertEquals(deviceStats.operations(), deserializedDeviceStats.operations());
|
||||||
|
assertEquals(deviceStats.readKilobytes(), deserializedDeviceStats.readKilobytes());
|
||||||
|
assertEquals(deviceStats.readOperations(), deserializedDeviceStats.readOperations());
|
||||||
|
assertEquals(deviceStats.writeKilobytes(), deserializedDeviceStats.writeKilobytes());
|
||||||
|
assertEquals(deviceStats.writeOperations(), deserializedDeviceStats.writeOperations());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (nodeStats.getTransport() == null) {
|
||||||
|
assertNull(deserializedNodeStats.getTransport());
|
||||||
|
} else {
|
||||||
|
assertEquals(nodeStats.getTransport().getRxCount(), deserializedNodeStats.getTransport().getRxCount());
|
||||||
|
assertEquals(nodeStats.getTransport().getRxSize(), deserializedNodeStats.getTransport().getRxSize());
|
||||||
|
assertEquals(nodeStats.getTransport().getServerOpen(), deserializedNodeStats.getTransport().getServerOpen());
|
||||||
|
assertEquals(nodeStats.getTransport().getTxCount(), deserializedNodeStats.getTransport().getTxCount());
|
||||||
|
assertEquals(nodeStats.getTransport().getTxSize(), deserializedNodeStats.getTransport().getTxSize());
|
||||||
|
}
|
||||||
|
if (nodeStats.getHttp() == null) {
|
||||||
|
assertNull(deserializedNodeStats.getHttp());
|
||||||
|
} else {
|
||||||
|
assertEquals(nodeStats.getHttp().getServerOpen(), deserializedNodeStats.getHttp().getServerOpen());
|
||||||
|
assertEquals(nodeStats.getHttp().getTotalOpen(), deserializedNodeStats.getHttp().getTotalOpen());
|
||||||
|
}
|
||||||
|
if (nodeStats.getBreaker() == null) {
|
||||||
|
assertNull(deserializedNodeStats.getBreaker());
|
||||||
|
} else {
|
||||||
|
assertEquals(nodeStats.getBreaker().getAllStats().length, deserializedNodeStats.getBreaker().getAllStats().length);
|
||||||
|
for (int i = 0; i < nodeStats.getBreaker().getAllStats().length; i++) {
|
||||||
|
CircuitBreakerStats circuitBreakerStats = nodeStats.getBreaker().getAllStats()[i];
|
||||||
|
CircuitBreakerStats deserializedCircuitBreakerStats = deserializedNodeStats.getBreaker().getAllStats()[i];
|
||||||
|
assertEquals(circuitBreakerStats.getEstimated(), deserializedCircuitBreakerStats.getEstimated());
|
||||||
|
assertEquals(circuitBreakerStats.getLimit(), deserializedCircuitBreakerStats.getLimit());
|
||||||
|
assertEquals(circuitBreakerStats.getName(), deserializedCircuitBreakerStats.getName());
|
||||||
|
assertEquals(circuitBreakerStats.getOverhead(), deserializedCircuitBreakerStats.getOverhead(), 0);
|
||||||
|
assertEquals(circuitBreakerStats.getTrippedCount(), deserializedCircuitBreakerStats.getTrippedCount(), 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ScriptStats scriptStats = nodeStats.getScriptStats();
|
||||||
|
if (scriptStats == null) {
|
||||||
|
assertNull(deserializedNodeStats.getScriptStats());
|
||||||
|
} else {
|
||||||
|
assertEquals(scriptStats.getCacheEvictions(), deserializedNodeStats.getScriptStats().getCacheEvictions());
|
||||||
|
assertEquals(scriptStats.getCompilations(), deserializedNodeStats.getScriptStats().getCompilations());
|
||||||
|
}
|
||||||
|
DiscoveryStats discoveryStats = nodeStats.getDiscoveryStats();
|
||||||
|
DiscoveryStats deserializedDiscoveryStats = deserializedNodeStats.getDiscoveryStats();
|
||||||
|
if (discoveryStats == null) {
|
||||||
|
assertNull(deserializedDiscoveryStats);
|
||||||
|
} else {
|
||||||
|
PendingClusterStateStats queueStats = discoveryStats.getQueueStats();
|
||||||
|
if (queueStats == null) {
|
||||||
|
assertNull(deserializedDiscoveryStats.getQueueStats());
|
||||||
|
} else {
|
||||||
|
assertEquals(queueStats.getCommitted(), deserializedDiscoveryStats.getQueueStats().getCommitted());
|
||||||
|
assertEquals(queueStats.getTotal(), deserializedDiscoveryStats.getQueueStats().getTotal());
|
||||||
|
assertEquals(queueStats.getPending(), deserializedDiscoveryStats.getQueueStats().getPending());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
IngestStats ingestStats = nodeStats.getIngestStats();
|
||||||
|
IngestStats deserializedIngestStats = deserializedNodeStats.getIngestStats();
|
||||||
|
if (ingestStats == null) {
|
||||||
|
assertNull(deserializedIngestStats);
|
||||||
|
} else {
|
||||||
|
IngestStats.Stats totalStats = ingestStats.getTotalStats();
|
||||||
|
assertEquals(totalStats.getIngestCount(), deserializedIngestStats.getTotalStats().getIngestCount());
|
||||||
|
assertEquals(totalStats.getIngestCurrent(), deserializedIngestStats.getTotalStats().getIngestCurrent());
|
||||||
|
assertEquals(totalStats.getIngestFailedCount(), deserializedIngestStats.getTotalStats().getIngestFailedCount());
|
||||||
|
assertEquals(totalStats.getIngestTimeInMillis(), deserializedIngestStats.getTotalStats().getIngestTimeInMillis());
|
||||||
|
assertEquals(ingestStats.getStatsPerPipeline().size(), deserializedIngestStats.getStatsPerPipeline().size());
|
||||||
|
for (Map.Entry<String, IngestStats.Stats> entry : ingestStats.getStatsPerPipeline().entrySet()) {
|
||||||
|
IngestStats.Stats stats = entry.getValue();
|
||||||
|
IngestStats.Stats deserializedStats = deserializedIngestStats.getStatsPerPipeline().get(entry.getKey());
|
||||||
|
assertEquals(stats.getIngestFailedCount(), deserializedStats.getIngestFailedCount());
|
||||||
|
assertEquals(stats.getIngestTimeInMillis(), deserializedStats.getIngestTimeInMillis());
|
||||||
|
assertEquals(stats.getIngestCurrent(), deserializedStats.getIngestCurrent());
|
||||||
|
assertEquals(stats.getIngestCount(), deserializedStats.getIngestCount());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static NodeStats createNodeStats() {
|
||||||
|
DiscoveryNode node = new DiscoveryNode("test_node", LocalTransportAddress.buildUnique(),
|
||||||
|
emptyMap(), emptySet(), VersionUtils.randomVersion(random()));
|
||||||
|
OsStats osStats = null;
|
||||||
|
if (frequently()) {
|
||||||
|
double loadAverages[] = new double[3];
|
||||||
|
for (int i = 0; i < 3; i++) {
|
||||||
|
loadAverages[i] = randomBoolean() ? randomDouble() : -1;
|
||||||
|
}
|
||||||
|
osStats = new OsStats(System.currentTimeMillis(), new OsStats.Cpu(randomShort(), loadAverages),
|
||||||
|
new OsStats.Mem(randomLong(), randomLong()),
|
||||||
|
new OsStats.Swap(randomLong(), randomLong()));
|
||||||
|
}
|
||||||
|
ProcessStats processStats = frequently() ? new ProcessStats(randomPositiveLong(), randomPositiveLong(), randomPositiveLong(),
|
||||||
|
new ProcessStats.Cpu(randomShort(), randomPositiveLong()),
|
||||||
|
new ProcessStats.Mem(randomPositiveLong())) : null;
|
||||||
|
JvmStats jvmStats = null;
|
||||||
|
if (frequently()) {
|
||||||
|
int numMemoryPools = randomIntBetween(0, 10);
|
||||||
|
List<JvmStats.MemoryPool> memoryPools = new ArrayList<>(numMemoryPools);
|
||||||
|
for (int i = 0; i < numMemoryPools; i++) {
|
||||||
|
memoryPools.add(new JvmStats.MemoryPool(randomAsciiOfLengthBetween(3, 10), randomPositiveLong(),
|
||||||
|
randomPositiveLong(), randomPositiveLong(), randomPositiveLong()));
|
||||||
|
}
|
||||||
|
JvmStats.Threads threads = new JvmStats.Threads(randomIntBetween(1, 1000), randomIntBetween(1, 1000));
|
||||||
|
int numGarbageCollectors = randomIntBetween(0, 10);
|
||||||
|
JvmStats.GarbageCollector[] garbageCollectorsArray = new JvmStats.GarbageCollector[numGarbageCollectors];
|
||||||
|
for (int i = 0; i < numGarbageCollectors; i++) {
|
||||||
|
garbageCollectorsArray[i] = new JvmStats.GarbageCollector(randomAsciiOfLengthBetween(3, 10),
|
||||||
|
randomPositiveLong(), randomPositiveLong());
|
||||||
|
}
|
||||||
|
JvmStats.GarbageCollectors garbageCollectors = new JvmStats.GarbageCollectors(garbageCollectorsArray);
|
||||||
|
int numBufferPools = randomIntBetween(0, 10);
|
||||||
|
List<JvmStats.BufferPool> bufferPoolList = new ArrayList<>();
|
||||||
|
for (int i = 0; i < numBufferPools; i++) {
|
||||||
|
bufferPoolList.add(new JvmStats.BufferPool(randomAsciiOfLengthBetween(3, 10), randomPositiveLong(), randomPositiveLong(),
|
||||||
|
randomPositiveLong()));
|
||||||
|
}
|
||||||
|
JvmStats.Classes classes = new JvmStats.Classes(randomPositiveLong(), randomPositiveLong(), randomPositiveLong());
|
||||||
|
jvmStats = frequently() ? new JvmStats(randomPositiveLong(), randomPositiveLong(), new JvmStats.Mem(randomPositiveLong(),
|
||||||
|
randomPositiveLong(), randomPositiveLong(), randomPositiveLong(), randomPositiveLong(), memoryPools), threads,
|
||||||
|
garbageCollectors, randomBoolean() ? Collections.emptyList() : bufferPoolList, classes) : null;
|
||||||
|
}
|
||||||
|
ThreadPoolStats threadPoolStats = null;
|
||||||
|
if (frequently()) {
|
||||||
|
int numThreadPoolStats = randomIntBetween(0, 10);
|
||||||
|
List<ThreadPoolStats.Stats> threadPoolStatsList = new ArrayList<>();
|
||||||
|
for (int i = 0; i < numThreadPoolStats; i++) {
|
||||||
|
threadPoolStatsList.add(new ThreadPoolStats.Stats(randomAsciiOfLengthBetween(3, 10), randomIntBetween(1, 1000),
|
||||||
|
randomIntBetween(1, 1000), randomIntBetween(1, 1000), randomPositiveLong(),
|
||||||
|
randomIntBetween(1, 1000), randomIntBetween(1, 1000)));
|
||||||
|
}
|
||||||
|
threadPoolStats = new ThreadPoolStats(threadPoolStatsList);
|
||||||
|
}
|
||||||
|
FsInfo fsInfo = null;
|
||||||
|
if (frequently()) {
|
||||||
|
int numDeviceStats = randomIntBetween(0, 10);
|
||||||
|
FsInfo.DeviceStats[] deviceStatsArray = new FsInfo.DeviceStats[numDeviceStats];
|
||||||
|
for (int i = 0; i < numDeviceStats; i++) {
|
||||||
|
FsInfo.DeviceStats previousDeviceStats = randomBoolean() ? null :
|
||||||
|
new FsInfo.DeviceStats(randomInt(), randomInt(), randomAsciiOfLengthBetween(3, 10),
|
||||||
|
randomPositiveLong(), randomPositiveLong(), randomPositiveLong(), randomPositiveLong(), null);
|
||||||
|
deviceStatsArray[i] = new FsInfo.DeviceStats(randomInt(), randomInt(), randomAsciiOfLengthBetween(3, 10),
|
||||||
|
randomPositiveLong(), randomPositiveLong(), randomPositiveLong(), randomPositiveLong(), previousDeviceStats);
|
||||||
|
}
|
||||||
|
FsInfo.IoStats ioStats = new FsInfo.IoStats(deviceStatsArray);
|
||||||
|
int numPaths = randomIntBetween(0, 10);
|
||||||
|
FsInfo.Path[] paths = new FsInfo.Path[numPaths];
|
||||||
|
for (int i = 0; i < numPaths; i++) {
|
||||||
|
paths[i] = new FsInfo.Path(randomAsciiOfLengthBetween(3, 10), randomBoolean() ? randomAsciiOfLengthBetween(3, 10) : null,
|
||||||
|
randomPositiveLong(), randomPositiveLong(), randomPositiveLong());
|
||||||
|
}
|
||||||
|
fsInfo = new FsInfo(randomPositiveLong(), ioStats, paths);
|
||||||
|
}
|
||||||
|
TransportStats transportStats = frequently() ? new TransportStats(randomPositiveLong(), randomPositiveLong(),
|
||||||
|
randomPositiveLong(), randomPositiveLong(), randomPositiveLong()) : null;
|
||||||
|
HttpStats httpStats = frequently() ? new HttpStats(randomPositiveLong(), randomPositiveLong()) : null;
|
||||||
|
AllCircuitBreakerStats allCircuitBreakerStats = null;
|
||||||
|
if (frequently()) {
|
||||||
|
int numCircuitBreakerStats = randomIntBetween(0, 10);
|
||||||
|
CircuitBreakerStats[] circuitBreakerStatsArray = new CircuitBreakerStats[numCircuitBreakerStats];
|
||||||
|
for (int i = 0; i < numCircuitBreakerStats; i++) {
|
||||||
|
circuitBreakerStatsArray[i] = new CircuitBreakerStats(randomAsciiOfLengthBetween(3, 10), randomPositiveLong(),
|
||||||
|
randomPositiveLong(), randomDouble(), randomPositiveLong());
|
||||||
|
}
|
||||||
|
allCircuitBreakerStats = new AllCircuitBreakerStats(circuitBreakerStatsArray);
|
||||||
|
}
|
||||||
|
ScriptStats scriptStats = frequently() ? new ScriptStats(randomPositiveLong(), randomPositiveLong()) : null;
|
||||||
|
DiscoveryStats discoveryStats = frequently() ? new DiscoveryStats(randomBoolean() ? new PendingClusterStateStats(randomInt(),
|
||||||
|
randomInt(), randomInt()) : null) : null;
|
||||||
|
IngestStats ingestStats = null;
|
||||||
|
if (frequently()) {
|
||||||
|
IngestStats.Stats totalStats = new IngestStats.Stats(randomPositiveLong(), randomPositiveLong(), randomPositiveLong(),
|
||||||
|
randomPositiveLong());
|
||||||
|
|
||||||
|
int numStatsPerPipeline = randomIntBetween(0, 10);
|
||||||
|
Map<String, IngestStats.Stats> statsPerPipeline = new HashMap<>();
|
||||||
|
for (int i = 0; i < numStatsPerPipeline; i++) {
|
||||||
|
statsPerPipeline.put(randomAsciiOfLengthBetween(3, 10), new IngestStats.Stats(randomPositiveLong(),
|
||||||
|
randomPositiveLong(), randomPositiveLong(), randomPositiveLong()));
|
||||||
|
}
|
||||||
|
ingestStats = new IngestStats(totalStats, statsPerPipeline);
|
||||||
|
}
|
||||||
|
//TODO NodeIndicesStats are not tested here, way too complicated to create, also they need to be migrated to Writeable yet
|
||||||
|
return new NodeStats(node, randomPositiveLong(), null, osStats, processStats, jvmStats, threadPoolStats, fsInfo,
|
||||||
|
transportStats, httpStats, allCircuitBreakerStats, scriptStats, discoveryStats, ingestStats);
|
||||||
|
}
|
||||||
|
}
|
@ -647,7 +647,7 @@ public class IndexStatsIT extends ESIntegTestCase {
|
|||||||
flags.writeTo(out);
|
flags.writeTo(out);
|
||||||
out.close();
|
out.close();
|
||||||
BytesReference bytes = out.bytes();
|
BytesReference bytes = out.bytes();
|
||||||
CommonStatsFlags readStats = CommonStatsFlags.readCommonStatsFlags(bytes.streamInput());
|
CommonStatsFlags readStats = new CommonStatsFlags(bytes.streamInput());
|
||||||
for (Flag flag : values) {
|
for (Flag flag : values) {
|
||||||
assertThat(flags.isSet(flag), equalTo(readStats.isSet(flag)));
|
assertThat(flags.isSet(flag), equalTo(readStats.isSet(flag)));
|
||||||
}
|
}
|
||||||
@ -661,7 +661,7 @@ public class IndexStatsIT extends ESIntegTestCase {
|
|||||||
flags.writeTo(out);
|
flags.writeTo(out);
|
||||||
out.close();
|
out.close();
|
||||||
BytesReference bytes = out.bytes();
|
BytesReference bytes = out.bytes();
|
||||||
CommonStatsFlags readStats = CommonStatsFlags.readCommonStatsFlags(bytes.streamInput());
|
CommonStatsFlags readStats = new CommonStatsFlags(bytes.streamInput());
|
||||||
for (Flag flag : values) {
|
for (Flag flag : values) {
|
||||||
assertThat(flags.isSet(flag), equalTo(readStats.isSet(flag)));
|
assertThat(flags.isSet(flag), equalTo(readStats.isSet(flag)));
|
||||||
}
|
}
|
||||||
|
@ -141,7 +141,7 @@ public class FsProbeTests extends ESTestCase {
|
|||||||
" 253 1 dm-1 112 0 4624 13 0 0 0 0 0 5 13",
|
" 253 1 dm-1 112 0 4624 13 0 0 0 0 0 5 13",
|
||||||
" 253 2 dm-2 48045 0 714866 49369 1372291 0 64128568 33730766 0 1058347 33782056"));
|
" 253 2 dm-2 48045 0 714866 49369 1372291 0 64128568 33730766 0 1058347 33782056"));
|
||||||
|
|
||||||
final FsInfo previous = new FsInfo(System.currentTimeMillis(), first, null);
|
final FsInfo previous = new FsInfo(System.currentTimeMillis(), first, new FsInfo.Path[0]);
|
||||||
final FsInfo.IoStats second = probe.ioStats(devicesNumbers, previous);
|
final FsInfo.IoStats second = probe.ioStats(devicesNumbers, previous);
|
||||||
assertNotNull(second);
|
assertNotNull(second);
|
||||||
assertThat(second.devicesStats[0].majorDeviceNumber, equalTo(253));
|
assertThat(second.devicesStats[0].majorDeviceNumber, equalTo(253));
|
||||||
|
@ -65,11 +65,11 @@ public class ProcessProbeTests extends ESTestCase {
|
|||||||
assertThat(cpu.getPercent(), anyOf(lessThan((short) 0), allOf(greaterThanOrEqualTo((short) 0), lessThanOrEqualTo((short) 100))));
|
assertThat(cpu.getPercent(), anyOf(lessThan((short) 0), allOf(greaterThanOrEqualTo((short) 0), lessThanOrEqualTo((short) 100))));
|
||||||
|
|
||||||
// CPU time can return -1 if the platform does not support this operation, let's see which platforms fail
|
// CPU time can return -1 if the platform does not support this operation, let's see which platforms fail
|
||||||
assertThat(cpu.total, greaterThan(0L));
|
assertThat(cpu.getTotal().millis(), greaterThan(0L));
|
||||||
|
|
||||||
ProcessStats.Mem mem = stats.getMem();
|
ProcessStats.Mem mem = stats.getMem();
|
||||||
assertNotNull(mem);
|
assertNotNull(mem);
|
||||||
// Commited total virtual memory can return -1 if not supported, let's see which platforms fail
|
// Commited total virtual memory can return -1 if not supported, let's see which platforms fail
|
||||||
assertThat(mem.totalVirtual, greaterThan(0L));
|
assertThat(mem.getTotalVirtual().bytes(), greaterThan(0L));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user