JvmStats to implement Writeable rather than Streamable

also removed null checks in toXContent for subobjects that cannot be null and added @Nullable annotation for memory pools
This commit is contained in:
javanna 2016-09-02 15:50:51 +02:00 committed by Luca Cavanna
parent 931a164b1f
commit 102dac2cd9
2 changed files with 221 additions and 299 deletions

View File

@ -218,7 +218,7 @@ public class NodeStats extends BaseNodeResponse implements ToXContent {
process = new ProcessStats(in); process = new ProcessStats(in);
} }
if (in.readBoolean()) { if (in.readBoolean()) {
jvm = JvmStats.readJvmStats(in); jvm = new JvmStats(in);
} }
if (in.readBoolean()) { if (in.readBoolean()) {
threadPool = ThreadPoolStats.readThreadPoolStats(in); threadPool = ThreadPoolStats.readThreadPoolStats(in);

View File

@ -19,9 +19,10 @@
package org.elasticsearch.monitor.jvm; package org.elasticsearch.monitor.jvm;
import org.elasticsearch.common.inject.internal.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.unit.TimeValue; import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.ToXContent;
@ -39,14 +40,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 +60,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 +89,84 @@ 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()]); MemoryPool[] memoryPools = pools.toArray(new MemoryPool[pools.size()]);
Mem mem = new Mem(heapCommitted, heapUsed, heapMax, nonHeapCommitted, nonHeapUsed, memoryPools);
stats.threads = new Threads(); Threads threads = new Threads(threadMXBean.getThreadCount(), threadMXBean.getPeakThreadCount());
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 = null;
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,
} @Nullable 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);
if (in.readBoolean()) {
bufferPools = in.readList(BufferPool::new);
} else {
bufferPools = Collections.emptyList();
}
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);
if (bufferPools == null) {
out.writeBoolean(false);
} else {
out.writeBoolean(true);
out.writeList(bufferPools);
}
classes.writeTo(out);
} }
public long getTimestamp() { public long getTimestamp() {
@ -178,7 +202,7 @@ 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.startObject(Fields.MEM);
builder.byteSizeField(Fields.HEAP_USED_IN_BYTES, Fields.HEAP_USED, mem.heapUsed); builder.byteSizeField(Fields.HEAP_USED_IN_BYTES, Fields.HEAP_USED, mem.heapUsed);
@ -204,14 +228,12 @@ public class JvmStats implements Streamable, ToXContent {
builder.endObject(); builder.endObject();
builder.endObject(); builder.endObject();
}
if (threads != null) {
builder.startObject(Fields.THREADS); builder.startObject(Fields.THREADS);
builder.field(Fields.COUNT, threads.getCount()); builder.field(Fields.COUNT, threads.getCount());
builder.field(Fields.PEAK_COUNT, threads.getPeakCount()); builder.field(Fields.PEAK_COUNT, threads.getPeakCount());
builder.endObject(); builder.endObject();
}
if (gc != null) {
builder.startObject(Fields.GC); builder.startObject(Fields.GC);
builder.startObject(Fields.COLLECTORS); builder.startObject(Fields.COLLECTORS);
@ -224,7 +246,6 @@ public class JvmStats implements Streamable, ToXContent {
builder.endObject(); builder.endObject();
builder.endObject(); builder.endObject();
}
if (bufferPools != null) { if (bufferPools != null) {
builder.startObject(Fields.BUFFER_POOLS); builder.startObject(Fields.BUFFER_POOLS);
@ -238,13 +259,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 +310,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 +319,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); public GarbageCollectors(GarbageCollector[] collectors) {
return jvmStats; this.collectors = collectors;
} }
@Override public GarbageCollectors(StreamInput in) throws IOException {
public void readFrom(StreamInput in) throws IOException { collectors = in.readArray(GarbageCollector::new, GarbageCollector[]::new);
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 @Override
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
out.writeVLong(timestamp); out.writeArray(collectors);
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 {
GarbageCollectors collectors = new GarbageCollectors();
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
public void writeTo(StreamOutput out) throws IOException {
out.writeVInt(collectors.length);
for (GarbageCollector gc : collectors) {
gc.writeTo(out);
}
} }
public GarbageCollector[] getCollectors() { public GarbageCollector[] getCollectors() {
@ -387,23 +346,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 +384,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 +404,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 static class MemoryPool implements Streamable { public int getPeakCount() {
return peakCount;
String name;
long used;
long max;
long peakUsed;
long peakMax;
MemoryPool() {
} }
}
public static class MemoryPool implements Writeable {
private final String name;
private final long used;
private final long max;
private final long peakUsed;
private final long peakMax;
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 +430,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 +466,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 static class Mem implements Writeable, Iterable<MemoryPool> {
public void writeTo(StreamOutput out) throws IOException {
out.writeString(name); private final long heapCommitted;
out.writeVLong(used); private final long heapUsed;
out.writeVLong(max); private final long heapMax;
out.writeVLong(peakUsed); private final long nonHeapCommitted;
out.writeVLong(peakMax); private final long nonHeapUsed;
} private final MemoryPool[] pools;
public Mem(long heapCommitted, long heapUsed, long heapMax, long nonHeapCommitted, long nonHeapUsed, MemoryPool[] pools) {
this.heapCommitted = heapCommitted;
this.heapUsed = heapUsed;
this.heapMax = heapMax;
this.nonHeapCommitted = nonHeapCommitted;
this.nonHeapUsed = nonHeapUsed;
this.pools = pools;
} }
public static class Mem implements Streamable, Iterable<MemoryPool> { public Mem(StreamInput in) throws IOException {
long heapCommitted;
long heapUsed;
long heapMax;
long nonHeapCommitted;
long nonHeapUsed;
MemoryPool[] pools = new MemoryPool[0];
Mem() {
}
public static Mem readMem(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.readArray(MemoryPool::new, MemoryPool[]::new);
for (int i = 0; i < pools.length; i++) {
pools[i] = MemoryPool.readMemoryPool(in);
}
} }
@Override @Override
@ -574,10 +502,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.writeArray(pools);
for (MemoryPool pool : pools) {
pool.writeTo(out);
} }
@Override
public Iterator<MemoryPool> iterator() {
return Arrays.stream(pools).iterator();
} }
public ByteSizeValue getHeapCommitted() { public ByteSizeValue getHeapCommitted() {
@ -614,15 +544,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 +558,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 +588,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 static class Classes implements Writeable {
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 { private final long loadedClassCount;
private final long totalLoadedClassCount;
long loadedClassCount; private final long unloadedClassCount;
long totalLoadedClassCount;
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 +602,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 +626,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);
}
} }
} }