This is an automated email from the ASF dual-hosted git repository.
lidongdai pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git
The following commit(s) were added to refs/heads/dev by this push:
new d39bdcb165 [RemoteLogging] Move init into loghandler (#15780)
d39bdcb165 is described below
commit d39bdcb165c069792fd33cad5c1fb441f7c5ae47
Author: John Huang <[email protected]>
AuthorDate: Sun Mar 31 21:47:26 2024 +0800
[RemoteLogging] Move init into loghandler (#15780)
Co-authored-by: 旺阳 <[email protected]>
---
.../common/log/remote/GcsRemoteLogHandler.java | 21 ++++++++-------------
.../common/log/remote/OssRemoteLogHandler.java | 17 ++++++-----------
.../common/log/remote/S3RemoteLogHandler.java | 19 +++++++------------
3 files changed, 21 insertions(+), 36 deletions(-)
diff --git
a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/log/remote/GcsRemoteLogHandler.java
b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/log/remote/GcsRemoteLogHandler.java
index 20fd30336e..ad6e534251 100644
---
a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/log/remote/GcsRemoteLogHandler.java
+++
b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/log/remote/GcsRemoteLogHandler.java
@@ -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();
@@ -73,6 +60,14 @@ public class GcsRemoteLogHandler implements
RemoteLogHandler, Closeable {
}
}
+ public static synchronized GcsRemoteLogHandler getInstance() {
+ if (instance == null) {
+ instance = new GcsRemoteLogHandler();
+ }
+
+ return instance;
+ }
+
@Override
public void close() throws IOException {
try {
diff --git
a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/log/remote/OssRemoteLogHandler.java
b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/log/remote/OssRemoteLogHandler.java
index 792085b194..59b1394515 100644
---
a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/log/remote/OssRemoteLogHandler.java
+++
b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/log/remote/OssRemoteLogHandler.java
@@ -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);
diff --git
a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/log/remote/S3RemoteLogHandler.java
b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/log/remote/S3RemoteLogHandler.java
index d1c8c41445..54dba2d5bd 100644
---
a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/log/remote/S3RemoteLogHandler.java
+++
b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/log/remote/S3RemoteLogHandler.java
@@ -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