-
Couldn't load subscription status.
- Fork 9.1k
MAPREDUCE-7429 Application log link is not accessible via TimelineServer WebUI in IPV6 scenario #5236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
MAPREDUCE-7429 Application log link is not accessible via TimelineServer WebUI in IPV6 scenario #5236
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,6 +46,7 @@ | |
|
|
||
| import javax.net.SocketFactory; | ||
|
|
||
| import org.apache.commons.lang3.StringUtils; | ||
| import org.apache.hadoop.security.AccessControlException; | ||
| import org.apache.hadoop.thirdparty.com.google.common.cache.Cache; | ||
| import org.apache.hadoop.thirdparty.com.google.common.cache.CacheBuilder; | ||
|
|
@@ -229,6 +230,23 @@ public static InetSocketAddress createSocketAddr(String target, | |
| } | ||
| target = target.trim(); | ||
| boolean hasScheme = target.contains("://"); | ||
| if (NetUtils.isIPV6Address(target)) { | ||
| // if scheme exists in the target, for example: | ||
| // https://ffff:ffff:ffff:ffff::1:8088 will be formed like | ||
| // https://[ffff:ffff:ffff:ffff::1]:8088 | ||
| if (hasScheme) { | ||
| int i = target.lastIndexOf("/"); | ||
| String scheme = target.substring(0, i + 1); | ||
| String ipAddrWithPort = target.substring(i + 1); | ||
| target = scheme + normalizeV6Address(ipAddrWithPort); | ||
| } else { | ||
| // if scheme does not exists in the target | ||
| // for example : ffff:ffff:ffff:ffff::1:8088 will be formed like | ||
| // [ffff:ffff:ffff:ffff::1]:8088 | ||
| target = normalizeV6Address(target); | ||
| } | ||
| } | ||
|
|
||
| URI uri = createURI(target, hasScheme, helpText, useCacheIfPresent); | ||
|
|
||
| String host = uri.getHost(); | ||
|
|
@@ -247,6 +265,28 @@ public static InetSocketAddress createSocketAddr(String target, | |
| return createSocketAddrForHost(host, port); | ||
| } | ||
|
|
||
| public static String normalizeV6Address(final String target) { | ||
| String normalizedAddr = target; | ||
| if (!target.startsWith("[")) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm pretty sure regex would help here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No? |
||
| if (target.contains("%")) { | ||
| int i = target.lastIndexOf('%'); | ||
| String port = target.trim().substring(target.lastIndexOf(":") + 1); | ||
| String addr = target.trim().substring(0, i); | ||
| normalizedAddr = "[" + addr + "]" + ":" + port; | ||
| } else { | ||
| int i = target.lastIndexOf(':'); | ||
| String port = target.substring(target.lastIndexOf(":") + 1); | ||
| String addr = target.substring(0, i); | ||
| normalizedAddr = "[" + addr + "]" + ":" + port; | ||
| } | ||
| } | ||
| return normalizedAddr; | ||
| } | ||
|
|
||
| public static boolean isIPV6Address(String addr) { | ||
| return StringUtils.countMatches(addr, ":") > 2; | ||
| } | ||
|
|
||
| private static final long URI_CACHE_SIZE_DEFAULT = 1000; | ||
| private static final long URI_CACHE_EXPIRE_TIME_DEFAULT = 12; | ||
| private static final Cache<String, URI> URI_CACHE = CacheBuilder.newBuilder() | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NetUtils.isIPV6Address(target) is slow