Ver Fonte

HADOOP-15024. AliyunOSS: Support user agent configuration and include that & Hadoop version information to oss server.

(cherry picked from commit abaabb5deccc770bb38c933174a4e91c081a45c7)
Sammi Chen há 7 anos atrás
pai
commit
6e24fe2998

+ 4 - 0
hadoop-tools/hadoop-aliyun/src/main/java/org/apache/hadoop/fs/aliyun/oss/AliyunOSSFileSystemStore.java

@@ -53,6 +53,7 @@ import org.apache.hadoop.fs.LocatedFileStatus;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.PathFilter;
 import org.apache.hadoop.fs.PathFilter;
 import org.apache.hadoop.fs.RemoteIterator;
 import org.apache.hadoop.fs.RemoteIterator;
+import org.apache.hadoop.util.VersionInfo;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
 
 
@@ -101,6 +102,9 @@ public class AliyunOSSFileSystemStore {
         ESTABLISH_TIMEOUT_DEFAULT));
         ESTABLISH_TIMEOUT_DEFAULT));
     clientConf.setSocketTimeout(conf.getInt(SOCKET_TIMEOUT_KEY,
     clientConf.setSocketTimeout(conf.getInt(SOCKET_TIMEOUT_KEY,
         SOCKET_TIMEOUT_DEFAULT));
         SOCKET_TIMEOUT_DEFAULT));
+    clientConf.setUserAgent(
+        conf.get(USER_AGENT_PREFIX, USER_AGENT_PREFIX_DEFAULT) + ", Hadoop/"
+            + VersionInfo.getVersion());
 
 
     String proxyHost = conf.getTrimmed(PROXY_HOST_KEY, "");
     String proxyHost = conf.getTrimmed(PROXY_HOST_KEY, "");
     int proxyPort = conf.getInt(PROXY_PORT_KEY, -1);
     int proxyPort = conf.getInt(PROXY_PORT_KEY, -1);

+ 7 - 0
hadoop-tools/hadoop-aliyun/src/main/java/org/apache/hadoop/fs/aliyun/oss/Constants.java

@@ -18,6 +18,8 @@
 
 
 package org.apache.hadoop.fs.aliyun.oss;
 package org.apache.hadoop.fs.aliyun.oss;
 
 
+import com.aliyun.oss.common.utils.VersionInfoUtils;
+
 /**
 /**
  * ALL configuration constants for OSS filesystem.
  * ALL configuration constants for OSS filesystem.
  */
  */
@@ -26,6 +28,11 @@ public final class Constants {
   private Constants() {
   private Constants() {
   }
   }
 
 
+  // User agent
+  public static final String USER_AGENT_PREFIX = "fs.oss.user.agent.prefix";
+  public static final String USER_AGENT_PREFIX_DEFAULT =
+          VersionInfoUtils.getDefaultUserAgent();
+
   // Class of credential provider
   // Class of credential provider
   public static final String ALIYUN_OSS_CREDENTIALS_PROVIDER_KEY =
   public static final String ALIYUN_OSS_CREDENTIALS_PROVIDER_KEY =
       "fs.oss.credentials.provider";
       "fs.oss.credentials.provider";

+ 1 - 1
hadoop-tools/hadoop-aliyun/src/site/markdown/tools/hadoop-aliyun/index.md

@@ -274,7 +274,7 @@ XInclude inclusion. Here is an example of `contract-test-options.xml`:
 
 
       <property>
       <property>
         <name>fs.oss.impl</name>
         <name>fs.oss.impl</name>
-        <value>org.apache.hadoop.fs.aliyun.AliyunOSSFileSystem</value>
+        <value>org.apache.hadoop.fs.aliyun.oss.AliyunOSSFileSystem</value>
       </property>
       </property>
 
 
       <property>
       <property>