aboutsummaryrefslogtreecommitdiff
path: root/spark-common/src/main/java/me/lucko/spark/common/util
diff options
context:
space:
mode:
authorLuck <git@lucko.me>2021-07-18 21:31:32 +0100
committerLuck <git@lucko.me>2021-07-18 21:31:32 +0100
commit8204f693071ed7411300231cba8225b7846cc500 (patch)
treea6d6c4959b7280a3def22a43dbf7e2a3c6046bd9 /spark-common/src/main/java/me/lucko/spark/common/util
parentc31c7033318509e53c790f6cd6618cb94dca3af7 (diff)
downloadspark-8204f693071ed7411300231cba8225b7846cc500.tar.gz
spark-8204f693071ed7411300231cba8225b7846cc500.tar.bz2
spark-8204f693071ed7411300231cba8225b7846cc500.zip
Add flag to save profile/heapsummary to files instead of uploading to bytebin
Diffstat (limited to 'spark-common/src/main/java/me/lucko/spark/common/util')
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/util/BytebinClient.java15
1 files changed, 15 insertions, 0 deletions
diff --git a/spark-common/src/main/java/me/lucko/spark/common/util/BytebinClient.java b/spark-common/src/main/java/me/lucko/spark/common/util/BytebinClient.java
index 9202303..29ee5bb 100644
--- a/spark-common/src/main/java/me/lucko/spark/common/util/BytebinClient.java
+++ b/spark-common/src/main/java/me/lucko/spark/common/util/BytebinClient.java
@@ -25,13 +25,18 @@
package me.lucko.spark.common.util;
+import com.google.protobuf.AbstractMessageLite;
+
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.io.OutputStream;
+import java.util.zip.GZIPOutputStream;
/**
* Utility for posting content to bytebin.
@@ -81,6 +86,16 @@ public class BytebinClient extends AbstractHttpClient {
}
}
+ public Content postContent(AbstractMessageLite<?, ?> proto, MediaType contentType) throws IOException {
+ ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
+ try (OutputStream out = new GZIPOutputStream(byteOut)) {
+ proto.writeTo(out);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ return postContent(byteOut.toByteArray(), contentType);
+ }
+
public static final class Content {
private final String key;