use read/writeOptionalWriteable in NodeInfo serialization code

This commit is contained in:
javanna 2016-09-01 18:56:38 +02:00 committed by Luca Cavanna
parent e98e37295a
commit 555db744f1
1 changed files with 16 additions and 72 deletions

View File

@ -201,30 +201,14 @@ public class NodeInfo extends BaseNodeResponse {
if (in.readBoolean()) { if (in.readBoolean()) {
settings = Settings.readSettingsFromStream(in); settings = Settings.readSettingsFromStream(in);
} }
if (in.readBoolean()) { os = in.readOptionalWriteable(OsInfo::new);
os = new OsInfo(in); process = in.readOptionalWriteable(ProcessInfo::new);
} jvm = in.readOptionalWriteable(JvmInfo::new);
if (in.readBoolean()) { threadPool = in.readOptionalWriteable(ThreadPoolInfo::new);
process = new ProcessInfo(in); transport = in.readOptionalWriteable(TransportInfo::new);
} http = in.readOptionalWriteable(HttpInfo::new);
if (in.readBoolean()) { plugins = in.readOptionalWriteable(PluginsAndModules::new);
jvm = new JvmInfo(in); ingest = in.readOptionalWriteable(IngestInfo::new);
}
if (in.readBoolean()) {
threadPool = new ThreadPoolInfo(in);
}
if (in.readBoolean()) {
transport = new TransportInfo(in);
}
if (in.readBoolean()) {
http = new HttpInfo(in);
}
if (in.readBoolean()) {
plugins = new PluginsAndModules(in);
}
if (in.readBoolean()) {
ingest = new IngestInfo(in);
}
} }
@Override @Override
@ -244,53 +228,13 @@ public class NodeInfo extends BaseNodeResponse {
out.writeBoolean(true); out.writeBoolean(true);
Settings.writeSettingsToStream(settings, out); Settings.writeSettingsToStream(settings, 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(transport);
} out.writeOptionalWriteable(http);
if (process == null) { out.writeOptionalWriteable(plugins);
out.writeBoolean(false); out.writeOptionalWriteable(ingest);
} else {
out.writeBoolean(true);
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 (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);
}
if (plugins == null) {
out.writeBoolean(false);
} else {
out.writeBoolean(true);
plugins.writeTo(out);
}
if (ingest == null) {
out.writeBoolean(false);
} else {
out.writeBoolean(true);
ingest.writeTo(out);
}
} }
} }