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

Simplify dataQueue.wait condition logical operation in DataStreamer::run()

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.0.0-beta1
    • Fix Version/s: 3.0.0-beta1
    • Component/s: hdfs-client
    • Labels:
      None
    • Environment:

      cluster: 3 nodes
      os:(Red Hat 2.6.33.20, Red Hat 3.10.0-514.6.1.el7.x86_64, Ubuntu4.4.0-31-generic)
      hadoop version: hadoop-3.0.0-beta1
      operation: Code review

    • Hadoop Flags:
      Reviewed

      Description

      When i read the run() of DataStream class in hdfs-client, i found the following condition code could be more simplify and easy to understand.

      DataStreamer.java
      // wait for a packet to be sent.
      long now = Time.monotonicNow();
      while ((!shouldStop() && dataQueue.size() == 0 &&
           (stage != BlockConstructionStage.DATA_STREAMING ||
            stage == BlockConstructionStage.DATA_STREAMING &&
                  now - lastPacket < halfSocketTimeout)) || doSleep ) {
      

      as described above code segmet, i find the code of stage !=DATA_STREAMING and stage==DATA_STREAMING appear at the same time in one condition, so i think this condition logical not good understanding and should simplify more.

        Attachments

        1. HDFS-12380.002.patch
          1 kB
          liaoyuxiangqin
        2. HDFS-12380.001.patch
          1 kB
          liaoyuxiangqin

          Activity

            People

            • Assignee:
              liaoyuxiangqin liaoyuxiangqin
              Reporter:
              liaoyuxiangqin liaoyuxiangqin
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 12h
                12h
                Remaining:
                Remaining Estimate - 12h
                12h
                Logged:
                Time Spent - Not Specified
                Not Specified