You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by GitBox <gi...@apache.org> on 2022/09/05 01:28:43 UTC

[GitHub] [dolphinscheduler] ruanwenjun commented on a diff in pull request #11708: [Feature][Resource Center] Add support for Alibaba Cloud OSS as storage of resource center

ruanwenjun commented on code in PR #11708:
URL: https://github.com/apache/dolphinscheduler/pull/11708#discussion_r962409758


##########
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/config/StoreConfiguration.java:
##########
@@ -41,6 +43,10 @@ public class StoreConfiguration {
     @Bean
     public StorageOperate storageOperate() {
         switch (PropertyUtils.getString(RESOURCE_STORAGE_TYPE)) {
+            case STORAGE_OSS:
+                OssOperator ossOperator = OssOperator.getInstance();
+                ossOperator.init();

Review Comment:
   Since this is a singleton, why you don't put the `init` method into constructor? Can the init method be executed multiple times?



##########
dolphinscheduler-common/pom.xml:
##########
@@ -275,6 +287,12 @@
             <scope>provided</scope>
         </dependency>
 
+        <dependency>
+            <groupId>com.aliyun.oss</groupId>
+            <artifactId>aliyun-sdk-oss</artifactId>
+            <version>3.15.1</version>

Review Comment:
   Please manage the version in bom.
   ```suggestion
   ```



##########
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/PropertyUtilsWrapper.java:
##########
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.common.utils;
+
+import lombok.Data;
+
+@Data
+public class PropertyUtilsWrapper {

Review Comment:
   I don't see this class doing any enhancement, why we don't directly execute `PropertyUtils.getString`



##########
tools/dependencies/known-dependencies.txt:
##########
@@ -289,3 +289,14 @@ zeppelin-client-0.10.1.jar
 zeppelin-common-0.10.1.jar
 zjsonpatch-0.3.0.jar
 zookeeper-3.4.14.jar
+aliyun-java-sdk-core-4.5.10.jar

Review Comment:
   Please update the LICENSE. 



##########
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/OssOperator.java:
##########
@@ -0,0 +1,321 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.common.utils;
+
+import static org.apache.dolphinscheduler.common.Constants.ALIBABA_CLOUD_OSS_END_POINT;
+import static org.apache.dolphinscheduler.common.Constants.FOLDER_SEPARATOR;
+import static org.apache.dolphinscheduler.common.Constants.FORMAT_S_S;
+import static org.apache.dolphinscheduler.common.Constants.RESOURCE_TYPE_FILE;
+import static org.apache.dolphinscheduler.common.Constants.RESOURCE_TYPE_UDF;
+
+import org.apache.dolphinscheduler.common.Constants;
+import org.apache.dolphinscheduler.common.enums.ResUploadType;
+import org.apache.dolphinscheduler.common.storage.StorageOperate;
+import org.apache.dolphinscheduler.plugin.task.api.TaskConstants;
+import org.apache.dolphinscheduler.spi.enums.ResourceType;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.Closeable;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.nio.file.Files;
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.aliyun.oss.OSS;
+import com.aliyun.oss.OSSClientBuilder;
+import com.aliyun.oss.OSSException;
+import com.aliyun.oss.model.Bucket;
+import com.aliyun.oss.model.OSSObject;
+import com.aliyun.oss.model.ObjectMetadata;
+import com.aliyun.oss.model.PutObjectRequest;
+
+public class OssOperator implements Closeable, StorageOperate {
+
+    private static final Logger logger = LoggerFactory.getLogger(OssOperator.class);
+
+    public static String ACCESS_KEY_ID;
+
+    public static String ACCESS_KEY_SECRET;
+
+    public static String REGION;
+
+    public static String BUCKET_NAME;
+
+    public static String BASE_DIR = "";
+
+    private OSS ossClient;
+
+    private PropertyUtilsWrapper propertyUtilsWrapper;
+
+    private OssOperator() {
+    }
+
+    private enum OssOperatorSingleton {
+
+        INSTANCE;
+
+        private final OssOperator instance;
+
+        OssOperatorSingleton() {
+            instance = new OssOperator();
+        }
+
+        private OssOperator getInstance() {
+            return instance;
+        }
+    }
+
+    public static OssOperator getInstance() {
+        return OssOperatorSingleton.INSTANCE.getInstance();
+    }
+
+    public void init() {
+        propertyUtilsWrapper = createPropertyUtilsWrapper();
+        ACCESS_KEY_ID = propertyUtilsWrapper.getString(TaskConstants.ALIBABA_CLOUD_ACCESS_KEY_ID);
+        ACCESS_KEY_SECRET = propertyUtilsWrapper.getString(TaskConstants.ALIBABA_CLOUD_ACCESS_KEY_SECRET);
+        REGION = propertyUtilsWrapper.getString(TaskConstants.ALIBABA_CLOUD_REGION);
+        BUCKET_NAME = propertyUtilsWrapper.getString(Constants.ALIBABA_CLOUD_OSS_BUCKET_NAME);
+
+        ossClient = buildOssClient();
+        ensureBucketSuccessfullyCreated(BUCKET_NAME);
+    }
+
+    @Override
+    public void close() throws IOException {
+        ossClient.shutdown();
+    }
+
+    @Override
+    public void createTenantDirIfNotExists(String tenantCode) throws Exception {
+        mkdir(tenantCode, getOssResDir(tenantCode));
+        mkdir(tenantCode, getOssUdfDir(tenantCode));
+    }
+
+    @Override
+    public String getResDir(String tenantCode) {
+        return getOssResDir(tenantCode) + FOLDER_SEPARATOR;
+    }
+
+    @Override
+    public String getUdfDir(String tenantCode) {
+        return getOssUdfDir(tenantCode) + FOLDER_SEPARATOR;
+    }
+
+    @Override
+    public boolean mkdir(String tenantCode, String path) throws IOException {
+        final String key = path + FOLDER_SEPARATOR;
+        if (!ossClient.doesObjectExist(BUCKET_NAME, key)) {
+            createOssPrefix(BUCKET_NAME, key);
+        }
+        return true;
+    }
+
+    protected void createOssPrefix(final String bucketName, final String key) {
+        ObjectMetadata metadata = new ObjectMetadata();
+        metadata.setContentLength(0);
+        InputStream emptyContent = new ByteArrayInputStream(new byte[0]);
+        PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, key, emptyContent, metadata);
+        ossClient.putObject(putObjectRequest);
+    }
+
+    @Override
+    public String getResourceFileName(String tenantCode, String fileName) {
+        if (fileName.startsWith(FOLDER_SEPARATOR)) {
+            fileName = fileName.replaceFirst(FOLDER_SEPARATOR, "");
+        }
+        return String.format(FORMAT_S_S, getOssResDir(tenantCode), fileName);
+    }
+
+    @Override
+    public String getFileName(ResourceType resourceType, String tenantCode, String fileName) {
+        if (fileName.startsWith(FOLDER_SEPARATOR)) {
+            fileName = fileName.replaceFirst(FOLDER_SEPARATOR, "");
+        }
+        return getDir(resourceType, tenantCode) + fileName;
+    }
+
+    @Override
+    public void download(String tenantCode, String srcFilePath, String dstFilePath, boolean deleteSource,
+                         boolean overwrite) throws IOException {
+        File dstFile = new File(dstFilePath);
+        if (dstFile.isDirectory()) {
+            Files.delete(dstFile.toPath());
+        } else {
+            Files.createDirectories(dstFile.getParentFile().toPath());
+        }
+        OSSObject ossObject = ossClient.getObject(BUCKET_NAME, srcFilePath);
+        try (
+                InputStream ossInputStream = ossObject.getObjectContent();
+                FileOutputStream fos = new FileOutputStream(dstFilePath)) {
+            byte[] readBuf = new byte[1024];
+            int readLen;
+            while ((readLen = ossInputStream.read(readBuf)) > 0) {
+                fos.write(readBuf, 0, readLen);
+            }
+        } catch (OSSException e) {
+            throw new IOException(e.getMessage());
+        } catch (FileNotFoundException e) {
+            logger.error("the destination file {} not found", dstFilePath);
+            throw e;
+        }
+    }
+
+    @Override
+    public boolean exists(String tenantCode, String fileName) throws IOException {
+        return ossClient.doesObjectExist(BUCKET_NAME, fileName);
+    }
+
+    @Override
+    public boolean delete(String tenantCode, String filePath, boolean recursive) throws IOException {
+        try {
+            ossClient.deleteObject(BUCKET_NAME, filePath);
+            return true;
+        } catch (OSSException e) {
+            logger.error("delete the object error,the resource path is {}", filePath);
+            return false;
+        }
+    }
+
+    @Override
+    public boolean copy(String srcPath, String dstPath, boolean deleteSource, boolean overwrite) throws IOException {
+        ossClient.copyObject(BUCKET_NAME, srcPath, BUCKET_NAME, dstPath);
+        ossClient.deleteObject(BUCKET_NAME, srcPath);
+        return true;
+    }
+
+    @Override
+    public String getDir(ResourceType resourceType, String tenantCode) {
+        switch (resourceType) {
+            case UDF:
+                return getUdfDir(tenantCode);
+            case FILE:
+                return getResDir(tenantCode);
+            default:
+                return BASE_DIR;
+        }
+    }
+
+    @Override
+    public boolean upload(String tenantCode, String srcFile, String dstPath, boolean deleteSource,
+                          boolean overwrite) throws IOException {
+        try {
+            ossClient.putObject(BUCKET_NAME, dstPath, new File(srcFile));
+            return true;
+        } catch (OSSException e) {
+            logger.error("upload failed,the bucketName is {},the filePath is {}", BUCKET_NAME, dstPath);

Review Comment:
   ```suggestion
               logger.error("upload failed,the bucketName is {},the filePath is {}", BUCKET_NAME, dstPath, e);
   ```



##########
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/OssOperator.java:
##########
@@ -0,0 +1,321 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.common.utils;
+
+import static org.apache.dolphinscheduler.common.Constants.ALIBABA_CLOUD_OSS_END_POINT;
+import static org.apache.dolphinscheduler.common.Constants.FOLDER_SEPARATOR;
+import static org.apache.dolphinscheduler.common.Constants.FORMAT_S_S;
+import static org.apache.dolphinscheduler.common.Constants.RESOURCE_TYPE_FILE;
+import static org.apache.dolphinscheduler.common.Constants.RESOURCE_TYPE_UDF;
+
+import org.apache.dolphinscheduler.common.Constants;
+import org.apache.dolphinscheduler.common.enums.ResUploadType;
+import org.apache.dolphinscheduler.common.storage.StorageOperate;
+import org.apache.dolphinscheduler.plugin.task.api.TaskConstants;
+import org.apache.dolphinscheduler.spi.enums.ResourceType;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.Closeable;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.nio.file.Files;
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.aliyun.oss.OSS;
+import com.aliyun.oss.OSSClientBuilder;
+import com.aliyun.oss.OSSException;
+import com.aliyun.oss.model.Bucket;
+import com.aliyun.oss.model.OSSObject;
+import com.aliyun.oss.model.ObjectMetadata;
+import com.aliyun.oss.model.PutObjectRequest;
+
+public class OssOperator implements Closeable, StorageOperate {
+
+    private static final Logger logger = LoggerFactory.getLogger(OssOperator.class);
+
+    public static String ACCESS_KEY_ID;
+
+    public static String ACCESS_KEY_SECRET;
+
+    public static String REGION;
+
+    public static String BUCKET_NAME;
+
+    public static String BASE_DIR = "";
+
+    private OSS ossClient;
+
+    private PropertyUtilsWrapper propertyUtilsWrapper;
+
+    private OssOperator() {
+    }
+
+    private enum OssOperatorSingleton {
+
+        INSTANCE;
+
+        private final OssOperator instance;
+
+        OssOperatorSingleton() {
+            instance = new OssOperator();
+        }
+
+        private OssOperator getInstance() {
+            return instance;
+        }
+    }
+
+    public static OssOperator getInstance() {
+        return OssOperatorSingleton.INSTANCE.getInstance();
+    }
+
+    public void init() {
+        propertyUtilsWrapper = createPropertyUtilsWrapper();
+        ACCESS_KEY_ID = propertyUtilsWrapper.getString(TaskConstants.ALIBABA_CLOUD_ACCESS_KEY_ID);
+        ACCESS_KEY_SECRET = propertyUtilsWrapper.getString(TaskConstants.ALIBABA_CLOUD_ACCESS_KEY_SECRET);
+        REGION = propertyUtilsWrapper.getString(TaskConstants.ALIBABA_CLOUD_REGION);
+        BUCKET_NAME = propertyUtilsWrapper.getString(Constants.ALIBABA_CLOUD_OSS_BUCKET_NAME);
+
+        ossClient = buildOssClient();
+        ensureBucketSuccessfullyCreated(BUCKET_NAME);
+    }
+
+    @Override
+    public void close() throws IOException {
+        ossClient.shutdown();
+    }
+
+    @Override
+    public void createTenantDirIfNotExists(String tenantCode) throws Exception {
+        mkdir(tenantCode, getOssResDir(tenantCode));
+        mkdir(tenantCode, getOssUdfDir(tenantCode));
+    }
+
+    @Override
+    public String getResDir(String tenantCode) {
+        return getOssResDir(tenantCode) + FOLDER_SEPARATOR;
+    }
+
+    @Override
+    public String getUdfDir(String tenantCode) {
+        return getOssUdfDir(tenantCode) + FOLDER_SEPARATOR;
+    }
+
+    @Override
+    public boolean mkdir(String tenantCode, String path) throws IOException {
+        final String key = path + FOLDER_SEPARATOR;
+        if (!ossClient.doesObjectExist(BUCKET_NAME, key)) {
+            createOssPrefix(BUCKET_NAME, key);
+        }
+        return true;
+    }
+
+    protected void createOssPrefix(final String bucketName, final String key) {
+        ObjectMetadata metadata = new ObjectMetadata();
+        metadata.setContentLength(0);
+        InputStream emptyContent = new ByteArrayInputStream(new byte[0]);
+        PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, key, emptyContent, metadata);
+        ossClient.putObject(putObjectRequest);
+    }
+
+    @Override
+    public String getResourceFileName(String tenantCode, String fileName) {
+        if (fileName.startsWith(FOLDER_SEPARATOR)) {
+            fileName = fileName.replaceFirst(FOLDER_SEPARATOR, "");
+        }
+        return String.format(FORMAT_S_S, getOssResDir(tenantCode), fileName);
+    }
+
+    @Override
+    public String getFileName(ResourceType resourceType, String tenantCode, String fileName) {
+        if (fileName.startsWith(FOLDER_SEPARATOR)) {
+            fileName = fileName.replaceFirst(FOLDER_SEPARATOR, "");
+        }
+        return getDir(resourceType, tenantCode) + fileName;
+    }
+
+    @Override
+    public void download(String tenantCode, String srcFilePath, String dstFilePath, boolean deleteSource,
+                         boolean overwrite) throws IOException {
+        File dstFile = new File(dstFilePath);
+        if (dstFile.isDirectory()) {
+            Files.delete(dstFile.toPath());
+        } else {
+            Files.createDirectories(dstFile.getParentFile().toPath());
+        }
+        OSSObject ossObject = ossClient.getObject(BUCKET_NAME, srcFilePath);
+        try (
+                InputStream ossInputStream = ossObject.getObjectContent();
+                FileOutputStream fos = new FileOutputStream(dstFilePath)) {
+            byte[] readBuf = new byte[1024];
+            int readLen;
+            while ((readLen = ossInputStream.read(readBuf)) > 0) {
+                fos.write(readBuf, 0, readLen);
+            }
+        } catch (OSSException e) {
+            throw new IOException(e.getMessage());

Review Comment:
   ```suggestion
               throw new IOException(e);
   ```
   Don't hide the stack.



##########
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/OssOperator.java:
##########
@@ -0,0 +1,321 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.common.utils;
+
+import static org.apache.dolphinscheduler.common.Constants.ALIBABA_CLOUD_OSS_END_POINT;
+import static org.apache.dolphinscheduler.common.Constants.FOLDER_SEPARATOR;
+import static org.apache.dolphinscheduler.common.Constants.FORMAT_S_S;
+import static org.apache.dolphinscheduler.common.Constants.RESOURCE_TYPE_FILE;
+import static org.apache.dolphinscheduler.common.Constants.RESOURCE_TYPE_UDF;
+
+import org.apache.dolphinscheduler.common.Constants;
+import org.apache.dolphinscheduler.common.enums.ResUploadType;
+import org.apache.dolphinscheduler.common.storage.StorageOperate;
+import org.apache.dolphinscheduler.plugin.task.api.TaskConstants;
+import org.apache.dolphinscheduler.spi.enums.ResourceType;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.Closeable;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.nio.file.Files;
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.aliyun.oss.OSS;
+import com.aliyun.oss.OSSClientBuilder;
+import com.aliyun.oss.OSSException;
+import com.aliyun.oss.model.Bucket;
+import com.aliyun.oss.model.OSSObject;
+import com.aliyun.oss.model.ObjectMetadata;
+import com.aliyun.oss.model.PutObjectRequest;
+
+public class OssOperator implements Closeable, StorageOperate {
+
+    private static final Logger logger = LoggerFactory.getLogger(OssOperator.class);
+
+    public static String ACCESS_KEY_ID;
+
+    public static String ACCESS_KEY_SECRET;
+
+    public static String REGION;
+
+    public static String BUCKET_NAME;
+
+    public static String BASE_DIR = "";
+
+    private OSS ossClient;
+
+    private PropertyUtilsWrapper propertyUtilsWrapper;
+
+    private OssOperator() {
+    }
+
+    private enum OssOperatorSingleton {
+
+        INSTANCE;
+
+        private final OssOperator instance;
+
+        OssOperatorSingleton() {
+            instance = new OssOperator();
+        }
+
+        private OssOperator getInstance() {
+            return instance;
+        }
+    }
+
+    public static OssOperator getInstance() {
+        return OssOperatorSingleton.INSTANCE.getInstance();
+    }
+
+    public void init() {
+        propertyUtilsWrapper = createPropertyUtilsWrapper();
+        ACCESS_KEY_ID = propertyUtilsWrapper.getString(TaskConstants.ALIBABA_CLOUD_ACCESS_KEY_ID);
+        ACCESS_KEY_SECRET = propertyUtilsWrapper.getString(TaskConstants.ALIBABA_CLOUD_ACCESS_KEY_SECRET);
+        REGION = propertyUtilsWrapper.getString(TaskConstants.ALIBABA_CLOUD_REGION);
+        BUCKET_NAME = propertyUtilsWrapper.getString(Constants.ALIBABA_CLOUD_OSS_BUCKET_NAME);
+
+        ossClient = buildOssClient();
+        ensureBucketSuccessfullyCreated(BUCKET_NAME);
+    }
+
+    @Override
+    public void close() throws IOException {
+        ossClient.shutdown();
+    }
+
+    @Override
+    public void createTenantDirIfNotExists(String tenantCode) throws Exception {
+        mkdir(tenantCode, getOssResDir(tenantCode));
+        mkdir(tenantCode, getOssUdfDir(tenantCode));
+    }
+
+    @Override
+    public String getResDir(String tenantCode) {
+        return getOssResDir(tenantCode) + FOLDER_SEPARATOR;
+    }
+
+    @Override
+    public String getUdfDir(String tenantCode) {
+        return getOssUdfDir(tenantCode) + FOLDER_SEPARATOR;
+    }
+
+    @Override
+    public boolean mkdir(String tenantCode, String path) throws IOException {
+        final String key = path + FOLDER_SEPARATOR;
+        if (!ossClient.doesObjectExist(BUCKET_NAME, key)) {
+            createOssPrefix(BUCKET_NAME, key);
+        }
+        return true;
+    }
+
+    protected void createOssPrefix(final String bucketName, final String key) {
+        ObjectMetadata metadata = new ObjectMetadata();
+        metadata.setContentLength(0);
+        InputStream emptyContent = new ByteArrayInputStream(new byte[0]);
+        PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, key, emptyContent, metadata);
+        ossClient.putObject(putObjectRequest);
+    }
+
+    @Override
+    public String getResourceFileName(String tenantCode, String fileName) {
+        if (fileName.startsWith(FOLDER_SEPARATOR)) {
+            fileName = fileName.replaceFirst(FOLDER_SEPARATOR, "");
+        }
+        return String.format(FORMAT_S_S, getOssResDir(tenantCode), fileName);
+    }
+
+    @Override
+    public String getFileName(ResourceType resourceType, String tenantCode, String fileName) {
+        if (fileName.startsWith(FOLDER_SEPARATOR)) {
+            fileName = fileName.replaceFirst(FOLDER_SEPARATOR, "");
+        }
+        return getDir(resourceType, tenantCode) + fileName;
+    }
+
+    @Override
+    public void download(String tenantCode, String srcFilePath, String dstFilePath, boolean deleteSource,
+                         boolean overwrite) throws IOException {
+        File dstFile = new File(dstFilePath);
+        if (dstFile.isDirectory()) {
+            Files.delete(dstFile.toPath());
+        } else {
+            Files.createDirectories(dstFile.getParentFile().toPath());
+        }
+        OSSObject ossObject = ossClient.getObject(BUCKET_NAME, srcFilePath);
+        try (
+                InputStream ossInputStream = ossObject.getObjectContent();
+                FileOutputStream fos = new FileOutputStream(dstFilePath)) {
+            byte[] readBuf = new byte[1024];
+            int readLen;
+            while ((readLen = ossInputStream.read(readBuf)) > 0) {
+                fos.write(readBuf, 0, readLen);
+            }
+        } catch (OSSException e) {
+            throw new IOException(e.getMessage());
+        } catch (FileNotFoundException e) {
+            logger.error("the destination file {} not found", dstFilePath);
+            throw e;
+        }
+    }
+
+    @Override
+    public boolean exists(String tenantCode, String fileName) throws IOException {
+        return ossClient.doesObjectExist(BUCKET_NAME, fileName);
+    }
+
+    @Override
+    public boolean delete(String tenantCode, String filePath, boolean recursive) throws IOException {
+        try {
+            ossClient.deleteObject(BUCKET_NAME, filePath);
+            return true;
+        } catch (OSSException e) {
+            logger.error("delete the object error,the resource path is {}", filePath);

Review Comment:
   ```suggestion
               logger.error("delete the object error,the resource path is {}", filePath, e);
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org