Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Improvement][RemoteLogging] Move init into loghandler #15780

Merged
merged 2 commits into from
Mar 31, 2024
Merged
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 @@ -49,19 +49,6 @@ public class GcsRemoteLogHandler implements RemoteLogHandler, Closeable {
private static GcsRemoteLogHandler instance;

private GcsRemoteLogHandler() {

}

public static synchronized GcsRemoteLogHandler getInstance() {
if (instance == null) {
instance = new GcsRemoteLogHandler();
instance.init();
}

return instance;
}

public void init() {
try {
credential = readCredentials();
bucketName = readBucketName();
Expand All @@ -73,6 +60,14 @@ public void init() {
}
}

public static synchronized GcsRemoteLogHandler getInstance() {
if (instance == null) {
instance = new GcsRemoteLogHandler();
}

return instance;
}

@Override
public void close() throws IOException {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,28 +44,23 @@ public class OssRemoteLogHandler implements RemoteLogHandler, Closeable {
private static OssRemoteLogHandler instance;

private OssRemoteLogHandler() {
String accessKeyId = readOssAccessKeyId();
String accessKeySecret = readOssAccessKeySecret();
String endpoint = readOssEndpoint();
ossClient = OssClientFactory.buildOssClient(new OssConnection(accessKeyId, accessKeySecret, endpoint));

bucketName = readOssBucketName();
checkBucketNameExists(bucketName);
}

public static synchronized OssRemoteLogHandler getInstance() {
if (instance == null) {
instance = new OssRemoteLogHandler();
instance.init();
}

return instance;
}

public void init() {
String accessKeyId = readOssAccessKeyId();
String accessKeySecret = readOssAccessKeySecret();
String endpoint = readOssEndpoint();
ossClient = OssClientFactory.buildOssClient(new OssConnection(accessKeyId, accessKeySecret, endpoint));

bucketName = readOssBucketName();
checkBucketNameExists(bucketName);
}

@Override
public void sendRemoteLog(String logPath) {
String objectName = RemoteLogUtils.getObjectNameFromLogPath(logPath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,28 +56,23 @@ public class S3RemoteLogHandler implements RemoteLogHandler, Closeable {
private static S3RemoteLogHandler instance;

private S3RemoteLogHandler() {

accessKeyId = readAccessKeyID();
accessKeySecret = readAccessKeySecret();
region = readRegion();
bucketName = readBucketName();
endPoint = readEndPoint();
s3Client = buildS3Client();
checkBucketNameExists(bucketName);
}

public static synchronized S3RemoteLogHandler getInstance() {
if (instance == null) {
instance = new S3RemoteLogHandler();
instance.init();
}

return instance;
}

public void init() {
accessKeyId = readAccessKeyID();
accessKeySecret = readAccessKeySecret();
region = readRegion();
bucketName = readBucketName();
endPoint = readEndPoint();
s3Client = buildS3Client();
checkBucketNameExists(bucketName);
}

protected AmazonS3 buildS3Client() {
if (StringUtils.isNotEmpty(endPoint)) {
return AmazonS3ClientBuilder
Expand Down
Loading