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

BELUGA BEHR commented on HADOOP-15830:
--------------------------------------

[~elgoiri] Thanks for the look!

Ya, I think the assumption is that if an items in the queue are timestamped as 
they are placed into the queue, so in essence, it is sorted.  However, I'm not 
always sure that is the case.  

{code}
// Item goes on the front of the list
call.connection.responseQueue.addFirst(call);
            
if (inHandler) {
  // timestamp is reset
  call.timestamp = Time.now();
...
{code}

So in this case, it is actually possible that the item at the front of the list 
has the newest timestamp in the queue.  I'm not sure in practice if this 
happens or if the purge can happen when this is the case, but it would cause 
the purge loop to bump out immediately and leave expired calls in the queue.  
Regardless, without a priority queue implementation, it seems best to not 
assume order.

> Server.java Prefer ArrayList
> ----------------------------
>
>                 Key: HADOOP-15830
>                 URL: https://issues.apache.org/jira/browse/HADOOP-15830
>             Project: Hadoop Common
>          Issue Type: Improvement
>          Components: ipc
>    Affects Versions: 3.2.0
>            Reporter: BELUGA BEHR
>            Assignee: BELUGA BEHR
>            Priority: Minor
>         Attachments: HDFS-13969.1.patch
>
>
> *  Prefer ArrayDeque over LinkedList (faster, less memory overhead)
> * Address this code:
> {code}
>     //
>     // Remove calls that have been pending in the responseQueue 
>     // for a long time.
>     //
>     private void doPurge(RpcCall call, long now) {
>       LinkedList<RpcCall> responseQueue = call.connection.responseQueue;
>       synchronized (responseQueue) {
>         Iterator<RpcCall> iter = responseQueue.listIterator(0);
>         while (iter.hasNext()) {
>           call = iter.next();
>           if (now > call.timestamp + PURGE_INTERVAL) {
>             closeConnection(call.connection);
>             break;
>           }
>         }
>       }
>     }
> {code}
> It says "Remove calls" (plural) but only one call will be removed because of 
> the 'break' statement.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
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