|
36 | 36 | import java.util.Locale; |
37 | 37 | import java.util.Map; |
38 | 38 | import java.util.NoSuchElementException; |
| 39 | +import java.util.Properties; |
39 | 40 | import java.util.Queue; |
40 | 41 | import java.util.Random; |
41 | 42 | import java.util.TreeMap; |
@@ -360,7 +361,8 @@ static boolean checkTable(Admin admin, TestOptions opts) throws IOException { |
360 | 361 | // {RegionSplitPolicy,replica count} does not match requested, or when the |
361 | 362 | // number of column families does not match requested. |
362 | 363 | if ( |
363 | | - (exists && opts.presplitRegions != DEFAULT_OPTS.presplitRegions) |
| 364 | + (exists && opts.presplitRegions != DEFAULT_OPTS.presplitRegions |
| 365 | + && opts.presplitRegions != admin.getRegions(tableName).size()) |
364 | 366 | || (!isReadCmd && desc != null |
365 | 367 | && !StringUtils.equals(desc.getRegionSplitPolicyClassName(), opts.splitPolicy)) |
366 | 368 | || (!isReadCmd && desc != null && desc.getRegionReplication() != opts.replicas) |
@@ -721,6 +723,7 @@ static class TestOptions { |
721 | 723 | boolean cacheBlocks = true; |
722 | 724 | Scan.ReadType scanReadType = Scan.ReadType.DEFAULT; |
723 | 725 | long bufferSize = 2l * 1024l * 1024l; |
| 726 | + Properties commandProperties; |
724 | 727 |
|
725 | 728 | public TestOptions() { |
726 | 729 | } |
@@ -777,6 +780,11 @@ public TestOptions(TestOptions that) { |
777 | 780 | this.cacheBlocks = that.cacheBlocks; |
778 | 781 | this.scanReadType = that.scanReadType; |
779 | 782 | this.bufferSize = that.bufferSize; |
| 783 | + this.commandProperties = that.commandProperties; |
| 784 | + } |
| 785 | + |
| 786 | + public Properties getCommandProperties() { |
| 787 | + return commandProperties; |
780 | 788 | } |
781 | 789 |
|
782 | 790 | public int getCaching() { |
@@ -1142,10 +1150,10 @@ private static long nextRandomSeed() { |
1142 | 1150 | protected final Configuration conf; |
1143 | 1151 | protected final TestOptions opts; |
1144 | 1152 |
|
1145 | | - private final Status status; |
| 1153 | + protected final Status status; |
1146 | 1154 |
|
1147 | 1155 | private String testName; |
1148 | | - private Histogram latencyHistogram; |
| 1156 | + protected Histogram latencyHistogram; |
1149 | 1157 | private Histogram replicaLatencyHistogram; |
1150 | 1158 | private Histogram valueSizeHistogram; |
1151 | 1159 | private Histogram rpcCallsHistogram; |
@@ -2618,7 +2626,7 @@ protected static void printUsage(final String shortName, final String message) { |
2618 | 2626 | System.err.println(message); |
2619 | 2627 | } |
2620 | 2628 | System.err.print("Usage: hbase " + shortName); |
2621 | | - System.err.println(" <OPTIONS> [-D<property=value>]* <command> <nclients>"); |
| 2629 | + System.err.println(" <OPTIONS> [-D<property=value>]* <command|class> <nclients>"); |
2622 | 2630 | System.err.println(); |
2623 | 2631 | System.err.println("General Options:"); |
2624 | 2632 | System.err.println( |
@@ -2719,6 +2727,13 @@ protected static void printUsage(final String shortName, final String message) { |
2719 | 2727 | System.err.println(String.format(" %-20s %s", command.getName(), command.getDescription())); |
2720 | 2728 | } |
2721 | 2729 | System.err.println(); |
| 2730 | + System.err.println("Class:"); |
| 2731 | + System.err.println("To run any custom implementation of PerformanceEvaluation.Test, " |
| 2732 | + + "provide the classname of the implementaion class in place of " |
| 2733 | + + "command name and it will be loaded at runtime from classpath.:"); |
| 2734 | + System.err.println("Please consider to contribute back " |
| 2735 | + + "this custom test impl into a builtin PE command for the benefit of the community"); |
| 2736 | + System.err.println(); |
2722 | 2737 | System.err.println("Args:"); |
2723 | 2738 | System.err.println(" nclients Integer. Required. Total number of clients " |
2724 | 2739 | + "(and HRegionServers) running. 1 <= value <= 500"); |
@@ -3013,6 +3028,20 @@ static TestOptions parseOpts(Queue<String> args) { |
3013 | 3028 | continue; |
3014 | 3029 | } |
3015 | 3030 |
|
| 3031 | + final String commandPropertiesFile = "--commandPropertiesFile="; |
| 3032 | + if (cmd.startsWith(commandPropertiesFile)) { |
| 3033 | + String fileName = String.valueOf(cmd.substring(commandPropertiesFile.length())); |
| 3034 | + Properties properties = new Properties(); |
| 3035 | + try { |
| 3036 | + properties |
| 3037 | + .load(PerformanceEvaluation.class.getClassLoader().getResourceAsStream(fileName)); |
| 3038 | + opts.commandProperties = properties; |
| 3039 | + } catch (IOException e) { |
| 3040 | + LOG.error("Failed to load metricIds from properties file", e); |
| 3041 | + } |
| 3042 | + continue; |
| 3043 | + } |
| 3044 | + |
3016 | 3045 | validateParsedOpts(opts); |
3017 | 3046 |
|
3018 | 3047 | if (isCommandClass(cmd)) { |
@@ -3126,7 +3155,20 @@ public int run(String[] args) throws Exception { |
3126 | 3155 | } |
3127 | 3156 |
|
3128 | 3157 | private static boolean isCommandClass(String cmd) { |
3129 | | - return COMMANDS.containsKey(cmd); |
| 3158 | + return COMMANDS.containsKey(cmd) || isCustomTestClass(cmd); |
| 3159 | + } |
| 3160 | + |
| 3161 | + private static boolean isCustomTestClass(String cmd) { |
| 3162 | + Class<? extends Test> cmdClass; |
| 3163 | + try { |
| 3164 | + cmdClass = |
| 3165 | + (Class<? extends Test>) PerformanceEvaluation.class.getClassLoader().loadClass(cmd); |
| 3166 | + addCommandDescriptor(cmdClass, cmd, "custom command"); |
| 3167 | + return true; |
| 3168 | + } catch (Throwable th) { |
| 3169 | + LOG.info("No class found for command: " + cmd, th); |
| 3170 | + return false; |
| 3171 | + } |
3130 | 3172 | } |
3131 | 3173 |
|
3132 | 3174 | private static Class<? extends TestBase> determineCommandClass(String cmd) { |
|
0 commit comments