diff --git a/s3stream/build.gradle b/s3stream/build.gradle index 88027458a..67c52c2c5 100644 --- a/s3stream/build.gradle +++ b/s3stream/build.gradle @@ -1,10 +1,28 @@ /* * This file was generated by the Gradle 'init' task. */ +import com.github.spotbugs.snom.Confidence +import com.github.spotbugs.snom.Effort plugins { id 'java-library' id 'maven-publish' + id("com.github.spotbugs") version "6.0.7" +} + +spotbugsMain { + reports { + html { + required = true + outputLocation = file("$buildDir/reports/spotbugs.html") + setStylesheet("fancy-hist.xsl") + } + } +} + +spotbugs { + effort = Effort.valueOf('DEFAULT') + reportLevel = Confidence.valueOf('HIGH') } repositories { diff --git a/s3stream/src/main/java/com/automq/stream/s3/wal/benchmark/WriteBench.java b/s3stream/src/main/java/com/automq/stream/s3/wal/benchmark/WriteBench.java index da60081d7..359e6d69a 100644 --- a/s3stream/src/main/java/com/automq/stream/s3/wal/benchmark/WriteBench.java +++ b/s3stream/src/main/java/com/automq/stream/s3/wal/benchmark/WriteBench.java @@ -55,6 +55,9 @@ public class WriteBench implements AutoCloseable { private final WriteAheadLog log; private final TrimOffset trimOffset = new TrimOffset(); + // Generate random payloads for this benchmark tool + private Random random = new Random(); + public WriteBench(Config config) throws IOException { BlockWALService.BlockWALServiceBuilder builder = BlockWALService.builder(config.path, config.capacity); if (config.depth != null) { @@ -177,7 +180,7 @@ private void runAppendTask(int index, AppendTaskConfig config, Stat stat) throws System.out.printf("Append task %d started\n", index); byte[] bytes = new byte[config.recordSizeBytes]; - new Random().nextBytes(bytes); + random.nextBytes(bytes); ByteBuf payload = Unpooled.wrappedBuffer(bytes).retain(); int intervalNanos = (int) TimeUnit.SECONDS.toNanos(1) / Math.max(1, config.throughputBytes / config.recordSizeBytes); long lastAppendTimeNanos = System.nanoTime(); diff --git a/s3stream/src/main/java/com/automq/stream/utils/S3Utils.java b/s3stream/src/main/java/com/automq/stream/utils/S3Utils.java index 84590eb57..805ada558 100644 --- a/s3stream/src/main/java/com/automq/stream/utils/S3Utils.java +++ b/s3stream/src/main/java/com/automq/stream/utils/S3Utils.java @@ -69,7 +69,7 @@ public static void checkS3Access(S3Context context) { System.exit(1); } - try (MultipartObjectOperationTask task = new MultipartObjectOperationTask(context)) { + try (S3MultipartUploadTestTask task = new S3MultipartUploadTestTask(context)) { task.run(); } catch (Throwable e) { System.out.println("ERROR: " + ExceptionUtils.getRootCause(e)); @@ -135,9 +135,11 @@ public void close() { } } - private static class MultipartObjectOperationTask extends ObjectOperationTask { - public MultipartObjectOperationTask(S3Context context) { - super(context, MultipartObjectOperationTask.class.getSimpleName()); + // This task is used to test s3 multipart upload + private static class S3MultipartUploadTestTask extends ObjectOperationTask { + private Random random = new Random(); + public S3MultipartUploadTestTask(S3Context context) { + super(context, S3MultipartUploadTestTask.class.getSimpleName()); } @Override @@ -152,12 +154,12 @@ public void run() { int totalSize = data1Size + data2Size; byte[] randomBytes = new byte[data1Size]; - new Random().nextBytes(randomBytes); + random.nextBytes(randomBytes); ByteBuf data1 = Unpooled.wrappedBuffer(randomBytes); writePart(uploadId, path, bucketName, data1, 1).thenAccept(parts::add).get(); byte[] randomBytes2 = new byte[data2Size]; - new Random().nextBytes(randomBytes2); + random.nextBytes(randomBytes2); ByteBuf data2 = Unpooled.wrappedBuffer(randomBytes2); writePart(uploadId, path, bucketName, data2, 2).thenAccept(parts::add).get();