hadoop-common-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Haohui Mai (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HADOOP-11387) Simplify NetUtils#canonicalizeHost()
Date Wed, 17 Dec 2014 01:19:13 GMT

    [ https://issues.apache.org/jira/browse/HADOOP-11387?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14249261#comment-14249261
] 

Haohui Mai commented on HADOOP-11387:
-------------------------------------

bq. Can you post the findbugs warning. 

https://builds.apache.org/job/PreCommit-HADOOP-Build/5275//artifact/patchprocess/newPatchFindbugsWarningshadoop-common.html

bq.  For small number hosts, this change is overkill.

As mentioned earlier, there are at most one or two entries in the cache. I'm fine with removing
the cache.

> Simplify NetUtils#canonicalizeHost()
> ------------------------------------
>
>                 Key: HADOOP-11387
>                 URL: https://issues.apache.org/jira/browse/HADOOP-11387
>             Project: Hadoop Common
>          Issue Type: Bug
>            Reporter: Haohui Mai
>            Assignee: Li Lu
>         Attachments: HADOOP-11387-121514-1.patch, HADOOP-11387-121514-2.patch, HADOOP-11387-121514.patch
>
>
> Currently {{NetUtils#canonicalizeHost}} uses a {{ConcurrentHashMap}} to cache the canonicalized
hostname.
> {code}
>   private static String canonicalizeHost(String host) {
>     // check if the host has already been canonicalized
>     String fqHost = canonicalizedHostCache.get(host);
>     if (fqHost == null) {
>       try {
>         fqHost = SecurityUtil.getByName(host).getHostName();
>         // slight race condition, but won't hurt
>         canonicalizedHostCache.put(host, fqHost);
>       } catch (UnknownHostException e) {
>         fqHost = host;
>       }
>     }
>     return fqHost;
>   }
> {code}
> The code triggers a findbugs warning. The cache is used for caching NN resolution for
the client-side {{FileSystem}} objects. In most of the use cases there are at most one or
two instances in the cache. This jira proposes to eliminate the findbugs warnings and to simplify
the code using {{CacheMap}}.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message