Repository: hadoop
Updated Branches:
  refs/heads/branch-3.0 149d3ad6b -> bfad0ca3b


HADOOP-14881. LoadGenerator should use Time.monotonicNow() to measure 
durations. Contributed by Bharat Viswanadham

(cherry picked from commit ac05a51bbb2a3fad4e85f9334a3408571967900a)


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/bfad0ca3
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/bfad0ca3
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/bfad0ca3

Branch: refs/heads/branch-3.0
Commit: bfad0ca3b0d2b9e70b505c21ad1bec93bf8b7ed2
Parents: 149d3ad
Author: Jason Lowe <jl...@apache.org>
Authored: Mon Sep 25 15:35:44 2017 -0500
Committer: Jason Lowe <jl...@apache.org>
Committed: Mon Sep 25 15:38:24 2017 -0500

----------------------------------------------------------------------
 .../hadoop/fs/loadGenerator/LoadGenerator.java  | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/bfad0ca3/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/loadGenerator/LoadGenerator.java
----------------------------------------------------------------------
diff --git 
a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/loadGenerator/LoadGenerator.java
 
b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/loadGenerator/LoadGenerator.java
index 6da5182..0bb1b46 100644
--- 
a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/loadGenerator/LoadGenerator.java
+++ 
b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/loadGenerator/LoadGenerator.java
@@ -277,9 +277,9 @@ public class LoadGenerator extends Configured implements 
Tool {
      * the entire file */
     private void read() throws IOException {
       String fileName = files.get(r.nextInt(files.size()));
-      long startTime = Time.now();
+      long startTimestamp = Time.monotonicNow();
       InputStream in = fc.open(new Path(fileName));
-      executionTime[OPEN] += (Time.now()-startTime);
+      executionTime[OPEN] += (Time.monotonicNow() - startTimestamp);
       totalNumOfOps[OPEN]++;
       while (in.read(buffer) != -1) {}
       in.close();
@@ -299,9 +299,9 @@ public class LoadGenerator extends Configured implements 
Tool {
       double fileSize = 0;
       while ((fileSize = r.nextGaussian()+2)<=0) {}
       genFile(file, (long)(fileSize*BLOCK_SIZE));
-      long startTime = Time.now();
+      long startTimestamp = Time.monotonicNow();
       fc.delete(file, true);
-      executionTime[DELETE] += (Time.now()-startTime);
+      executionTime[DELETE] += (Time.monotonicNow() - startTimestamp);
       totalNumOfOps[DELETE]++;
     }
     
@@ -310,9 +310,9 @@ public class LoadGenerator extends Configured implements 
Tool {
      */
     private void list() throws IOException {
       String dirName = dirs.get(r.nextInt(dirs.size()));
-      long startTime = Time.now();
+      long startTimestamp = Time.monotonicNow();
       fc.listStatus(new Path(dirName));
-      executionTime[LIST] += (Time.now()-startTime);
+      executionTime[LIST] += (Time.monotonicNow() - startTimestamp);
       totalNumOfOps[LIST]++;
     }
 
@@ -320,14 +320,14 @@ public class LoadGenerator extends Configured implements 
Tool {
      * The file is filled with 'a'.
      */
     private void genFile(Path file, long fileSize) throws IOException {
-      long startTime = Time.now();
+      long startTimestamp = Time.monotonicNow();
       FSDataOutputStream out = null;
       try {
         out = fc.create(file,
             EnumSet.of(CreateFlag.CREATE, CreateFlag.OVERWRITE),
             CreateOpts.createParent(), CreateOpts.bufferSize(4096),
             CreateOpts.repFac((short) 3));
-        executionTime[CREATE] += (Time.now() - startTime);
+        executionTime[CREATE] += (Time.monotonicNow() - startTimestamp);
         numOfOps[CREATE]++;
 
         long i = fileSize;
@@ -337,8 +337,8 @@ public class LoadGenerator extends Configured implements 
Tool {
           i -= s;
         }
 
-        startTime = Time.now();
-        executionTime[WRITE_CLOSE] += (Time.now() - startTime);
+        startTimestamp = Time.monotonicNow();
+        executionTime[WRITE_CLOSE] += (Time.monotonicNow() - startTimestamp);
         numOfOps[WRITE_CLOSE]++;
       } finally {
         IOUtils.cleanupWithLogger(LOG, out);


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

Reply via email to