Uploaded image for project: 'Hadoop Common'
  1. Hadoop Common
  2. HADOOP-14276

Add a nanosecond API to Time/Timer/FakeTimer

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.9.0, 2.7.4, 3.0.0-alpha4, 2.8.2
    • Component/s: util
    • Labels:
      None
    • Hadoop Flags:
      Reviewed

      Description

      Right now Time/Timer export functionality for retrieving time at a millisecond-level precision but not at a nanosecond-level precision, which is required for some applications (there's ~70 usages). Most of these seem not to need mocking functionality for tests; only one class currently mocks this out (LightWeightCache) but we would like to add another as part of HDFS-11615 and want to avoid code duplication. This could be useful for other classes in the future as well.

        Issue Links

          Activity

          Hide
          vinodkv Vinod Kumar Vavilapalli added a comment -

          2.8.1 became a security release. Moving fix-version to 2.8.2 after the fact.

          Show
          vinodkv Vinod Kumar Vavilapalli added a comment - 2.8.1 became a security release. Moving fix-version to 2.8.2 after the fact.
          Hide
          hudson Hudson added a comment -

          SUCCESS: Integrated in Jenkins build Hadoop-trunk-Commit #11591 (See https://builds.apache.org/job/Hadoop-trunk-Commit/11591/)
          HADOOP-14276. Add a nanosecond API to Time/Timer/FakeTimer. Contributed (zhz: rev 95b7f1d29a5e2dadd70a56fca5faa006c5bd74fc)

          • (edit) hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/Timer.java
          • (edit) hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/Time.java
          • (edit) hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestLightWeightCache.java
          • (edit) hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/LightWeightCache.java
          • (edit) hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/FakeTimer.java
          Show
          hudson Hudson added a comment - SUCCESS: Integrated in Jenkins build Hadoop-trunk-Commit #11591 (See https://builds.apache.org/job/Hadoop-trunk-Commit/11591/ ) HADOOP-14276 . Add a nanosecond API to Time/Timer/FakeTimer. Contributed (zhz: rev 95b7f1d29a5e2dadd70a56fca5faa006c5bd74fc) (edit) hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/Timer.java (edit) hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/Time.java (edit) hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestLightWeightCache.java (edit) hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/LightWeightCache.java (edit) hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/FakeTimer.java
          Hide
          andrew.wang Andrew Wang added a comment -

          The change to the start time broke an HDFS test, I have a patch up at HADOOP-14293 to make this 1000ms again.

          Show
          andrew.wang Andrew Wang added a comment - The change to the start time broke an HDFS test, I have a patch up at HADOOP-14293 to make this 1000ms again.
          Hide
          zhz Zhe Zhang added a comment -

          Committed all the way to branch-2.7. Thanks Erik for the work.

          Show
          zhz Zhe Zhang added a comment - Committed all the way to branch-2.7. Thanks Erik for the work.
          Hide
          hudson Hudson added a comment -

          SUCCESS: Integrated in Jenkins build Hadoop-trunk-Commit #11544 (See https://builds.apache.org/job/Hadoop-trunk-Commit/11544/)
          HADOOP-14276. Add a nanosecond API to Time/Timer/FakeTimer. Contributed (zhz: rev 95b7f1d29a5e2dadd70a56fca5faa006c5bd74fc)

          • (edit) hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestLightWeightCache.java
          • (edit) hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/LightWeightCache.java
          • (edit) hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/Time.java
          • (edit) hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/Timer.java
          • (edit) hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/FakeTimer.java
          Show
          hudson Hudson added a comment - SUCCESS: Integrated in Jenkins build Hadoop-trunk-Commit #11544 (See https://builds.apache.org/job/Hadoop-trunk-Commit/11544/ ) HADOOP-14276 . Add a nanosecond API to Time/Timer/FakeTimer. Contributed (zhz: rev 95b7f1d29a5e2dadd70a56fca5faa006c5bd74fc) (edit) hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestLightWeightCache.java (edit) hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/LightWeightCache.java (edit) hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/Time.java (edit) hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/Timer.java (edit) hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/FakeTimer.java
          Hide
          zhz Zhe Zhang added a comment -

          Committed to trunk. YARN-6288 is breaking branch-2 build, waiting for the fix.

          Show
          zhz Zhe Zhang added a comment - Committed to trunk. YARN-6288 is breaking branch-2 build, waiting for the fix.
          Hide
          zhz Zhe Zhang added a comment -

          Thanks for confirming Liang. I'll commit the patch to trunk~branch-2.7 soon.

          Show
          zhz Zhe Zhang added a comment - Thanks for confirming Liang. I'll commit the patch to trunk~branch-2.7 soon.
          Hide
          vagarychen Chen Liang added a comment -

          Erik Krogen that =1000 was added in HADOOP-10755, so I quickly read through the patches and the comments there, this value does not seem to have any particular purpose, so I would say any arbitrary value is fine by me

          Show
          vagarychen Chen Liang added a comment - Erik Krogen that =1000 was added in HADOOP-10755 , so I quickly read through the patches and the comments there, this value does not seem to have any particular purpose, so I would say any arbitrary value is fine by me
          Hide
          xkrogen Erik Krogen added a comment -

          Chen Liang that's true. To maintain exact same behavior I can bump the initial value to 1000 ms instead of 1000 ns. It seems no tests failed as a result of the change but it seems the original intent was probably to make sure that prod code wasn't making assumptions about the value, so provide some arbitrary value rather than just 0. Maybe it would be better to initialize it to a random value?

          Show
          xkrogen Erik Krogen added a comment - Chen Liang that's true. To maintain exact same behavior I can bump the initial value to 1000 ms instead of 1000 ns. It seems no tests failed as a result of the change but it seems the original intent was probably to make sure that prod code wasn't making assumptions about the value, so provide some arbitrary value rather than just 0. Maybe it would be better to initialize it to a random value?
          Hide
          vagarychen Chen Liang added a comment -

          Thanks Erik Krogen for working on this! v000 patch LGTM, only one minor thing though, FakeTimer seems to have changed the behaviour the monotonicNow() a little bit. More specifically, imagine I call monotonicNow() on a newly created FakeTimer, the old version will return 1000, because that's the initial value. While the new version will return TimeUnit.NANOSECONDS.toMillis(1000);, which I guess would be a 0. Is this fine? (This does not seem to be an issue to me, but still want to make sure.)

          Show
          vagarychen Chen Liang added a comment - Thanks Erik Krogen for working on this! v000 patch LGTM, only one minor thing though, FakeTimer seems to have changed the behaviour the monotonicNow() a little bit. More specifically, imagine I call monotonicNow() on a newly created FakeTimer , the old version will return 1000, because that's the initial value. While the new version will return TimeUnit.NANOSECONDS.toMillis(1000); , which I guess would be a 0. Is this fine? (This does not seem to be an issue to me, but still want to make sure.)
          Hide
          zhz Zhe Zhang added a comment -

          Thanks Erik. The analysis makes sense and +1 on the patch. Will wait for 2 hours before committing.

          Show
          zhz Zhe Zhang added a comment - Thanks Erik. The analysis makes sense and +1 on the patch. Will wait for 2 hours before committing.
          Hide
          hadoopqa Hadoop QA added a comment -
          -1 overall



          Vote Subsystem Runtime Comment
          0 reexec 0m 16s Docker mode activated.
          +1 @author 0m 0s The patch does not contain any @author tags.
          +1 test4tests 0m 0s The patch appears to include 2 new or modified test files.
          +1 mvninstall 13m 10s trunk passed
          +1 compile 16m 42s trunk passed
          +1 checkstyle 0m 38s trunk passed
          +1 mvnsite 1m 13s trunk passed
          +1 mvneclipse 0m 20s trunk passed
          +1 findbugs 1m 45s trunk passed
          +1 javadoc 0m 57s trunk passed
          +1 mvninstall 0m 38s the patch passed
          +1 compile 14m 44s the patch passed
          +1 javac 14m 44s the patch passed
          +1 checkstyle 0m 39s hadoop-common-project/hadoop-common: The patch generated 0 new + 37 unchanged - 4 fixed = 37 total (was 41)
          +1 mvnsite 1m 7s the patch passed
          +1 mvneclipse 0m 18s the patch passed
          +1 whitespace 0m 0s The patch has no whitespace issues.
          +1 findbugs 1m 56s the patch passed
          +1 javadoc 0m 57s the patch passed
          -1 unit 8m 51s hadoop-common in the patch failed.
          +1 asflicense 0m 38s The patch does not generate ASF License warnings.
          66m 42s



          Reason Tests
          Failed junit tests hadoop.security.TestKDiag



          Subsystem Report/Notes
          Docker Image:yetus/hadoop:a9ad5d6
          JIRA Issue HADOOP-14276
          JIRA Patch URL https://issues.apache.org/jira/secure/attachment/12862328/HADOOP-14276.000.patch
          Optional Tests asflicense compile javac javadoc mvninstall mvnsite unit findbugs checkstyle
          uname Linux fb82dfb863b6 3.13.0-106-generic #153-Ubuntu SMP Tue Dec 6 15:44:32 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
          Build tool maven
          Personality /testptch/hadoop/patchprocess/precommit/personality/provided.sh
          git revision trunk / 1a9439e
          Default Java 1.8.0_121
          findbugs v3.0.0
          unit https://builds.apache.org/job/PreCommit-HADOOP-Build/12043/artifact/patchprocess/patch-unit-hadoop-common-project_hadoop-common.txt
          Test Results https://builds.apache.org/job/PreCommit-HADOOP-Build/12043/testReport/
          modules C: hadoop-common-project/hadoop-common U: hadoop-common-project/hadoop-common
          Console output https://builds.apache.org/job/PreCommit-HADOOP-Build/12043/console
          Powered by Apache Yetus 0.5.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 16s Docker mode activated. +1 @author 0m 0s The patch does not contain any @author tags. +1 test4tests 0m 0s The patch appears to include 2 new or modified test files. +1 mvninstall 13m 10s trunk passed +1 compile 16m 42s trunk passed +1 checkstyle 0m 38s trunk passed +1 mvnsite 1m 13s trunk passed +1 mvneclipse 0m 20s trunk passed +1 findbugs 1m 45s trunk passed +1 javadoc 0m 57s trunk passed +1 mvninstall 0m 38s the patch passed +1 compile 14m 44s the patch passed +1 javac 14m 44s the patch passed +1 checkstyle 0m 39s hadoop-common-project/hadoop-common: The patch generated 0 new + 37 unchanged - 4 fixed = 37 total (was 41) +1 mvnsite 1m 7s the patch passed +1 mvneclipse 0m 18s the patch passed +1 whitespace 0m 0s The patch has no whitespace issues. +1 findbugs 1m 56s the patch passed +1 javadoc 0m 57s the patch passed -1 unit 8m 51s hadoop-common in the patch failed. +1 asflicense 0m 38s The patch does not generate ASF License warnings. 66m 42s Reason Tests Failed junit tests hadoop.security.TestKDiag Subsystem Report/Notes Docker Image:yetus/hadoop:a9ad5d6 JIRA Issue HADOOP-14276 JIRA Patch URL https://issues.apache.org/jira/secure/attachment/12862328/HADOOP-14276.000.patch Optional Tests asflicense compile javac javadoc mvninstall mvnsite unit findbugs checkstyle uname Linux fb82dfb863b6 3.13.0-106-generic #153-Ubuntu SMP Tue Dec 6 15:44:32 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux Build tool maven Personality /testptch/hadoop/patchprocess/precommit/personality/provided.sh git revision trunk / 1a9439e Default Java 1.8.0_121 findbugs v3.0.0 unit https://builds.apache.org/job/PreCommit-HADOOP-Build/12043/artifact/patchprocess/patch-unit-hadoop-common-project_hadoop-common.txt Test Results https://builds.apache.org/job/PreCommit-HADOOP-Build/12043/testReport/ modules C: hadoop-common-project/hadoop-common U: hadoop-common-project/hadoop-common Console output https://builds.apache.org/job/PreCommit-HADOOP-Build/12043/console Powered by Apache Yetus 0.5.0-SNAPSHOT http://yetus.apache.org This message was automatically generated.
          Hide
          xkrogen Erik Krogen added a comment -

          Attaching v000 patch which adds Time#monotonicNowNanos() and the corresponding Timer method. LightWeightCacheSet has been changed to use this new util API rather than building its own static inner class.

          Show
          xkrogen Erik Krogen added a comment - Attaching v000 patch which adds Time#monotonicNowNanos() and the corresponding Timer method. LightWeightCacheSet has been changed to use this new util API rather than building its own static inner class.

            People

            • Assignee:
              xkrogen Erik Krogen
              Reporter:
              xkrogen Erik Krogen
            • Votes:
              0 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development