junegunn commented on code in PR #7052: URL: https://github.com/apache/hbase/pull/7052#discussion_r2119786558
########## hbase-diagnostics/src/main/java/org/apache/hadoop/hbase/PerformanceEvaluation.java: ########## @@ -2843,7 +2845,71 @@ protected static void printUsage(final String shortName, final String message) { * arguments. */ static TestOptions parseOpts(Queue<String> args) { - TestOptions opts = new TestOptions(); + final TestOptions opts = new TestOptions(); + + final Map<String, Consumer<Boolean>> flagHandlers = new HashMap<>(); + flagHandlers.put("nomapred", v -> opts.nomapred = v); + flagHandlers.put("flushCommits", v -> opts.flushCommits = v); + flagHandlers.put("writeToWAL", v -> opts.writeToWAL = v); + flagHandlers.put("inmemory", v -> opts.inMemoryCF = v); + flagHandlers.put("autoFlush", v -> opts.autoFlush = v); + flagHandlers.put("oneCon", v -> opts.oneCon = v); + flagHandlers.put("latency", v -> opts.reportLatency = v); + flagHandlers.put("usetags", v -> opts.useTags = v); + flagHandlers.put("filterAll", v -> opts.filterAll = v); + flagHandlers.put("valueRandom", v -> opts.valueRandom = v); + flagHandlers.put("valueZipf", v -> opts.valueZipf = v); + flagHandlers.put("addColumns", v -> opts.addColumns = v); + flagHandlers.put("asyncPrefetch", v -> opts.asyncPrefetch = v); + flagHandlers.put("cacheBlocks", v -> opts.cacheBlocks = v); + + final Map<String, Consumer<String>> handlers = new HashMap<>(); + handlers.put("rows", v -> opts.perClientRunRows = Long.parseLong(v)); + handlers.put("cycles", v -> opts.cycles = Integer.parseInt(v)); + handlers.put("sampleRate", v -> opts.sampleRate = Float.parseFloat(v)); + handlers.put("table", v -> opts.tableName = v); + handlers.put("startRow", v -> opts.startRow = Long.parseLong(v)); + handlers.put("compress", v -> opts.compression = Compression.Algorithm.valueOf(v)); + handlers.put("encryption", v -> opts.encryption = v); + handlers.put("traceRate", v -> opts.traceRate = Double.parseDouble(v)); + handlers.put("blockEncoding", v -> opts.blockEncoding = DataBlockEncoding.valueOf(v)); + handlers.put("presplit", v -> opts.presplitRegions = Integer.parseInt(v)); + handlers.put("connCount", v -> opts.connCount = Integer.parseInt(v)); + handlers.put("latencyThreshold", v -> opts.latencyThreshold = Integer.parseInt(v)); + handlers.put("multiGet", v -> opts.multiGet = Integer.parseInt(v)); + handlers.put("multiPut", v -> opts.multiPut = Integer.parseInt(v)); + handlers.put("numoftags", v -> opts.noOfTags = Integer.parseInt(v)); + handlers.put("replicas", v -> opts.replicas = Integer.parseInt(v)); + handlers.put("size", v -> { + opts.size = Float.parseFloat(v); + if (opts.size <= 1.0f) { + throw new IllegalStateException("Size must be > 1; i.e. 1GB"); + } + }); + handlers.put("splitPolicy", v -> opts.splitPolicy = v); + handlers.put("randomSleep", v -> opts.randomSleep = Integer.parseInt(v)); + handlers.put("measureAfter", v -> opts.measureAfter = Integer.parseInt(v)); + handlers.put("bloomFilter", v -> opts.bloomType = BloomType.valueOf(v)); + handlers.put("blockSize", v -> opts.blockSize = Integer.parseInt(v)); + handlers.put("valueSize", v -> opts.valueSize = Integer.parseInt(v)); + handlers.put("period", v -> opts.period = Integer.parseInt(v)); + handlers.put("inmemoryCompaction", + v -> opts.inMemoryCompaction = MemoryCompactionPolicy.valueOf(v)); + handlers.put("columns", v -> opts.columns = Integer.parseInt(v)); + handlers.put("families", v -> opts.families = Integer.parseInt(v)); + handlers.put("caching", v -> opts.caching = Integer.parseInt(v)); + handlers.put("scanReadType", v -> opts.scanReadType = Scan.ReadType.valueOf(v.toUpperCase())); + handlers.put("bufferSize", v -> opts.bufferSize = Long.parseLong(v)); + handlers.put("commandPropertiesFile", fileName -> { + final Properties properties = new Properties(); + try { + properties.load(PerformanceEvaluation.class.getClassLoader().getResourceAsStream(fileName)); Review Comment: This may be a little out of scope for this pull request, but I went ahead and followed the suggestion as it improves the error message. 858e01ebcb ``` $ bin/hbase pe --commandPropertiesFile=log4j3.properties java.lang.IllegalArgumentException: Invalid option: --commandPropertiesFile=log4j3.properties at org.apache.hadoop.hbase.PerformanceEvaluation.parseOpts(PerformanceEvaluation.java:2952) at org.apache.hadoop.hbase.PerformanceEvaluation.run(PerformanceEvaluation.java:3042) at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:82) at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:97) at org.apache.hadoop.hbase.PerformanceEvaluation.main(PerformanceEvaluation.java:3098) Caused by: java.lang.IllegalArgumentException: Resource file not found: log4j3.properties at org.apache.hadoop.hbase.PerformanceEvaluation.lambda$parseOpts$45(PerformanceEvaluation.java:2911) at org.apache.hadoop.hbase.PerformanceEvaluation.parseOpts(PerformanceEvaluation.java:2948) ... 4 more ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@hbase.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org