HADOOP-15024 Support user agent configuration and include that & Hadoop version information to oss server.
Contributed by Sammi Chen.
This commit is contained in:
parent
9fb4effd2c
commit
c326fc89b0
@ -53,6 +53,7 @@
|
||||
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 void initialize(URI uri, Configuration conf,
|
||||
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);
|
||||
|
@ -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";
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user