diff options
author | Luck <git@lucko.me> | 2019-05-13 11:28:35 +0100 |
---|---|---|
committer | Luck <git@lucko.me> | 2019-05-13 11:28:35 +0100 |
commit | 6602483b18ff556147094c2e6b816b0898ed698e (patch) | |
tree | a433ae3390cda98a9c4e1e525cbe80cac87e794b /spark-common/src/main/java/me/lucko/spark/common/heapdump | |
parent | 226d205fc6606cc3360791f2aea3a491d577750e (diff) | |
download | spark-6602483b18ff556147094c2e6b816b0898ed698e.tar.gz spark-6602483b18ff556147094c2e6b816b0898ed698e.tar.bz2 spark-6602483b18ff556147094c2e6b816b0898ed698e.zip |
Include sender metadata too
Diffstat (limited to 'spark-common/src/main/java/me/lucko/spark/common/heapdump')
-rw-r--r-- | spark-common/src/main/java/me/lucko/spark/common/heapdump/HeapDumpSummary.java | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/spark-common/src/main/java/me/lucko/spark/common/heapdump/HeapDumpSummary.java b/spark-common/src/main/java/me/lucko/spark/common/heapdump/HeapDumpSummary.java index c95e9ab..6021d92 100644 --- a/spark-common/src/main/java/me/lucko/spark/common/heapdump/HeapDumpSummary.java +++ b/spark-common/src/main/java/me/lucko/spark/common/heapdump/HeapDumpSummary.java @@ -20,7 +20,9 @@ package me.lucko.spark.common.heapdump; +import com.google.gson.Gson; import com.google.gson.stream.JsonWriter; +import me.lucko.spark.common.CommandSender; import me.lucko.spark.common.util.TypeDescriptors; import javax.management.JMX; @@ -106,9 +108,15 @@ public final class HeapDumpSummary { this.entries = entries; } - private void writeOutput(JsonWriter writer) throws IOException { + private void writeOutput(JsonWriter writer, CommandSender creator) throws IOException { writer.beginObject(); writer.name("type").value("heap"); + + writer.name("metadata").beginObject(); + writer.name("user"); + new Gson().toJson(creator.toData().serialize(), writer); + writer.endObject(); + writer.name("entries").beginArray(); for (Entry entry : this.entries) { writer.beginObject(); @@ -122,11 +130,11 @@ public final class HeapDumpSummary { writer.endObject(); } - public byte[] formCompressedDataPayload() { + public byte[] formCompressedDataPayload(CommandSender creator) { ByteArrayOutputStream byteOut = new ByteArrayOutputStream(); try (Writer writer = new OutputStreamWriter(new GZIPOutputStream(byteOut), StandardCharsets.UTF_8)) { try (JsonWriter jsonWriter = new JsonWriter(writer)) { - writeOutput(jsonWriter); + writeOutput(jsonWriter, creator); } } catch (IOException e) { throw new RuntimeException(e); |