Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.google.common.annotations.VisibleForTesting;

import com.google.common.io.ByteStreams;
import com.wavefront.sdk.common.Constants;
import com.wavefront.sdk.common.Utils;
import com.wavefront.sdk.common.clients.service.token.TokenService;
Expand Down Expand Up @@ -82,10 +83,7 @@ public int send(String format, InputStream stream) {
urlConn.setReadTimeout(READ_TIMEOUT_MILLIS);

try (GZIPOutputStream gzipOS = new GZIPOutputStream(urlConn.getOutputStream())) {
byte[] buffer = new byte[BUFFER_SIZE];
while (stream.available() > 0) {
gzipOS.write(buffer, 0, stream.read(buffer));
}
ByteStreams.copy(stream, gzipOS);
gzipOS.flush();
}
statusCode = urlConn.getResponseCode();
Expand Down Expand Up @@ -125,20 +123,14 @@ public int sendEvent(InputStream stream) {
urlConn.addRequestProperty("Content-Type", "application/octet-stream");
urlConn.addRequestProperty("Content-Encoding", "gzip");
try (GZIPOutputStream gzipOS = new GZIPOutputStream(urlConn.getOutputStream())) {
byte[] buffer = new byte[BUFFER_SIZE];
while (stream.available() > 0) {
gzipOS.write(buffer, 0, stream.read(buffer));
}
ByteStreams.copy(stream, gzipOS);
gzipOS.flush();
}
} else {
// Event is in uncompressed JSON format for direct ingestion.
urlConn.addRequestProperty("Content-Type", "application/json");
try (OutputStream urlOS = urlConn.getOutputStream()) {
byte[] buffer = new byte[BUFFER_SIZE];
while (stream.available() > 0) {
urlOS.write(buffer, 0, stream.read(buffer));
}
ByteStreams.copy(stream, urlOS);
urlOS.flush();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.wavefront.sdk.direct.ingestion;

import com.google.common.io.ByteStreams;
import com.wavefront.sdk.common.clients.WavefrontClientFactory;
import com.wavefront.sdk.common.clients.service.ReportingService;

Expand Down Expand Up @@ -60,10 +61,7 @@ public int report(String format, InputStream stream) {
urlConn.setReadTimeout(READ_TIMEOUT_MILLIS);

try (GZIPOutputStream gzipOS = new GZIPOutputStream(urlConn.getOutputStream())) {
byte[] buffer = new byte[4096];
while (stream.available() > 0) {
gzipOS.write(buffer, 0, stream.read(buffer));
}
ByteStreams.copy(stream, gzipOS);
gzipOS.flush();
}
statusCode = urlConn.getResponseCode();
Expand Down