David Mollitor created HDFS-14864:
-------------------------------------

             Summary: DatanodeDescriptor Use Concurrent BlockingQueue
                 Key: HDFS-14864
                 URL: https://issues.apache.org/jira/browse/HDFS-14864
             Project: Hadoop HDFS
          Issue Type: Improvement
          Components: namenode
    Affects Versions: 3.2.0
            Reporter: David Mollitor
            Assignee: David Mollitor


https://github.com/apache/hadoop/blob/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/DatanodeDescriptor.java#L104-L106

This collection needs to be thread safe and it needs to repeatedly poll the 
queue to drain it, so use {{BlockingQueue}} which has a {{drain()}} method just 
for this purpose:

{quote}
This operation may be more efficient than repeatedly polling this queue.
{quote}
[https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/BlockingQueue.html#drainTo(java.util.Collection,%20int)]

Also, the collection returns 'null' if there is nothing to drain from the 
queue.  This is a confusing and error-prone affect.  It should just return an 
empty list.  I've also updated the code to be more consistent and to return a 
java {{List}} in all places instead of a {{List}} in some and a native array in 
others.  This will make the entire usage much more consistent and safe.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

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

Reply via email to