You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by "Mighten (via GitHub)" <gi...@apache.org> on 2024/09/02 11:08:23 UTC

[PR] [feature-16396][Resource Center] Tencent Cloud COS Storage Plugin [dolphinscheduler]

Mighten opened a new pull request, #16565:
URL: https://github.com/apache/dolphinscheduler/pull/16565

   <!--Thanks very much for contributing to Apache DolphinScheduler, we are happy that you want to help us improve DolphinScheduler! -->
   
   ## Purpose of the pull request
   
   This pull request adds a Storage Plugin to the DS Resource Center to support Tencent Cloud COS and aims to close #16396 .
   - #16396 
   
   <!--(For example: This pull request adds checkstyle plugin).-->
   
   ## Brief change log
   
   - *Add `dolphinscheduler-storage-cos` in `dolphinscheduler-storage-plugin`*
   - *Add qcloud cos_api to pom.xml files*
   
   ## Verify this pull request
   
   ![Screenshot-ds](https://github.com/user-attachments/assets/05ecf0ee-7b5e-4da5-89cd-64d1c310c24a)
   
   ![Screenshot-qcloud](https://github.com/user-attachments/assets/c5519b78-fcf0-48ac-99b0-2ac7ac661fe3)
   
   ## Pull Request Notice
   [Pull Request Notice](https://github.com/apache/dolphinscheduler/blob/dev/docs/docs/en/contribute/join/pull-request.md)
   
   If your pull request contain incompatible change, you should also add it to `docs/docs/en/guide/upgrede/incompatible.md`
   


-- 
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


Re: [PR] [Feature-16396][storage-plugin] Tencent Cloud COS Storage Plugin [dolphinscheduler]

Posted by "Mighten (via GitHub)" <gi...@apache.org>.
Mighten commented on code in PR #16565:
URL: https://github.com/apache/dolphinscheduler/pull/16565#discussion_r1740905639


##########
tools/dependencies/known-dependencies.txt:
##########
@@ -485,6 +485,7 @@ azure-storage-blob-12.21.0.jar
 azure-storage-internal-avro-12.6.0.jar
 vertica-jdbc-12.0.4-0.jar
 esdk-obs-java-bundle-3.23.3.jar
+cos_api-5.6.231.jar

Review Comment:
   license for `cos_api-5.6.231.jar` is defined in `dolphinscheduler-dist/release-docs/LICENSE`:
   
   ```text
   cos_api 5.6.231 https://mvnrepository.com/artifact/com.qcloud/cos_api/5.6.231, MIT
   ```
   



-- 
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


Re: [PR] [Feature-16396][storage-plugin] Add Tencent Cloud COS Storage Plugin [dolphinscheduler]

Posted by "SbloodyS (via GitHub)" <gi...@apache.org>.
SbloodyS commented on code in PR #16565:
URL: https://github.com/apache/dolphinscheduler/pull/16565#discussion_r1775211878


##########
dolphinscheduler-storage-plugin/dolphinscheduler-storage-cos/pom.xml:
##########
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.dolphinscheduler</groupId>
+        <artifactId>dolphinscheduler-storage-plugin</artifactId>
+        <version>dev-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>dolphinscheduler-storage-cos</artifactId>
+
+    <properties>
+        <plugin.name>storage.cos</plugin.name>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.dolphinscheduler</groupId>
+            <artifactId>dolphinscheduler-common</artifactId>
+            <version>${project.version}</version>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>com.qcloud</groupId>
+            <artifactId>cos_api</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.dolphinscheduler</groupId>
+            <artifactId>dolphinscheduler-storage-api</artifactId>
+            <version>${project.version}</version>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.dolphinscheduler</groupId>
+            <artifactId>dolphinscheduler-task-api</artifactId>

Review Comment:
   Why import this module?



##########
dolphinscheduler-storage-plugin/dolphinscheduler-storage-cos/pom.xml:
##########
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.dolphinscheduler</groupId>
+        <artifactId>dolphinscheduler-storage-plugin</artifactId>
+        <version>dev-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>dolphinscheduler-storage-cos</artifactId>
+
+    <properties>
+        <plugin.name>storage.cos</plugin.name>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.dolphinscheduler</groupId>
+            <artifactId>dolphinscheduler-common</artifactId>
+            <version>${project.version}</version>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>com.qcloud</groupId>
+            <artifactId>cos_api</artifactId>
+        </dependency>

Review Comment:
   Please put the dependency of dolphinscheduler above the third-party dependency, and the third-party dependency below.



-- 
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


Re: [PR] [Feature-16396][storage-plugin] Tencent Cloud COS Storage Plugin [dolphinscheduler]

Posted by "Mighten (via GitHub)" <gi...@apache.org>.
Mighten commented on code in PR #16565:
URL: https://github.com/apache/dolphinscheduler/pull/16565#discussion_r1769532967


##########
dolphinscheduler-storage-plugin/dolphinscheduler-storage-cos/src/main/java/org/apache/dolphinscheduler/plugin/storage/cos/CosStorageOperator.java:
##########
@@ -0,0 +1,332 @@
+/*
+ * 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.plugin.storage.cos;
+
+import org.apache.dolphinscheduler.common.constants.Constants;
+import org.apache.dolphinscheduler.common.utils.FileUtils;
+import org.apache.dolphinscheduler.plugin.storage.api.AbstractStorageOperator;
+import org.apache.dolphinscheduler.plugin.storage.api.ResourceMetadata;
+import org.apache.dolphinscheduler.plugin.storage.api.StorageEntity;
+import org.apache.dolphinscheduler.plugin.storage.api.StorageOperator;
+
+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.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.nio.file.FileAlreadyExistsException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.stream.Collectors;
+
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+
+import com.qcloud.cos.COSClient;
+import com.qcloud.cos.ClientConfig;
+import com.qcloud.cos.auth.BasicCOSCredentials;
+import com.qcloud.cos.auth.COSCredentials;
+import com.qcloud.cos.exception.CosServiceException;
+import com.qcloud.cos.http.HttpProtocol;
+import com.qcloud.cos.model.COSObject;
+import com.qcloud.cos.model.COSObjectSummary;
+import com.qcloud.cos.model.CopyObjectRequest;
+import com.qcloud.cos.model.CopyResult;
+import com.qcloud.cos.model.GetObjectRequest;
+import com.qcloud.cos.model.ListObjectsRequest;
+import com.qcloud.cos.model.ObjectListing;
+import com.qcloud.cos.model.ObjectMetadata;
+import com.qcloud.cos.model.PutObjectRequest;
+import com.qcloud.cos.model.UploadResult;
+import com.qcloud.cos.region.Region;
+import com.qcloud.cos.transfer.Copy;
+import com.qcloud.cos.transfer.Download;
+import com.qcloud.cos.transfer.TransferManager;
+import com.qcloud.cos.transfer.TransferManagerConfiguration;
+import com.qcloud.cos.transfer.Upload;
+
+@Slf4j
+public class CosStorageOperator extends AbstractStorageOperator implements Closeable, StorageOperator {
+
+    private static final int TRANSFER_THREAD_POOL_SIZE = 16;
+
+    private static final long MULTIPART_UPLOAD_BYTES_THRESHOLD = 5 * 1024 * 1024L;
+    private static final long MIN_UPLOAD_PART_BYTES = 1024 * 1024L;
+
+    private final String bucketName;
+
+    private final COSClient cosClient;
+
+    private final TransferManager cosTransferManager;
+
+    public CosStorageOperator(CosStorageProperties cosStorageProperties) {
+        super(cosStorageProperties.getResourceUploadPath());
+        String secretId = cosStorageProperties.getAccessKeyId();
+        String secretKey = cosStorageProperties.getAccessKeySecret();
+        COSCredentials cosCredentials = new BasicCOSCredentials(secretId, secretKey);
+        String regionName = cosStorageProperties.getRegion();
+        ClientConfig clientConfig = new ClientConfig(new Region(regionName));
+        clientConfig.setHttpProtocol(HttpProtocol.https);
+        this.cosClient = new COSClient(cosCredentials, clientConfig);
+        this.bucketName = cosStorageProperties.getBucketName();
+        ensureBucketSuccessfullyCreated(bucketName);
+        this.cosTransferManager = getCosTransferManager();
+    }
+
+    @Override
+    public void close() throws IOException {
+        this.cosTransferManager.shutdownNow(true);
+    }
+
+    @Override
+    public String getStorageBaseDirectory() {
+        // All directory should end with File.separator
+        if (resourceBaseAbsolutePath.startsWith("/")) {

Review Comment:
   The `File.separator` works poorly on Windows 11 x64.
   
   ![Screenshot 2024-09-21 184343](https://github.com/user-attachments/assets/e53415c7-1afb-4cfe-be99-225bf36ae793)
   
   - When the user successfully uploads the "test.log" file, there is no way to enter the deeper directory to view the file.
   - When the user tries to delete the folder, an exception is thrown stating that the folder does not exist.
   
   So, for now, I think we should continue using the UNIX filesystem separator ("/"), just like the already existing code, until a **DSIP** for *Windows platform compatibility* is provided.
   
   ![existing-unix-like-file-separator-codes](https://github.com/user-attachments/assets/43052efa-9a57-46ff-90d6-73276e6d3ab5)
   



-- 
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


Re: [PR] [Feature-16396][storage-plugin] Tencent Cloud COS Storage Plugin [dolphinscheduler]

Posted by "fuchanghai (via GitHub)" <gi...@apache.org>.
fuchanghai commented on PR #16565:
URL: https://github.com/apache/dolphinscheduler/pull/16565#issuecomment-2357320637

   <img width="1435" alt="image" src="https://github.com/user-attachments/assets/55aef24c-4682-4fa1-846e-5709665eb56a">
   we should remove bcprov-jdk15on-1.69


-- 
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


Re: [PR] [Feature-16396][storage-plugin] Tencent Cloud COS Storage Plugin [dolphinscheduler]

Posted by "fuchanghai (via GitHub)" <gi...@apache.org>.
fuchanghai commented on code in PR #16565:
URL: https://github.com/apache/dolphinscheduler/pull/16565#discussion_r1764296023


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/TaskConstants.java:
##########
@@ -389,6 +389,12 @@ private TaskConstants() {
     public static final String HUAWEI_CLOUD_ACCESS_KEY_ID = "resource.huawei.cloud.access.key.id";
     public static final String HUAWEI_CLOUD_ACCESS_KEY_SECRET = "resource.huawei.cloud.access.key.secret";
 
+    /**
+     * tencent cloud config
+     */
+    public static final String TENCENT_CLOUD_ACCESS_KEY_ID = "resource.tencent.cloud.access.key.id";
+    public static final String TENCENT_CLOUD_ACCESS_KEY_SECRET = "resource.tencent.cloud.access.key.secret";
+

Review Comment:
   > Move to storage plugin module
   
   agree with @ruanwenjun ,Although the keys and secrets of various storage types are currently placed in the task-api module, I think this is unreasonable and should be placed in their own storage modules or in the storage-api module WDYT @Mighten  cc @SbloodyS  @rickchengx  
   
   <img width="1426" alt="image" src="https://github.com/user-attachments/assets/23b51e31-fdd1-4eb2-a82b-6e3c20e16eb4">
   



-- 
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


Re: [PR] [Feature-16396][storage-plugin] Add Tencent Cloud COS Storage Plugin [dolphinscheduler]

Posted by "SbloodyS (via GitHub)" <gi...@apache.org>.
SbloodyS merged PR #16565:
URL: https://github.com/apache/dolphinscheduler/pull/16565


-- 
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


Re: [PR] [Feature-16396][storage-plugin] Add Tencent Cloud COS Storage Plugin [dolphinscheduler]

Posted by "SbloodyS (via GitHub)" <gi...@apache.org>.
SbloodyS commented on code in PR #16565:
URL: https://github.com/apache/dolphinscheduler/pull/16565#discussion_r1770789511


##########
dolphinscheduler-storage-plugin/dolphinscheduler-storage-cos/pom.xml:
##########
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.dolphinscheduler</groupId>
+        <artifactId>dolphinscheduler-storage-plugin</artifactId>
+        <version>dev-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>dolphinscheduler-storage-cos</artifactId>
+
+    <dependencies>
+        <dependency>
+            <groupId>com.qcloud</groupId>
+            <artifactId>cos_api</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.dolphinscheduler</groupId>
+            <artifactId>dolphinscheduler-storage-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.dolphinscheduler</groupId>
+            <artifactId>dolphinscheduler-task-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+    </dependencies>

Review Comment:
   Can you point out what the problem is?



-- 
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


Re: [PR] [Feature-16396][storage-plugin] Tencent Cloud COS Storage Plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16565:
URL: https://github.com/apache/dolphinscheduler/pull/16565#issuecomment-2366293498

   ## [![Quality Gate Failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-failed-20px.png 'Quality Gate Failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16565) **Quality Gate failed**  
   Failed conditions  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/failed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16565&metric=new_coverage&view=list) (required ≥ 60%)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16565)
   
   


-- 
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


Re: [PR] [Feature-16396][storage-plugin] Add Tencent Cloud COS Storage Plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16565:
URL: https://github.com/apache/dolphinscheduler/pull/16565#issuecomment-2367280506

   ## [![Quality Gate Failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-failed-20px.png 'Quality Gate Failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16565) **Quality Gate failed**  
   Failed conditions  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/failed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16565&metric=new_coverage&view=list) (required ≥ 60%)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16565)
   
   


-- 
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


Re: [PR] [Feature-16396][storage-plugin] Add Tencent Cloud COS Storage Plugin [dolphinscheduler]

Posted by "Mighten (via GitHub)" <gi...@apache.org>.
Mighten commented on code in PR #16565:
URL: https://github.com/apache/dolphinscheduler/pull/16565#discussion_r1770825420


##########
dolphinscheduler-storage-plugin/dolphinscheduler-storage-cos/pom.xml:
##########
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.dolphinscheduler</groupId>
+        <artifactId>dolphinscheduler-storage-plugin</artifactId>
+        <version>dev-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>dolphinscheduler-storage-cos</artifactId>
+
+    <dependencies>
+        <dependency>
+            <groupId>com.qcloud</groupId>
+            <artifactId>cos_api</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.dolphinscheduler</groupId>
+            <artifactId>dolphinscheduler-storage-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.dolphinscheduler</groupId>
+            <artifactId>dolphinscheduler-task-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+    </dependencies>

Review Comment:
   Please see another *unresolved conversation* regarding this PR (#16565), at the file: `CosStorageOperator.java`:
   
   > ```java
   >            log.warn("{} -> {} should not start with / in cos", Constants.RESOURCE_UPLOAD_PATH,
   >                    resourceBaseAbsolutePath);
   >            return resourceBaseAbsolutePath.substring(1);
   > ```
   > [@SbloodyS](https://github.com/SbloodyS): It's better to throw exception here since there may be abnormal data in this.
   
   
   The updated code will throw an exception and get stuck on the login page:
   
   ```java
       @Override
       public String getStorageBaseDirectory() {
           // All directory should end with File.separator
           if (resourceBaseAbsolutePath.startsWith("/")) { //  use ----> File.separator
               String errorMessage =
                       String.format("%s -> %s should not start with %s in tencent cos",
                               StorageConstants.RESOURCE_UPLOAD_PATH,
                               resourceBaseAbsolutePath, "/"); // use ----> File.separator
               throw new IllegalArgumentException(errorMessage);
           }
           return resourceBaseAbsolutePath;
       }
   ```
   
   ![Screenshot 2024-09-23 123421](https://github.com/user-attachments/assets/09d8f292-27f2-4cbc-8a07-6fe036ff369f)
   
   Since there are existing test cases stating that `resource.storage.upload.base.path=/dolphinscheduler`:
   
   ![Screenshot 2024-09-23 123813](https://github.com/user-attachments/assets/91746449-27e7-4a2f-8a13-1b26c8a38253)
   
   Throwing an exception will cause the E2E tests to fail.



-- 
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


Re: [PR] [Feature-16396][storage-plugin] Add Tencent Cloud COS Storage Plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16565:
URL: https://github.com/apache/dolphinscheduler/pull/16565#issuecomment-2370103175

   ## [![Quality Gate Failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-failed-20px.png 'Quality Gate Failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16565) **Quality Gate failed**  
   Failed conditions  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/failed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16565&metric=new_coverage&view=list) (required ≥ 60%)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16565)
   
   


-- 
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


Re: [PR] [Feature-16396][storage-plugin] Add Tencent Cloud COS Storage Plugin [dolphinscheduler]

Posted by "boring-cyborg[bot] (via GitHub)" <gi...@apache.org>.
boring-cyborg[bot] commented on PR #16565:
URL: https://github.com/apache/dolphinscheduler/pull/16565#issuecomment-2378803853

   Awesome work, congrats on your first merged pull request!
   


-- 
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


Re: [PR] [Feature-16396][storage-plugin] Add Tencent Cloud COS Storage Plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16565:
URL: https://github.com/apache/dolphinscheduler/pull/16565#issuecomment-2377003423

   Please retry analysis of this Pull-Request directly on SonarCloud


-- 
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


Re: [PR] [Feature-16396][storage-plugin] Tencent Cloud COS Storage Plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16565:
URL: https://github.com/apache/dolphinscheduler/pull/16565#issuecomment-2365430294

   ## [![Quality Gate Failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-failed-20px.png 'Quality Gate Failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16565) **Quality Gate failed**  
   Failed conditions  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/failed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16565&metric=new_coverage&view=list) (required ≥ 60%)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16565)
   
   


-- 
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


Re: [PR] [Feature-16396][storage-plugin] Tencent Cloud COS Storage Plugin [dolphinscheduler]

Posted by "fuchanghai (via GitHub)" <gi...@apache.org>.
fuchanghai commented on code in PR #16565:
URL: https://github.com/apache/dolphinscheduler/pull/16565#discussion_r1769585062


##########
dolphinscheduler-storage-plugin/dolphinscheduler-storage-cos/src/main/java/org/apache/dolphinscheduler/plugin/storage/cos/CosStorageConstants.java:
##########
@@ -0,0 +1,31 @@
+/*
+ * 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.plugin.storage.cos;
+
+public class CosStorageConstants {
+
+    // Tencent Cloud Storage (COS) configuration
+    public static final String TENCENT_CLOUD_COS_PROPERTY_PREFIX = "resource.tencent.cloud";
+    public static final String TENCENT_CLOUD_COS_BUCKET_NAME = "resource.tencent.cloud.cos.bucket.name";
+    public static final String TENCENT_CLOUD_COS_REGION = "resource.tencent.cloud.cos.region";
+    public static final String TENCENT_CLOUD_ACCESS_KEY_ID = "resource.tencent.cloud.access.key.id";
+    public static final String TENCENT_CLOUD_ACCESS_KEY_SECRET = "resource.tencent.cloud.access.key.secret";
+
+    public static final String ILLEGAL_DOWNLOAD_PATH_PREFIX_ETC = "/etc";

Review Comment:
   user ```data.basedir.path```



-- 
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


Re: [PR] [Feature-16396][storage-plugin] Tencent Cloud COS Storage Plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16565:
URL: https://github.com/apache/dolphinscheduler/pull/16565#issuecomment-2363186871

   ## [![Quality Gate Failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-failed-20px.png 'Quality Gate Failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16565) **Quality Gate failed**  
   Failed conditions  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/failed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16565&metric=new_coverage&view=list) (required ≥ 60%)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16565)
   
   


-- 
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


Re: [PR] [Feature-16396][storage-plugin] Tencent Cloud COS Storage Plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16565:
URL: https://github.com/apache/dolphinscheduler/pull/16565#issuecomment-2347865671

   ## [![Quality Gate Failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-failed-20px.png 'Quality Gate Failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16565) **Quality Gate failed**  
   Failed conditions  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/failed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16565&metric=new_coverage&view=list) (required ≥ 60%)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16565)
   
   


-- 
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


Re: [PR] [Feature-16396][storage-plugin] Tencent Cloud COS Storage Plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16565:
URL: https://github.com/apache/dolphinscheduler/pull/16565#issuecomment-2363185032

   ## [![Quality Gate Failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-failed-20px.png 'Quality Gate Failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16565) **Quality Gate failed**  
   Failed conditions  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/failed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16565&metric=new_coverage&view=list) (required ≥ 60%)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16565)
   
   


-- 
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


Re: [PR] [Feature-16396][storage-plugin] Tencent Cloud COS Storage Plugin [dolphinscheduler]

Posted by "fuchanghai (via GitHub)" <gi...@apache.org>.
fuchanghai commented on code in PR #16565:
URL: https://github.com/apache/dolphinscheduler/pull/16565#discussion_r1769512199


##########
dolphinscheduler-storage-plugin/dolphinscheduler-storage-cos/src/main/java/org/apache/dolphinscheduler/plugin/storage/cos/CosStorageOperator.java:
##########
@@ -0,0 +1,332 @@
+/*
+ * 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.plugin.storage.cos;
+
+import org.apache.dolphinscheduler.common.constants.Constants;
+import org.apache.dolphinscheduler.common.utils.FileUtils;
+import org.apache.dolphinscheduler.plugin.storage.api.AbstractStorageOperator;
+import org.apache.dolphinscheduler.plugin.storage.api.ResourceMetadata;
+import org.apache.dolphinscheduler.plugin.storage.api.StorageEntity;
+import org.apache.dolphinscheduler.plugin.storage.api.StorageOperator;
+
+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.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.nio.file.FileAlreadyExistsException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.stream.Collectors;
+
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+
+import com.qcloud.cos.COSClient;
+import com.qcloud.cos.ClientConfig;
+import com.qcloud.cos.auth.BasicCOSCredentials;
+import com.qcloud.cos.auth.COSCredentials;
+import com.qcloud.cos.exception.CosServiceException;
+import com.qcloud.cos.http.HttpProtocol;
+import com.qcloud.cos.model.COSObject;
+import com.qcloud.cos.model.COSObjectSummary;
+import com.qcloud.cos.model.CopyObjectRequest;
+import com.qcloud.cos.model.CopyResult;
+import com.qcloud.cos.model.GetObjectRequest;
+import com.qcloud.cos.model.ListObjectsRequest;
+import com.qcloud.cos.model.ObjectListing;
+import com.qcloud.cos.model.ObjectMetadata;
+import com.qcloud.cos.model.PutObjectRequest;
+import com.qcloud.cos.model.UploadResult;
+import com.qcloud.cos.region.Region;
+import com.qcloud.cos.transfer.Copy;
+import com.qcloud.cos.transfer.Download;
+import com.qcloud.cos.transfer.TransferManager;
+import com.qcloud.cos.transfer.TransferManagerConfiguration;
+import com.qcloud.cos.transfer.Upload;
+
+@Slf4j
+public class CosStorageOperator extends AbstractStorageOperator implements Closeable, StorageOperator {
+
+    private static final int TRANSFER_THREAD_POOL_SIZE = 16;
+
+    private static final long MULTIPART_UPLOAD_BYTES_THRESHOLD = 5 * 1024 * 1024L;
+    private static final long MIN_UPLOAD_PART_BYTES = 1024 * 1024L;
+
+    private final String bucketName;
+
+    private final COSClient cosClient;
+
+    private final TransferManager cosTransferManager;
+
+    public CosStorageOperator(CosStorageProperties cosStorageProperties) {
+        super(cosStorageProperties.getResourceUploadPath());
+        String secretId = cosStorageProperties.getAccessKeyId();
+        String secretKey = cosStorageProperties.getAccessKeySecret();
+        COSCredentials cosCredentials = new BasicCOSCredentials(secretId, secretKey);
+        String regionName = cosStorageProperties.getRegion();
+        ClientConfig clientConfig = new ClientConfig(new Region(regionName));
+        clientConfig.setHttpProtocol(HttpProtocol.https);
+        this.cosClient = new COSClient(cosCredentials, clientConfig);
+        this.bucketName = cosStorageProperties.getBucketName();
+        ensureBucketSuccessfullyCreated(bucketName);
+        this.cosTransferManager = getCosTransferManager();
+    }
+
+    @Override
+    public void close() throws IOException {
+        this.cosTransferManager.shutdownNow(true);
+    }
+
+    @Override
+    public String getStorageBaseDirectory() {
+        // All directory should end with File.separator
+        if (resourceBaseAbsolutePath.startsWith("/")) {
+            log.warn("{} -> {} should not start with / in cos", Constants.RESOURCE_UPLOAD_PATH,
+                    resourceBaseAbsolutePath);
+            return resourceBaseAbsolutePath.substring(1);
+        }
+        return resourceBaseAbsolutePath;
+    }
+
+    @SneakyThrows
+    @Override
+    public void createStorageDir(String directoryAbsolutePath) {
+        String cosKey = transformAbsolutePathToCOSKey(directoryAbsolutePath);
+        if (cosClient.doesObjectExist(bucketName, cosKey)) {
+            throw new FileAlreadyExistsException("directory: " + cosKey + " already exists");
+        }
+        ObjectMetadata metadata = new ObjectMetadata();
+        metadata.setContentLength(0L);
+        InputStream emptyContent = new ByteArrayInputStream(new byte[0]);
+        PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, cosKey, emptyContent, metadata);
+        cosClient.putObject(putObjectRequest);
+    }
+
+    @SneakyThrows
+    @Override
+    public void download(String srcFilePath, String dstFilePath, boolean overwrite) {
+        String cosKey = transformAbsolutePathToCOSKey(srcFilePath);
+        Path normalizedFilePath = Paths.get(dstFilePath).normalize();
+        if (normalizedFilePath.startsWith("/etc")) {

Review Comment:
   reduce magic value



##########
dolphinscheduler-storage-plugin/dolphinscheduler-storage-cos/src/main/java/org/apache/dolphinscheduler/plugin/storage/cos/CosStorageOperatorFactory.java:
##########
@@ -0,0 +1,56 @@
+/*
+ * 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.plugin.storage.cos;
+
+import org.apache.dolphinscheduler.common.constants.Constants;
+import org.apache.dolphinscheduler.common.utils.PropertyUtils;
+import org.apache.dolphinscheduler.plugin.storage.api.StorageOperator;
+import org.apache.dolphinscheduler.plugin.storage.api.StorageOperatorFactory;
+import org.apache.dolphinscheduler.plugin.storage.api.StorageType;
+
+import java.util.Map;
+
+import com.google.auto.service.AutoService;
+
+@AutoService(StorageOperatorFactory.class)
+public class CosStorageOperatorFactory implements StorageOperatorFactory {
+
+    @Override
+    public StorageOperator createStorageOperate() {
+        final CosStorageProperties cosStorageProperties = getCosStorageProperties();
+        return new CosStorageOperator(cosStorageProperties);
+    }
+
+    @Override
+    public StorageType getStorageOperate() {
+        return StorageType.COS;
+    }
+
+    private CosStorageProperties getCosStorageProperties() {
+
+        Map<String, String> cosPropertiesMap = PropertyUtils.getByPrefix("resource.tencent.cloud");
+
+        return CosStorageProperties.builder()
+                .region(cosPropertiesMap.get(CosStorageConstants.TENCENT_CLOUD_COS_REGION))
+                .accessKeyId(cosPropertiesMap.get(CosStorageConstants.TENCENT_CLOUD_ACCESS_KEY_ID))
+                .accessKeySecret(cosPropertiesMap.get(CosStorageConstants.TENCENT_CLOUD_ACCESS_KEY_SECRET))
+                .bucketName(cosPropertiesMap.get(CosStorageConstants.TENCENT_CLOUD_COS_BUCKET_NAME))
+                .resourceUploadPath(cosPropertiesMap.getOrDefault(Constants.RESOURCE_UPLOAD_PATH, "/dolphinscheduler"))

Review Comment:
   ```/dolphinscheduler``` Can be extracted into a constant instead



##########
dolphinscheduler-storage-plugin/dolphinscheduler-storage-cos/src/main/java/org/apache/dolphinscheduler/plugin/storage/cos/CosStorageOperator.java:
##########
@@ -0,0 +1,332 @@
+/*
+ * 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.plugin.storage.cos;
+
+import org.apache.dolphinscheduler.common.constants.Constants;
+import org.apache.dolphinscheduler.common.utils.FileUtils;
+import org.apache.dolphinscheduler.plugin.storage.api.AbstractStorageOperator;
+import org.apache.dolphinscheduler.plugin.storage.api.ResourceMetadata;
+import org.apache.dolphinscheduler.plugin.storage.api.StorageEntity;
+import org.apache.dolphinscheduler.plugin.storage.api.StorageOperator;
+
+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.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.nio.file.FileAlreadyExistsException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.stream.Collectors;
+
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+
+import com.qcloud.cos.COSClient;
+import com.qcloud.cos.ClientConfig;
+import com.qcloud.cos.auth.BasicCOSCredentials;
+import com.qcloud.cos.auth.COSCredentials;
+import com.qcloud.cos.exception.CosServiceException;
+import com.qcloud.cos.http.HttpProtocol;
+import com.qcloud.cos.model.COSObject;
+import com.qcloud.cos.model.COSObjectSummary;
+import com.qcloud.cos.model.CopyObjectRequest;
+import com.qcloud.cos.model.CopyResult;
+import com.qcloud.cos.model.GetObjectRequest;
+import com.qcloud.cos.model.ListObjectsRequest;
+import com.qcloud.cos.model.ObjectListing;
+import com.qcloud.cos.model.ObjectMetadata;
+import com.qcloud.cos.model.PutObjectRequest;
+import com.qcloud.cos.model.UploadResult;
+import com.qcloud.cos.region.Region;
+import com.qcloud.cos.transfer.Copy;
+import com.qcloud.cos.transfer.Download;
+import com.qcloud.cos.transfer.TransferManager;
+import com.qcloud.cos.transfer.TransferManagerConfiguration;
+import com.qcloud.cos.transfer.Upload;
+
+@Slf4j
+public class CosStorageOperator extends AbstractStorageOperator implements Closeable, StorageOperator {
+
+    private static final int TRANSFER_THREAD_POOL_SIZE = 16;
+
+    private static final long MULTIPART_UPLOAD_BYTES_THRESHOLD = 5 * 1024 * 1024L;
+    private static final long MIN_UPLOAD_PART_BYTES = 1024 * 1024L;
+
+    private final String bucketName;
+
+    private final COSClient cosClient;
+
+    private final TransferManager cosTransferManager;
+
+    public CosStorageOperator(CosStorageProperties cosStorageProperties) {
+        super(cosStorageProperties.getResourceUploadPath());
+        String secretId = cosStorageProperties.getAccessKeyId();
+        String secretKey = cosStorageProperties.getAccessKeySecret();
+        COSCredentials cosCredentials = new BasicCOSCredentials(secretId, secretKey);
+        String regionName = cosStorageProperties.getRegion();
+        ClientConfig clientConfig = new ClientConfig(new Region(regionName));
+        clientConfig.setHttpProtocol(HttpProtocol.https);
+        this.cosClient = new COSClient(cosCredentials, clientConfig);
+        this.bucketName = cosStorageProperties.getBucketName();
+        ensureBucketSuccessfullyCreated(bucketName);
+        this.cosTransferManager = getCosTransferManager();
+    }
+
+    @Override
+    public void close() throws IOException {
+        this.cosTransferManager.shutdownNow(true);
+    }
+
+    @Override
+    public String getStorageBaseDirectory() {
+        // All directory should end with File.separator
+        if (resourceBaseAbsolutePath.startsWith("/")) {
+            log.warn("{} -> {} should not start with / in cos", Constants.RESOURCE_UPLOAD_PATH,
+                    resourceBaseAbsolutePath);
+            return resourceBaseAbsolutePath.substring(1);
+        }
+        return resourceBaseAbsolutePath;
+    }
+
+    @SneakyThrows
+    @Override
+    public void createStorageDir(String directoryAbsolutePath) {
+        String cosKey = transformAbsolutePathToCOSKey(directoryAbsolutePath);
+        if (cosClient.doesObjectExist(bucketName, cosKey)) {
+            throw new FileAlreadyExistsException("directory: " + cosKey + " already exists");
+        }
+        ObjectMetadata metadata = new ObjectMetadata();
+        metadata.setContentLength(0L);
+        InputStream emptyContent = new ByteArrayInputStream(new byte[0]);
+        PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, cosKey, emptyContent, metadata);
+        cosClient.putObject(putObjectRequest);
+    }
+
+    @SneakyThrows
+    @Override
+    public void download(String srcFilePath, String dstFilePath, boolean overwrite) {
+        String cosKey = transformAbsolutePathToCOSKey(srcFilePath);
+        Path normalizedFilePath = Paths.get(dstFilePath).normalize();
+        if (normalizedFilePath.startsWith("/etc")) {
+            throw new IllegalArgumentException("failed to download to " + normalizedFilePath);
+        }
+        File dstFile = normalizedFilePath.toFile();
+        if (dstFile.isDirectory()) {
+            Files.delete(dstFile.toPath());
+        } else {
+            FileUtils.createDirectoryWith755(dstFile.getParentFile().toPath());
+        }
+
+        GetObjectRequest getObjectRequest = new GetObjectRequest(bucketName, cosKey);
+        Download download = cosTransferManager.download(getObjectRequest, dstFile);
+        download.waitForCompletion();
+    }
+
+    @Override
+    public boolean exists(String fileName) {
+        String cosKey = transformAbsolutePathToCOSKey(fileName);
+        return cosClient.doesObjectExist(bucketName, cosKey);
+    }
+
+    @Override
+    public void delete(String filePath, boolean recursive) {
+        String cosKey = transformAbsolutePathToCOSKey(filePath);
+        cosClient.deleteObject(bucketName, cosKey);
+    }
+
+    @SneakyThrows
+    @Override
+    public void copy(String srcPath, String dstPath, boolean deleteSource, boolean overwrite) {
+        String srcCosKey = transformAbsolutePathToCOSKey(srcPath);
+        String destCosKey = transformAbsolutePathToCOSKey(dstPath);
+        CopyObjectRequest copyObjectRequest = new CopyObjectRequest(bucketName, srcCosKey, bucketName, destCosKey);
+        Copy copy = cosTransferManager.copy(copyObjectRequest, cosClient, null);
+
+        CopyResult copyResult = copy.waitForCopyResult();
+        if (copyResult != null && deleteSource) {
+            cosClient.deleteObject(bucketName, srcPath);
+        }
+    }
+
+    @SneakyThrows
+    @Override
+    public void upload(String srcFile, String dstPath, boolean deleteSource, boolean overwrite) {
+        dstPath = transformAbsolutePathToCOSKey(dstPath);
+
+        if (cosClient.doesObjectExist(bucketName, dstPath)) {
+            if (!overwrite) {
+                throw new CosServiceException("file: " + dstPath + " already exists");
+            } else {
+                cosClient.deleteObject(bucketName, dstPath);
+            }
+        }
+
+        PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, dstPath, new File(srcFile));
+        Upload upload = cosTransferManager.upload(putObjectRequest);
+        UploadResult uploadResult = upload.waitForUploadResult();
+        if (uploadResult != null && deleteSource) {
+            Files.delete(Paths.get(srcFile));
+        }
+    }
+
+    @SneakyThrows
+    @Override
+    public List<String> fetchFileContent(String filePath, int skipLineNums, int limit) {
+        String cosKey = transformAbsolutePathToCOSKey(filePath);
+
+        COSObject cosObject = cosClient.getObject(bucketName, cosKey);
+        try (
+                InputStreamReader inputStreamReader = new InputStreamReader(cosObject.getObjectContent());
+                BufferedReader bufferedReader = new BufferedReader(inputStreamReader)) {
+            return bufferedReader
+                    .lines()
+                    .skip(skipLineNums)
+                    .limit(limit)
+                    .collect(Collectors.toList());
+        }
+    }
+
+    @Override
+    public List<StorageEntity> listStorageEntity(String resourceAbsolutePath) {
+        resourceAbsolutePath = transformCOSKeyToAbsolutePath(resourceAbsolutePath);
+
+        ListObjectsRequest request = new ListObjectsRequest();
+        request.setBucketName(bucketName);
+        request.setPrefix(resourceAbsolutePath);
+        request.setDelimiter("/");
+
+        ObjectListing result = cosClient.listObjects(request);
+
+        return result.getObjectSummaries()
+                .stream()
+                .map((COSObjectSummary summary) -> {
+                    ObjectMetadata metadata = new ObjectMetadata();
+                    metadata.setContentLength(summary.getSize());
+                    metadata.setLastModified(summary.getLastModified());
+                    COSObject object = new COSObject();
+                    object.setObjectMetadata(metadata);
+                    object.setKey(summary.getKey());
+                    return transformCOSObjectToStorageEntity(object);
+                })
+                .collect(Collectors.toList());
+    }
+
+    @Override
+    public List<StorageEntity> listFileStorageEntityRecursively(String resourceAbsolutePath) {
+        resourceAbsolutePath = transformCOSKeyToAbsolutePath(resourceAbsolutePath);
+
+        Set<String> visited = new HashSet<>();
+        List<StorageEntity> storageEntityList = new ArrayList<>();
+        LinkedList<String> foldersToFetch = new LinkedList<>();
+        foldersToFetch.addLast(resourceAbsolutePath);
+
+        while (!foldersToFetch.isEmpty()) {
+            String pathToExplore = foldersToFetch.pop();
+            visited.add(pathToExplore);
+            List<StorageEntity> storageEntities = listStorageEntity(pathToExplore);
+            for (StorageEntity entity : storageEntities) {
+                if (entity.isDirectory()) {
+                    if (visited.contains(entity.getFullName())) {
+                        continue;
+                    }
+                    foldersToFetch.add(entity.getFullName());
+                }
+            }
+            storageEntityList.addAll(storageEntities);
+        }
+
+        return storageEntityList;
+    }
+
+    @Override
+    public StorageEntity getStorageEntity(String resourceAbsolutePath) {
+        String cosKey = transformCOSKeyToAbsolutePath(resourceAbsolutePath);
+
+        COSObject object = cosClient.getObject(bucketName, cosKey);
+        return transformCOSObjectToStorageEntity(object);
+    }
+
+    public void ensureBucketSuccessfullyCreated(String bucketName) {
+        if (StringUtils.isBlank(bucketName)) {
+            throw new IllegalArgumentException("resource.tencent.cloud.cos.bucket.name is empty");
+        }
+
+        if (!cosClient.doesBucketExist(bucketName)) {
+            throw new IllegalArgumentException(
+                    "bucketName: " + bucketName + " is not exists, you need to create them by yourself");
+        }
+
+        log.info("bucketName: {} has been found", bucketName);
+    }
+
+    protected StorageEntity transformCOSObjectToStorageEntity(COSObject object) {
+        ObjectMetadata metadata = object.getObjectMetadata();
+        String fileAbsolutePath = transformCOSKeyToAbsolutePath(object.getKey());
+        ResourceMetadata resourceMetaData = getResourceMetaData(fileAbsolutePath);
+        String fileExtension = com.google.common.io.Files.getFileExtension(resourceMetaData.getResourceAbsolutePath());
+
+        return StorageEntity.builder()
+                .fileName(new File(fileAbsolutePath).getName())
+                .fullName(fileAbsolutePath)
+                .pfullName(resourceMetaData.getResourceParentAbsolutePath())
+                .type(resourceMetaData.getResourceType())
+                .isDirectory(StringUtils.isEmpty(fileExtension))
+                .size(metadata.getContentLength())
+                .createTime(metadata.getLastModified())
+                .updateTime(metadata.getLastModified())
+                .build();
+    }
+
+    private String transformAbsolutePathToCOSKey(String absolutePath) {
+        ResourceMetadata resourceMetaData = getResourceMetaData(absolutePath);
+        if (resourceMetaData.isDirectory()) {
+            return FileUtils.concatFilePath(absolutePath, "/");

Review Comment:
   same



-- 
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


Re: [PR] [Feature-16396][storage-plugin] Tencent Cloud COS Storage Plugin [dolphinscheduler]

Posted by "ruanwenjun (via GitHub)" <gi...@apache.org>.
ruanwenjun commented on code in PR #16565:
URL: https://github.com/apache/dolphinscheduler/pull/16565#discussion_r1740872405


##########
dolphinscheduler-storage-plugin/dolphinscheduler-storage-cos/src/test/resources/logback.xml:
##########
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>

Review Comment:
   Why add this file?



##########
dolphinscheduler-common/src/main/resources/common.properties:
##########
@@ -73,6 +73,16 @@ resource.huawei.cloud.obs.bucket.name=dolphinscheduler
 resource.huawei.cloud.obs.endpoint=obs.cn-southwest-2.huaweicloud.com
 
 
+# tencent cloud access key id, required if you set resource.storage.type=COS
+resource.tencent.cloud.access.key.id=<your-access-key-id>
+# access key secret, required if you set resource.storage.type=COS
+resource.tencent.cloud.access.key.secret=<your-access-key-secret>
+# cos bucket name, required if you set resource.storage.type=COS
+resource.tencent.cloud.cos.bucket.name=dolphinscheduler
+# cos bucket region, required if you set resource.storage.type=COS, see: https://cloud.tencent.com/document/product/436/6224
+resource.tencent.cloud.cos.region=ap-nanjing

Review Comment:
   Can we add a cos.yaml to storage the config? We don't want to continue add new config in this file,



##########
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/TaskConstants.java:
##########
@@ -389,6 +389,12 @@ private TaskConstants() {
     public static final String HUAWEI_CLOUD_ACCESS_KEY_ID = "resource.huawei.cloud.access.key.id";
     public static final String HUAWEI_CLOUD_ACCESS_KEY_SECRET = "resource.huawei.cloud.access.key.secret";
 
+    /**
+     * tencent cloud config
+     */
+    public static final String TENCENT_CLOUD_ACCESS_KEY_ID = "resource.tencent.cloud.access.key.id";
+    public static final String TENCENT_CLOUD_ACCESS_KEY_SECRET = "resource.tencent.cloud.access.key.secret";
+

Review Comment:
   Move to storage plugin module 



-- 
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


Re: [PR] [Feature-16396][storage-plugin] Tencent Cloud COS Storage Plugin [dolphinscheduler]

Posted by "Mighten (via GitHub)" <gi...@apache.org>.
Mighten commented on code in PR #16565:
URL: https://github.com/apache/dolphinscheduler/pull/16565#discussion_r1740911657


##########
dolphinscheduler-common/src/main/resources/common.properties:
##########
@@ -73,6 +73,16 @@ resource.huawei.cloud.obs.bucket.name=dolphinscheduler
 resource.huawei.cloud.obs.endpoint=obs.cn-southwest-2.huaweicloud.com
 
 
+# tencent cloud access key id, required if you set resource.storage.type=COS
+resource.tencent.cloud.access.key.id=<your-access-key-id>
+# access key secret, required if you set resource.storage.type=COS
+resource.tencent.cloud.access.key.secret=<your-access-key-secret>
+# cos bucket name, required if you set resource.storage.type=COS
+resource.tencent.cloud.cos.bucket.name=dolphinscheduler
+# cos bucket region, required if you set resource.storage.type=COS, see: https://cloud.tencent.com/document/product/436/6224
+resource.tencent.cloud.cos.region=ap-nanjing

Review Comment:
   Yes, I think it is a good idea, especially given the many storage plugins that already exist.



-- 
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


Re: [PR] [Feature-16396][storage-plugin] Tencent Cloud COS Storage Plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16565:
URL: https://github.com/apache/dolphinscheduler/pull/16565#issuecomment-2366112273

   ## [![Quality Gate Failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-failed-20px.png 'Quality Gate Failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16565) **Quality Gate failed**  
   Failed conditions  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/failed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16565&metric=new_coverage&view=list) (required ≥ 60%)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16565)
   
   


-- 
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


Re: [PR] [Feature-16396][storage-plugin] Add Tencent Cloud COS Storage Plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16565:
URL: https://github.com/apache/dolphinscheduler/pull/16565#issuecomment-2378800593

   ## [![Quality Gate Failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-failed-20px.png 'Quality Gate Failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16565) **Quality Gate failed**  
   Failed conditions  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/failed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16565&metric=new_coverage&view=list) (required ≥ 60%)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16565)
   
   


-- 
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


Re: [PR] [Feature-16396][storage-plugin] Tencent Cloud COS Storage Plugin [dolphinscheduler]

Posted by "github-advanced-security[bot] (via GitHub)" <gi...@apache.org>.
github-advanced-security[bot] commented on code in PR #16565:
URL: https://github.com/apache/dolphinscheduler/pull/16565#discussion_r1746480149


##########
dolphinscheduler-storage-plugin/dolphinscheduler-storage-cos/src/main/java/org/apache/dolphinscheduler/plugin/storage/cos/CosStorageOperator.java:
##########
@@ -0,0 +1,328 @@
+/*
+ * 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.plugin.storage.cos;
+
+import org.apache.dolphinscheduler.common.constants.Constants;
+import org.apache.dolphinscheduler.common.utils.FileUtils;
+import org.apache.dolphinscheduler.plugin.storage.api.AbstractStorageOperator;
+import org.apache.dolphinscheduler.plugin.storage.api.ResourceMetadata;
+import org.apache.dolphinscheduler.plugin.storage.api.StorageEntity;
+import org.apache.dolphinscheduler.plugin.storage.api.StorageOperator;
+
+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.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.nio.file.FileAlreadyExistsException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.stream.Collectors;
+
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+
+import com.qcloud.cos.COSClient;
+import com.qcloud.cos.ClientConfig;
+import com.qcloud.cos.auth.BasicCOSCredentials;
+import com.qcloud.cos.auth.COSCredentials;
+import com.qcloud.cos.exception.CosServiceException;
+import com.qcloud.cos.http.HttpProtocol;
+import com.qcloud.cos.model.COSObject;
+import com.qcloud.cos.model.COSObjectSummary;
+import com.qcloud.cos.model.CopyObjectRequest;
+import com.qcloud.cos.model.CopyResult;
+import com.qcloud.cos.model.GetObjectRequest;
+import com.qcloud.cos.model.ListObjectsRequest;
+import com.qcloud.cos.model.ObjectListing;
+import com.qcloud.cos.model.ObjectMetadata;
+import com.qcloud.cos.model.PutObjectRequest;
+import com.qcloud.cos.model.UploadResult;
+import com.qcloud.cos.region.Region;
+import com.qcloud.cos.transfer.Copy;
+import com.qcloud.cos.transfer.Download;
+import com.qcloud.cos.transfer.TransferManager;
+import com.qcloud.cos.transfer.TransferManagerConfiguration;
+import com.qcloud.cos.transfer.Upload;
+
+@Slf4j
+public class CosStorageOperator extends AbstractStorageOperator implements Closeable, StorageOperator {
+
+    private static final int TRANSFER_THREAD_POOL_SIZE = 16;
+
+    private static final long MULTIPART_UPLOAD_BYTES_THRESHOLD = 5 * 1024 * 1024;
+    private static final long MIN_UPLOAD_PART_BYTES = 1024 * 1024;
+
+    private final String bucketName;
+
+    private final COSClient cosClient;
+
+    private final TransferManager cosTransferManager;
+
+    public CosStorageOperator(CosStorageProperties cosStorageProperties) {
+        super(cosStorageProperties.getResourceUploadPath());
+        String secretId = cosStorageProperties.getAccessKeyId();
+        String secretKey = cosStorageProperties.getAccessKeySecret();
+        COSCredentials cosCredentials = new BasicCOSCredentials(secretId, secretKey);
+        String regionName = cosStorageProperties.getRegion();
+        ClientConfig clientConfig = new ClientConfig(new Region(regionName));
+        clientConfig.setHttpProtocol(HttpProtocol.https);
+        this.cosClient = new COSClient(cosCredentials, clientConfig);
+        this.bucketName = cosStorageProperties.getBucketName();
+        ensureBucketSuccessfullyCreated(bucketName);
+        this.cosTransferManager = getCosTransferManager();
+    }
+
+    @Override
+    public void close() throws IOException {
+        this.cosTransferManager.shutdownNow(true);
+    }
+
+    @Override
+    public String getStorageBaseDirectory() {
+        // All directory should end with File.separator
+        if (resourceBaseAbsolutePath.startsWith("/")) {
+            log.warn("{} -> {} should not start with / in cos", Constants.RESOURCE_UPLOAD_PATH,
+                    resourceBaseAbsolutePath);
+            return resourceBaseAbsolutePath.substring(1);
+        }
+        return resourceBaseAbsolutePath;
+    }
+
+    @SneakyThrows
+    @Override
+    public void createStorageDir(String directoryAbsolutePath) {
+        String cosKey = transformAbsolutePathToCOSKey(directoryAbsolutePath);
+        if (cosClient.doesObjectExist(bucketName, cosKey)) {
+            throw new FileAlreadyExistsException("directory: " + cosKey + " already exists");
+        }
+        ObjectMetadata metadata = new ObjectMetadata();
+        metadata.setContentLength(0L);
+        InputStream emptyContent = new ByteArrayInputStream(new byte[0]);
+        PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, cosKey, emptyContent, metadata);
+        cosClient.putObject(putObjectRequest);
+    }
+
+    @SneakyThrows
+    @Override
+    public void download(String srcFilePath, String dstFilePath, boolean overwrite) {
+        String cosKey = transformAbsolutePathToCOSKey(srcFilePath);
+
+        File dstFile = new File(dstFilePath);
+        if (dstFile.isDirectory()) {

Review Comment:
   ## Uncontrolled data used in path expression
   
   This path depends on a [user-provided value](1).
   
   [Show more details](https://github.com/apache/dolphinscheduler/security/code-scanning/4858)



##########
dolphinscheduler-storage-plugin/dolphinscheduler-storage-cos/src/main/java/org/apache/dolphinscheduler/plugin/storage/cos/CosStorageOperator.java:
##########
@@ -0,0 +1,328 @@
+/*
+ * 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.plugin.storage.cos;
+
+import org.apache.dolphinscheduler.common.constants.Constants;
+import org.apache.dolphinscheduler.common.utils.FileUtils;
+import org.apache.dolphinscheduler.plugin.storage.api.AbstractStorageOperator;
+import org.apache.dolphinscheduler.plugin.storage.api.ResourceMetadata;
+import org.apache.dolphinscheduler.plugin.storage.api.StorageEntity;
+import org.apache.dolphinscheduler.plugin.storage.api.StorageOperator;
+
+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.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.nio.file.FileAlreadyExistsException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.stream.Collectors;
+
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+
+import com.qcloud.cos.COSClient;
+import com.qcloud.cos.ClientConfig;
+import com.qcloud.cos.auth.BasicCOSCredentials;
+import com.qcloud.cos.auth.COSCredentials;
+import com.qcloud.cos.exception.CosServiceException;
+import com.qcloud.cos.http.HttpProtocol;
+import com.qcloud.cos.model.COSObject;
+import com.qcloud.cos.model.COSObjectSummary;
+import com.qcloud.cos.model.CopyObjectRequest;
+import com.qcloud.cos.model.CopyResult;
+import com.qcloud.cos.model.GetObjectRequest;
+import com.qcloud.cos.model.ListObjectsRequest;
+import com.qcloud.cos.model.ObjectListing;
+import com.qcloud.cos.model.ObjectMetadata;
+import com.qcloud.cos.model.PutObjectRequest;
+import com.qcloud.cos.model.UploadResult;
+import com.qcloud.cos.region.Region;
+import com.qcloud.cos.transfer.Copy;
+import com.qcloud.cos.transfer.Download;
+import com.qcloud.cos.transfer.TransferManager;
+import com.qcloud.cos.transfer.TransferManagerConfiguration;
+import com.qcloud.cos.transfer.Upload;
+
+@Slf4j
+public class CosStorageOperator extends AbstractStorageOperator implements Closeable, StorageOperator {
+
+    private static final int TRANSFER_THREAD_POOL_SIZE = 16;
+
+    private static final long MULTIPART_UPLOAD_BYTES_THRESHOLD = 5 * 1024 * 1024;
+    private static final long MIN_UPLOAD_PART_BYTES = 1024 * 1024;
+
+    private final String bucketName;
+
+    private final COSClient cosClient;
+
+    private final TransferManager cosTransferManager;
+
+    public CosStorageOperator(CosStorageProperties cosStorageProperties) {
+        super(cosStorageProperties.getResourceUploadPath());
+        String secretId = cosStorageProperties.getAccessKeyId();
+        String secretKey = cosStorageProperties.getAccessKeySecret();
+        COSCredentials cosCredentials = new BasicCOSCredentials(secretId, secretKey);
+        String regionName = cosStorageProperties.getRegion();
+        ClientConfig clientConfig = new ClientConfig(new Region(regionName));
+        clientConfig.setHttpProtocol(HttpProtocol.https);
+        this.cosClient = new COSClient(cosCredentials, clientConfig);
+        this.bucketName = cosStorageProperties.getBucketName();
+        ensureBucketSuccessfullyCreated(bucketName);
+        this.cosTransferManager = getCosTransferManager();
+    }
+
+    @Override
+    public void close() throws IOException {
+        this.cosTransferManager.shutdownNow(true);
+    }
+
+    @Override
+    public String getStorageBaseDirectory() {
+        // All directory should end with File.separator
+        if (resourceBaseAbsolutePath.startsWith("/")) {
+            log.warn("{} -> {} should not start with / in cos", Constants.RESOURCE_UPLOAD_PATH,
+                    resourceBaseAbsolutePath);
+            return resourceBaseAbsolutePath.substring(1);
+        }
+        return resourceBaseAbsolutePath;
+    }
+
+    @SneakyThrows
+    @Override
+    public void createStorageDir(String directoryAbsolutePath) {
+        String cosKey = transformAbsolutePathToCOSKey(directoryAbsolutePath);
+        if (cosClient.doesObjectExist(bucketName, cosKey)) {
+            throw new FileAlreadyExistsException("directory: " + cosKey + " already exists");
+        }
+        ObjectMetadata metadata = new ObjectMetadata();
+        metadata.setContentLength(0L);
+        InputStream emptyContent = new ByteArrayInputStream(new byte[0]);
+        PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, cosKey, emptyContent, metadata);
+        cosClient.putObject(putObjectRequest);
+    }
+
+    @SneakyThrows
+    @Override
+    public void download(String srcFilePath, String dstFilePath, boolean overwrite) {
+        String cosKey = transformAbsolutePathToCOSKey(srcFilePath);
+
+        File dstFile = new File(dstFilePath);
+        if (dstFile.isDirectory()) {
+            Files.delete(dstFile.toPath());

Review Comment:
   ## Uncontrolled data used in path expression
   
   This path depends on a [user-provided value](1).
   
   [Show more details](https://github.com/apache/dolphinscheduler/security/code-scanning/4859)



-- 
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


Re: [PR] [Feature-16396][storage-plugin] Tencent Cloud COS Storage Plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16565:
URL: https://github.com/apache/dolphinscheduler/pull/16565#issuecomment-2333193133

   ## [![Quality Gate Failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-failed-20px.png 'Quality Gate Failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16565) **Quality Gate failed**  
   Failed conditions  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/failed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16565&metric=new_coverage&view=list) (required ≥ 60%)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/failed-16px.png '') [B Reliability Rating on New Code](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16565) (required ≥ A)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16565)
   
   ##   
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/light_bulb-16px.png '') Catch issues before they fail your Quality Gate with our IDE extension ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/sonarlint-16px.png '') [SonarLint](https://www.sonarsource.com/products/sonarlint/features/connected-mode/?referrer=pull-request)
   
   


-- 
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


Re: [PR] [Feature-16396][storage-plugin] Tencent Cloud COS Storage Plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16565:
URL: https://github.com/apache/dolphinscheduler/pull/16565#issuecomment-2333193544

   ## [![Quality Gate Failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-failed-20px.png 'Quality Gate Failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16565) **Quality Gate failed**  
   Failed conditions  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/failed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16565&metric=new_coverage&view=list) (required ≥ 60%)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/failed-16px.png '') [B Reliability Rating on New Code](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16565) (required ≥ A)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16565)
   
   ##   
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/light_bulb-16px.png '') Catch issues before they fail your Quality Gate with our IDE extension ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/sonarlint-16px.png '') [SonarLint](https://www.sonarsource.com/products/sonarlint/features/connected-mode/?referrer=pull-request)
   
   


-- 
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


Re: [PR] [Feature-16396][storage-plugin] Tencent Cloud COS Storage Plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16565:
URL: https://github.com/apache/dolphinscheduler/pull/16565#issuecomment-2345366927

   ## [![Quality Gate Failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-failed-20px.png 'Quality Gate Failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16565) **Quality Gate failed**  
   Failed conditions  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/failed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16565&metric=new_coverage&view=list) (required ≥ 60%)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16565)
   
   


-- 
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


Re: [PR] [Feature-16396][storage-plugin] Tencent Cloud COS Storage Plugin [dolphinscheduler]

Posted by "ruanwenjun (via GitHub)" <gi...@apache.org>.
ruanwenjun commented on code in PR #16565:
URL: https://github.com/apache/dolphinscheduler/pull/16565#discussion_r1740891535


##########
tools/dependencies/known-dependencies.txt:
##########
@@ -485,6 +485,7 @@ azure-storage-blob-12.21.0.jar
 azure-storage-internal-avro-12.6.0.jar
 vertica-jdbc-12.0.4-0.jar
 esdk-obs-java-bundle-3.23.3.jar
+cos_api-5.6.231.jar

Review Comment:
   Missing license file.



-- 
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


Re: [PR] [Feature-16396][storage-plugin] Add Tencent Cloud COS Storage Plugin [dolphinscheduler]

Posted by "Mighten (via GitHub)" <gi...@apache.org>.
Mighten commented on code in PR #16565:
URL: https://github.com/apache/dolphinscheduler/pull/16565#discussion_r1770766692


##########
dolphinscheduler-storage-plugin/dolphinscheduler-storage-cos/src/main/java/org/apache/dolphinscheduler/plugin/storage/cos/CosStorageOperator.java:
##########
@@ -0,0 +1,335 @@
+/*
+ * 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.plugin.storage.cos;
+
+import org.apache.dolphinscheduler.common.constants.Constants;
+import org.apache.dolphinscheduler.common.utils.FileUtils;
+import org.apache.dolphinscheduler.plugin.storage.api.AbstractStorageOperator;
+import org.apache.dolphinscheduler.plugin.storage.api.ResourceMetadata;
+import org.apache.dolphinscheduler.plugin.storage.api.StorageEntity;
+import org.apache.dolphinscheduler.plugin.storage.api.StorageOperator;
+
+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.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.nio.file.FileAlreadyExistsException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.stream.Collectors;
+
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+
+import com.qcloud.cos.COSClient;
+import com.qcloud.cos.ClientConfig;
+import com.qcloud.cos.auth.BasicCOSCredentials;
+import com.qcloud.cos.auth.COSCredentials;
+import com.qcloud.cos.exception.CosServiceException;
+import com.qcloud.cos.http.HttpProtocol;
+import com.qcloud.cos.model.COSObject;
+import com.qcloud.cos.model.COSObjectSummary;
+import com.qcloud.cos.model.CopyObjectRequest;
+import com.qcloud.cos.model.CopyResult;
+import com.qcloud.cos.model.GetObjectRequest;
+import com.qcloud.cos.model.ListObjectsRequest;
+import com.qcloud.cos.model.ObjectListing;
+import com.qcloud.cos.model.ObjectMetadata;
+import com.qcloud.cos.model.PutObjectRequest;
+import com.qcloud.cos.model.UploadResult;
+import com.qcloud.cos.region.Region;
+import com.qcloud.cos.transfer.Copy;
+import com.qcloud.cos.transfer.Download;
+import com.qcloud.cos.transfer.TransferManager;
+import com.qcloud.cos.transfer.TransferManagerConfiguration;
+import com.qcloud.cos.transfer.Upload;
+
+@Slf4j
+public class CosStorageOperator extends AbstractStorageOperator implements Closeable, StorageOperator {
+
+    private static final int TRANSFER_THREAD_POOL_SIZE = 16;
+
+    private static final long MULTIPART_UPLOAD_BYTES_THRESHOLD = 5 * 1024 * 1024L;
+    private static final long MIN_UPLOAD_PART_BYTES = 1024 * 1024L;
+
+    private final String bucketName;
+
+    private final COSClient cosClient;
+
+    private final TransferManager cosTransferManager;
+
+    public CosStorageOperator(CosStorageProperties cosStorageProperties) {
+        super(cosStorageProperties.getResourceUploadPath());
+        String secretId = cosStorageProperties.getAccessKeyId();
+        String secretKey = cosStorageProperties.getAccessKeySecret();
+        COSCredentials cosCredentials = new BasicCOSCredentials(secretId, secretKey);
+        String regionName = cosStorageProperties.getRegion();
+        ClientConfig clientConfig = new ClientConfig(new Region(regionName));
+        clientConfig.setHttpProtocol(HttpProtocol.https);
+        this.cosClient = new COSClient(cosCredentials, clientConfig);
+        this.bucketName = cosStorageProperties.getBucketName();
+        ensureBucketSuccessfullyCreated(bucketName);
+        this.cosTransferManager = getCosTransferManager();
+    }
+
+    @Override
+    public void close() throws IOException {
+        this.cosTransferManager.shutdownNow(true);
+    }
+
+    @Override
+    public String getStorageBaseDirectory() {
+        // All directory should end with File.separator
+        if (resourceBaseAbsolutePath.startsWith("/")) {
+            log.warn("{} -> {} should not start with / in cos", Constants.RESOURCE_UPLOAD_PATH,
+                    resourceBaseAbsolutePath);
+            return resourceBaseAbsolutePath.substring(1);

Review Comment:
   The updated code will throw an exception and get stuck on the login page:
   
   ```java
       @Override
       public String getStorageBaseDirectory() {
           // All directory should end with File.separator
           if (resourceBaseAbsolutePath.startsWith("/")) { //  use ----> File.separator
               String errorMessage =
                       String.format("%s -> %s should not start with %s in tencent cos",
                               StorageConstants.RESOURCE_UPLOAD_PATH,
                               resourceBaseAbsolutePath, "/"); // use ----> File.separator
               throw new IllegalArgumentException(errorMessage);
           }
           return resourceBaseAbsolutePath;
       }
   ```
   
   ![Screenshot 2024-09-23 123421](https://github.com/user-attachments/assets/09d8f292-27f2-4cbc-8a07-6fe036ff369f)
   
   
   
   
   Since there are existing test cases stating that `resource.storage.upload.base.path=/dolphinscheduler`:
   
   ![Screenshot 2024-09-23 123813](https://github.com/user-attachments/assets/91746449-27e7-4a2f-8a13-1b26c8a38253)
   
   Throwing an exception will cause the E2E tests to fail.



-- 
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


Re: [PR] [Feature-16396][storage-plugin] Tencent Cloud COS Storage Plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16565:
URL: https://github.com/apache/dolphinscheduler/pull/16565#issuecomment-2365429950

   ## [![Quality Gate Failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-failed-20px.png 'Quality Gate Failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16565) **Quality Gate failed**  
   Failed conditions  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/failed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16565&metric=new_coverage&view=list) (required ≥ 60%)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16565)
   
   


-- 
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


Re: [PR] [Feature-16396][storage-plugin] Tencent Cloud COS Storage Plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16565:
URL: https://github.com/apache/dolphinscheduler/pull/16565#issuecomment-2366293592

   ## [![Quality Gate Failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-failed-20px.png 'Quality Gate Failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16565) **Quality Gate failed**  
   Failed conditions  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/failed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16565&metric=new_coverage&view=list) (required ≥ 60%)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16565)
   
   


-- 
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


Re: [PR] [Feature-16396][storage-plugin] Tencent Cloud COS Storage Plugin [dolphinscheduler]

Posted by "fuchanghai (via GitHub)" <gi...@apache.org>.
fuchanghai commented on PR #16565:
URL: https://github.com/apache/dolphinscheduler/pull/16565#issuecomment-2367088026

   > Since we don't have any tencent cos support for integration testing. I will -1 on this until we can find a way to test against this in out UT, IT and E2E.
   
   If ```COS ``` is merged, I will maintain the test related functions


-- 
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


Re: [PR] [Feature-16396][storage-plugin] Tencent Cloud COS Storage Plugin [dolphinscheduler]

Posted by "fuchanghai (via GitHub)" <gi...@apache.org>.
fuchanghai commented on code in PR #16565:
URL: https://github.com/apache/dolphinscheduler/pull/16565#discussion_r1769512104


##########
dolphinscheduler-storage-plugin/dolphinscheduler-storage-cos/src/main/java/org/apache/dolphinscheduler/plugin/storage/cos/CosStorageOperator.java:
##########
@@ -0,0 +1,332 @@
+/*
+ * 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.plugin.storage.cos;
+
+import org.apache.dolphinscheduler.common.constants.Constants;
+import org.apache.dolphinscheduler.common.utils.FileUtils;
+import org.apache.dolphinscheduler.plugin.storage.api.AbstractStorageOperator;
+import org.apache.dolphinscheduler.plugin.storage.api.ResourceMetadata;
+import org.apache.dolphinscheduler.plugin.storage.api.StorageEntity;
+import org.apache.dolphinscheduler.plugin.storage.api.StorageOperator;
+
+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.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.nio.file.FileAlreadyExistsException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.stream.Collectors;
+
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+
+import com.qcloud.cos.COSClient;
+import com.qcloud.cos.ClientConfig;
+import com.qcloud.cos.auth.BasicCOSCredentials;
+import com.qcloud.cos.auth.COSCredentials;
+import com.qcloud.cos.exception.CosServiceException;
+import com.qcloud.cos.http.HttpProtocol;
+import com.qcloud.cos.model.COSObject;
+import com.qcloud.cos.model.COSObjectSummary;
+import com.qcloud.cos.model.CopyObjectRequest;
+import com.qcloud.cos.model.CopyResult;
+import com.qcloud.cos.model.GetObjectRequest;
+import com.qcloud.cos.model.ListObjectsRequest;
+import com.qcloud.cos.model.ObjectListing;
+import com.qcloud.cos.model.ObjectMetadata;
+import com.qcloud.cos.model.PutObjectRequest;
+import com.qcloud.cos.model.UploadResult;
+import com.qcloud.cos.region.Region;
+import com.qcloud.cos.transfer.Copy;
+import com.qcloud.cos.transfer.Download;
+import com.qcloud.cos.transfer.TransferManager;
+import com.qcloud.cos.transfer.TransferManagerConfiguration;
+import com.qcloud.cos.transfer.Upload;
+
+@Slf4j
+public class CosStorageOperator extends AbstractStorageOperator implements Closeable, StorageOperator {
+
+    private static final int TRANSFER_THREAD_POOL_SIZE = 16;
+
+    private static final long MULTIPART_UPLOAD_BYTES_THRESHOLD = 5 * 1024 * 1024L;
+    private static final long MIN_UPLOAD_PART_BYTES = 1024 * 1024L;
+
+    private final String bucketName;
+
+    private final COSClient cosClient;
+
+    private final TransferManager cosTransferManager;
+
+    public CosStorageOperator(CosStorageProperties cosStorageProperties) {
+        super(cosStorageProperties.getResourceUploadPath());
+        String secretId = cosStorageProperties.getAccessKeyId();
+        String secretKey = cosStorageProperties.getAccessKeySecret();
+        COSCredentials cosCredentials = new BasicCOSCredentials(secretId, secretKey);
+        String regionName = cosStorageProperties.getRegion();
+        ClientConfig clientConfig = new ClientConfig(new Region(regionName));
+        clientConfig.setHttpProtocol(HttpProtocol.https);
+        this.cosClient = new COSClient(cosCredentials, clientConfig);
+        this.bucketName = cosStorageProperties.getBucketName();
+        ensureBucketSuccessfullyCreated(bucketName);
+        this.cosTransferManager = getCosTransferManager();
+    }
+
+    @Override
+    public void close() throws IOException {
+        this.cosTransferManager.shutdownNow(true);
+    }
+
+    @Override
+    public String getStorageBaseDirectory() {
+        // All directory should end with File.separator
+        if (resourceBaseAbsolutePath.startsWith("/")) {

Review Comment:
   use ``` File.separator``` to instead of ``` /```



-- 
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


Re: [PR] [Feature-16396][storage-plugin] Tencent Cloud COS Storage Plugin [dolphinscheduler]

Posted by "SbloodyS (via GitHub)" <gi...@apache.org>.
SbloodyS commented on code in PR #16565:
URL: https://github.com/apache/dolphinscheduler/pull/16565#discussion_r1770714449


##########
dolphinscheduler-storage-plugin/dolphinscheduler-storage-cos/pom.xml:
##########
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.dolphinscheduler</groupId>
+        <artifactId>dolphinscheduler-storage-plugin</artifactId>
+        <version>dev-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>dolphinscheduler-storage-cos</artifactId>
+
+    <dependencies>
+        <dependency>
+            <groupId>com.qcloud</groupId>
+            <artifactId>cos_api</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.dolphinscheduler</groupId>
+            <artifactId>dolphinscheduler-storage-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.dolphinscheduler</groupId>
+            <artifactId>dolphinscheduler-task-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+    </dependencies>

Review Comment:
   We've already refactored the package logic. Please refer to the PR #16613 to add shaded logic here.



-- 
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


Re: [PR] [Feature-16396][storage-plugin] Add Tencent Cloud COS Storage Plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16565:
URL: https://github.com/apache/dolphinscheduler/pull/16565#issuecomment-2370104301

   ## [![Quality Gate Failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-failed-20px.png 'Quality Gate Failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16565) **Quality Gate failed**  
   Failed conditions  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/failed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16565&metric=new_coverage&view=list) (required ≥ 60%)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16565)
   
   


-- 
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


Re: [PR] [Feature-16396][storage-plugin] Add Tencent Cloud COS Storage Plugin [dolphinscheduler]

Posted by "fuchanghai (via GitHub)" <gi...@apache.org>.
fuchanghai commented on code in PR #16565:
URL: https://github.com/apache/dolphinscheduler/pull/16565#discussion_r1770876334


##########
dolphinscheduler-storage-plugin/dolphinscheduler-storage-cos/pom.xml:
##########
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.dolphinscheduler</groupId>
+        <artifactId>dolphinscheduler-storage-plugin</artifactId>
+        <version>dev-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>dolphinscheduler-storage-cos</artifactId>
+
+    <dependencies>
+        <dependency>
+            <groupId>com.qcloud</groupId>
+            <artifactId>cos_api</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.dolphinscheduler</groupId>
+            <artifactId>dolphinscheduler-storage-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.dolphinscheduler</groupId>
+            <artifactId>dolphinscheduler-task-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+    </dependencies>

Review Comment:
   <img width="1031" alt="image" src="https://github.com/user-attachments/assets/2b033f20-2eab-4bb3-a4bb-2f4c9ea4abee">
   use ```start with```



-- 
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


Re: [PR] [Feature-16396][storage-plugin] Add Tencent Cloud COS Storage Plugin [dolphinscheduler]

Posted by "fuchanghai (via GitHub)" <gi...@apache.org>.
fuchanghai commented on code in PR #16565:
URL: https://github.com/apache/dolphinscheduler/pull/16565#discussion_r1770829102


##########
dolphinscheduler-storage-plugin/dolphinscheduler-storage-cos/pom.xml:
##########
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.dolphinscheduler</groupId>
+        <artifactId>dolphinscheduler-storage-plugin</artifactId>
+        <version>dev-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>dolphinscheduler-storage-cos</artifactId>
+
+    <dependencies>
+        <dependency>
+            <groupId>com.qcloud</groupId>
+            <artifactId>cos_api</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.dolphinscheduler</groupId>
+            <artifactId>dolphinscheduler-storage-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.dolphinscheduler</groupId>
+            <artifactId>dolphinscheduler-task-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+    </dependencies>

Review Comment:
   maybe you should change to ```.startWith(StorageConstants.RESOURCE_UPLOAD_PATH) ``` @Mighten  cc @SbloodyS 



-- 
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


Re: [PR] [Feature-16396][storage-plugin] Add Tencent Cloud COS Storage Plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16565:
URL: https://github.com/apache/dolphinscheduler/pull/16565#issuecomment-2377002930

   ## [![Quality Gate Failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-failed-20px.png 'Quality Gate Failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16565) **Quality Gate failed**  
   Failed conditions  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/failed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16565&metric=new_coverage&view=list) (required ≥ 60%)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16565)
   
   


-- 
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


Re: [PR] [Feature-16396][storage-plugin] Tencent Cloud COS Storage Plugin [dolphinscheduler]

Posted by "Mighten (via GitHub)" <gi...@apache.org>.
Mighten commented on code in PR #16565:
URL: https://github.com/apache/dolphinscheduler/pull/16565#discussion_r1769532967


##########
dolphinscheduler-storage-plugin/dolphinscheduler-storage-cos/src/main/java/org/apache/dolphinscheduler/plugin/storage/cos/CosStorageOperator.java:
##########
@@ -0,0 +1,332 @@
+/*
+ * 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.plugin.storage.cos;
+
+import org.apache.dolphinscheduler.common.constants.Constants;
+import org.apache.dolphinscheduler.common.utils.FileUtils;
+import org.apache.dolphinscheduler.plugin.storage.api.AbstractStorageOperator;
+import org.apache.dolphinscheduler.plugin.storage.api.ResourceMetadata;
+import org.apache.dolphinscheduler.plugin.storage.api.StorageEntity;
+import org.apache.dolphinscheduler.plugin.storage.api.StorageOperator;
+
+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.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.nio.file.FileAlreadyExistsException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.stream.Collectors;
+
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+
+import com.qcloud.cos.COSClient;
+import com.qcloud.cos.ClientConfig;
+import com.qcloud.cos.auth.BasicCOSCredentials;
+import com.qcloud.cos.auth.COSCredentials;
+import com.qcloud.cos.exception.CosServiceException;
+import com.qcloud.cos.http.HttpProtocol;
+import com.qcloud.cos.model.COSObject;
+import com.qcloud.cos.model.COSObjectSummary;
+import com.qcloud.cos.model.CopyObjectRequest;
+import com.qcloud.cos.model.CopyResult;
+import com.qcloud.cos.model.GetObjectRequest;
+import com.qcloud.cos.model.ListObjectsRequest;
+import com.qcloud.cos.model.ObjectListing;
+import com.qcloud.cos.model.ObjectMetadata;
+import com.qcloud.cos.model.PutObjectRequest;
+import com.qcloud.cos.model.UploadResult;
+import com.qcloud.cos.region.Region;
+import com.qcloud.cos.transfer.Copy;
+import com.qcloud.cos.transfer.Download;
+import com.qcloud.cos.transfer.TransferManager;
+import com.qcloud.cos.transfer.TransferManagerConfiguration;
+import com.qcloud.cos.transfer.Upload;
+
+@Slf4j
+public class CosStorageOperator extends AbstractStorageOperator implements Closeable, StorageOperator {
+
+    private static final int TRANSFER_THREAD_POOL_SIZE = 16;
+
+    private static final long MULTIPART_UPLOAD_BYTES_THRESHOLD = 5 * 1024 * 1024L;
+    private static final long MIN_UPLOAD_PART_BYTES = 1024 * 1024L;
+
+    private final String bucketName;
+
+    private final COSClient cosClient;
+
+    private final TransferManager cosTransferManager;
+
+    public CosStorageOperator(CosStorageProperties cosStorageProperties) {
+        super(cosStorageProperties.getResourceUploadPath());
+        String secretId = cosStorageProperties.getAccessKeyId();
+        String secretKey = cosStorageProperties.getAccessKeySecret();
+        COSCredentials cosCredentials = new BasicCOSCredentials(secretId, secretKey);
+        String regionName = cosStorageProperties.getRegion();
+        ClientConfig clientConfig = new ClientConfig(new Region(regionName));
+        clientConfig.setHttpProtocol(HttpProtocol.https);
+        this.cosClient = new COSClient(cosCredentials, clientConfig);
+        this.bucketName = cosStorageProperties.getBucketName();
+        ensureBucketSuccessfullyCreated(bucketName);
+        this.cosTransferManager = getCosTransferManager();
+    }
+
+    @Override
+    public void close() throws IOException {
+        this.cosTransferManager.shutdownNow(true);
+    }
+
+    @Override
+    public String getStorageBaseDirectory() {
+        // All directory should end with File.separator
+        if (resourceBaseAbsolutePath.startsWith("/")) {

Review Comment:
   The `File.separator` works poorly on Windows 11 x64.
   
   ![Screenshot 2024-09-21 184343](https://github.com/user-attachments/assets/e53415c7-1afb-4cfe-be99-225bf36ae793)
   
   - When the user successfully uploads the "test.log" file, there is no way to enter the deeper directory to view the file.
   - When the user tries to delete the folder, an exception is thrown stating that the folder does not exist.
   
   So, for now, I think we should continue using the UNIX filesystem separator ("/"), just like the already existing code, until a **DSIP** for *Windows platform compatibility* is provided.
   
   ![existing-unix-like-file-separator-codes](https://github.com/user-attachments/assets/2bbd6cbf-c67b-4bfe-8c5f-098bbb601a16)
   
   
   
   
   



-- 
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


Re: [PR] [Feature-16396][storage-plugin] Tencent Cloud COS Storage Plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16565:
URL: https://github.com/apache/dolphinscheduler/pull/16565#issuecomment-2347867438

   ## [![Quality Gate Failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-failed-20px.png 'Quality Gate Failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16565) **Quality Gate failed**  
   Failed conditions  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/failed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16565&metric=new_coverage&view=list) (required ≥ 60%)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16565)
   
   


-- 
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


Re: [PR] [Feature-16396][storage-plugin] Tencent Cloud COS Storage Plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16565:
URL: https://github.com/apache/dolphinscheduler/pull/16565#issuecomment-2357375000

   ## [![Quality Gate Failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-failed-20px.png 'Quality Gate Failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16565) **Quality Gate failed**  
   Failed conditions  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/failed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16565&metric=new_coverage&view=list) (required ≥ 60%)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16565)
   
   


-- 
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


Re: [PR] [Feature-16396][storage-plugin] Tencent Cloud COS Storage Plugin [dolphinscheduler]

Posted by "fuchanghai (via GitHub)" <gi...@apache.org>.
fuchanghai commented on code in PR #16565:
URL: https://github.com/apache/dolphinscheduler/pull/16565#discussion_r1769585062


##########
dolphinscheduler-storage-plugin/dolphinscheduler-storage-cos/src/main/java/org/apache/dolphinscheduler/plugin/storage/cos/CosStorageConstants.java:
##########
@@ -0,0 +1,31 @@
+/*
+ * 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.plugin.storage.cos;
+
+public class CosStorageConstants {
+
+    // Tencent Cloud Storage (COS) configuration
+    public static final String TENCENT_CLOUD_COS_PROPERTY_PREFIX = "resource.tencent.cloud";
+    public static final String TENCENT_CLOUD_COS_BUCKET_NAME = "resource.tencent.cloud.cos.bucket.name";
+    public static final String TENCENT_CLOUD_COS_REGION = "resource.tencent.cloud.cos.region";
+    public static final String TENCENT_CLOUD_ACCESS_KEY_ID = "resource.tencent.cloud.access.key.id";
+    public static final String TENCENT_CLOUD_ACCESS_KEY_SECRET = "resource.tencent.cloud.access.key.secret";
+
+    public static final String ILLEGAL_DOWNLOAD_PATH_PREFIX_ETC = "/etc";

Review Comment:
   use  vaule of ```data.basedir.path```



-- 
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


Re: [PR] [Feature-16396][storage-plugin] Tencent Cloud COS Storage Plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16565:
URL: https://github.com/apache/dolphinscheduler/pull/16565#issuecomment-2365503895

   Please retry analysis of this Pull-Request directly on SonarCloud


-- 
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


Re: [PR] [Feature-16396][storage-plugin] Add Tencent Cloud COS Storage Plugin [dolphinscheduler]

Posted by "Mighten (via GitHub)" <gi...@apache.org>.
Mighten commented on code in PR #16565:
URL: https://github.com/apache/dolphinscheduler/pull/16565#discussion_r1770777688


##########
dolphinscheduler-storage-plugin/dolphinscheduler-storage-cos/pom.xml:
##########
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.dolphinscheduler</groupId>
+        <artifactId>dolphinscheduler-storage-plugin</artifactId>
+        <version>dev-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>dolphinscheduler-storage-cos</artifactId>
+
+    <dependencies>
+        <dependency>
+            <groupId>com.qcloud</groupId>
+            <artifactId>cos_api</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.dolphinscheduler</groupId>
+            <artifactId>dolphinscheduler-storage-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.dolphinscheduler</groupId>
+            <artifactId>dolphinscheduler-task-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+    </dependencies>

Review Comment:
   Fixed, in accordance with the conventions of the `maven-shade-plugin`.
   
   Please take a look at the `log.warn` problem (dolphinscheduler/plugin/storage/cos/CosStorageOperator.java); I'm having some trouble fixing it.
   
   Thank you for your precious time.



-- 
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


Re: [PR] [Feature-16396][storage-plugin] Add Tencent Cloud COS Storage Plugin [dolphinscheduler]

Posted by "SbloodyS (via GitHub)" <gi...@apache.org>.
SbloodyS commented on code in PR #16565:
URL: https://github.com/apache/dolphinscheduler/pull/16565#discussion_r1770832899


##########
dolphinscheduler-storage-plugin/dolphinscheduler-storage-cos/pom.xml:
##########
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.dolphinscheduler</groupId>
+        <artifactId>dolphinscheduler-storage-plugin</artifactId>
+        <version>dev-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>dolphinscheduler-storage-cos</artifactId>
+
+    <dependencies>
+        <dependency>
+            <groupId>com.qcloud</groupId>
+            <artifactId>cos_api</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.dolphinscheduler</groupId>
+            <artifactId>dolphinscheduler-storage-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.dolphinscheduler</groupId>
+            <artifactId>dolphinscheduler-task-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+    </dependencies>

Review Comment:
   > maybe you should change to `.startWith(StorageConstants.RESOURCE_UPLOAD_PATH) ` @Mighten cc @SbloodyS
   
   Yes.



-- 
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


Re: [PR] [Feature-16396][storage-plugin] Add Tencent Cloud COS Storage Plugin [dolphinscheduler]

Posted by "fuchanghai (via GitHub)" <gi...@apache.org>.
fuchanghai commented on code in PR #16565:
URL: https://github.com/apache/dolphinscheduler/pull/16565#discussion_r1770876334


##########
dolphinscheduler-storage-plugin/dolphinscheduler-storage-cos/pom.xml:
##########
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.dolphinscheduler</groupId>
+        <artifactId>dolphinscheduler-storage-plugin</artifactId>
+        <version>dev-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>dolphinscheduler-storage-cos</artifactId>
+
+    <dependencies>
+        <dependency>
+            <groupId>com.qcloud</groupId>
+            <artifactId>cos_api</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.dolphinscheduler</groupId>
+            <artifactId>dolphinscheduler-storage-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.dolphinscheduler</groupId>
+            <artifactId>dolphinscheduler-task-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+    </dependencies>

Review Comment:
   <img width="1031" alt="image" src="https://github.com/user-attachments/assets/2b033f20-2eab-4bb3-a4bb-2f4c9ea4abee">
   use ```start with```



-- 
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


Re: [PR] [Feature-16396][storage-plugin] Add Tencent Cloud COS Storage Plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16565:
URL: https://github.com/apache/dolphinscheduler/pull/16565#issuecomment-2367280785

   ## [![Quality Gate Failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-failed-20px.png 'Quality Gate Failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16565) **Quality Gate failed**  
   Failed conditions  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/failed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16565&metric=new_coverage&view=list) (required ≥ 60%)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16565)
   
   


-- 
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


Re: [PR] [Feature-16396][storage-plugin] Add Tencent Cloud COS Storage Plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16565:
URL: https://github.com/apache/dolphinscheduler/pull/16565#issuecomment-2378802889

   ## [![Quality Gate Failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-failed-20px.png 'Quality Gate Failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16565) **Quality Gate failed**  
   Failed conditions  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/failed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16565&metric=new_coverage&view=list) (required ≥ 60%)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16565)
   
   


-- 
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


Re: [PR] [Feature-16396][storage-plugin] Tencent Cloud COS Storage Plugin [dolphinscheduler]

Posted by "Mighten (via GitHub)" <gi...@apache.org>.
Mighten commented on code in PR #16565:
URL: https://github.com/apache/dolphinscheduler/pull/16565#discussion_r1756751167


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/TaskConstants.java:
##########
@@ -389,6 +389,12 @@ private TaskConstants() {
     public static final String HUAWEI_CLOUD_ACCESS_KEY_ID = "resource.huawei.cloud.access.key.id";
     public static final String HUAWEI_CLOUD_ACCESS_KEY_SECRET = "resource.huawei.cloud.access.key.secret";
 
+    /**
+     * tencent cloud config
+     */
+    public static final String TENCENT_CLOUD_ACCESS_KEY_ID = "resource.tencent.cloud.access.key.id";
+    public static final String TENCENT_CLOUD_ACCESS_KEY_SECRET = "resource.tencent.cloud.access.key.secret";
+

Review Comment:
   Thank you for your valuable opinions.
   
   But I don't think placing these Tencent Credential Constants in the *storage plugin* is a good idea.
   
   Cloud providers (Azure, Alibaba, Huawei, and Tencent) offer not only storage services but also other types of services.
   
   Therefore, I believe Tencent Credential Constants should remain in `task-plugin/task-api/org.apache.dolphinscheduler.plugin.task.api.TaskConstants`, alongside the credential constants for other cloud providers.



-- 
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


Re: [PR] [Feature-16396][storage-plugin] Add Tencent Cloud COS Storage Plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16565:
URL: https://github.com/apache/dolphinscheduler/pull/16565#issuecomment-2376638830

   ## [![Quality Gate Failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-failed-20px.png 'Quality Gate Failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16565) **Quality Gate failed**  
   Failed conditions  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/failed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16565&metric=new_coverage&view=list) (required ≥ 60%)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16565)
   
   


-- 
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


Re: [PR] [Feature-16396][storage-plugin] Add Tencent Cloud COS Storage Plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16565:
URL: https://github.com/apache/dolphinscheduler/pull/16565#issuecomment-2376635512

   ## [![Quality Gate Failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-failed-20px.png 'Quality Gate Failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16565) **Quality Gate failed**  
   Failed conditions  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/failed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16565&metric=new_coverage&view=list) (required ≥ 60%)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16565)
   
   


-- 
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


Re: [PR] [Feature-16396][storage-plugin] Tencent Cloud COS Storage Plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16565:
URL: https://github.com/apache/dolphinscheduler/pull/16565#issuecomment-2357372125

   ## [![Quality Gate Failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-failed-20px.png 'Quality Gate Failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16565) **Quality Gate failed**  
   Failed conditions  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/failed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16565&metric=new_coverage&view=list) (required ≥ 60%)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16565)
   
   


-- 
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


Re: [PR] [Feature-16396][storage-plugin] Add Tencent Cloud COS Storage Plugin [dolphinscheduler]

Posted by "fuchanghai (via GitHub)" <gi...@apache.org>.
fuchanghai commented on code in PR #16565:
URL: https://github.com/apache/dolphinscheduler/pull/16565#discussion_r1770829102


##########
dolphinscheduler-storage-plugin/dolphinscheduler-storage-cos/pom.xml:
##########
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.dolphinscheduler</groupId>
+        <artifactId>dolphinscheduler-storage-plugin</artifactId>
+        <version>dev-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>dolphinscheduler-storage-cos</artifactId>
+
+    <dependencies>
+        <dependency>
+            <groupId>com.qcloud</groupId>
+            <artifactId>cos_api</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.dolphinscheduler</groupId>
+            <artifactId>dolphinscheduler-storage-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.dolphinscheduler</groupId>
+            <artifactId>dolphinscheduler-task-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+    </dependencies>

Review Comment:
   maybe you should change to ```.startWith(StorageConstants.RESOURCE_UPLOAD_PATH) ``` cc @SbloodyS 



-- 
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


Re: [PR] [Feature-16396][storage-plugin] Tencent Cloud COS Storage Plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16565:
URL: https://github.com/apache/dolphinscheduler/pull/16565#issuecomment-2365503847

   ## [![Quality Gate Failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-failed-20px.png 'Quality Gate Failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16565) **Quality Gate failed**  
   Failed conditions  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/failed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16565&metric=new_coverage&view=list) (required ≥ 60%)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16565)
   
   


-- 
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


Re: [PR] [Feature-16396][storage-plugin] Tencent Cloud COS Storage Plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16565:
URL: https://github.com/apache/dolphinscheduler/pull/16565#issuecomment-2366107685

   ## [![Quality Gate Failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-failed-20px.png 'Quality Gate Failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16565) **Quality Gate failed**  
   Failed conditions  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/failed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16565&metric=new_coverage&view=list) (required ≥ 60%)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16565)
   
   


-- 
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


Re: [PR] [Feature-16396][storage-plugin] Tencent Cloud COS Storage Plugin [dolphinscheduler]

Posted by "SbloodyS (via GitHub)" <gi...@apache.org>.
SbloodyS commented on code in PR #16565:
URL: https://github.com/apache/dolphinscheduler/pull/16565#discussion_r1770701485


##########
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/log/remote/CosRemoteLogHandler.java:
##########
@@ -0,0 +1,112 @@
+/*
+ * 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.log.remote;
+
+import org.apache.dolphinscheduler.common.constants.Constants;
+import org.apache.dolphinscheduler.common.utils.PropertyUtils;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.io.Closeable;
+import java.io.File;
+import java.io.IOException;
+
+import lombok.extern.slf4j.Slf4j;
+
+import com.qcloud.cos.COSClient;
+import com.qcloud.cos.ClientConfig;
+import com.qcloud.cos.auth.BasicCOSCredentials;
+import com.qcloud.cos.auth.COSCredentials;
+import com.qcloud.cos.http.HttpProtocol;
+import com.qcloud.cos.model.GetObjectRequest;
+import com.qcloud.cos.model.PutObjectRequest;
+import com.qcloud.cos.region.Region;
+
+@Slf4j
+public class CosRemoteLogHandler implements RemoteLogHandler, Closeable {
+
+    private final COSClient cosClient;
+
+    private final String bucketName;
+
+    private static CosRemoteLogHandler instance;
+
+    private CosRemoteLogHandler() {
+        String secretId = PropertyUtils.getString(Constants.REMOTE_LOGGING_COS_ACCESS_KEY_ID);
+        String secretKey = PropertyUtils.getString(Constants.REMOTE_LOGGING_COS_ACCESS_KEY_SECRET);
+        COSCredentials cosCredentials = new BasicCOSCredentials(secretId, secretKey);
+        String regionName = PropertyUtils.getString(Constants.REMOTE_LOGGING_COS_REGION);
+        ClientConfig clientConfig = new ClientConfig(new Region(regionName));
+        clientConfig.setHttpProtocol(HttpProtocol.https);
+        this.cosClient = new COSClient(cosCredentials, clientConfig);
+        this.bucketName = PropertyUtils.getString(Constants.REMOTE_LOGGING_COS_BUCKET_NAME);
+        checkBucketNameExists(this.bucketName);
+    }
+
+    public static synchronized CosRemoteLogHandler getInstance() {
+        if (instance == null) {
+            instance = new CosRemoteLogHandler();
+        }
+        return instance;
+    }
+
+    @Override
+    public void sendRemoteLog(String logPath) {
+        String objectName = RemoteLogUtils.getObjectNameFromLogPath(logPath);
+
+        try {
+            log.info("send remote log {} to COS {}", logPath, objectName);
+            PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, objectName, new File(logPath));
+            cosClient.putObject(putObjectRequest);
+        } catch (Exception e) {
+            log.error("error while sending remote log {} to COS {}", logPath, objectName, e);

Review Comment:
   ```suggestion
               log.error("error while sending remote log from {} to tencent cos {}, reason:", logPath, objectName, e);
   ```



##########
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/log/remote/CosRemoteLogHandler.java:
##########
@@ -0,0 +1,112 @@
+/*
+ * 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.log.remote;
+
+import org.apache.dolphinscheduler.common.constants.Constants;
+import org.apache.dolphinscheduler.common.utils.PropertyUtils;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.io.Closeable;
+import java.io.File;
+import java.io.IOException;
+
+import lombok.extern.slf4j.Slf4j;
+
+import com.qcloud.cos.COSClient;
+import com.qcloud.cos.ClientConfig;
+import com.qcloud.cos.auth.BasicCOSCredentials;
+import com.qcloud.cos.auth.COSCredentials;
+import com.qcloud.cos.http.HttpProtocol;
+import com.qcloud.cos.model.GetObjectRequest;
+import com.qcloud.cos.model.PutObjectRequest;
+import com.qcloud.cos.region.Region;
+
+@Slf4j
+public class CosRemoteLogHandler implements RemoteLogHandler, Closeable {
+
+    private final COSClient cosClient;
+
+    private final String bucketName;
+
+    private static CosRemoteLogHandler instance;
+
+    private CosRemoteLogHandler() {
+        String secretId = PropertyUtils.getString(Constants.REMOTE_LOGGING_COS_ACCESS_KEY_ID);
+        String secretKey = PropertyUtils.getString(Constants.REMOTE_LOGGING_COS_ACCESS_KEY_SECRET);
+        COSCredentials cosCredentials = new BasicCOSCredentials(secretId, secretKey);
+        String regionName = PropertyUtils.getString(Constants.REMOTE_LOGGING_COS_REGION);
+        ClientConfig clientConfig = new ClientConfig(new Region(regionName));
+        clientConfig.setHttpProtocol(HttpProtocol.https);
+        this.cosClient = new COSClient(cosCredentials, clientConfig);
+        this.bucketName = PropertyUtils.getString(Constants.REMOTE_LOGGING_COS_BUCKET_NAME);
+        checkBucketNameExists(this.bucketName);
+    }
+
+    public static synchronized CosRemoteLogHandler getInstance() {
+        if (instance == null) {
+            instance = new CosRemoteLogHandler();
+        }
+        return instance;
+    }
+
+    @Override
+    public void sendRemoteLog(String logPath) {
+        String objectName = RemoteLogUtils.getObjectNameFromLogPath(logPath);
+
+        try {
+            log.info("send remote log {} to COS {}", logPath, objectName);

Review Comment:
   ```suggestion
               log.info("send remote log from {} to tencent cos {}", logPath, objectName);
   ```



##########
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/log/remote/CosRemoteLogHandler.java:
##########
@@ -0,0 +1,112 @@
+/*
+ * 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.log.remote;
+
+import org.apache.dolphinscheduler.common.constants.Constants;
+import org.apache.dolphinscheduler.common.utils.PropertyUtils;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.io.Closeable;
+import java.io.File;
+import java.io.IOException;
+
+import lombok.extern.slf4j.Slf4j;
+
+import com.qcloud.cos.COSClient;
+import com.qcloud.cos.ClientConfig;
+import com.qcloud.cos.auth.BasicCOSCredentials;
+import com.qcloud.cos.auth.COSCredentials;
+import com.qcloud.cos.http.HttpProtocol;
+import com.qcloud.cos.model.GetObjectRequest;
+import com.qcloud.cos.model.PutObjectRequest;
+import com.qcloud.cos.region.Region;
+
+@Slf4j
+public class CosRemoteLogHandler implements RemoteLogHandler, Closeable {
+
+    private final COSClient cosClient;
+
+    private final String bucketName;
+
+    private static CosRemoteLogHandler instance;
+
+    private CosRemoteLogHandler() {
+        String secretId = PropertyUtils.getString(Constants.REMOTE_LOGGING_COS_ACCESS_KEY_ID);
+        String secretKey = PropertyUtils.getString(Constants.REMOTE_LOGGING_COS_ACCESS_KEY_SECRET);
+        COSCredentials cosCredentials = new BasicCOSCredentials(secretId, secretKey);
+        String regionName = PropertyUtils.getString(Constants.REMOTE_LOGGING_COS_REGION);
+        ClientConfig clientConfig = new ClientConfig(new Region(regionName));
+        clientConfig.setHttpProtocol(HttpProtocol.https);
+        this.cosClient = new COSClient(cosCredentials, clientConfig);
+        this.bucketName = PropertyUtils.getString(Constants.REMOTE_LOGGING_COS_BUCKET_NAME);
+        checkBucketNameExists(this.bucketName);
+    }
+
+    public static synchronized CosRemoteLogHandler getInstance() {
+        if (instance == null) {
+            instance = new CosRemoteLogHandler();
+        }
+        return instance;
+    }
+
+    @Override
+    public void sendRemoteLog(String logPath) {
+        String objectName = RemoteLogUtils.getObjectNameFromLogPath(logPath);
+
+        try {
+            log.info("send remote log {} to COS {}", logPath, objectName);
+            PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, objectName, new File(logPath));
+            cosClient.putObject(putObjectRequest);
+        } catch (Exception e) {
+            log.error("error while sending remote log {} to COS {}", logPath, objectName, e);
+        }
+    }
+
+    @Override
+    public void getRemoteLog(String logPath) {
+        String objectName = RemoteLogUtils.getObjectNameFromLogPath(logPath);
+
+        try {
+            log.info("get remote log on COS {} to {}", objectName, logPath);
+            cosClient.getObject(new GetObjectRequest(bucketName, objectName), new File(logPath));
+        } catch (Exception e) {
+            log.error("error while getting remote log on COS {} to {}", objectName, logPath, e);
+        }
+    }
+
+    @Override
+    public void close() throws IOException {
+        if (cosClient != null) {
+            cosClient.shutdown();
+        }
+    }
+
+    private void checkBucketNameExists(String bucketName) {
+        if (StringUtils.isBlank(bucketName)) {
+            throw new IllegalArgumentException(Constants.REMOTE_LOGGING_COS_BUCKET_NAME + " is empty");
+        }
+        boolean existsBucket = cosClient.doesBucketExist(bucketName);
+        if (!existsBucket) {
+            throw new IllegalArgumentException(
+                    "bucketName: " + bucketName + " is not exists, you need to create them by yourself");
+        }
+
+        log.info("Tencent COS bucket '{}' has been found for remote logging", bucketName);

Review Comment:
   ```suggestion
           log.debug("tencent cos bucket {} has been found for remote logging", bucketName);
   ```



##########
dolphinscheduler-storage-plugin/dolphinscheduler-storage-cos/src/main/java/org/apache/dolphinscheduler/plugin/storage/cos/CosStorageOperator.java:
##########
@@ -0,0 +1,335 @@
+/*
+ * 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.plugin.storage.cos;
+
+import org.apache.dolphinscheduler.common.constants.Constants;
+import org.apache.dolphinscheduler.common.utils.FileUtils;
+import org.apache.dolphinscheduler.plugin.storage.api.AbstractStorageOperator;
+import org.apache.dolphinscheduler.plugin.storage.api.ResourceMetadata;
+import org.apache.dolphinscheduler.plugin.storage.api.StorageEntity;
+import org.apache.dolphinscheduler.plugin.storage.api.StorageOperator;
+
+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.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.nio.file.FileAlreadyExistsException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.stream.Collectors;
+
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+
+import com.qcloud.cos.COSClient;
+import com.qcloud.cos.ClientConfig;
+import com.qcloud.cos.auth.BasicCOSCredentials;
+import com.qcloud.cos.auth.COSCredentials;
+import com.qcloud.cos.exception.CosServiceException;
+import com.qcloud.cos.http.HttpProtocol;
+import com.qcloud.cos.model.COSObject;
+import com.qcloud.cos.model.COSObjectSummary;
+import com.qcloud.cos.model.CopyObjectRequest;
+import com.qcloud.cos.model.CopyResult;
+import com.qcloud.cos.model.GetObjectRequest;
+import com.qcloud.cos.model.ListObjectsRequest;
+import com.qcloud.cos.model.ObjectListing;
+import com.qcloud.cos.model.ObjectMetadata;
+import com.qcloud.cos.model.PutObjectRequest;
+import com.qcloud.cos.model.UploadResult;
+import com.qcloud.cos.region.Region;
+import com.qcloud.cos.transfer.Copy;
+import com.qcloud.cos.transfer.Download;
+import com.qcloud.cos.transfer.TransferManager;
+import com.qcloud.cos.transfer.TransferManagerConfiguration;
+import com.qcloud.cos.transfer.Upload;
+
+@Slf4j
+public class CosStorageOperator extends AbstractStorageOperator implements Closeable, StorageOperator {
+
+    private static final int TRANSFER_THREAD_POOL_SIZE = 16;
+
+    private static final long MULTIPART_UPLOAD_BYTES_THRESHOLD = 5 * 1024 * 1024L;
+    private static final long MIN_UPLOAD_PART_BYTES = 1024 * 1024L;
+
+    private final String bucketName;
+
+    private final COSClient cosClient;
+
+    private final TransferManager cosTransferManager;
+
+    public CosStorageOperator(CosStorageProperties cosStorageProperties) {
+        super(cosStorageProperties.getResourceUploadPath());
+        String secretId = cosStorageProperties.getAccessKeyId();
+        String secretKey = cosStorageProperties.getAccessKeySecret();
+        COSCredentials cosCredentials = new BasicCOSCredentials(secretId, secretKey);
+        String regionName = cosStorageProperties.getRegion();
+        ClientConfig clientConfig = new ClientConfig(new Region(regionName));
+        clientConfig.setHttpProtocol(HttpProtocol.https);
+        this.cosClient = new COSClient(cosCredentials, clientConfig);
+        this.bucketName = cosStorageProperties.getBucketName();
+        ensureBucketSuccessfullyCreated(bucketName);
+        this.cosTransferManager = getCosTransferManager();
+    }
+
+    @Override
+    public void close() throws IOException {
+        this.cosTransferManager.shutdownNow(true);
+    }
+
+    @Override
+    public String getStorageBaseDirectory() {
+        // All directory should end with File.separator
+        if (resourceBaseAbsolutePath.startsWith("/")) {
+            log.warn("{} -> {} should not start with / in cos", Constants.RESOURCE_UPLOAD_PATH,
+                    resourceBaseAbsolutePath);
+            return resourceBaseAbsolutePath.substring(1);
+        }
+        return resourceBaseAbsolutePath;
+    }
+
+    @SneakyThrows
+    @Override
+    public void createStorageDir(String directoryAbsolutePath) {
+        String cosKey = transformAbsolutePathToCOSKey(directoryAbsolutePath);
+        if (cosClient.doesObjectExist(bucketName, cosKey)) {
+            throw new FileAlreadyExistsException("directory: " + cosKey + " already exists");
+        }
+        ObjectMetadata metadata = new ObjectMetadata();
+        metadata.setContentLength(0L);
+        InputStream emptyContent = new ByteArrayInputStream(new byte[0]);
+        PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, cosKey, emptyContent, metadata);
+        cosClient.putObject(putObjectRequest);
+    }
+
+    @SneakyThrows
+    @Override
+    public void download(String srcFilePath, String dstFilePath, boolean overwrite) {
+        String cosKey = transformAbsolutePathToCOSKey(srcFilePath);
+        Path dsTempFolder = Paths.get(FileUtils.DATA_BASEDIR).normalize().toAbsolutePath();
+        Path fileDownloadPathNormalized = dsTempFolder.resolve(dstFilePath).normalize().toAbsolutePath();
+        if (!fileDownloadPathNormalized.startsWith(dsTempFolder)) {
+            // if the destination file path is NOT in DS temp folder (e.g., '/tmp/dolphinscheduler'),
+            // an IllegalArgumentException should be thrown.
+            throw new IllegalArgumentException("failed to download to " + fileDownloadPathNormalized);
+        }
+        File dstFile = fileDownloadPathNormalized.toFile();
+        if (dstFile.isDirectory()) {
+            Files.delete(dstFile.toPath());
+        } else {
+            FileUtils.createDirectoryWith755(dstFile.getParentFile().toPath());
+        }
+
+        GetObjectRequest getObjectRequest = new GetObjectRequest(bucketName, cosKey);
+        Download download = cosTransferManager.download(getObjectRequest, dstFile);
+        download.waitForCompletion();
+    }
+
+    @Override
+    public boolean exists(String fileName) {
+        String cosKey = transformAbsolutePathToCOSKey(fileName);
+        return cosClient.doesObjectExist(bucketName, cosKey);
+    }
+
+    @Override
+    public void delete(String filePath, boolean recursive) {
+        String cosKey = transformAbsolutePathToCOSKey(filePath);
+        cosClient.deleteObject(bucketName, cosKey);
+    }
+
+    @SneakyThrows
+    @Override
+    public void copy(String srcPath, String dstPath, boolean deleteSource, boolean overwrite) {
+        String srcCosKey = transformAbsolutePathToCOSKey(srcPath);
+        String destCosKey = transformAbsolutePathToCOSKey(dstPath);
+        CopyObjectRequest copyObjectRequest = new CopyObjectRequest(bucketName, srcCosKey, bucketName, destCosKey);
+        Copy copy = cosTransferManager.copy(copyObjectRequest, cosClient, null);
+
+        CopyResult copyResult = copy.waitForCopyResult();
+        if (copyResult != null && deleteSource) {
+            cosClient.deleteObject(bucketName, srcPath);
+        }
+    }
+
+    @SneakyThrows
+    @Override
+    public void upload(String srcFile, String dstPath, boolean deleteSource, boolean overwrite) {
+        dstPath = transformAbsolutePathToCOSKey(dstPath);
+
+        if (cosClient.doesObjectExist(bucketName, dstPath)) {
+            if (!overwrite) {
+                throw new CosServiceException("file: " + dstPath + " already exists");
+            } else {
+                cosClient.deleteObject(bucketName, dstPath);
+            }
+        }
+
+        PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, dstPath, new File(srcFile));
+        Upload upload = cosTransferManager.upload(putObjectRequest);
+        UploadResult uploadResult = upload.waitForUploadResult();
+        if (uploadResult != null && deleteSource) {
+            Files.delete(Paths.get(srcFile));
+        }
+    }
+
+    @SneakyThrows
+    @Override
+    public List<String> fetchFileContent(String filePath, int skipLineNums, int limit) {
+        String cosKey = transformAbsolutePathToCOSKey(filePath);
+
+        COSObject cosObject = cosClient.getObject(bucketName, cosKey);
+        try (
+                InputStreamReader inputStreamReader = new InputStreamReader(cosObject.getObjectContent());
+                BufferedReader bufferedReader = new BufferedReader(inputStreamReader)) {
+            return bufferedReader
+                    .lines()
+                    .skip(skipLineNums)
+                    .limit(limit)
+                    .collect(Collectors.toList());
+        }
+    }
+
+    @Override
+    public List<StorageEntity> listStorageEntity(String resourceAbsolutePath) {
+        resourceAbsolutePath = transformCOSKeyToAbsolutePath(resourceAbsolutePath);
+
+        ListObjectsRequest request = new ListObjectsRequest();
+        request.setBucketName(bucketName);
+        request.setPrefix(resourceAbsolutePath);
+        request.setDelimiter("/");

Review Comment:
   Same here.



##########
dolphinscheduler-storage-plugin/dolphinscheduler-storage-cos/src/main/java/org/apache/dolphinscheduler/plugin/storage/cos/CosStorageOperator.java:
##########
@@ -0,0 +1,335 @@
+/*
+ * 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.plugin.storage.cos;
+
+import org.apache.dolphinscheduler.common.constants.Constants;
+import org.apache.dolphinscheduler.common.utils.FileUtils;
+import org.apache.dolphinscheduler.plugin.storage.api.AbstractStorageOperator;
+import org.apache.dolphinscheduler.plugin.storage.api.ResourceMetadata;
+import org.apache.dolphinscheduler.plugin.storage.api.StorageEntity;
+import org.apache.dolphinscheduler.plugin.storage.api.StorageOperator;
+
+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.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.nio.file.FileAlreadyExistsException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.stream.Collectors;
+
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+
+import com.qcloud.cos.COSClient;
+import com.qcloud.cos.ClientConfig;
+import com.qcloud.cos.auth.BasicCOSCredentials;
+import com.qcloud.cos.auth.COSCredentials;
+import com.qcloud.cos.exception.CosServiceException;
+import com.qcloud.cos.http.HttpProtocol;
+import com.qcloud.cos.model.COSObject;
+import com.qcloud.cos.model.COSObjectSummary;
+import com.qcloud.cos.model.CopyObjectRequest;
+import com.qcloud.cos.model.CopyResult;
+import com.qcloud.cos.model.GetObjectRequest;
+import com.qcloud.cos.model.ListObjectsRequest;
+import com.qcloud.cos.model.ObjectListing;
+import com.qcloud.cos.model.ObjectMetadata;
+import com.qcloud.cos.model.PutObjectRequest;
+import com.qcloud.cos.model.UploadResult;
+import com.qcloud.cos.region.Region;
+import com.qcloud.cos.transfer.Copy;
+import com.qcloud.cos.transfer.Download;
+import com.qcloud.cos.transfer.TransferManager;
+import com.qcloud.cos.transfer.TransferManagerConfiguration;
+import com.qcloud.cos.transfer.Upload;
+
+@Slf4j
+public class CosStorageOperator extends AbstractStorageOperator implements Closeable, StorageOperator {
+
+    private static final int TRANSFER_THREAD_POOL_SIZE = 16;
+
+    private static final long MULTIPART_UPLOAD_BYTES_THRESHOLD = 5 * 1024 * 1024L;
+    private static final long MIN_UPLOAD_PART_BYTES = 1024 * 1024L;
+
+    private final String bucketName;
+
+    private final COSClient cosClient;
+
+    private final TransferManager cosTransferManager;
+
+    public CosStorageOperator(CosStorageProperties cosStorageProperties) {
+        super(cosStorageProperties.getResourceUploadPath());
+        String secretId = cosStorageProperties.getAccessKeyId();
+        String secretKey = cosStorageProperties.getAccessKeySecret();
+        COSCredentials cosCredentials = new BasicCOSCredentials(secretId, secretKey);
+        String regionName = cosStorageProperties.getRegion();
+        ClientConfig clientConfig = new ClientConfig(new Region(regionName));
+        clientConfig.setHttpProtocol(HttpProtocol.https);
+        this.cosClient = new COSClient(cosCredentials, clientConfig);
+        this.bucketName = cosStorageProperties.getBucketName();
+        ensureBucketSuccessfullyCreated(bucketName);
+        this.cosTransferManager = getCosTransferManager();
+    }
+
+    @Override
+    public void close() throws IOException {
+        this.cosTransferManager.shutdownNow(true);
+    }
+
+    @Override
+    public String getStorageBaseDirectory() {
+        // All directory should end with File.separator
+        if (resourceBaseAbsolutePath.startsWith("/")) {
+            log.warn("{} -> {} should not start with / in cos", Constants.RESOURCE_UPLOAD_PATH,
+                    resourceBaseAbsolutePath);
+            return resourceBaseAbsolutePath.substring(1);
+        }
+        return resourceBaseAbsolutePath;
+    }
+
+    @SneakyThrows
+    @Override
+    public void createStorageDir(String directoryAbsolutePath) {
+        String cosKey = transformAbsolutePathToCOSKey(directoryAbsolutePath);
+        if (cosClient.doesObjectExist(bucketName, cosKey)) {
+            throw new FileAlreadyExistsException("directory: " + cosKey + " already exists");
+        }
+        ObjectMetadata metadata = new ObjectMetadata();
+        metadata.setContentLength(0L);
+        InputStream emptyContent = new ByteArrayInputStream(new byte[0]);
+        PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, cosKey, emptyContent, metadata);
+        cosClient.putObject(putObjectRequest);
+    }
+
+    @SneakyThrows
+    @Override
+    public void download(String srcFilePath, String dstFilePath, boolean overwrite) {
+        String cosKey = transformAbsolutePathToCOSKey(srcFilePath);
+        Path dsTempFolder = Paths.get(FileUtils.DATA_BASEDIR).normalize().toAbsolutePath();
+        Path fileDownloadPathNormalized = dsTempFolder.resolve(dstFilePath).normalize().toAbsolutePath();
+        if (!fileDownloadPathNormalized.startsWith(dsTempFolder)) {
+            // if the destination file path is NOT in DS temp folder (e.g., '/tmp/dolphinscheduler'),
+            // an IllegalArgumentException should be thrown.
+            throw new IllegalArgumentException("failed to download to " + fileDownloadPathNormalized);
+        }
+        File dstFile = fileDownloadPathNormalized.toFile();
+        if (dstFile.isDirectory()) {
+            Files.delete(dstFile.toPath());
+        } else {
+            FileUtils.createDirectoryWith755(dstFile.getParentFile().toPath());
+        }
+
+        GetObjectRequest getObjectRequest = new GetObjectRequest(bucketName, cosKey);
+        Download download = cosTransferManager.download(getObjectRequest, dstFile);
+        download.waitForCompletion();
+    }
+
+    @Override
+    public boolean exists(String fileName) {
+        String cosKey = transformAbsolutePathToCOSKey(fileName);
+        return cosClient.doesObjectExist(bucketName, cosKey);
+    }
+
+    @Override
+    public void delete(String filePath, boolean recursive) {
+        String cosKey = transformAbsolutePathToCOSKey(filePath);
+        cosClient.deleteObject(bucketName, cosKey);
+    }
+
+    @SneakyThrows
+    @Override
+    public void copy(String srcPath, String dstPath, boolean deleteSource, boolean overwrite) {
+        String srcCosKey = transformAbsolutePathToCOSKey(srcPath);
+        String destCosKey = transformAbsolutePathToCOSKey(dstPath);
+        CopyObjectRequest copyObjectRequest = new CopyObjectRequest(bucketName, srcCosKey, bucketName, destCosKey);
+        Copy copy = cosTransferManager.copy(copyObjectRequest, cosClient, null);
+
+        CopyResult copyResult = copy.waitForCopyResult();
+        if (copyResult != null && deleteSource) {
+            cosClient.deleteObject(bucketName, srcPath);
+        }
+    }
+
+    @SneakyThrows
+    @Override
+    public void upload(String srcFile, String dstPath, boolean deleteSource, boolean overwrite) {
+        dstPath = transformAbsolutePathToCOSKey(dstPath);
+
+        if (cosClient.doesObjectExist(bucketName, dstPath)) {
+            if (!overwrite) {
+                throw new CosServiceException("file: " + dstPath + " already exists");
+            } else {
+                cosClient.deleteObject(bucketName, dstPath);
+            }
+        }
+
+        PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, dstPath, new File(srcFile));
+        Upload upload = cosTransferManager.upload(putObjectRequest);
+        UploadResult uploadResult = upload.waitForUploadResult();
+        if (uploadResult != null && deleteSource) {
+            Files.delete(Paths.get(srcFile));
+        }
+    }
+
+    @SneakyThrows
+    @Override
+    public List<String> fetchFileContent(String filePath, int skipLineNums, int limit) {
+        String cosKey = transformAbsolutePathToCOSKey(filePath);
+
+        COSObject cosObject = cosClient.getObject(bucketName, cosKey);
+        try (
+                InputStreamReader inputStreamReader = new InputStreamReader(cosObject.getObjectContent());
+                BufferedReader bufferedReader = new BufferedReader(inputStreamReader)) {
+            return bufferedReader
+                    .lines()
+                    .skip(skipLineNums)
+                    .limit(limit)
+                    .collect(Collectors.toList());
+        }
+    }
+
+    @Override
+    public List<StorageEntity> listStorageEntity(String resourceAbsolutePath) {
+        resourceAbsolutePath = transformCOSKeyToAbsolutePath(resourceAbsolutePath);
+
+        ListObjectsRequest request = new ListObjectsRequest();
+        request.setBucketName(bucketName);
+        request.setPrefix(resourceAbsolutePath);
+        request.setDelimiter("/");
+
+        ObjectListing result = cosClient.listObjects(request);
+
+        return result.getObjectSummaries()
+                .stream()
+                .map((COSObjectSummary summary) -> {
+                    ObjectMetadata metadata = new ObjectMetadata();
+                    metadata.setContentLength(summary.getSize());
+                    metadata.setLastModified(summary.getLastModified());
+                    COSObject object = new COSObject();
+                    object.setObjectMetadata(metadata);
+                    object.setKey(summary.getKey());
+                    return transformCOSObjectToStorageEntity(object);
+                })
+                .collect(Collectors.toList());
+    }
+
+    @Override
+    public List<StorageEntity> listFileStorageEntityRecursively(String resourceAbsolutePath) {
+        resourceAbsolutePath = transformCOSKeyToAbsolutePath(resourceAbsolutePath);
+
+        Set<String> visited = new HashSet<>();
+        List<StorageEntity> storageEntityList = new ArrayList<>();
+        LinkedList<String> foldersToFetch = new LinkedList<>();
+        foldersToFetch.addLast(resourceAbsolutePath);
+
+        while (!foldersToFetch.isEmpty()) {
+            String pathToExplore = foldersToFetch.pop();
+            visited.add(pathToExplore);
+            List<StorageEntity> storageEntities = listStorageEntity(pathToExplore);
+            for (StorageEntity entity : storageEntities) {
+                if (entity.isDirectory()) {
+                    if (visited.contains(entity.getFullName())) {
+                        continue;
+                    }
+                    foldersToFetch.add(entity.getFullName());
+                }
+            }
+            storageEntityList.addAll(storageEntities);
+        }
+
+        return storageEntityList;
+    }
+
+    @Override
+    public StorageEntity getStorageEntity(String resourceAbsolutePath) {
+        String cosKey = transformCOSKeyToAbsolutePath(resourceAbsolutePath);
+
+        COSObject object = cosClient.getObject(bucketName, cosKey);
+        return transformCOSObjectToStorageEntity(object);
+    }
+
+    public void ensureBucketSuccessfullyCreated(String bucketName) {
+        if (StringUtils.isBlank(bucketName)) {
+            throw new IllegalArgumentException("resource.tencent.cloud.cos.bucket.name is empty");
+        }
+
+        if (!cosClient.doesBucketExist(bucketName)) {
+            throw new IllegalArgumentException(
+                    "bucketName: " + bucketName + " is not exists, you need to create them by yourself");
+        }
+
+        log.info("bucketName: {} has been found", bucketName);
+    }
+
+    protected StorageEntity transformCOSObjectToStorageEntity(COSObject object) {
+        ObjectMetadata metadata = object.getObjectMetadata();
+        String fileAbsolutePath = transformCOSKeyToAbsolutePath(object.getKey());
+        ResourceMetadata resourceMetaData = getResourceMetaData(fileAbsolutePath);
+        String fileExtension = com.google.common.io.Files.getFileExtension(resourceMetaData.getResourceAbsolutePath());
+
+        return StorageEntity.builder()
+                .fileName(new File(fileAbsolutePath).getName())
+                .fullName(fileAbsolutePath)
+                .pfullName(resourceMetaData.getResourceParentAbsolutePath())
+                .type(resourceMetaData.getResourceType())
+                .isDirectory(StringUtils.isEmpty(fileExtension))
+                .size(metadata.getContentLength())
+                .createTime(metadata.getLastModified())
+                .updateTime(metadata.getLastModified())
+                .build();
+    }
+
+    private String transformAbsolutePathToCOSKey(String absolutePath) {
+        ResourceMetadata resourceMetaData = getResourceMetaData(absolutePath);
+        if (resourceMetaData.isDirectory()) {
+            return FileUtils.concatFilePath(absolutePath, "/");
+        }
+        return absolutePath;
+    }
+
+    private String transformCOSKeyToAbsolutePath(String s3Key) {

Review Comment:
   ```suggestion
       private String transformCOSKeyToAbsolutePath(String cosKey) {
   ```



##########
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/log/remote/CosRemoteLogHandler.java:
##########
@@ -0,0 +1,112 @@
+/*
+ * 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.log.remote;
+
+import org.apache.dolphinscheduler.common.constants.Constants;
+import org.apache.dolphinscheduler.common.utils.PropertyUtils;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.io.Closeable;
+import java.io.File;
+import java.io.IOException;
+
+import lombok.extern.slf4j.Slf4j;
+
+import com.qcloud.cos.COSClient;
+import com.qcloud.cos.ClientConfig;
+import com.qcloud.cos.auth.BasicCOSCredentials;
+import com.qcloud.cos.auth.COSCredentials;
+import com.qcloud.cos.http.HttpProtocol;
+import com.qcloud.cos.model.GetObjectRequest;
+import com.qcloud.cos.model.PutObjectRequest;
+import com.qcloud.cos.region.Region;
+
+@Slf4j
+public class CosRemoteLogHandler implements RemoteLogHandler, Closeable {
+
+    private final COSClient cosClient;
+
+    private final String bucketName;
+
+    private static CosRemoteLogHandler instance;
+
+    private CosRemoteLogHandler() {
+        String secretId = PropertyUtils.getString(Constants.REMOTE_LOGGING_COS_ACCESS_KEY_ID);
+        String secretKey = PropertyUtils.getString(Constants.REMOTE_LOGGING_COS_ACCESS_KEY_SECRET);
+        COSCredentials cosCredentials = new BasicCOSCredentials(secretId, secretKey);
+        String regionName = PropertyUtils.getString(Constants.REMOTE_LOGGING_COS_REGION);
+        ClientConfig clientConfig = new ClientConfig(new Region(regionName));
+        clientConfig.setHttpProtocol(HttpProtocol.https);
+        this.cosClient = new COSClient(cosCredentials, clientConfig);
+        this.bucketName = PropertyUtils.getString(Constants.REMOTE_LOGGING_COS_BUCKET_NAME);
+        checkBucketNameExists(this.bucketName);
+    }
+
+    public static synchronized CosRemoteLogHandler getInstance() {
+        if (instance == null) {
+            instance = new CosRemoteLogHandler();
+        }
+        return instance;
+    }
+
+    @Override
+    public void sendRemoteLog(String logPath) {
+        String objectName = RemoteLogUtils.getObjectNameFromLogPath(logPath);
+
+        try {
+            log.info("send remote log {} to COS {}", logPath, objectName);
+            PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, objectName, new File(logPath));
+            cosClient.putObject(putObjectRequest);
+        } catch (Exception e) {
+            log.error("error while sending remote log {} to COS {}", logPath, objectName, e);
+        }
+    }
+
+    @Override
+    public void getRemoteLog(String logPath) {
+        String objectName = RemoteLogUtils.getObjectNameFromLogPath(logPath);
+
+        try {
+            log.info("get remote log on COS {} to {}", objectName, logPath);
+            cosClient.getObject(new GetObjectRequest(bucketName, objectName), new File(logPath));
+        } catch (Exception e) {
+            log.error("error while getting remote log on COS {} to {}", objectName, logPath, e);

Review Comment:
   ```suggestion
               log.error("error while getting remote log from tencent cos {} to {}, reason:", objectName, logPath, e);
   ```



##########
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/log/remote/CosRemoteLogHandler.java:
##########
@@ -0,0 +1,112 @@
+/*
+ * 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.log.remote;
+
+import org.apache.dolphinscheduler.common.constants.Constants;
+import org.apache.dolphinscheduler.common.utils.PropertyUtils;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.io.Closeable;
+import java.io.File;
+import java.io.IOException;
+
+import lombok.extern.slf4j.Slf4j;
+
+import com.qcloud.cos.COSClient;
+import com.qcloud.cos.ClientConfig;
+import com.qcloud.cos.auth.BasicCOSCredentials;
+import com.qcloud.cos.auth.COSCredentials;
+import com.qcloud.cos.http.HttpProtocol;
+import com.qcloud.cos.model.GetObjectRequest;
+import com.qcloud.cos.model.PutObjectRequest;
+import com.qcloud.cos.region.Region;
+
+@Slf4j
+public class CosRemoteLogHandler implements RemoteLogHandler, Closeable {
+
+    private final COSClient cosClient;
+
+    private final String bucketName;
+
+    private static CosRemoteLogHandler instance;
+
+    private CosRemoteLogHandler() {
+        String secretId = PropertyUtils.getString(Constants.REMOTE_LOGGING_COS_ACCESS_KEY_ID);
+        String secretKey = PropertyUtils.getString(Constants.REMOTE_LOGGING_COS_ACCESS_KEY_SECRET);
+        COSCredentials cosCredentials = new BasicCOSCredentials(secretId, secretKey);
+        String regionName = PropertyUtils.getString(Constants.REMOTE_LOGGING_COS_REGION);
+        ClientConfig clientConfig = new ClientConfig(new Region(regionName));
+        clientConfig.setHttpProtocol(HttpProtocol.https);
+        this.cosClient = new COSClient(cosCredentials, clientConfig);
+        this.bucketName = PropertyUtils.getString(Constants.REMOTE_LOGGING_COS_BUCKET_NAME);
+        checkBucketNameExists(this.bucketName);
+    }
+
+    public static synchronized CosRemoteLogHandler getInstance() {
+        if (instance == null) {
+            instance = new CosRemoteLogHandler();
+        }
+        return instance;
+    }
+
+    @Override
+    public void sendRemoteLog(String logPath) {
+        String objectName = RemoteLogUtils.getObjectNameFromLogPath(logPath);
+
+        try {
+            log.info("send remote log {} to COS {}", logPath, objectName);
+            PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, objectName, new File(logPath));
+            cosClient.putObject(putObjectRequest);
+        } catch (Exception e) {
+            log.error("error while sending remote log {} to COS {}", logPath, objectName, e);
+        }
+    }
+
+    @Override
+    public void getRemoteLog(String logPath) {
+        String objectName = RemoteLogUtils.getObjectNameFromLogPath(logPath);
+
+        try {
+            log.info("get remote log on COS {} to {}", objectName, logPath);

Review Comment:
   ```suggestion
               log.info("get remote log from tencent cos {} to {}", objectName, logPath);
   ```



##########
dolphinscheduler-storage-plugin/dolphinscheduler-storage-cos/src/main/java/org/apache/dolphinscheduler/plugin/storage/cos/CosStorageOperator.java:
##########
@@ -0,0 +1,335 @@
+/*
+ * 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.plugin.storage.cos;
+
+import org.apache.dolphinscheduler.common.constants.Constants;
+import org.apache.dolphinscheduler.common.utils.FileUtils;
+import org.apache.dolphinscheduler.plugin.storage.api.AbstractStorageOperator;
+import org.apache.dolphinscheduler.plugin.storage.api.ResourceMetadata;
+import org.apache.dolphinscheduler.plugin.storage.api.StorageEntity;
+import org.apache.dolphinscheduler.plugin.storage.api.StorageOperator;
+
+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.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.nio.file.FileAlreadyExistsException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.stream.Collectors;
+
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+
+import com.qcloud.cos.COSClient;
+import com.qcloud.cos.ClientConfig;
+import com.qcloud.cos.auth.BasicCOSCredentials;
+import com.qcloud.cos.auth.COSCredentials;
+import com.qcloud.cos.exception.CosServiceException;
+import com.qcloud.cos.http.HttpProtocol;
+import com.qcloud.cos.model.COSObject;
+import com.qcloud.cos.model.COSObjectSummary;
+import com.qcloud.cos.model.CopyObjectRequest;
+import com.qcloud.cos.model.CopyResult;
+import com.qcloud.cos.model.GetObjectRequest;
+import com.qcloud.cos.model.ListObjectsRequest;
+import com.qcloud.cos.model.ObjectListing;
+import com.qcloud.cos.model.ObjectMetadata;
+import com.qcloud.cos.model.PutObjectRequest;
+import com.qcloud.cos.model.UploadResult;
+import com.qcloud.cos.region.Region;
+import com.qcloud.cos.transfer.Copy;
+import com.qcloud.cos.transfer.Download;
+import com.qcloud.cos.transfer.TransferManager;
+import com.qcloud.cos.transfer.TransferManagerConfiguration;
+import com.qcloud.cos.transfer.Upload;
+
+@Slf4j
+public class CosStorageOperator extends AbstractStorageOperator implements Closeable, StorageOperator {
+
+    private static final int TRANSFER_THREAD_POOL_SIZE = 16;
+
+    private static final long MULTIPART_UPLOAD_BYTES_THRESHOLD = 5 * 1024 * 1024L;
+    private static final long MIN_UPLOAD_PART_BYTES = 1024 * 1024L;
+
+    private final String bucketName;
+
+    private final COSClient cosClient;
+
+    private final TransferManager cosTransferManager;
+
+    public CosStorageOperator(CosStorageProperties cosStorageProperties) {
+        super(cosStorageProperties.getResourceUploadPath());
+        String secretId = cosStorageProperties.getAccessKeyId();
+        String secretKey = cosStorageProperties.getAccessKeySecret();
+        COSCredentials cosCredentials = new BasicCOSCredentials(secretId, secretKey);
+        String regionName = cosStorageProperties.getRegion();
+        ClientConfig clientConfig = new ClientConfig(new Region(regionName));
+        clientConfig.setHttpProtocol(HttpProtocol.https);
+        this.cosClient = new COSClient(cosCredentials, clientConfig);
+        this.bucketName = cosStorageProperties.getBucketName();
+        ensureBucketSuccessfullyCreated(bucketName);
+        this.cosTransferManager = getCosTransferManager();
+    }
+
+    @Override
+    public void close() throws IOException {
+        this.cosTransferManager.shutdownNow(true);
+    }
+
+    @Override
+    public String getStorageBaseDirectory() {
+        // All directory should end with File.separator
+        if (resourceBaseAbsolutePath.startsWith("/")) {
+            log.warn("{} -> {} should not start with / in cos", Constants.RESOURCE_UPLOAD_PATH,
+                    resourceBaseAbsolutePath);
+            return resourceBaseAbsolutePath.substring(1);

Review Comment:
   It's better to throw exception here since there may be abnormal data in this.



##########
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/log/remote/CosRemoteLogHandler.java:
##########
@@ -0,0 +1,112 @@
+/*
+ * 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.log.remote;
+
+import org.apache.dolphinscheduler.common.constants.Constants;
+import org.apache.dolphinscheduler.common.utils.PropertyUtils;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.io.Closeable;
+import java.io.File;
+import java.io.IOException;
+
+import lombok.extern.slf4j.Slf4j;
+
+import com.qcloud.cos.COSClient;
+import com.qcloud.cos.ClientConfig;
+import com.qcloud.cos.auth.BasicCOSCredentials;
+import com.qcloud.cos.auth.COSCredentials;
+import com.qcloud.cos.http.HttpProtocol;
+import com.qcloud.cos.model.GetObjectRequest;
+import com.qcloud.cos.model.PutObjectRequest;
+import com.qcloud.cos.region.Region;
+
+@Slf4j
+public class CosRemoteLogHandler implements RemoteLogHandler, Closeable {
+
+    private final COSClient cosClient;
+
+    private final String bucketName;
+
+    private static CosRemoteLogHandler instance;
+
+    private CosRemoteLogHandler() {
+        String secretId = PropertyUtils.getString(Constants.REMOTE_LOGGING_COS_ACCESS_KEY_ID);
+        String secretKey = PropertyUtils.getString(Constants.REMOTE_LOGGING_COS_ACCESS_KEY_SECRET);
+        COSCredentials cosCredentials = new BasicCOSCredentials(secretId, secretKey);
+        String regionName = PropertyUtils.getString(Constants.REMOTE_LOGGING_COS_REGION);
+        ClientConfig clientConfig = new ClientConfig(new Region(regionName));
+        clientConfig.setHttpProtocol(HttpProtocol.https);
+        this.cosClient = new COSClient(cosCredentials, clientConfig);
+        this.bucketName = PropertyUtils.getString(Constants.REMOTE_LOGGING_COS_BUCKET_NAME);
+        checkBucketNameExists(this.bucketName);
+    }
+
+    public static synchronized CosRemoteLogHandler getInstance() {
+        if (instance == null) {
+            instance = new CosRemoteLogHandler();
+        }
+        return instance;
+    }
+
+    @Override
+    public void sendRemoteLog(String logPath) {
+        String objectName = RemoteLogUtils.getObjectNameFromLogPath(logPath);
+
+        try {
+            log.info("send remote log {} to COS {}", logPath, objectName);
+            PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, objectName, new File(logPath));
+            cosClient.putObject(putObjectRequest);
+        } catch (Exception e) {
+            log.error("error while sending remote log {} to COS {}", logPath, objectName, e);
+        }
+    }
+
+    @Override
+    public void getRemoteLog(String logPath) {
+        String objectName = RemoteLogUtils.getObjectNameFromLogPath(logPath);
+
+        try {
+            log.info("get remote log on COS {} to {}", objectName, logPath);
+            cosClient.getObject(new GetObjectRequest(bucketName, objectName), new File(logPath));
+        } catch (Exception e) {
+            log.error("error while getting remote log on COS {} to {}", objectName, logPath, e);
+        }
+    }
+
+    @Override
+    public void close() throws IOException {
+        if (cosClient != null) {
+            cosClient.shutdown();
+        }
+    }
+
+    private void checkBucketNameExists(String bucketName) {
+        if (StringUtils.isBlank(bucketName)) {
+            throw new IllegalArgumentException(Constants.REMOTE_LOGGING_COS_BUCKET_NAME + " is empty");
+        }
+        boolean existsBucket = cosClient.doesBucketExist(bucketName);
+        if (!existsBucket) {
+            throw new IllegalArgumentException(
+                    "bucketName: " + bucketName + " is not exists, you need to create them by yourself");

Review Comment:
   ```suggestion
                       "bucketName: " + bucketName + " does not exists, you should create it first");
   ```



##########
dolphinscheduler-storage-plugin/dolphinscheduler-storage-cos/src/main/java/org/apache/dolphinscheduler/plugin/storage/cos/CosStorageOperator.java:
##########
@@ -0,0 +1,335 @@
+/*
+ * 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.plugin.storage.cos;
+
+import org.apache.dolphinscheduler.common.constants.Constants;
+import org.apache.dolphinscheduler.common.utils.FileUtils;
+import org.apache.dolphinscheduler.plugin.storage.api.AbstractStorageOperator;
+import org.apache.dolphinscheduler.plugin.storage.api.ResourceMetadata;
+import org.apache.dolphinscheduler.plugin.storage.api.StorageEntity;
+import org.apache.dolphinscheduler.plugin.storage.api.StorageOperator;
+
+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.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.nio.file.FileAlreadyExistsException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.stream.Collectors;
+
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+
+import com.qcloud.cos.COSClient;
+import com.qcloud.cos.ClientConfig;
+import com.qcloud.cos.auth.BasicCOSCredentials;
+import com.qcloud.cos.auth.COSCredentials;
+import com.qcloud.cos.exception.CosServiceException;
+import com.qcloud.cos.http.HttpProtocol;
+import com.qcloud.cos.model.COSObject;
+import com.qcloud.cos.model.COSObjectSummary;
+import com.qcloud.cos.model.CopyObjectRequest;
+import com.qcloud.cos.model.CopyResult;
+import com.qcloud.cos.model.GetObjectRequest;
+import com.qcloud.cos.model.ListObjectsRequest;
+import com.qcloud.cos.model.ObjectListing;
+import com.qcloud.cos.model.ObjectMetadata;
+import com.qcloud.cos.model.PutObjectRequest;
+import com.qcloud.cos.model.UploadResult;
+import com.qcloud.cos.region.Region;
+import com.qcloud.cos.transfer.Copy;
+import com.qcloud.cos.transfer.Download;
+import com.qcloud.cos.transfer.TransferManager;
+import com.qcloud.cos.transfer.TransferManagerConfiguration;
+import com.qcloud.cos.transfer.Upload;
+
+@Slf4j
+public class CosStorageOperator extends AbstractStorageOperator implements Closeable, StorageOperator {
+
+    private static final int TRANSFER_THREAD_POOL_SIZE = 16;
+
+    private static final long MULTIPART_UPLOAD_BYTES_THRESHOLD = 5 * 1024 * 1024L;
+    private static final long MIN_UPLOAD_PART_BYTES = 1024 * 1024L;
+
+    private final String bucketName;
+
+    private final COSClient cosClient;
+
+    private final TransferManager cosTransferManager;
+
+    public CosStorageOperator(CosStorageProperties cosStorageProperties) {
+        super(cosStorageProperties.getResourceUploadPath());
+        String secretId = cosStorageProperties.getAccessKeyId();
+        String secretKey = cosStorageProperties.getAccessKeySecret();
+        COSCredentials cosCredentials = new BasicCOSCredentials(secretId, secretKey);
+        String regionName = cosStorageProperties.getRegion();
+        ClientConfig clientConfig = new ClientConfig(new Region(regionName));
+        clientConfig.setHttpProtocol(HttpProtocol.https);
+        this.cosClient = new COSClient(cosCredentials, clientConfig);
+        this.bucketName = cosStorageProperties.getBucketName();
+        ensureBucketSuccessfullyCreated(bucketName);
+        this.cosTransferManager = getCosTransferManager();
+    }
+
+    @Override
+    public void close() throws IOException {
+        this.cosTransferManager.shutdownNow(true);
+    }
+
+    @Override
+    public String getStorageBaseDirectory() {
+        // All directory should end with File.separator
+        if (resourceBaseAbsolutePath.startsWith("/")) {
+            log.warn("{} -> {} should not start with / in cos", Constants.RESOURCE_UPLOAD_PATH,
+                    resourceBaseAbsolutePath);
+            return resourceBaseAbsolutePath.substring(1);
+        }
+        return resourceBaseAbsolutePath;
+    }
+
+    @SneakyThrows
+    @Override
+    public void createStorageDir(String directoryAbsolutePath) {
+        String cosKey = transformAbsolutePathToCOSKey(directoryAbsolutePath);
+        if (cosClient.doesObjectExist(bucketName, cosKey)) {
+            throw new FileAlreadyExistsException("directory: " + cosKey + " already exists");
+        }
+        ObjectMetadata metadata = new ObjectMetadata();
+        metadata.setContentLength(0L);
+        InputStream emptyContent = new ByteArrayInputStream(new byte[0]);
+        PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, cosKey, emptyContent, metadata);
+        cosClient.putObject(putObjectRequest);
+    }
+
+    @SneakyThrows
+    @Override
+    public void download(String srcFilePath, String dstFilePath, boolean overwrite) {
+        String cosKey = transformAbsolutePathToCOSKey(srcFilePath);
+        Path dsTempFolder = Paths.get(FileUtils.DATA_BASEDIR).normalize().toAbsolutePath();
+        Path fileDownloadPathNormalized = dsTempFolder.resolve(dstFilePath).normalize().toAbsolutePath();
+        if (!fileDownloadPathNormalized.startsWith(dsTempFolder)) {
+            // if the destination file path is NOT in DS temp folder (e.g., '/tmp/dolphinscheduler'),
+            // an IllegalArgumentException should be thrown.
+            throw new IllegalArgumentException("failed to download to " + fileDownloadPathNormalized);
+        }
+        File dstFile = fileDownloadPathNormalized.toFile();
+        if (dstFile.isDirectory()) {
+            Files.delete(dstFile.toPath());
+        } else {
+            FileUtils.createDirectoryWith755(dstFile.getParentFile().toPath());
+        }
+
+        GetObjectRequest getObjectRequest = new GetObjectRequest(bucketName, cosKey);
+        Download download = cosTransferManager.download(getObjectRequest, dstFile);
+        download.waitForCompletion();
+    }
+
+    @Override
+    public boolean exists(String fileName) {
+        String cosKey = transformAbsolutePathToCOSKey(fileName);
+        return cosClient.doesObjectExist(bucketName, cosKey);
+    }
+
+    @Override
+    public void delete(String filePath, boolean recursive) {
+        String cosKey = transformAbsolutePathToCOSKey(filePath);
+        cosClient.deleteObject(bucketName, cosKey);
+    }
+
+    @SneakyThrows
+    @Override
+    public void copy(String srcPath, String dstPath, boolean deleteSource, boolean overwrite) {
+        String srcCosKey = transformAbsolutePathToCOSKey(srcPath);
+        String destCosKey = transformAbsolutePathToCOSKey(dstPath);
+        CopyObjectRequest copyObjectRequest = new CopyObjectRequest(bucketName, srcCosKey, bucketName, destCosKey);
+        Copy copy = cosTransferManager.copy(copyObjectRequest, cosClient, null);
+
+        CopyResult copyResult = copy.waitForCopyResult();
+        if (copyResult != null && deleteSource) {
+            cosClient.deleteObject(bucketName, srcPath);
+        }
+    }
+
+    @SneakyThrows
+    @Override
+    public void upload(String srcFile, String dstPath, boolean deleteSource, boolean overwrite) {
+        dstPath = transformAbsolutePathToCOSKey(dstPath);
+
+        if (cosClient.doesObjectExist(bucketName, dstPath)) {
+            if (!overwrite) {
+                throw new CosServiceException("file: " + dstPath + " already exists");
+            } else {
+                cosClient.deleteObject(bucketName, dstPath);
+            }
+        }
+
+        PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, dstPath, new File(srcFile));
+        Upload upload = cosTransferManager.upload(putObjectRequest);
+        UploadResult uploadResult = upload.waitForUploadResult();
+        if (uploadResult != null && deleteSource) {
+            Files.delete(Paths.get(srcFile));
+        }
+    }
+
+    @SneakyThrows
+    @Override
+    public List<String> fetchFileContent(String filePath, int skipLineNums, int limit) {
+        String cosKey = transformAbsolutePathToCOSKey(filePath);
+
+        COSObject cosObject = cosClient.getObject(bucketName, cosKey);
+        try (
+                InputStreamReader inputStreamReader = new InputStreamReader(cosObject.getObjectContent());
+                BufferedReader bufferedReader = new BufferedReader(inputStreamReader)) {
+            return bufferedReader
+                    .lines()
+                    .skip(skipLineNums)
+                    .limit(limit)
+                    .collect(Collectors.toList());
+        }
+    }
+
+    @Override
+    public List<StorageEntity> listStorageEntity(String resourceAbsolutePath) {
+        resourceAbsolutePath = transformCOSKeyToAbsolutePath(resourceAbsolutePath);
+
+        ListObjectsRequest request = new ListObjectsRequest();
+        request.setBucketName(bucketName);
+        request.setPrefix(resourceAbsolutePath);
+        request.setDelimiter("/");
+
+        ObjectListing result = cosClient.listObjects(request);
+
+        return result.getObjectSummaries()
+                .stream()
+                .map((COSObjectSummary summary) -> {
+                    ObjectMetadata metadata = new ObjectMetadata();
+                    metadata.setContentLength(summary.getSize());
+                    metadata.setLastModified(summary.getLastModified());
+                    COSObject object = new COSObject();
+                    object.setObjectMetadata(metadata);
+                    object.setKey(summary.getKey());
+                    return transformCOSObjectToStorageEntity(object);
+                })
+                .collect(Collectors.toList());
+    }
+
+    @Override
+    public List<StorageEntity> listFileStorageEntityRecursively(String resourceAbsolutePath) {
+        resourceAbsolutePath = transformCOSKeyToAbsolutePath(resourceAbsolutePath);
+
+        Set<String> visited = new HashSet<>();
+        List<StorageEntity> storageEntityList = new ArrayList<>();
+        LinkedList<String> foldersToFetch = new LinkedList<>();
+        foldersToFetch.addLast(resourceAbsolutePath);
+
+        while (!foldersToFetch.isEmpty()) {
+            String pathToExplore = foldersToFetch.pop();
+            visited.add(pathToExplore);
+            List<StorageEntity> storageEntities = listStorageEntity(pathToExplore);
+            for (StorageEntity entity : storageEntities) {
+                if (entity.isDirectory()) {
+                    if (visited.contains(entity.getFullName())) {
+                        continue;
+                    }
+                    foldersToFetch.add(entity.getFullName());
+                }
+            }
+            storageEntityList.addAll(storageEntities);
+        }
+
+        return storageEntityList;
+    }
+
+    @Override
+    public StorageEntity getStorageEntity(String resourceAbsolutePath) {
+        String cosKey = transformCOSKeyToAbsolutePath(resourceAbsolutePath);
+
+        COSObject object = cosClient.getObject(bucketName, cosKey);
+        return transformCOSObjectToStorageEntity(object);
+    }
+
+    public void ensureBucketSuccessfullyCreated(String bucketName) {
+        if (StringUtils.isBlank(bucketName)) {
+            throw new IllegalArgumentException("resource.tencent.cloud.cos.bucket.name is empty");

Review Comment:
   It's better to use `Constants` to replace `resource.tencent.cloud.cos.bucket.name`



##########
dolphinscheduler-storage-plugin/dolphinscheduler-storage-cos/src/main/java/org/apache/dolphinscheduler/plugin/storage/cos/CosStorageOperator.java:
##########
@@ -0,0 +1,335 @@
+/*
+ * 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.plugin.storage.cos;
+
+import org.apache.dolphinscheduler.common.constants.Constants;
+import org.apache.dolphinscheduler.common.utils.FileUtils;
+import org.apache.dolphinscheduler.plugin.storage.api.AbstractStorageOperator;
+import org.apache.dolphinscheduler.plugin.storage.api.ResourceMetadata;
+import org.apache.dolphinscheduler.plugin.storage.api.StorageEntity;
+import org.apache.dolphinscheduler.plugin.storage.api.StorageOperator;
+
+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.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.nio.file.FileAlreadyExistsException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.stream.Collectors;
+
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+
+import com.qcloud.cos.COSClient;
+import com.qcloud.cos.ClientConfig;
+import com.qcloud.cos.auth.BasicCOSCredentials;
+import com.qcloud.cos.auth.COSCredentials;
+import com.qcloud.cos.exception.CosServiceException;
+import com.qcloud.cos.http.HttpProtocol;
+import com.qcloud.cos.model.COSObject;
+import com.qcloud.cos.model.COSObjectSummary;
+import com.qcloud.cos.model.CopyObjectRequest;
+import com.qcloud.cos.model.CopyResult;
+import com.qcloud.cos.model.GetObjectRequest;
+import com.qcloud.cos.model.ListObjectsRequest;
+import com.qcloud.cos.model.ObjectListing;
+import com.qcloud.cos.model.ObjectMetadata;
+import com.qcloud.cos.model.PutObjectRequest;
+import com.qcloud.cos.model.UploadResult;
+import com.qcloud.cos.region.Region;
+import com.qcloud.cos.transfer.Copy;
+import com.qcloud.cos.transfer.Download;
+import com.qcloud.cos.transfer.TransferManager;
+import com.qcloud.cos.transfer.TransferManagerConfiguration;
+import com.qcloud.cos.transfer.Upload;
+
+@Slf4j
+public class CosStorageOperator extends AbstractStorageOperator implements Closeable, StorageOperator {
+
+    private static final int TRANSFER_THREAD_POOL_SIZE = 16;
+
+    private static final long MULTIPART_UPLOAD_BYTES_THRESHOLD = 5 * 1024 * 1024L;
+    private static final long MIN_UPLOAD_PART_BYTES = 1024 * 1024L;
+
+    private final String bucketName;
+
+    private final COSClient cosClient;
+
+    private final TransferManager cosTransferManager;
+
+    public CosStorageOperator(CosStorageProperties cosStorageProperties) {
+        super(cosStorageProperties.getResourceUploadPath());
+        String secretId = cosStorageProperties.getAccessKeyId();
+        String secretKey = cosStorageProperties.getAccessKeySecret();
+        COSCredentials cosCredentials = new BasicCOSCredentials(secretId, secretKey);
+        String regionName = cosStorageProperties.getRegion();
+        ClientConfig clientConfig = new ClientConfig(new Region(regionName));
+        clientConfig.setHttpProtocol(HttpProtocol.https);
+        this.cosClient = new COSClient(cosCredentials, clientConfig);
+        this.bucketName = cosStorageProperties.getBucketName();
+        ensureBucketSuccessfullyCreated(bucketName);
+        this.cosTransferManager = getCosTransferManager();
+    }
+
+    @Override
+    public void close() throws IOException {
+        this.cosTransferManager.shutdownNow(true);
+    }
+
+    @Override
+    public String getStorageBaseDirectory() {
+        // All directory should end with File.separator
+        if (resourceBaseAbsolutePath.startsWith("/")) {
+            log.warn("{} -> {} should not start with / in cos", Constants.RESOURCE_UPLOAD_PATH,
+                    resourceBaseAbsolutePath);
+            return resourceBaseAbsolutePath.substring(1);
+        }
+        return resourceBaseAbsolutePath;
+    }
+
+    @SneakyThrows
+    @Override
+    public void createStorageDir(String directoryAbsolutePath) {
+        String cosKey = transformAbsolutePathToCOSKey(directoryAbsolutePath);
+        if (cosClient.doesObjectExist(bucketName, cosKey)) {
+            throw new FileAlreadyExistsException("directory: " + cosKey + " already exists");
+        }
+        ObjectMetadata metadata = new ObjectMetadata();
+        metadata.setContentLength(0L);
+        InputStream emptyContent = new ByteArrayInputStream(new byte[0]);
+        PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, cosKey, emptyContent, metadata);
+        cosClient.putObject(putObjectRequest);
+    }
+
+    @SneakyThrows
+    @Override
+    public void download(String srcFilePath, String dstFilePath, boolean overwrite) {
+        String cosKey = transformAbsolutePathToCOSKey(srcFilePath);
+        Path dsTempFolder = Paths.get(FileUtils.DATA_BASEDIR).normalize().toAbsolutePath();
+        Path fileDownloadPathNormalized = dsTempFolder.resolve(dstFilePath).normalize().toAbsolutePath();
+        if (!fileDownloadPathNormalized.startsWith(dsTempFolder)) {
+            // if the destination file path is NOT in DS temp folder (e.g., '/tmp/dolphinscheduler'),
+            // an IllegalArgumentException should be thrown.
+            throw new IllegalArgumentException("failed to download to " + fileDownloadPathNormalized);
+        }
+        File dstFile = fileDownloadPathNormalized.toFile();
+        if (dstFile.isDirectory()) {
+            Files.delete(dstFile.toPath());
+        } else {
+            FileUtils.createDirectoryWith755(dstFile.getParentFile().toPath());
+        }
+
+        GetObjectRequest getObjectRequest = new GetObjectRequest(bucketName, cosKey);
+        Download download = cosTransferManager.download(getObjectRequest, dstFile);
+        download.waitForCompletion();
+    }
+
+    @Override
+    public boolean exists(String fileName) {
+        String cosKey = transformAbsolutePathToCOSKey(fileName);
+        return cosClient.doesObjectExist(bucketName, cosKey);
+    }
+
+    @Override
+    public void delete(String filePath, boolean recursive) {
+        String cosKey = transformAbsolutePathToCOSKey(filePath);
+        cosClient.deleteObject(bucketName, cosKey);
+    }
+
+    @SneakyThrows
+    @Override
+    public void copy(String srcPath, String dstPath, boolean deleteSource, boolean overwrite) {
+        String srcCosKey = transformAbsolutePathToCOSKey(srcPath);
+        String destCosKey = transformAbsolutePathToCOSKey(dstPath);
+        CopyObjectRequest copyObjectRequest = new CopyObjectRequest(bucketName, srcCosKey, bucketName, destCosKey);
+        Copy copy = cosTransferManager.copy(copyObjectRequest, cosClient, null);
+
+        CopyResult copyResult = copy.waitForCopyResult();
+        if (copyResult != null && deleteSource) {
+            cosClient.deleteObject(bucketName, srcPath);
+        }
+    }
+
+    @SneakyThrows
+    @Override
+    public void upload(String srcFile, String dstPath, boolean deleteSource, boolean overwrite) {
+        dstPath = transformAbsolutePathToCOSKey(dstPath);
+
+        if (cosClient.doesObjectExist(bucketName, dstPath)) {
+            if (!overwrite) {
+                throw new CosServiceException("file: " + dstPath + " already exists");
+            } else {
+                cosClient.deleteObject(bucketName, dstPath);
+            }
+        }
+
+        PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, dstPath, new File(srcFile));
+        Upload upload = cosTransferManager.upload(putObjectRequest);
+        UploadResult uploadResult = upload.waitForUploadResult();
+        if (uploadResult != null && deleteSource) {
+            Files.delete(Paths.get(srcFile));
+        }
+    }
+
+    @SneakyThrows
+    @Override
+    public List<String> fetchFileContent(String filePath, int skipLineNums, int limit) {
+        String cosKey = transformAbsolutePathToCOSKey(filePath);
+
+        COSObject cosObject = cosClient.getObject(bucketName, cosKey);
+        try (
+                InputStreamReader inputStreamReader = new InputStreamReader(cosObject.getObjectContent());
+                BufferedReader bufferedReader = new BufferedReader(inputStreamReader)) {
+            return bufferedReader
+                    .lines()
+                    .skip(skipLineNums)
+                    .limit(limit)
+                    .collect(Collectors.toList());
+        }
+    }
+
+    @Override
+    public List<StorageEntity> listStorageEntity(String resourceAbsolutePath) {
+        resourceAbsolutePath = transformCOSKeyToAbsolutePath(resourceAbsolutePath);
+
+        ListObjectsRequest request = new ListObjectsRequest();
+        request.setBucketName(bucketName);
+        request.setPrefix(resourceAbsolutePath);
+        request.setDelimiter("/");
+
+        ObjectListing result = cosClient.listObjects(request);
+
+        return result.getObjectSummaries()
+                .stream()
+                .map((COSObjectSummary summary) -> {
+                    ObjectMetadata metadata = new ObjectMetadata();
+                    metadata.setContentLength(summary.getSize());
+                    metadata.setLastModified(summary.getLastModified());
+                    COSObject object = new COSObject();
+                    object.setObjectMetadata(metadata);
+                    object.setKey(summary.getKey());
+                    return transformCOSObjectToStorageEntity(object);
+                })
+                .collect(Collectors.toList());
+    }
+
+    @Override
+    public List<StorageEntity> listFileStorageEntityRecursively(String resourceAbsolutePath) {
+        resourceAbsolutePath = transformCOSKeyToAbsolutePath(resourceAbsolutePath);
+
+        Set<String> visited = new HashSet<>();
+        List<StorageEntity> storageEntityList = new ArrayList<>();
+        LinkedList<String> foldersToFetch = new LinkedList<>();
+        foldersToFetch.addLast(resourceAbsolutePath);
+
+        while (!foldersToFetch.isEmpty()) {
+            String pathToExplore = foldersToFetch.pop();
+            visited.add(pathToExplore);
+            List<StorageEntity> storageEntities = listStorageEntity(pathToExplore);
+            for (StorageEntity entity : storageEntities) {
+                if (entity.isDirectory()) {
+                    if (visited.contains(entity.getFullName())) {
+                        continue;
+                    }
+                    foldersToFetch.add(entity.getFullName());
+                }
+            }
+            storageEntityList.addAll(storageEntities);
+        }
+
+        return storageEntityList;
+    }
+
+    @Override
+    public StorageEntity getStorageEntity(String resourceAbsolutePath) {
+        String cosKey = transformCOSKeyToAbsolutePath(resourceAbsolutePath);
+
+        COSObject object = cosClient.getObject(bucketName, cosKey);
+        return transformCOSObjectToStorageEntity(object);
+    }
+
+    public void ensureBucketSuccessfullyCreated(String bucketName) {
+        if (StringUtils.isBlank(bucketName)) {
+            throw new IllegalArgumentException("resource.tencent.cloud.cos.bucket.name is empty");
+        }
+
+        if (!cosClient.doesBucketExist(bucketName)) {
+            throw new IllegalArgumentException(
+                    "bucketName: " + bucketName + " is not exists, you need to create them by yourself");
+        }
+
+        log.info("bucketName: {} has been found", bucketName);
+    }
+
+    protected StorageEntity transformCOSObjectToStorageEntity(COSObject object) {
+        ObjectMetadata metadata = object.getObjectMetadata();
+        String fileAbsolutePath = transformCOSKeyToAbsolutePath(object.getKey());
+        ResourceMetadata resourceMetaData = getResourceMetaData(fileAbsolutePath);
+        String fileExtension = com.google.common.io.Files.getFileExtension(resourceMetaData.getResourceAbsolutePath());
+
+        return StorageEntity.builder()
+                .fileName(new File(fileAbsolutePath).getName())
+                .fullName(fileAbsolutePath)
+                .pfullName(resourceMetaData.getResourceParentAbsolutePath())
+                .type(resourceMetaData.getResourceType())
+                .isDirectory(StringUtils.isEmpty(fileExtension))
+                .size(metadata.getContentLength())
+                .createTime(metadata.getLastModified())
+                .updateTime(metadata.getLastModified())
+                .build();
+    }
+
+    private String transformAbsolutePathToCOSKey(String absolutePath) {
+        ResourceMetadata resourceMetaData = getResourceMetaData(absolutePath);
+        if (resourceMetaData.isDirectory()) {
+            return FileUtils.concatFilePath(absolutePath, "/");
+        }
+        return absolutePath;
+    }
+
+    private String transformCOSKeyToAbsolutePath(String s3Key) {

Review Comment:
   The following is the same.



##########
dolphinscheduler-storage-plugin/dolphinscheduler-storage-cos/src/main/java/org/apache/dolphinscheduler/plugin/storage/cos/CosStorageOperator.java:
##########
@@ -0,0 +1,332 @@
+/*
+ * 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.plugin.storage.cos;
+
+import org.apache.dolphinscheduler.common.constants.Constants;
+import org.apache.dolphinscheduler.common.utils.FileUtils;
+import org.apache.dolphinscheduler.plugin.storage.api.AbstractStorageOperator;
+import org.apache.dolphinscheduler.plugin.storage.api.ResourceMetadata;
+import org.apache.dolphinscheduler.plugin.storage.api.StorageEntity;
+import org.apache.dolphinscheduler.plugin.storage.api.StorageOperator;
+
+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.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.nio.file.FileAlreadyExistsException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.stream.Collectors;
+
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+
+import com.qcloud.cos.COSClient;
+import com.qcloud.cos.ClientConfig;
+import com.qcloud.cos.auth.BasicCOSCredentials;
+import com.qcloud.cos.auth.COSCredentials;
+import com.qcloud.cos.exception.CosServiceException;
+import com.qcloud.cos.http.HttpProtocol;
+import com.qcloud.cos.model.COSObject;
+import com.qcloud.cos.model.COSObjectSummary;
+import com.qcloud.cos.model.CopyObjectRequest;
+import com.qcloud.cos.model.CopyResult;
+import com.qcloud.cos.model.GetObjectRequest;
+import com.qcloud.cos.model.ListObjectsRequest;
+import com.qcloud.cos.model.ObjectListing;
+import com.qcloud.cos.model.ObjectMetadata;
+import com.qcloud.cos.model.PutObjectRequest;
+import com.qcloud.cos.model.UploadResult;
+import com.qcloud.cos.region.Region;
+import com.qcloud.cos.transfer.Copy;
+import com.qcloud.cos.transfer.Download;
+import com.qcloud.cos.transfer.TransferManager;
+import com.qcloud.cos.transfer.TransferManagerConfiguration;
+import com.qcloud.cos.transfer.Upload;
+
+@Slf4j
+public class CosStorageOperator extends AbstractStorageOperator implements Closeable, StorageOperator {
+
+    private static final int TRANSFER_THREAD_POOL_SIZE = 16;
+
+    private static final long MULTIPART_UPLOAD_BYTES_THRESHOLD = 5 * 1024 * 1024L;
+    private static final long MIN_UPLOAD_PART_BYTES = 1024 * 1024L;
+
+    private final String bucketName;
+
+    private final COSClient cosClient;
+
+    private final TransferManager cosTransferManager;
+
+    public CosStorageOperator(CosStorageProperties cosStorageProperties) {
+        super(cosStorageProperties.getResourceUploadPath());
+        String secretId = cosStorageProperties.getAccessKeyId();
+        String secretKey = cosStorageProperties.getAccessKeySecret();
+        COSCredentials cosCredentials = new BasicCOSCredentials(secretId, secretKey);
+        String regionName = cosStorageProperties.getRegion();
+        ClientConfig clientConfig = new ClientConfig(new Region(regionName));
+        clientConfig.setHttpProtocol(HttpProtocol.https);
+        this.cosClient = new COSClient(cosCredentials, clientConfig);
+        this.bucketName = cosStorageProperties.getBucketName();
+        ensureBucketSuccessfullyCreated(bucketName);
+        this.cosTransferManager = getCosTransferManager();
+    }
+
+    @Override
+    public void close() throws IOException {
+        this.cosTransferManager.shutdownNow(true);
+    }
+
+    @Override
+    public String getStorageBaseDirectory() {
+        // All directory should end with File.separator
+        if (resourceBaseAbsolutePath.startsWith("/")) {

Review Comment:
   > use ` File.separator` to instead of ` /`
   
   +1, We have no plans to support windows for now.



-- 
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


Re: [PR] [Feature-16396][storage-plugin] Tencent Cloud COS Storage Plugin [dolphinscheduler]

Posted by "Mighten (via GitHub)" <gi...@apache.org>.
Mighten commented on code in PR #16565:
URL: https://github.com/apache/dolphinscheduler/pull/16565#discussion_r1740898939


##########
dolphinscheduler-storage-plugin/dolphinscheduler-storage-cos/src/test/resources/logback.xml:
##########
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>

Review Comment:
   This line also appears in `dolphinscheduler-storage-plugin/dolphinscheduler-storage-{abs, gcs, hdfs, obs, oss, s3}/src/test/resources/logback.xml`.
   
   So I just simply obey this rule.



-- 
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