Skip to content

Commit

Permalink
feat(s3stream): show s3 configure in DefaultS3Operator; add S3Utils (#…
Browse files Browse the repository at this point in the history
…840)

Signed-off-by: Curtis Wan <[email protected]>
  • Loading branch information
mooc9988 authored Dec 16, 2023
1 parent 1b2e195 commit 6a00e83
Show file tree
Hide file tree
Showing 2 changed files with 487 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.automq.stream.utils.ThreadUtils;
import com.automq.stream.utils.Threads;
import com.automq.stream.utils.Utils;
import com.automq.stream.utils.S3Utils;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.CompositeByteBuf;
import io.netty.buffer.Unpooled;
Expand Down Expand Up @@ -121,8 +122,16 @@ public DefaultS3Operator(String endpoint, String region, String bucket, boolean
this.bucket = bucket;
scheduler.scheduleWithFixedDelay(this::tryMergeRead, 1, 1, TimeUnit.MILLISECONDS);
checkConfig();
S3Utils.S3Context s3Context = S3Utils.S3Context.builder()
.setEndpoint(endpoint)
.setRegion(region)
.setBucketName(bucket)
.setForcePathStyle(forcePathStyle)
.setAccessKey(accessKey)
.setSecretKey(secretKey)
.build();
LOGGER.info("You are using s3Context: {}", s3Context);
checkAvailable();
LOGGER.info("S3Operator init with endpoint={} region={} bucket={}, read data sparsity rate={}", endpoint, region, bucket, this.maxMergeReadSparsityRate);
}

public static Builder builder() {
Expand Down Expand Up @@ -585,8 +594,8 @@ private void checkAvailable() {
read.release();
this.delete(multipartPath).get(30, TimeUnit.SECONDS);
} catch (Throwable e) {
LOGGER.error("Try connect s3 fail, please re-check the server configs", e);
throw new IllegalArgumentException("Try connect s3 fail, please re-check the server configs", e);
LOGGER.error("Try to write/read/delete object to S3 fail ", e);
throw new RuntimeException("Try connect s3 fail, please re-check the server configs", e);
}
}

Expand Down
Loading

0 comments on commit 6a00e83

Please sign in to comment.