morningman commented on code in PR #44947:
URL: https://github.com/apache/doris/pull/44947#discussion_r1875581404


##########
regression-test/plugins/aliyunOssSdk.groovy:
##########
@@ -0,0 +1,169 @@
+
+
+// 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.
+import org.apache.doris.regression.suite.Suite;
+import org.apache.doris.regression.Config;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import com.aliyun.oss.ClientException;
+import com.aliyun.oss.OSS;
+import com.aliyun.oss.OSSClientBuilder;
+import com.aliyun.oss.OSSException;
+import com.aliyun.oss.model.DeleteObjectsRequest;
+import com.aliyun.oss.model.DeleteObjectsResult;
+import com.aliyun.oss.model.ListObjectsRequest;
+import com.aliyun.oss.model.OSSObjectSummary;
+import com.aliyun.oss.model.ObjectListing;
+
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
+import groovy.util.logging.Slf4j
+
+Suite.metaClass.initOssClient = { String accessKeyId, String accessKeySecret, 
String endpoint ->
+    return new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret)
+}
+
+Suite.metaClass.listOssObjectWithPrefix = { OSS client, String bucketName, 
String prefix="" ->
+    try {
+        ObjectListing objectListing = null;
+        String nextMarker = null;
+        final int maxKeys = 500;
+        List<OSSObjectSummary> sums = null;
+        
+        if (!client.doesBucketExist(bucketName)) {
+            logger.info("no bucket named ${bucketName} in ${endpoint}")
+            return
+        }
+
+        // Gets all object with specified marker by paging. Each page will 
have up to 100 entries.
+        logger.info("List all objects with prefix:");
+        nextMarker = null;
+        do {
+            objectListing = client.listObjects(new 
ListObjectsRequest(bucketName).
+                    
withPrefix(prefix).withMarker(nextMarker).withMaxKeys(maxKeys));
+            
+            sums = objectListing.getObjectSummaries();
+            for (OSSObjectSummary s : sums) {
+                logger.info("\t" + s.getKey());
+            }
+            
+            nextMarker = objectListing.getNextMarker();
+            
+        } while (objectListing.isTruncated());
+    } catch (OSSException oe) {
+        logger.error("Caught an OSSException, which means your request made it 
to OSS, "
+                + "but was rejected with an error response for some reason.");
+        logger.error("Error Message: " + oe.getErrorMessage());
+        logger.error("Error Code:       " + oe.getErrorCode());
+        logger.error("Request ID:      " + oe.getRequestId());
+        logger.error("Host ID:           " + oe.getHostId());
+    } catch (ClientException ce) {
+        logger.error("Caught an ClientException, which means the client 
encountered "
+                + "a serious internal problem while trying to communicate with 
OSS, "
+                + "such as not being able to access the network.");
+        logger.error("Error Message: " + ce.getMessage());
+    } finally {
+        /*
+            * Do not forget to shut down the client finally to release all 
allocated resources.
+            */
+        //client.shutdown();
+        logger.info("Done!")
+    }
+
+}
+
+// 获取某个存储空间下指定目录(文件夹)下的文件大小。

Review Comment:
   English



-- 
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-unsubscr...@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to