-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
Closed
Closed
MAPREDUCE-7429 Application log link is not accessible via TimelineServer WebUI in IPV6 scenario #5236
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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("[")) { | ||
|
Member
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.
Member
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() | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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