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

(cherry picked from commit abaabb5dec)
This commit is contained in:
Sammi Chen 2017-12-08 21:43:05 +08:00
parent 1e0f7a1631
commit 6e24fe2998
3 changed files with 12 additions and 1 deletions

View File

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

View File

@ -18,6 +18,8 @@
package org.apache.hadoop.fs.aliyun.oss;
import com.aliyun.oss.common.utils.VersionInfoUtils;
/**
* ALL configuration constants for OSS filesystem.
*/
@ -26,6 +28,11 @@ public final class 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
public static final String ALIYUN_OSS_CREDENTIALS_PROVIDER_KEY =
"fs.oss.credentials.provider";

View File

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