Calvin979 commented on code in PR #3595: URL: https://github.com/apache/hertzbeat/pull/3595#discussion_r2217893121
########## hertzbeat-warehouse/src/main/java/org/apache/hertzbeat/warehouse/store/history/tsdb/vm/VictoriaMetricsDataStorage.java: ########## @@ -625,11 +627,24 @@ private void doSaveData(List<VictoriaMetricsContent> contentList) { String encodedAuth = Base64Util.encode(authStr); headers.add(HttpHeaders.AUTHORIZATION, NetworkConstants.BASIC + SignConstants.BLANK + encodedAuth); } + headers.set(HttpHeaders.CONTENT_ENCODING, "gzip"); + StringBuilder stringBuilder = new StringBuilder(); for (VictoriaMetricsContent content : contentList) { stringBuilder.append(JsonUtil.toJson(content)).append("\n"); } - HttpEntity<String> httpEntity = new HttpEntity<>(stringBuilder.toString(), headers); + String payload = stringBuilder.toString(); + // compress the payload using gzip + byte[] compressedPayload; + try (ByteArrayOutputStream bos = new ByteArrayOutputStream(payload.length()); + GZIPOutputStream gzip = new GZIPOutputStream(bos)) { + gzip.write(payload.getBytes(StandardCharsets.UTF_8)); + // gzip stream must be turned off to complete the compression + gzip.close(); Review Comment: Why need to call `close` here, `GZIPOutputStream` is already defined within `try` keyword. I've found a method `finish` in `GZIPOutputStream`, is it the method you wanna execute here? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@hertzbeat.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@hertzbeat.apache.org For additional commands, e-mail: notifications-h...@hertzbeat.apache.org