|
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;
|
@@ -358,7 +359,8 @@ static boolean checkTable(Admin admin, TestOptions opts) throws IOException {
|
358 | 359 | // {RegionSplitPolicy,replica count} does not match requested, or when the
|
359 | 360 | // number of column families does not match requested.
|
360 | 361 | if (
|
361 |
| - (exists && opts.presplitRegions != DEFAULT_OPTS.presplitRegions) |
| 362 | + (exists && opts.presplitRegions != DEFAULT_OPTS.presplitRegions |
| 363 | + && opts.presplitRegions != admin.getRegions(tableName).size()) |
362 | 364 | || (!isReadCmd && desc != null
|
363 | 365 | && !StringUtils.equals(desc.getRegionSplitPolicyClassName(), opts.splitPolicy))
|
364 | 366 | || (!isReadCmd && desc != null && desc.getRegionReplication() != opts.replicas)
|
@@ -719,6 +721,7 @@ static class TestOptions {
|
719 | 721 | boolean cacheBlocks = true;
|
720 | 722 | Scan.ReadType scanReadType = Scan.ReadType.DEFAULT;
|
721 | 723 | long bufferSize = 2l * 1024l * 1024l;
|
| 724 | + Properties commandProperties; |
722 | 725 |
|
723 | 726 | public TestOptions() {
|
724 | 727 | }
|
@@ -775,6 +778,11 @@ public TestOptions(TestOptions that) {
|
775 | 778 | this.cacheBlocks = that.cacheBlocks;
|
776 | 779 | this.scanReadType = that.scanReadType;
|
777 | 780 | this.bufferSize = that.bufferSize;
|
| 781 | + this.commandProperties = that.commandProperties; |
| 782 | + } |
| 783 | + |
| 784 | + public Properties getCommandProperties() { |
| 785 | + return commandProperties; |
778 | 786 | }
|
779 | 787 |
|
780 | 788 | public int getCaching() {
|
@@ -1140,10 +1148,10 @@ private static long nextRandomSeed() {
|
1140 | 1148 | protected final Configuration conf;
|
1141 | 1149 | protected final TestOptions opts;
|
1142 | 1150 |
|
1143 |
| - private final Status status; |
| 1151 | + protected final Status status; |
1144 | 1152 |
|
1145 | 1153 | private String testName;
|
1146 |
| - private Histogram latencyHistogram; |
| 1154 | + protected Histogram latencyHistogram; |
1147 | 1155 | private Histogram replicaLatencyHistogram;
|
1148 | 1156 | private Histogram valueSizeHistogram;
|
1149 | 1157 | private Histogram rpcCallsHistogram;
|
@@ -2573,7 +2581,7 @@ protected static void printUsage(final String shortName, final String message) {
|
2573 | 2581 | System.err.println(message);
|
2574 | 2582 | }
|
2575 | 2583 | System.err.print("Usage: hbase " + shortName);
|
2576 |
| - System.err.println(" <OPTIONS> [-D<property=value>]* <command> <nclients>"); |
| 2584 | + System.err.println(" <OPTIONS> [-D<property=value>]* <command|class> <nclients>"); |
2577 | 2585 | System.err.println();
|
2578 | 2586 | System.err.println("General Options:");
|
2579 | 2587 | System.err.println(
|
@@ -2674,6 +2682,13 @@ protected static void printUsage(final String shortName, final String message) {
|
2674 | 2682 | System.err.println(String.format(" %-20s %s", command.getName(), command.getDescription()));
|
2675 | 2683 | }
|
2676 | 2684 | System.err.println();
|
| 2685 | + System.err.println("Class:"); |
| 2686 | + System.err.println("To run any custom implementation of PerformanceEvaluation.Test, " |
| 2687 | + + "provide the classname of the implementaion class in place of " |
| 2688 | + + "command name and it will be loaded at runtime from classpath.:"); |
| 2689 | + System.err.println("Please consider to contribute back " |
| 2690 | + + "this custom test impl into a builtin PE command for the benefit of the community"); |
| 2691 | + System.err.println(); |
2677 | 2692 | System.err.println("Args:");
|
2678 | 2693 | System.err.println(" nclients Integer. Required. Total number of clients "
|
2679 | 2694 | + "(and HRegionServers) running. 1 <= value <= 500");
|
@@ -2968,6 +2983,20 @@ static TestOptions parseOpts(Queue<String> args) {
|
2968 | 2983 | continue;
|
2969 | 2984 | }
|
2970 | 2985 |
|
| 2986 | + final String commandPropertiesFile = "--commandPropertiesFile="; |
| 2987 | + if (cmd.startsWith(commandPropertiesFile)) { |
| 2988 | + String fileName = String.valueOf(cmd.substring(commandPropertiesFile.length())); |
| 2989 | + Properties properties = new Properties(); |
| 2990 | + try { |
| 2991 | + properties |
| 2992 | + .load(PerformanceEvaluation.class.getClassLoader().getResourceAsStream(fileName)); |
| 2993 | + opts.commandProperties = properties; |
| 2994 | + } catch (IOException e) { |
| 2995 | + LOG.error("Failed to load metricIds from properties file", e); |
| 2996 | + } |
| 2997 | + continue; |
| 2998 | + } |
| 2999 | + |
2971 | 3000 | validateParsedOpts(opts);
|
2972 | 3001 |
|
2973 | 3002 | if (isCommandClass(cmd)) {
|
@@ -3081,7 +3110,20 @@ public int run(String[] args) throws Exception {
|
3081 | 3110 | }
|
3082 | 3111 |
|
3083 | 3112 | private static boolean isCommandClass(String cmd) {
|
3084 |
| - return COMMANDS.containsKey(cmd); |
| 3113 | + return COMMANDS.containsKey(cmd) || isCustomTestClass(cmd); |
| 3114 | + } |
| 3115 | + |
| 3116 | + private static boolean isCustomTestClass(String cmd) { |
| 3117 | + Class<? extends Test> cmdClass; |
| 3118 | + try { |
| 3119 | + cmdClass = |
| 3120 | + (Class<? extends Test>) PerformanceEvaluation.class.getClassLoader().loadClass(cmd); |
| 3121 | + addCommandDescriptor(cmdClass, cmd, "custom command"); |
| 3122 | + return true; |
| 3123 | + } catch (Throwable th) { |
| 3124 | + LOG.info("No class found for command: " + cmd, th); |
| 3125 | + return false; |
| 3126 | + } |
3085 | 3127 | }
|
3086 | 3128 |
|
3087 | 3129 | private static Class<? extends TestBase> determineCommandClass(String cmd) {
|
|
0 commit comments