This is an automated email from the ASF dual-hosted git repository.

rakeshr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hadoop-ozone.git


The following commit(s) were added to refs/heads/master by this push:
     new c7ae9fe  HDDS-4035. Update logs of HadoopDirGenerator. (#1264)
c7ae9fe is described below

commit c7ae9fe363355306896133b4b92a113abb79864e
Author: Aryan Gupta <[email protected]>
AuthorDate: Wed Aug 5 22:03:53 2020 +0530

    HDDS-4035. Update logs of HadoopDirGenerator. (#1264)
---
 .../hadoop/ozone/freon/BaseFreonGenerator.java     | 10 ++++++
 .../hadoop/ozone/freon/HadoopDirTreeGenerator.java | 40 +++++++++++-----------
 .../ozone/freon/HadoopNestedDirGenerator.java      | 22 ++++++++----
 3 files changed, 46 insertions(+), 26 deletions(-)

diff --git 
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/freon/BaseFreonGenerator.java
 
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/freon/BaseFreonGenerator.java
index aa8282e..b9b59ef 100644
--- 
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/freon/BaseFreonGenerator.java
+++ 
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/freon/BaseFreonGenerator.java
@@ -302,6 +302,16 @@ public class BaseFreonGenerator {
   }
 
   /**
+   * Print out reports with the given message.
+   */
+  public void print(String msg){
+    Consumer<String> print = freonCommand.isInteractive()
+            ? System.out::println
+            : LOG::info;
+    print.accept(msg);
+  }
+
+  /**
    * Create the OM RPC client to use it for testing.
    */
   public OzoneManagerProtocolClientSideTranslatorPB createOmClient(
diff --git 
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/freon/HadoopDirTreeGenerator.java
 
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/freon/HadoopDirTreeGenerator.java
index 62a4965..348aa24 100644
--- 
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/freon/HadoopDirTreeGenerator.java
+++ 
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/freon/HadoopDirTreeGenerator.java
@@ -97,17 +97,24 @@ public class HadoopDirTreeGenerator extends 
BaseFreonGenerator
 
   @Override
   public Void call() throws Exception {
-
-    init();
-    OzoneConfiguration configuration = createOzoneConfiguration();
-    fileSystem = FileSystem.get(URI.create(rootPath), configuration);
-
-    contentGenerator = new ContentGenerator(fileSizeInBytes, bufferSize);
-    timer = getMetrics().timer("file-create");
-
-    runTests(this::createDir);
+    String s;
+    if (depth <= 0) {
+      s = "Invalid depth value, depth value should be greater than zero!";
+      print(s);
+    } else if (span <= 0) {
+      s = "Invalid span value, span value should be greater than zero!";
+      print(s);
+    } else {
+      init();
+      OzoneConfiguration configuration = createOzoneConfiguration();
+      fileSystem = FileSystem.get(URI.create(rootPath), configuration);
+
+      contentGenerator = new ContentGenerator(fileSizeInBytes, bufferSize);
+      timer = getMetrics().timer("file-create");
+
+      runTests(this::createDir);
+    }
     return null;
-
   }
 
   /*
@@ -139,21 +146,14 @@ public class HadoopDirTreeGenerator extends 
BaseFreonGenerator
      created.
    */
   private void createDir(long counter) throws Exception {
-    if (depth <= 0) {
-      LOG.info("Invalid depth value, at least one depth should be passed!");
-      return;
-    }
-    if (span <= 0) {
-      LOG.info("Invalid span value, at least one span should be passed!");
-      return;
-    }
     String dir = makeDirWithGivenNumberOfFiles(rootPath);
     if (depth > 1) {
       createSubDirRecursively(dir, 1, 1);
     }
-    System.out.println("Successfully created directories & files. Total Dirs " 
+
+    String message = "Successfully created directories & files. Total Dirs " +
             "Count=" + totalDirsCnt.get() + ", Total Files Count=" +
-            timer.getCount());
+            timer.getCount();
+    print(message);
   }
 
   private void createSubDirRecursively(String parent, int depthIndex,
diff --git 
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/freon/HadoopNestedDirGenerator.java
 
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/freon/HadoopNestedDirGenerator.java
index 72d096c..8bc8a37 100644
--- 
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/freon/HadoopNestedDirGenerator.java
+++ 
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/freon/HadoopNestedDirGenerator.java
@@ -72,13 +72,20 @@ public class HadoopNestedDirGenerator extends 
BaseFreonGenerator
 
   @Override
   public Void call() throws Exception {
-
-    init();
-    OzoneConfiguration configuration = createOzoneConfiguration();
-    fileSystem = FileSystem.get(URI.create(rootPath), configuration);
-    runTests(this::createDir);
+    String s;
+    if (depth <= 0) {
+      s = "Invalid depth value, depth value should be greater than zero!";
+      print(s);
+    } else if (span < 0) {
+      s = "Invalid span value, span value should be greater or equal to zero!";
+      print(s);
+    } else {
+      init();
+      OzoneConfiguration configuration = createOzoneConfiguration();
+      fileSystem = FileSystem.get(URI.create(rootPath), configuration);
+      runTests(this::createDir);
+    }
     return null;
-
   }
 
   /*
@@ -109,5 +116,8 @@ public class HadoopNestedDirGenerator extends 
BaseFreonGenerator
       Path dir = new Path(rootPath.concat("/").concat(childDir));
       fileSystem.mkdirs(dir.getParent());
     }
+    String message = "\nSuccessfully created directories. " +
+            "Total Directories with level = " + depth + " and span = " + span;
+    print(message);
   }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to