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