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.

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

        Activity

        Hide
        hadoopqa Hadoop QA added a comment -
        -1 overall



        Vote Subsystem Runtime Comment
        0 reexec 17m 47s Docker mode activated.
              Prechecks
        +1 @author 0m 0s The patch does not contain any @author tags.
        -1 test4tests 0m 0s The patch doesn't appear to include any new or modified tests. Please justify why no new tests are needed for this patch. Also please list what manual steps were performed to verify this patch.
              trunk Compile Tests
        +1 mvninstall 13m 45s trunk passed
        +1 compile 0m 32s trunk passed
        +1 checkstyle 0m 17s trunk passed
        +1 mvnsite 0m 36s trunk passed
        +1 findbugs 1m 24s trunk passed
        +1 javadoc 0m 22s trunk passed
              Patch Compile Tests
        +1 mvninstall 0m 32s the patch passed
        +1 compile 0m 30s the patch passed
        +1 javac 0m 30s the patch passed
        -0 checkstyle 0m 14s hadoop-hdfs-project/hadoop-hdfs-client: The patch generated 1 new + 74 unchanged - 1 fixed = 75 total (was 75)
        +1 mvnsite 0m 31s the patch passed
        +1 whitespace 0m 0s The patch has no whitespace issues.
        +1 findbugs 1m 29s the patch passed
        +1 javadoc 0m 18s the patch passed
              Other Tests
        +1 unit 1m 13s hadoop-hdfs-client in the patch passed.
        +1 asflicense 0m 13s The patch does not generate ASF License warnings.
        40m 58s



        Subsystem Report/Notes
        Docker Image:yetus/hadoop:71bbb86
        JIRA Issue HDFS-12380
        JIRA Patch URL https://issues.apache.org/jira/secure/attachment/12884616/HDFS-12380.001.patch
        Optional Tests asflicense compile javac javadoc mvninstall mvnsite unit findbugs checkstyle
        uname Linux 28bce86c2020 3.13.0-119-generic #166-Ubuntu SMP Wed May 3 12:18:55 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
        Build tool maven
        Personality /testptch/hadoop/patchprocess/precommit/personality/provided.sh
        git revision trunk / 71bbb86
        Default Java 1.8.0_144
        findbugs v3.1.0-RC1
        checkstyle https://builds.apache.org/job/PreCommit-HDFS-Build/20935/artifact/patchprocess/diff-checkstyle-hadoop-hdfs-project_hadoop-hdfs-client.txt
        Test Results https://builds.apache.org/job/PreCommit-HDFS-Build/20935/testReport/
        modules C: hadoop-hdfs-project/hadoop-hdfs-client U: hadoop-hdfs-project/hadoop-hdfs-client
        Console output https://builds.apache.org/job/PreCommit-HDFS-Build/20935/console
        Powered by Apache Yetus 0.6.0-SNAPSHOT http://yetus.apache.org

        This message was automatically generated.

        Show
        hadoopqa Hadoop QA added a comment - -1 overall Vote Subsystem Runtime Comment 0 reexec 17m 47s Docker mode activated.       Prechecks +1 @author 0m 0s The patch does not contain any @author tags. -1 test4tests 0m 0s The patch doesn't appear to include any new or modified tests. Please justify why no new tests are needed for this patch. Also please list what manual steps were performed to verify this patch.       trunk Compile Tests +1 mvninstall 13m 45s trunk passed +1 compile 0m 32s trunk passed +1 checkstyle 0m 17s trunk passed +1 mvnsite 0m 36s trunk passed +1 findbugs 1m 24s trunk passed +1 javadoc 0m 22s trunk passed       Patch Compile Tests +1 mvninstall 0m 32s the patch passed +1 compile 0m 30s the patch passed +1 javac 0m 30s the patch passed -0 checkstyle 0m 14s hadoop-hdfs-project/hadoop-hdfs-client: The patch generated 1 new + 74 unchanged - 1 fixed = 75 total (was 75) +1 mvnsite 0m 31s the patch passed +1 whitespace 0m 0s The patch has no whitespace issues. +1 findbugs 1m 29s the patch passed +1 javadoc 0m 18s the patch passed       Other Tests +1 unit 1m 13s hadoop-hdfs-client in the patch passed. +1 asflicense 0m 13s The patch does not generate ASF License warnings. 40m 58s Subsystem Report/Notes Docker Image:yetus/hadoop:71bbb86 JIRA Issue HDFS-12380 JIRA Patch URL https://issues.apache.org/jira/secure/attachment/12884616/HDFS-12380.001.patch Optional Tests asflicense compile javac javadoc mvninstall mvnsite unit findbugs checkstyle uname Linux 28bce86c2020 3.13.0-119-generic #166-Ubuntu SMP Wed May 3 12:18:55 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux Build tool maven Personality /testptch/hadoop/patchprocess/precommit/personality/provided.sh git revision trunk / 71bbb86 Default Java 1.8.0_144 findbugs v3.1.0-RC1 checkstyle https://builds.apache.org/job/PreCommit-HDFS-Build/20935/artifact/patchprocess/diff-checkstyle-hadoop-hdfs-project_hadoop-hdfs-client.txt Test Results https://builds.apache.org/job/PreCommit-HDFS-Build/20935/testReport/ modules C: hadoop-hdfs-project/hadoop-hdfs-client U: hadoop-hdfs-project/hadoop-hdfs-client Console output https://builds.apache.org/job/PreCommit-HDFS-Build/20935/console Powered by Apache Yetus 0.6.0-SNAPSHOT http://yetus.apache.org This message was automatically generated.
        Hide
        shahrs87 Rushabh S Shah added a comment -

        Thanks liaoyuxiangqin for the find and the patch.
        The patch makes sense to me.
        +1 non-binding.
        Even though your patch didn't introduce the checkstyle warning, it would be nice if you can fix it.
        Thanks !

        Show
        shahrs87 Rushabh S Shah added a comment - Thanks liaoyuxiangqin for the find and the patch. The patch makes sense to me. +1 non-binding. Even though your patch didn't introduce the checkstyle warning, it would be nice if you can fix it. Thanks !
        Hide
        liaoyuxiangqin liaoyuxiangqin added a comment -

        Thanks Rushabh S Shah for review on this, i have fix the checkstyle warning and attach a new patch,thanks!

        Show
        liaoyuxiangqin liaoyuxiangqin added a comment - Thanks Rushabh S Shah for review on this, i have fix the checkstyle warning and attach a new patch,thanks!
        Hide
        hadoopqa Hadoop QA added a comment -
        -1 overall



        Vote Subsystem Runtime Comment
        0 reexec 0m 14s Docker mode activated.
              Prechecks
        +1 @author 0m 0s The patch does not contain any @author tags.
        -1 test4tests 0m 0s The patch doesn't appear to include any new or modified tests. Please justify why no new tests are needed for this patch. Also please list what manual steps were performed to verify this patch.
              trunk Compile Tests
        +1 mvninstall 14m 6s trunk passed
        +1 compile 0m 33s trunk passed
        +1 checkstyle 0m 18s trunk passed
        +1 mvnsite 0m 35s trunk passed
        +1 findbugs 1m 24s trunk passed
        +1 javadoc 0m 21s trunk passed
              Patch Compile Tests
        +1 mvninstall 0m 32s the patch passed
        +1 compile 0m 30s the patch passed
        +1 javac 0m 30s the patch passed
        +1 checkstyle 0m 14s hadoop-hdfs-project/hadoop-hdfs-client: The patch generated 0 new + 74 unchanged - 1 fixed = 74 total (was 75)
        +1 mvnsite 0m 32s the patch passed
        +1 whitespace 0m 0s The patch has no whitespace issues.
        +1 findbugs 1m 29s the patch passed
        +1 javadoc 0m 19s the patch passed
              Other Tests
        +1 unit 1m 12s hadoop-hdfs-client in the patch passed.
        +1 asflicense 0m 14s The patch does not generate ASF License warnings.
        23m 50s



        Subsystem Report/Notes
        Docker Image:yetus/hadoop:71bbb86
        JIRA Issue HDFS-12380
        JIRA Patch URL https://issues.apache.org/jira/secure/attachment/12884849/HDFS-12380.002.patch
        Optional Tests asflicense compile javac javadoc mvninstall mvnsite unit findbugs checkstyle
        uname Linux 11c45382926f 3.13.0-123-generic #172-Ubuntu SMP Mon Jun 26 18:04:35 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
        Build tool maven
        Personality /testptch/hadoop/patchprocess/precommit/personality/provided.sh
        git revision trunk / 1904100
        Default Java 1.8.0_144
        findbugs v3.1.0-RC1
        Test Results https://builds.apache.org/job/PreCommit-HDFS-Build/20957/testReport/
        modules C: hadoop-hdfs-project/hadoop-hdfs-client U: hadoop-hdfs-project/hadoop-hdfs-client
        Console output https://builds.apache.org/job/PreCommit-HDFS-Build/20957/console
        Powered by Apache Yetus 0.6.0-SNAPSHOT http://yetus.apache.org

        This message was automatically generated.

        Show
        hadoopqa Hadoop QA added a comment - -1 overall Vote Subsystem Runtime Comment 0 reexec 0m 14s Docker mode activated.       Prechecks +1 @author 0m 0s The patch does not contain any @author tags. -1 test4tests 0m 0s The patch doesn't appear to include any new or modified tests. Please justify why no new tests are needed for this patch. Also please list what manual steps were performed to verify this patch.       trunk Compile Tests +1 mvninstall 14m 6s trunk passed +1 compile 0m 33s trunk passed +1 checkstyle 0m 18s trunk passed +1 mvnsite 0m 35s trunk passed +1 findbugs 1m 24s trunk passed +1 javadoc 0m 21s trunk passed       Patch Compile Tests +1 mvninstall 0m 32s the patch passed +1 compile 0m 30s the patch passed +1 javac 0m 30s the patch passed +1 checkstyle 0m 14s hadoop-hdfs-project/hadoop-hdfs-client: The patch generated 0 new + 74 unchanged - 1 fixed = 74 total (was 75) +1 mvnsite 0m 32s the patch passed +1 whitespace 0m 0s The patch has no whitespace issues. +1 findbugs 1m 29s the patch passed +1 javadoc 0m 19s the patch passed       Other Tests +1 unit 1m 12s hadoop-hdfs-client in the patch passed. +1 asflicense 0m 14s The patch does not generate ASF License warnings. 23m 50s Subsystem Report/Notes Docker Image:yetus/hadoop:71bbb86 JIRA Issue HDFS-12380 JIRA Patch URL https://issues.apache.org/jira/secure/attachment/12884849/HDFS-12380.002.patch Optional Tests asflicense compile javac javadoc mvninstall mvnsite unit findbugs checkstyle uname Linux 11c45382926f 3.13.0-123-generic #172-Ubuntu SMP Mon Jun 26 18:04:35 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux Build tool maven Personality /testptch/hadoop/patchprocess/precommit/personality/provided.sh git revision trunk / 1904100 Default Java 1.8.0_144 findbugs v3.1.0-RC1 Test Results https://builds.apache.org/job/PreCommit-HDFS-Build/20957/testReport/ modules C: hadoop-hdfs-project/hadoop-hdfs-client U: hadoop-hdfs-project/hadoop-hdfs-client Console output https://builds.apache.org/job/PreCommit-HDFS-Build/20957/console Powered by Apache Yetus 0.6.0-SNAPSHOT http://yetus.apache.org This message was automatically generated.
        Hide
        liuml07 Mingliang Liu added a comment -

        +1

        Committed to trunk branch. Thanks for your contribution liaoyuxiangqin.
        Thanks for your review Rushabh S Shah.

        Show
        liuml07 Mingliang Liu added a comment - +1 Committed to trunk branch. Thanks for your contribution liaoyuxiangqin . Thanks for your review Rushabh S Shah .
        Hide
        hudson Hudson added a comment -

        SUCCESS: Integrated in Jenkins build Hadoop-trunk-Commit #12294 (See https://builds.apache.org/job/Hadoop-trunk-Commit/12294/)
        HDFS-12380. Simplify dataQueue.wait condition logical operation in (liuml07: rev 36f33a1efb35e9f6986516499b54fdfa38fac2a1)

        • (edit) hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DataStreamer.java
        Show
        hudson Hudson added a comment - SUCCESS: Integrated in Jenkins build Hadoop-trunk-Commit #12294 (See https://builds.apache.org/job/Hadoop-trunk-Commit/12294/ ) HDFS-12380 . Simplify dataQueue.wait condition logical operation in (liuml07: rev 36f33a1efb35e9f6986516499b54fdfa38fac2a1) (edit) hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DataStreamer.java

          People

          • Assignee:
            liaoyuxiangqin liaoyuxiangqin
            Reporter:
            liaoyuxiangqin liaoyuxiangqin
          • Votes:
            0 Vote for this issue
            Watchers:
            5 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

                Development