masteryhx commented on code in PR #6967:
URL: https://github.com/apache/hadoop/pull/6967#discussion_r1735580171


##########
hadoop-tools/hadoop-aliyun/src/main/java/org/apache/hadoop/fs/aliyun/oss/AliyunOSSFileSystemStore.java:
##########
@@ -147,6 +147,13 @@ public void initialize(URI uri, Configuration conf, String 
user,
       throw new IllegalArgumentException(msg);
     }
 
+    boolean redirectEnable = conf.getBoolean(REDIRECT_ENABLE_KEY,
+    REDIRECT_ENABLE_DEFAULT);
+    if (!redirectEnable) {

Review Comment:
   Could we just use  `clientConf.setRedirectEnable(redirectEnable);` ?
   Current implementation always assumes `true` is default for clientConf, 
right ?



##########
hadoop-tools/hadoop-aliyun/src/test/java/org/apache/hadoop/fs/aliyun/oss/TestAliyunOSSRedirect.java:
##########
@@ -0,0 +1,279 @@
+/**
+ * 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.hadoop.fs.aliyun.oss;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.math3.analysis.function.Log;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FSDataInputStream;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.contract.ContractTestUtils;
+import org.apache.hadoop.fs.impl.prefetch.ExceptionAsserts;
+import org.apache.hadoop.io.IOUtils;
+import org.apache.hadoop.util.VersionInfo;
+import org.apache.hadoop.fs.FileStatus;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.internal.AssumptionViolatedException;
+import org.junit.rules.Timeout;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.xbill.DNS.tools.primary;
+
+import com.aliyun.oss.ClientConfiguration;
+import com.aliyun.oss.OSSClient;
+import com.aliyun.oss.OSSException;
+import com.aliyun.oss.common.auth.CredentialsProvider;
+import com.aliyun.oss.common.comm.Protocol;
+import com.aliyun.oss.model.BucketWebsiteResult;
+import com.aliyun.oss.model.CannedAccessControlList;
+import com.aliyun.oss.model.RoutingRule;
+import com.aliyun.oss.model.SetBucketWebsiteRequest;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Random;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertThrows;
+import static org.junit.Assert.assertTrue;
+import static org.apache.hadoop.fs.aliyun.oss.Constants.*;
+import static org.hamcrest.CoreMatchers.nullValue;
+
+import com.aliyun.oss.ClientException;
+
+/**
+ * Tests basic functionality for AliyunOSSInputStream, including seeking and
+ * reading files.
+ */
+public class TestAliyunOSSRedirect {
+
+  private FileSystem fs;
+
+  private OSSClient ossClient;
+
+  private String bucketName;
+
+  private URI testURI;
+
+  private static final Logger LOG = 
LoggerFactory.getLogger(TestAliyunOSSInputStream.class);
+
+  private static String testRootPath = 
AliyunOSSTestUtils.generateUniqueTestPath();
+
+  @Rule
+  public Timeout testTimeout = new Timeout(30 * 60 * 1000);
+
+  @Before
+  public void setUp() throws Exception {
+    Configuration conf = new Configuration();
+    constructOssClient(conf);
+    cleanRedirectRule(ossClient);
+    setRedirectRule(ossClient);
+  }
+
+  @After
+  public void tearDown() throws Exception {
+    if (fs != null) {
+      fs.delete(new Path(testRootPath), true);
+    }
+
+    cleanRedirectRule(ossClient);
+    if (ossClient != null) {
+      ossClient.shutdown();
+    }
+
+  }
+
+  private Path setPath(String path) {
+    if (path.startsWith("/")) {
+      return new Path(testRootPath + path);
+    } else {
+      return new Path(testRootPath + "/" + path);
+    }
+  }
+
+  private void constructOssClient(Configuration conf) throws IOException {

Review Comment:
   Could we avoid repeating these codes?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to