|
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; |
@@ -362,7 +363,8 @@ static boolean checkTable(Admin admin, TestOptions opts) throws IOException { |
362 | 363 | // {RegionSplitPolicy,replica count} does not match requested, or when the |
363 | 364 | // number of column families does not match requested. |
364 | 365 | if ( |
365 | | - (exists && opts.presplitRegions != DEFAULT_OPTS.presplitRegions) |
| 366 | + (exists && opts.presplitRegions != DEFAULT_OPTS.presplitRegions |
| 367 | + && opts.presplitRegions != admin.getRegions(tableName).size()) |
366 | 368 | || (!isReadCmd && desc != null |
367 | 369 | && !StringUtils.equals(desc.getRegionSplitPolicyClassName(), opts.splitPolicy)) |
368 | 370 | || (!isReadCmd && desc != null && desc.getRegionReplication() != opts.replicas) |
@@ -730,6 +732,7 @@ static class TestOptions { |
730 | 732 | boolean cacheBlocks = true; |
731 | 733 | Scan.ReadType scanReadType = Scan.ReadType.DEFAULT; |
732 | 734 | long bufferSize = 2l * 1024l * 1024l; |
| 735 | + Properties commandProperties; |
733 | 736 |
|
734 | 737 | public TestOptions() { |
735 | 738 | } |
@@ -786,6 +789,11 @@ public TestOptions(TestOptions that) { |
786 | 789 | this.cacheBlocks = that.cacheBlocks; |
787 | 790 | this.scanReadType = that.scanReadType; |
788 | 791 | this.bufferSize = that.bufferSize; |
| 792 | + this.commandProperties = that.commandProperties; |
| 793 | + } |
| 794 | + |
| 795 | + public Properties getCommandProperties() { |
| 796 | + return commandProperties; |
789 | 797 | } |
790 | 798 |
|
791 | 799 | public int getCaching() { |
@@ -1151,10 +1159,10 @@ private static long nextRandomSeed() { |
1151 | 1159 | protected final Configuration conf; |
1152 | 1160 | protected final TestOptions opts; |
1153 | 1161 |
|
1154 | | - private final Status status; |
| 1162 | + protected final Status status; |
1155 | 1163 |
|
1156 | 1164 | private String testName; |
1157 | | - private Histogram latencyHistogram; |
| 1165 | + protected Histogram latencyHistogram; |
1158 | 1166 | private Histogram replicaLatencyHistogram; |
1159 | 1167 | private Histogram valueSizeHistogram; |
1160 | 1168 | private Histogram rpcCallsHistogram; |
@@ -2626,7 +2634,7 @@ protected static void printUsage(final String shortName, final String message) { |
2626 | 2634 | System.err.println(message); |
2627 | 2635 | } |
2628 | 2636 | System.err.print("Usage: hbase " + shortName); |
2629 | | - System.err.println(" <OPTIONS> [-D<property=value>]* <command> <nclients>"); |
| 2637 | + System.err.println(" <OPTIONS> [-D<property=value>]* <command|class> <nclients>"); |
2630 | 2638 | System.err.println(); |
2631 | 2639 | System.err.println("General Options:"); |
2632 | 2640 | System.err.println( |
@@ -2727,6 +2735,13 @@ protected static void printUsage(final String shortName, final String message) { |
2727 | 2735 | System.err.println(String.format(" %-20s %s", command.getName(), command.getDescription())); |
2728 | 2736 | } |
2729 | 2737 | System.err.println(); |
| 2738 | + System.err.println("Class:"); |
| 2739 | + System.err.println("To run any custom implementation of PerformanceEvaluation.Test, " |
| 2740 | + + "provide the classname of the implementaion class in place of " |
| 2741 | + + "command name and it will be loaded at runtime from classpath.:"); |
| 2742 | + System.err.println("Please consider to contribute back " |
| 2743 | + + "this custom test impl into a builtin PE command for the benefit of the community"); |
| 2744 | + System.err.println(); |
2730 | 2745 | System.err.println("Args:"); |
2731 | 2746 | System.err.println(" nclients Integer. Required. Total number of clients " |
2732 | 2747 | + "(and HRegionServers) running. 1 <= value <= 500"); |
@@ -3021,6 +3036,20 @@ static TestOptions parseOpts(Queue<String> args) { |
3021 | 3036 | continue; |
3022 | 3037 | } |
3023 | 3038 |
|
| 3039 | + final String commandPropertiesFile = "--commandPropertiesFile="; |
| 3040 | + if (cmd.startsWith(commandPropertiesFile)) { |
| 3041 | + String fileName = String.valueOf(cmd.substring(commandPropertiesFile.length())); |
| 3042 | + Properties properties = new Properties(); |
| 3043 | + try { |
| 3044 | + properties |
| 3045 | + .load(PerformanceEvaluation.class.getClassLoader().getResourceAsStream(fileName)); |
| 3046 | + opts.commandProperties = properties; |
| 3047 | + } catch (IOException e) { |
| 3048 | + LOG.error("Failed to load metricIds from properties file", e); |
| 3049 | + } |
| 3050 | + continue; |
| 3051 | + } |
| 3052 | + |
3024 | 3053 | validateParsedOpts(opts); |
3025 | 3054 |
|
3026 | 3055 | if (isCommandClass(cmd)) { |
@@ -3134,7 +3163,20 @@ public int run(String[] args) throws Exception { |
3134 | 3163 | } |
3135 | 3164 |
|
3136 | 3165 | private static boolean isCommandClass(String cmd) { |
3137 | | - return COMMANDS.containsKey(cmd); |
| 3166 | + return COMMANDS.containsKey(cmd) || isCustomTestClass(cmd); |
| 3167 | + } |
| 3168 | + |
| 3169 | + private static boolean isCustomTestClass(String cmd) { |
| 3170 | + Class<? extends Test> cmdClass; |
| 3171 | + try { |
| 3172 | + cmdClass = |
| 3173 | + (Class<? extends Test>) PerformanceEvaluation.class.getClassLoader().loadClass(cmd); |
| 3174 | + addCommandDescriptor(cmdClass, cmd, "custom command"); |
| 3175 | + return true; |
| 3176 | + } catch (Throwable th) { |
| 3177 | + LOG.info("No class found for command: " + cmd, th); |
| 3178 | + return false; |
| 3179 | + } |
3138 | 3180 | } |
3139 | 3181 |
|
3140 | 3182 | private static Class<? extends TestBase> determineCommandClass(String cmd) { |
|
0 commit comments