junegunn commented on code in PR #7052:
URL: https://github.com/apache/hbase/pull/7052#discussion_r2117009848
##########
hbase-diagnostics/src/main/java/org/apache/hadoop/hbase/PerformanceEvaluation.java:
##########
@@ -2853,310 +2919,61 @@ static TestOptions parseOpts(Queue<String> args) {
break;
}
- final String nmr = "--nomapred";
- if (cmd.startsWith(nmr)) {
- opts.nomapred = true;
- continue;
- }
-
- final String rows = "--rows=";
- if (cmd.startsWith(rows)) {
- opts.perClientRunRows = Long.parseLong(cmd.substring(rows.length()));
- continue;
- }
-
- final String cycles = "--cycles=";
- if (cmd.startsWith(cycles)) {
- opts.cycles = Integer.parseInt(cmd.substring(cycles.length()));
- continue;
- }
-
- final String sampleRate = "--sampleRate=";
- if (cmd.startsWith(sampleRate)) {
- opts.sampleRate = Float.parseFloat(cmd.substring(sampleRate.length()));
- continue;
- }
-
- final String table = "--table=";
- if (cmd.startsWith(table)) {
- opts.tableName = cmd.substring(table.length());
- continue;
- }
-
- final String startRow = "--startRow=";
- if (cmd.startsWith(startRow)) {
- opts.startRow = Long.parseLong(cmd.substring(startRow.length()));
- continue;
- }
-
- final String compress = "--compress=";
- if (cmd.startsWith(compress)) {
- opts.compression =
Compression.Algorithm.valueOf(cmd.substring(compress.length()));
- continue;
- }
-
- final String encryption = "--encryption=";
- if (cmd.startsWith(encryption)) {
- opts.encryption = cmd.substring(encryption.length());
- continue;
- }
-
- final String traceRate = "--traceRate=";
- if (cmd.startsWith(traceRate)) {
- opts.traceRate = Double.parseDouble(cmd.substring(traceRate.length()));
- continue;
- }
-
- final String blockEncoding = "--blockEncoding=";
- if (cmd.startsWith(blockEncoding)) {
- opts.blockEncoding =
DataBlockEncoding.valueOf(cmd.substring(blockEncoding.length()));
- continue;
- }
-
- final String flushCommits = "--flushCommits=";
- if (cmd.startsWith(flushCommits)) {
- opts.flushCommits =
Boolean.parseBoolean(cmd.substring(flushCommits.length()));
- continue;
- }
-
- final String writeToWAL = "--writeToWAL=";
- if (cmd.startsWith(writeToWAL)) {
- opts.writeToWAL =
Boolean.parseBoolean(cmd.substring(writeToWAL.length()));
- continue;
- }
-
- final String presplit = "--presplit=";
- if (cmd.startsWith(presplit)) {
- opts.presplitRegions =
Integer.parseInt(cmd.substring(presplit.length()));
- continue;
- }
-
- final String inMemory = "--inmemory=";
- if (cmd.startsWith(inMemory)) {
- opts.inMemoryCF =
Boolean.parseBoolean(cmd.substring(inMemory.length()));
- continue;
- }
-
- final String autoFlush = "--autoFlush=";
- if (cmd.startsWith(autoFlush)) {
- opts.autoFlush =
Boolean.parseBoolean(cmd.substring(autoFlush.length()));
- continue;
- }
-
- final String onceCon = "--oneCon=";
- if (cmd.startsWith(onceCon)) {
- opts.oneCon = Boolean.parseBoolean(cmd.substring(onceCon.length()));
- continue;
- }
-
- final String connCount = "--connCount=";
- if (cmd.startsWith(connCount)) {
- opts.connCount = Integer.parseInt(cmd.substring(connCount.length()));
- continue;
- }
-
- final String latencyThreshold = "--latencyThreshold=";
- if (cmd.startsWith(latencyThreshold)) {
- opts.latencyThreshold =
Integer.parseInt(cmd.substring(latencyThreshold.length()));
- continue;
- }
-
- final String latency = "--latency";
- if (cmd.startsWith(latency)) {
- opts.reportLatency = true;
- continue;
- }
-
- final String multiGet = "--multiGet=";
- if (cmd.startsWith(multiGet)) {
- opts.multiGet = Integer.parseInt(cmd.substring(multiGet.length()));
- continue;
- }
-
- final String multiPut = "--multiPut=";
- if (cmd.startsWith(multiPut)) {
- opts.multiPut = Integer.parseInt(cmd.substring(multiPut.length()));
- continue;
- }
-
- final String useTags = "--usetags=";
- if (cmd.startsWith(useTags)) {
- opts.useTags = Boolean.parseBoolean(cmd.substring(useTags.length()));
- continue;
- }
-
- final String noOfTags = "--numoftags=";
- if (cmd.startsWith(noOfTags)) {
- opts.noOfTags = Integer.parseInt(cmd.substring(noOfTags.length()));
- continue;
- }
-
- final String replicas = "--replicas=";
- if (cmd.startsWith(replicas)) {
- opts.replicas = Integer.parseInt(cmd.substring(replicas.length()));
- continue;
- }
-
- final String filterOutAll = "--filterAll";
- if (cmd.startsWith(filterOutAll)) {
- opts.filterAll = true;
- continue;
- }
-
- final String size = "--size=";
- if (cmd.startsWith(size)) {
- opts.size = Float.parseFloat(cmd.substring(size.length()));
- if (opts.size <= 1.0f) throw new IllegalStateException("Size must be >
1; i.e. 1GB");
- continue;
- }
-
- final String splitPolicy = "--splitPolicy=";
- if (cmd.startsWith(splitPolicy)) {
- opts.splitPolicy = cmd.substring(splitPolicy.length());
- continue;
- }
-
- final String randomSleep = "--randomSleep=";
- if (cmd.startsWith(randomSleep)) {
- opts.randomSleep =
Integer.parseInt(cmd.substring(randomSleep.length()));
- continue;
- }
-
- final String measureAfter = "--measureAfter=";
- if (cmd.startsWith(measureAfter)) {
- opts.measureAfter =
Integer.parseInt(cmd.substring(measureAfter.length()));
- continue;
- }
-
- final String bloomFilter = "--bloomFilter=";
- if (cmd.startsWith(bloomFilter)) {
- opts.bloomType =
BloomType.valueOf(cmd.substring(bloomFilter.length()));
- continue;
- }
-
- final String blockSize = "--blockSize=";
- if (cmd.startsWith(blockSize)) {
- opts.blockSize = Integer.parseInt(cmd.substring(blockSize.length()));
- continue;
- }
-
- final String valueSize = "--valueSize=";
- if (cmd.startsWith(valueSize)) {
- opts.valueSize = Integer.parseInt(cmd.substring(valueSize.length()));
- continue;
- }
-
- final String valueRandom = "--valueRandom";
- if (cmd.startsWith(valueRandom)) {
- opts.valueRandom = true;
- continue;
- }
-
- final String valueZipf = "--valueZipf";
- if (cmd.startsWith(valueZipf)) {
- opts.valueZipf = true;
- continue;
- }
-
- final String period = "--period=";
- if (cmd.startsWith(period)) {
- opts.period = Integer.parseInt(cmd.substring(period.length()));
- continue;
- }
-
- final String addColumns = "--addColumns=";
- if (cmd.startsWith(addColumns)) {
- opts.addColumns =
Boolean.parseBoolean(cmd.substring(addColumns.length()));
- continue;
- }
-
- final String inMemoryCompaction = "--inmemoryCompaction=";
- if (cmd.startsWith(inMemoryCompaction)) {
- opts.inMemoryCompaction =
-
MemoryCompactionPolicy.valueOf(cmd.substring(inMemoryCompaction.length()));
- continue;
- }
-
- final String columns = "--columns=";
- if (cmd.startsWith(columns)) {
- opts.columns = Integer.parseInt(cmd.substring(columns.length()));
- continue;
- }
+ if (cmd.startsWith("--")) {
+ final String[] parts = cmd.substring(2).split("=", 2);
+ final String key = parts[0];
- final String families = "--families=";
- if (cmd.startsWith(families)) {
- opts.families = Integer.parseInt(cmd.substring(families.length()));
- continue;
- }
-
- final String caching = "--caching=";
- if (cmd.startsWith(caching)) {
- opts.caching = Integer.parseInt(cmd.substring(caching.length()));
- continue;
- }
-
- final String asyncPrefetch = "--asyncPrefetch";
- if (cmd.startsWith(asyncPrefetch)) {
- opts.asyncPrefetch = true;
- continue;
- }
-
- final String cacheBlocks = "--cacheBlocks=";
- if (cmd.startsWith(cacheBlocks)) {
- opts.cacheBlocks =
Boolean.parseBoolean(cmd.substring(cacheBlocks.length()));
- continue;
- }
-
- final String scanReadType = "--scanReadType=";
- if (cmd.startsWith(scanReadType)) {
- opts.scanReadType =
-
Scan.ReadType.valueOf(cmd.substring(scanReadType.length()).toUpperCase());
- continue;
- }
-
- final String bufferSize = "--bufferSize=";
- if (cmd.startsWith(bufferSize)) {
- opts.bufferSize = Long.parseLong(cmd.substring(bufferSize.length()));
- continue;
- }
-
- final String commandPropertiesFile = "--commandPropertiesFile=";
- if (cmd.startsWith(commandPropertiesFile)) {
- String fileName =
String.valueOf(cmd.substring(commandPropertiesFile.length()));
- Properties properties = new Properties();
try {
- properties
-
.load(PerformanceEvaluation.class.getClassLoader().getResourceAsStream(fileName));
- opts.commandProperties = properties;
- } catch (IOException e) {
- LOG.error("Failed to load metricIds from properties file", e);
Review Comment:
I changed two things here.
* The original error message was a bit strange. Where did `metricIds` come
from? I changed it to `Failed to load command properties from file`
* It used to print the error message and proceed. I decided to throw the
exception instead.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]