Uploaded image for project: 'Hadoop HDFS'
  1. Hadoop HDFS
  2. HDFS-14864

DatanodeDescriptor Use Concurrent BlockingQueue

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Patch Available
    • Minor
    • Resolution: Unresolved
    • 3.2.0
    • None
    • namenode
    • None
    • Patch

    Description

      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:

      This operation may be more efficient than repeatedly polling this queue.

      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.

      Attachments

        1. HDFS-14864.1.patch
          9 kB
          David Mollitor
        2. HDFS-14864.2.patch
          9 kB
          David Mollitor
        3. HDFS-14864.3.patch
          9 kB
          David Mollitor
        4. HDFS-14864.4.patch
          9 kB
          David Mollitor

        Activity

          People

            belugabehr David Mollitor
            belugabehr David Mollitor
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: