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

Kihwal Lee commented on HADOOP-13742:
-------------------------------------

At a first glance, the following seems racy. Since 
{{processConnectionContext()}} is done by the reader threads, unless you 
configure with only one reader thread, one can step over another one adding a 
new count for the same user. Also the decrement method could remove the hash 
map entry after this method verified it not being null. The update will be lost 
in this case too.
{code}
    void incrUserConnections(String user) {
      AtomicInteger count = userVsConnectionsMap.get(user);
      if (count == null) {
        count = new AtomicInteger(1);
        userVsConnectionsMap.put(user, count);
      } else {
        count.getAndIncrement();
      }
    }
{code}

Slapping a big synchronization will make it safe, but then that's not desirable 
for the performance. Probably there can be a fine-grained way.

> Expose "NumOpenConnectionsPerUser" as a metric
> ----------------------------------------------
>
>                 Key: HADOOP-13742
>                 URL: https://issues.apache.org/jira/browse/HADOOP-13742
>             Project: Hadoop Common
>          Issue Type: Improvement
>            Reporter: Brahma Reddy Battula
>            Assignee: Brahma Reddy Battula
>         Attachments: HADOOP-13742-002.patch, HADOOP-13742.patch
>
>
> To track user level connections( How many connections for each user) in busy 
> cluster where so many connections to server.



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

---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-issues-h...@hadoop.apache.org

Reply via email to