task-64: transient payload 压缩改为直接 gzip 二进制流上传

- RustfsObjectStorageService 新增 uploadBytes/readObjectBytes 二进制流 API
  (application/gzip),uploadText/readObjectAsString 改为其薄包装
- TransientPayloadStorageService 的 encodeStoredPayload 直接输出 gzip 字节,
  不再经过 gzip64 + Base64 文本编码(消除 33% 体积膨胀与中间字符串副本)
- 读取端按 gzip magic 识别二进制流解压;兼容旧 gzip64: 文本与历史裸文本
- 本地回落文件同步改为写二进制(Files.write),超限判定基于 gzip 后字节数
This commit is contained in:
2026-08-30 18:42:19 +08:00
parent dcaf655aaf
commit 927c3c931e
3 changed files with 260 additions and 34 deletions
@@ -80,12 +80,17 @@ public class RustfsObjectStorageService {
}
public String uploadText(String objectKey, String content, boolean verifyAfterUpload) {
byte[] bytes = Objects.requireNonNullElse(content, "").getBytes(StandardCharsets.UTF_8);
return uploadBytes(objectKey, bytes, verifyAfterUpload);
}
public String uploadBytes(String objectKey, byte[] content, boolean verifyAfterUpload) {
long deadlineNanos = operationDeadlineNanos();
if (!isConfigured()) {
throw new IllegalStateException("transient storage is not configured");
}
rejectIfCircuitOpen(OP_UPLOAD, objectKey);
byte[] bytes = Objects.requireNonNullElse(content, "").getBytes(StandardCharsets.UTF_8);
byte[] bytes = content == null ? new byte[0] : content;
recordPayloadBytes(bytes.length);
AtomicBoolean putCompleted = new AtomicBoolean();
try {
@@ -96,7 +101,7 @@ public class RustfsObjectStorageService {
.bucket(properties.getBucket())
.object(objectKey)
.stream(stream, bytes.length, -1)
.contentType("application/json")
.contentType("application/gzip")
.build());
putCompleted.set(true);
return objectKey;
@@ -117,6 +122,11 @@ public class RustfsObjectStorageService {
}
public String readObjectAsString(String objectKey) {
byte[] bytes = readObjectBytes(objectKey);
return new String(bytes, StandardCharsets.UTF_8);
}
public byte[] readObjectBytes(String objectKey) {
long deadlineNanos = operationDeadlineNanos();
if (!isConfigured()) {
throw new IllegalStateException("transient storage is not configured");
@@ -128,7 +138,7 @@ public class RustfsObjectStorageService {
.bucket(properties.getBucket())
.object(objectKey)
.build())) {
return new String(stream.readAllBytes(), StandardCharsets.UTF_8);
return stream.readAllBytes();
}
});
}