You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by el...@apache.org on 2019/02/26 15:14:07 UTC

[hadoop] branch trunk updated: HDDS-1104. Use picocli with Ozone genesis tool. Contributed by Lokesh Jain.

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

elek pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/hadoop.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 585cebf  HDDS-1104. Use picocli with Ozone genesis tool. Contributed by Lokesh Jain.
585cebf is described below

commit 585cebf26bab7e63e6f03039bec237b426d42474
Author: Márton Elek <el...@apache.org>
AuthorDate: Tue Feb 26 16:11:02 2019 +0100

    HDDS-1104. Use picocli with Ozone genesis tool. Contributed by Lokesh Jain.
---
 .../org/apache/hadoop/ozone/genesis/Genesis.java   | 57 ++++++++++++++++------
 1 file changed, 43 insertions(+), 14 deletions(-)

diff --git a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/genesis/Genesis.java b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/genesis/Genesis.java
index faa535f..74de2d9 100644
--- a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/genesis/Genesis.java
+++ b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/genesis/Genesis.java
@@ -21,8 +21,10 @@ package org.apache.hadoop.ozone.genesis;
 import org.openjdk.jmh.profile.StackProfiler;
 import org.openjdk.jmh.runner.Runner;
 import org.openjdk.jmh.runner.RunnerException;
-import org.openjdk.jmh.runner.options.Options;
 import org.openjdk.jmh.runner.options.OptionsBuilder;
+import picocli.CommandLine;
+import picocli.CommandLine.Option;
+import picocli.CommandLine.Command;
 
 /**
  * Main class that executes a set of HDDS/Ozone benchmarks.
@@ -32,30 +34,57 @@ import org.openjdk.jmh.runner.options.OptionsBuilder;
  * Hence, these classes do not use the Tool/Runner pattern of standard Hadoop
  * CLI.
  */
+@Command(name = "ozone genesis",
+    description = "Tool for running ozone benchmarks",
+    mixinStandardHelpOptions = true)
 public final class Genesis {
 
+  // For adding benchmark to Genesis add the benchmark name in the default value
+  // and description for this option.
+  @Option(names = "-benchmark", required = true, split = ",",
+      defaultValue = "BenchMarkContainerStateMap,BenchMarkOMKeyAllocation,"
+          + "BenchMarkBlockManager,BenchMarkMetadataStoreReads,"
+          + "BenchMarkMetadataStoreWrites,BenchMarkDatanodeDispatcher"
+          + "BenchMarkRocksDbStore",
+      description =
+      "Option used for specifying benchmarks to run.\n"
+          + "Ex. ozone genesis -benchmark BenchMarkContainerStateMap,"
+          + "BenchMarkOMKeyAllocation.\n"
+          + "Possible benchmarks which can be used are "
+          + "{BenchMarkContainerStateMap, BenchMarkOMKeyAllocation, "
+          + "BenchMarkBlockManager, BenchMarkMetadataStoreReads, "
+          + "BenchMarkMetadataStoreWrites, BenchMarkDatanodeDispatcher, "
+          + "BenchMarkRocksDbStore}")
+  private static String[] benchmarks;
+
+  @Option(names = "-t", defaultValue = "4",
+      description = "Number of threads to use for the benchmark.\n"
+          + "This option can be overridden by threads mentioned in benchmark.")
+  private static int numThreads;
+
   private Genesis() {
   }
 
   public static void main(String[] args) throws RunnerException {
-    Options opt = new OptionsBuilder()
-        .include(BenchMarkContainerStateMap.class.getSimpleName())
-        .include(BenchMarkOMKeyAllocation.class.getSimpleName())
-        .include(BenchMarkBlockManager.class.getSimpleName())
-//        .include(BenchMarkMetadataStoreReads.class.getSimpleName())
-//        .include(BenchMarkMetadataStoreWrites.class.getSimpleName())
-//        .include(BenchMarkDatanodeDispatcher.class.getSimpleName())
-// Commenting this test out, till we support either a command line or a config
-        // file based ability to run tests.
-//        .include(BenchMarkRocksDbStore.class.getSimpleName())
-        .warmupIterations(5)
+    CommandLine commandLine = new CommandLine(new Genesis());
+    commandLine.parse(args);
+    if (commandLine.isUsageHelpRequested()) {
+      commandLine.usage(System.out);
+      return;
+    }
+
+    OptionsBuilder optionsBuilder = new OptionsBuilder();
+    for (String benchmark : benchmarks) {
+      optionsBuilder.include(benchmark);
+    }
+    optionsBuilder.warmupIterations(2)
         .measurementIterations(20)
         .addProfiler(StackProfiler.class)
         .shouldDoGC(true)
         .forks(1)
-        .build();
+        .threads(numThreads);
 
-    new Runner(opt).run();
+    new Runner(optionsBuilder.build()).run();
   }
 }
 


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