use read/writeList and readMap where possible
This commit is contained in:
parent
68eb58f9e3
commit
6873454f33
|
@ -44,30 +44,14 @@ public class PluginsAndModules implements Writeable, ToXContent {
|
||||||
}
|
}
|
||||||
|
|
||||||
public PluginsAndModules(StreamInput in) throws IOException {
|
public PluginsAndModules(StreamInput in) throws IOException {
|
||||||
int pluginsSize = in.readInt();
|
this.plugins = Collections.unmodifiableList(in.readList(PluginInfo::new));
|
||||||
List<PluginInfo> plugins = new ArrayList<>(pluginsSize);
|
this.modules = Collections.unmodifiableList(in.readList(PluginInfo::new));
|
||||||
for (int i = 0; i < pluginsSize; i++) {
|
|
||||||
plugins.add(new PluginInfo(in));
|
|
||||||
}
|
|
||||||
this.plugins = Collections.unmodifiableList(plugins);
|
|
||||||
int modulesSize = in.readInt();
|
|
||||||
List<PluginInfo> modules = new ArrayList<>(modulesSize);
|
|
||||||
for (int i = 0; i < modulesSize; i++) {
|
|
||||||
modules.add(new PluginInfo(in));
|
|
||||||
}
|
|
||||||
this.modules = Collections.unmodifiableList(modules);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeTo(StreamOutput out) throws IOException {
|
public void writeTo(StreamOutput out) throws IOException {
|
||||||
out.writeInt(plugins.size());
|
out.writeList(plugins);
|
||||||
for (PluginInfo plugin : getPluginInfos()) {
|
out.writeList(modules);
|
||||||
plugin.writeTo(out);
|
|
||||||
}
|
|
||||||
out.writeInt(modules.size());
|
|
||||||
for (PluginInfo module : getModuleInfos()) {
|
|
||||||
module.writeTo(out);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -36,7 +36,6 @@ import java.lang.management.PlatformManagedObject;
|
||||||
import java.lang.management.RuntimeMXBean;
|
import java.lang.management.RuntimeMXBean;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -226,11 +225,7 @@ public class JvmInfo implements Writeable, ToXContent {
|
||||||
}
|
}
|
||||||
bootClassPath = in.readString();
|
bootClassPath = in.readString();
|
||||||
classPath = in.readString();
|
classPath = in.readString();
|
||||||
systemProperties = new HashMap<>();
|
systemProperties = in.readMap(StreamInput::readString, StreamInput::readString);
|
||||||
int size = in.readInt();
|
|
||||||
for (int i = 0; i < size; i++) {
|
|
||||||
systemProperties.put(in.readString(), in.readString());
|
|
||||||
}
|
|
||||||
mem = new Mem(in);
|
mem = new Mem(in);
|
||||||
gcCollectors = in.readStringArray();
|
gcCollectors = in.readStringArray();
|
||||||
memoryPools = in.readStringArray();
|
memoryPools = in.readStringArray();
|
||||||
|
@ -257,7 +252,7 @@ public class JvmInfo implements Writeable, ToXContent {
|
||||||
}
|
}
|
||||||
out.writeString(bootClassPath);
|
out.writeString(bootClassPath);
|
||||||
out.writeString(classPath);
|
out.writeString(classPath);
|
||||||
out.writeInt(systemProperties.size());
|
out.writeVInt(this.systemProperties.size());
|
||||||
for (Map.Entry<String, String> entry : systemProperties.entrySet()) {
|
for (Map.Entry<String, String> entry : systemProperties.entrySet()) {
|
||||||
out.writeString(entry.getKey());
|
out.writeString(entry.getKey());
|
||||||
out.writeString(entry.getValue());
|
out.writeString(entry.getValue());
|
||||||
|
|
|
@ -26,7 +26,6 @@ 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;
|
||||||
|
@ -40,20 +39,12 @@ public class ThreadPoolInfo implements Writeable, Iterable<ThreadPool.Info>, ToX
|
||||||
}
|
}
|
||||||
|
|
||||||
public ThreadPoolInfo(StreamInput in) throws IOException {
|
public ThreadPoolInfo(StreamInput in) throws IOException {
|
||||||
int size = in.readVInt();
|
this.infos = Collections.unmodifiableList(in.readList(ThreadPool.Info::new));
|
||||||
List<ThreadPool.Info> infos = new ArrayList<>(size);
|
|
||||||
for (int i = 0; i < size; i++) {
|
|
||||||
infos.add(new ThreadPool.Info(in));
|
|
||||||
}
|
|
||||||
this.infos = Collections.unmodifiableList(infos);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeTo(StreamOutput out) throws IOException {
|
public void writeTo(StreamOutput out) throws IOException {
|
||||||
out.writeVInt(infos.size());
|
out.writeList(infos);
|
||||||
for (ThreadPool.Info info : infos) {
|
|
||||||
info.writeTo(out);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue