YARN-1215. Merging change r1528233 from trunk to branch-2.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1528234 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d8ade0804d
commit
f5951d2695
|
@ -39,6 +39,8 @@ Release 2.3.0 - UNRELEASED
|
||||||
YARN-1188. The context of QueueMetrics becomes default when using
|
YARN-1188. The context of QueueMetrics becomes default when using
|
||||||
FairScheduler (Tsuyoshi Ozawa via Sandy Ryza)
|
FairScheduler (Tsuyoshi Ozawa via Sandy Ryza)
|
||||||
|
|
||||||
|
YARN-1215. Yarn URL should include userinfo. (Chuan Liu via cnauroth)
|
||||||
|
|
||||||
Release 2.2.0 - UNRELEASED
|
Release 2.2.0 - UNRELEASED
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -56,6 +56,22 @@ public abstract class URL {
|
||||||
@Stable
|
@Stable
|
||||||
public abstract void setScheme(String scheme);
|
public abstract void setScheme(String scheme);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the user info of the URL.
|
||||||
|
* @return user info of the URL
|
||||||
|
*/
|
||||||
|
@Public
|
||||||
|
@Stable
|
||||||
|
public abstract String getUserInfo();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the user info of the URL.
|
||||||
|
* @param userInfo user info of the URL
|
||||||
|
*/
|
||||||
|
@Public
|
||||||
|
@Stable
|
||||||
|
public abstract void setUserInfo(String userInfo);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the host of the URL.
|
* Get the host of the URL.
|
||||||
* @return host of the URL
|
* @return host of the URL
|
||||||
|
|
|
@ -100,6 +100,7 @@ message URLProto {
|
||||||
optional string host = 2;
|
optional string host = 2;
|
||||||
optional int32 port = 3;
|
optional int32 port = 3;
|
||||||
optional string file = 4;
|
optional string file = 4;
|
||||||
|
optional string userInfo = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum LocalResourceVisibilityProto {
|
enum LocalResourceVisibilityProto {
|
||||||
|
|
|
@ -113,6 +113,26 @@ public class URLPBImpl extends URL {
|
||||||
}
|
}
|
||||||
builder.setScheme((scheme));
|
builder.setScheme((scheme));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUserInfo() {
|
||||||
|
URLProtoOrBuilder p = viaProto ? proto : builder;
|
||||||
|
if (!p.hasUserInfo()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return (p.getUserInfo());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setUserInfo(String userInfo) {
|
||||||
|
maybeInitBuilder();
|
||||||
|
if (userInfo == null) {
|
||||||
|
builder.clearUserInfo();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
builder.setUserInfo((userInfo));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getHost() {
|
public String getHost() {
|
||||||
URLProtoOrBuilder p = viaProto ? proto : builder;
|
URLProtoOrBuilder p = viaProto ? proto : builder;
|
||||||
|
|
|
@ -69,6 +69,9 @@ public class ConverterUtils {
|
||||||
String authority = "";
|
String authority = "";
|
||||||
if (url.getHost() != null) {
|
if (url.getHost() != null) {
|
||||||
authority = url.getHost();
|
authority = url.getHost();
|
||||||
|
if (url.getUserInfo() != null) {
|
||||||
|
authority = url.getUserInfo() + "@" + authority;
|
||||||
|
}
|
||||||
if (url.getPort() > 0) {
|
if (url.getPort() > 0) {
|
||||||
authority += ":" + url.getPort();
|
authority += ":" + url.getPort();
|
||||||
}
|
}
|
||||||
|
@ -102,6 +105,9 @@ public class ConverterUtils {
|
||||||
if (uri.getHost() != null) {
|
if (uri.getHost() != null) {
|
||||||
url.setHost(uri.getHost());
|
url.setHost(uri.getHost());
|
||||||
}
|
}
|
||||||
|
if (uri.getUserInfo() != null) {
|
||||||
|
url.setUserInfo(uri.getUserInfo());
|
||||||
|
}
|
||||||
url.setPort(uri.getPort());
|
url.setPort(uri.getPort());
|
||||||
url.setScheme(uri.getScheme());
|
url.setScheme(uri.getScheme());
|
||||||
url.setFile(uri.getPath());
|
url.setFile(uri.getPath());
|
||||||
|
|
|
@ -38,6 +38,14 @@ public class TestConverterUtils {
|
||||||
assertEquals(expectedPath, actualPath);
|
assertEquals(expectedPath, actualPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testConvertUrlWithUserinfo() throws URISyntaxException {
|
||||||
|
Path expectedPath = new Path("foo://username:password@example.com:8042");
|
||||||
|
URL url = ConverterUtils.getYarnUrlFromPath(expectedPath);
|
||||||
|
Path actualPath = ConverterUtils.getPathFromYarnURL(url);
|
||||||
|
assertEquals(expectedPath, actualPath);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testContainerId() throws URISyntaxException {
|
public void testContainerId() throws URISyntaxException {
|
||||||
ContainerId id = TestContainerId.newContainerId(0, 0, 0, 0);
|
ContainerId id = TestContainerId.newContainerId(0, 0, 0, 0);
|
||||||
|
|
Loading…
Reference in New Issue