diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/PerformanceEvaluation.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/PerformanceEvaluation.java index 83d6d2f7cba9..891d5d7a098b 100644 --- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/PerformanceEvaluation.java +++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/PerformanceEvaluation.java @@ -36,6 +36,7 @@ import java.util.Locale; import java.util.Map; import java.util.NoSuchElementException; +import java.util.Properties; import java.util.Queue; import java.util.Random; import java.util.TreeMap; @@ -358,7 +359,8 @@ static boolean checkTable(Admin admin, TestOptions opts) throws IOException { // {RegionSplitPolicy,replica count} does not match requested, or when the // number of column families does not match requested. if ( - (exists && opts.presplitRegions != DEFAULT_OPTS.presplitRegions) + (exists && opts.presplitRegions != DEFAULT_OPTS.presplitRegions + && opts.presplitRegions != admin.getRegions(tableName).size()) || (!isReadCmd && desc != null && !StringUtils.equals(desc.getRegionSplitPolicyClassName(), opts.splitPolicy)) || (!isReadCmd && desc != null && desc.getRegionReplication() != opts.replicas) @@ -719,6 +721,7 @@ static class TestOptions { boolean cacheBlocks = true; Scan.ReadType scanReadType = Scan.ReadType.DEFAULT; long bufferSize = 2l * 1024l * 1024l; + Properties commandProperties; public TestOptions() { } @@ -775,6 +778,11 @@ public TestOptions(TestOptions that) { this.cacheBlocks = that.cacheBlocks; this.scanReadType = that.scanReadType; this.bufferSize = that.bufferSize; + this.commandProperties = that.commandProperties; + } + + public Properties getCommandProperties() { + return commandProperties; } public int getCaching() { @@ -1140,10 +1148,10 @@ private static long nextRandomSeed() { protected final Configuration conf; protected final TestOptions opts; - private final Status status; + protected final Status status; private String testName; - private Histogram latencyHistogram; + protected Histogram latencyHistogram; private Histogram replicaLatencyHistogram; private Histogram valueSizeHistogram; private Histogram rpcCallsHistogram; @@ -2300,7 +2308,7 @@ protected byte[] generateRow(final int i) { } @Override - boolean testRow(final int i, final long startTime) throws IOException { + protected boolean testRow(final int i, final long startTime) throws IOException { byte[] row = generateRow(i); Put put = new Put(row); for (int family = 0; family < opts.families; family++) { @@ -2673,6 +2681,8 @@ protected static void printUsage(final String shortName, final String message) { for (CmdDescriptor command : COMMANDS.values()) { System.err.println(String.format(" %-20s %s", command.getName(), command.getDescription())); } + System.err.println(String.format(" %-20s %s", "? extends Test", + "Run custom implementation of provided Test present in classpath")); System.err.println(); System.err.println("Args:"); System.err.println(" nclients Integer. Required. Total number of clients " @@ -2968,6 +2978,20 @@ static TestOptions parseOpts(Queue args) { 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); + } + continue; + } + validateParsedOpts(opts); if (isCommandClass(cmd)) { @@ -3081,7 +3105,20 @@ public int run(String[] args) throws Exception { } private static boolean isCommandClass(String cmd) { - return COMMANDS.containsKey(cmd); + return !COMMANDS.containsKey(cmd) ? isCustomTestClass(cmd) : true; + } + + private static boolean isCustomTestClass(String cmd) { + Class cmdClass; + try { + cmdClass = + (Class) PerformanceEvaluation.class.getClassLoader().loadClass(cmd); + addCommandDescriptor(cmdClass, cmd, "custom command"); + return true; + } catch (Throwable th) { + LOG.info("No class found for command: " + cmd, th); + return false; + } } private static Class determineCommandClass(String cmd) {