http://git-wip-us.apache.org/repos/asf/hbase-site/blob/f2065178/testdevapidocs/src-html/org/apache/hadoop/hbase/PerformanceEvaluation.RandomScanWithRange10Test.html ---------------------------------------------------------------------- diff --git a/testdevapidocs/src-html/org/apache/hadoop/hbase/PerformanceEvaluation.RandomScanWithRange10Test.html b/testdevapidocs/src-html/org/apache/hadoop/hbase/PerformanceEvaluation.RandomScanWithRange10Test.html index 2510283..418c60c 100644 --- a/testdevapidocs/src-html/org/apache/hadoop/hbase/PerformanceEvaluation.RandomScanWithRange10Test.html +++ b/testdevapidocs/src-html/org/apache/hadoop/hbase/PerformanceEvaluation.RandomScanWithRange10Test.html @@ -77,77 +77,77 @@ <span class="sourceLineNo">069</span>import org.apache.hadoop.hbase.client.RowMutations;<a name="line.69"></a> <span class="sourceLineNo">070</span>import org.apache.hadoop.hbase.client.Scan;<a name="line.70"></a> <span class="sourceLineNo">071</span>import org.apache.hadoop.hbase.client.Table;<a name="line.71"></a> -<span class="sourceLineNo">072</span>import org.apache.hadoop.hbase.filter.BinaryComparator;<a name="line.72"></a> -<span class="sourceLineNo">073</span>import org.apache.hadoop.hbase.filter.Filter;<a name="line.73"></a> -<span class="sourceLineNo">074</span>import org.apache.hadoop.hbase.filter.FilterAllFilter;<a name="line.74"></a> -<span class="sourceLineNo">075</span>import org.apache.hadoop.hbase.filter.FilterList;<a name="line.75"></a> -<span class="sourceLineNo">076</span>import org.apache.hadoop.hbase.filter.PageFilter;<a name="line.76"></a> -<span class="sourceLineNo">077</span>import org.apache.hadoop.hbase.filter.SingleColumnValueFilter;<a name="line.77"></a> -<span class="sourceLineNo">078</span>import org.apache.hadoop.hbase.filter.WhileMatchFilter;<a name="line.78"></a> -<span class="sourceLineNo">079</span>import org.apache.hadoop.hbase.io.compress.Compression;<a name="line.79"></a> -<span class="sourceLineNo">080</span>import org.apache.hadoop.hbase.io.encoding.DataBlockEncoding;<a name="line.80"></a> -<span class="sourceLineNo">081</span>import org.apache.hadoop.hbase.io.hfile.RandomDistribution;<a name="line.81"></a> -<span class="sourceLineNo">082</span>import org.apache.hadoop.hbase.mapreduce.TableMapReduceUtil;<a name="line.82"></a> -<span class="sourceLineNo">083</span>import org.apache.hadoop.hbase.regionserver.BloomType;<a name="line.83"></a> -<span class="sourceLineNo">084</span>import org.apache.hadoop.hbase.regionserver.CompactingMemStore;<a name="line.84"></a> -<span class="sourceLineNo">085</span>import org.apache.hadoop.hbase.trace.HBaseHTraceConfiguration;<a name="line.85"></a> -<span class="sourceLineNo">086</span>import org.apache.hadoop.hbase.trace.SpanReceiverHost;<a name="line.86"></a> -<span class="sourceLineNo">087</span>import org.apache.hadoop.hbase.trace.TraceUtil;<a name="line.87"></a> -<span class="sourceLineNo">088</span>import org.apache.hadoop.hbase.util.ByteArrayHashKey;<a name="line.88"></a> -<span class="sourceLineNo">089</span>import org.apache.hadoop.hbase.util.Bytes;<a name="line.89"></a> -<span class="sourceLineNo">090</span>import org.apache.hadoop.hbase.util.Hash;<a name="line.90"></a> -<span class="sourceLineNo">091</span>import org.apache.hadoop.hbase.util.MurmurHash;<a name="line.91"></a> -<span class="sourceLineNo">092</span>import org.apache.hadoop.hbase.util.Pair;<a name="line.92"></a> -<span class="sourceLineNo">093</span>import org.apache.hadoop.hbase.util.YammerHistogramUtils;<a name="line.93"></a> -<span class="sourceLineNo">094</span>import org.apache.hadoop.io.LongWritable;<a name="line.94"></a> -<span class="sourceLineNo">095</span>import org.apache.hadoop.io.Text;<a name="line.95"></a> -<span class="sourceLineNo">096</span>import org.apache.hadoop.mapreduce.Job;<a name="line.96"></a> -<span class="sourceLineNo">097</span>import org.apache.hadoop.mapreduce.Mapper;<a name="line.97"></a> -<span class="sourceLineNo">098</span>import org.apache.hadoop.mapreduce.lib.input.NLineInputFormat;<a name="line.98"></a> -<span class="sourceLineNo">099</span>import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat;<a name="line.99"></a> -<span class="sourceLineNo">100</span>import org.apache.hadoop.mapreduce.lib.reduce.LongSumReducer;<a name="line.100"></a> -<span class="sourceLineNo">101</span>import org.apache.hadoop.util.Tool;<a name="line.101"></a> -<span class="sourceLineNo">102</span>import org.apache.hadoop.util.ToolRunner;<a name="line.102"></a> -<span class="sourceLineNo">103</span>import org.apache.htrace.core.ProbabilitySampler;<a name="line.103"></a> -<span class="sourceLineNo">104</span>import org.apache.htrace.core.Sampler;<a name="line.104"></a> -<span class="sourceLineNo">105</span>import org.apache.htrace.core.TraceScope;<a name="line.105"></a> -<span class="sourceLineNo">106</span>import org.apache.yetus.audience.InterfaceAudience;<a name="line.106"></a> -<span class="sourceLineNo">107</span>import org.slf4j.Logger;<a name="line.107"></a> -<span class="sourceLineNo">108</span>import org.slf4j.LoggerFactory;<a name="line.108"></a> -<span class="sourceLineNo">109</span>import org.apache.hbase.thirdparty.com.google.common.base.MoreObjects;<a name="line.109"></a> -<span class="sourceLineNo">110</span>import org.apache.hbase.thirdparty.com.google.common.util.concurrent.ThreadFactoryBuilder;<a name="line.110"></a> -<span class="sourceLineNo">111</span><a name="line.111"></a> -<span class="sourceLineNo">112</span>/**<a name="line.112"></a> -<span class="sourceLineNo">113</span> * Script used evaluating HBase performance and scalability. Runs a HBase<a name="line.113"></a> -<span class="sourceLineNo">114</span> * client that steps through one of a set of hardcoded tests or 'experiments'<a name="line.114"></a> -<span class="sourceLineNo">115</span> * (e.g. a random reads test, a random writes test, etc.). Pass on the<a name="line.115"></a> -<span class="sourceLineNo">116</span> * command-line which test to run and how many clients are participating in<a name="line.116"></a> -<span class="sourceLineNo">117</span> * this experiment. Run {@code PerformanceEvaluation --help} to obtain usage.<a name="line.117"></a> -<span class="sourceLineNo">118</span> *<a name="line.118"></a> -<span class="sourceLineNo">119</span> * <p>This class sets up and runs the evaluation programs described in<a name="line.119"></a> -<span class="sourceLineNo">120</span> * Section 7, <i>Performance Evaluation</i>, of the <a<a name="line.120"></a> -<span class="sourceLineNo">121</span> * href="http://labs.google.com/papers/bigtable.html">Bigtable</a><a name="line.121"></a> -<span class="sourceLineNo">122</span> * paper, pages 8-10.<a name="line.122"></a> -<span class="sourceLineNo">123</span> *<a name="line.123"></a> -<span class="sourceLineNo">124</span> * <p>By default, runs as a mapreduce job where each mapper runs a single test<a name="line.124"></a> -<span class="sourceLineNo">125</span> * client. Can also run as a non-mapreduce, multithreaded application by<a name="line.125"></a> -<span class="sourceLineNo">126</span> * specifying {@code --nomapred}. Each client does about 1GB of data, unless<a name="line.126"></a> -<span class="sourceLineNo">127</span> * specified otherwise.<a name="line.127"></a> -<span class="sourceLineNo">128</span> */<a name="line.128"></a> -<span class="sourceLineNo">129</span>@InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.TOOLS)<a name="line.129"></a> -<span class="sourceLineNo">130</span>public class PerformanceEvaluation extends Configured implements Tool {<a name="line.130"></a> -<span class="sourceLineNo">131</span> static final String RANDOM_SEEK_SCAN = "randomSeekScan";<a name="line.131"></a> -<span class="sourceLineNo">132</span> static final String RANDOM_READ = "randomRead";<a name="line.132"></a> -<span class="sourceLineNo">133</span> private static final Logger LOG = LoggerFactory.getLogger(PerformanceEvaluation.class.getName());<a name="line.133"></a> -<span class="sourceLineNo">134</span> private static final ObjectMapper MAPPER = new ObjectMapper();<a name="line.134"></a> -<span class="sourceLineNo">135</span> static {<a name="line.135"></a> -<span class="sourceLineNo">136</span> MAPPER.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true);<a name="line.136"></a> -<span class="sourceLineNo">137</span> }<a name="line.137"></a> -<span class="sourceLineNo">138</span><a name="line.138"></a> -<span class="sourceLineNo">139</span> public static final String TABLE_NAME = "TestTable";<a name="line.139"></a> -<span class="sourceLineNo">140</span> public static final byte[] FAMILY_NAME = Bytes.toBytes("info");<a name="line.140"></a> -<span class="sourceLineNo">141</span> public static final byte [] COLUMN_ZERO = Bytes.toBytes("" + 0);<a name="line.141"></a> -<span class="sourceLineNo">142</span> public static final byte [] QUALIFIER_NAME = COLUMN_ZERO;<a name="line.142"></a> +<span class="sourceLineNo">072</span>import org.apache.hadoop.hbase.client.metrics.ScanMetrics;<a name="line.72"></a> +<span class="sourceLineNo">073</span>import org.apache.hadoop.hbase.filter.BinaryComparator;<a name="line.73"></a> +<span class="sourceLineNo">074</span>import org.apache.hadoop.hbase.filter.Filter;<a name="line.74"></a> +<span class="sourceLineNo">075</span>import org.apache.hadoop.hbase.filter.FilterAllFilter;<a name="line.75"></a> +<span class="sourceLineNo">076</span>import org.apache.hadoop.hbase.filter.FilterList;<a name="line.76"></a> +<span class="sourceLineNo">077</span>import org.apache.hadoop.hbase.filter.PageFilter;<a name="line.77"></a> +<span class="sourceLineNo">078</span>import org.apache.hadoop.hbase.filter.SingleColumnValueFilter;<a name="line.78"></a> +<span class="sourceLineNo">079</span>import org.apache.hadoop.hbase.filter.WhileMatchFilter;<a name="line.79"></a> +<span class="sourceLineNo">080</span>import org.apache.hadoop.hbase.io.compress.Compression;<a name="line.80"></a> +<span class="sourceLineNo">081</span>import org.apache.hadoop.hbase.io.encoding.DataBlockEncoding;<a name="line.81"></a> +<span class="sourceLineNo">082</span>import org.apache.hadoop.hbase.io.hfile.RandomDistribution;<a name="line.82"></a> +<span class="sourceLineNo">083</span>import org.apache.hadoop.hbase.mapreduce.TableMapReduceUtil;<a name="line.83"></a> +<span class="sourceLineNo">084</span>import org.apache.hadoop.hbase.regionserver.BloomType;<a name="line.84"></a> +<span class="sourceLineNo">085</span>import org.apache.hadoop.hbase.regionserver.CompactingMemStore;<a name="line.85"></a> +<span class="sourceLineNo">086</span>import org.apache.hadoop.hbase.trace.HBaseHTraceConfiguration;<a name="line.86"></a> +<span class="sourceLineNo">087</span>import org.apache.hadoop.hbase.trace.SpanReceiverHost;<a name="line.87"></a> +<span class="sourceLineNo">088</span>import org.apache.hadoop.hbase.trace.TraceUtil;<a name="line.88"></a> +<span class="sourceLineNo">089</span>import org.apache.hadoop.hbase.util.ByteArrayHashKey;<a name="line.89"></a> +<span class="sourceLineNo">090</span>import org.apache.hadoop.hbase.util.Bytes;<a name="line.90"></a> +<span class="sourceLineNo">091</span>import org.apache.hadoop.hbase.util.Hash;<a name="line.91"></a> +<span class="sourceLineNo">092</span>import org.apache.hadoop.hbase.util.MurmurHash;<a name="line.92"></a> +<span class="sourceLineNo">093</span>import org.apache.hadoop.hbase.util.Pair;<a name="line.93"></a> +<span class="sourceLineNo">094</span>import org.apache.hadoop.hbase.util.YammerHistogramUtils;<a name="line.94"></a> +<span class="sourceLineNo">095</span>import org.apache.hadoop.io.LongWritable;<a name="line.95"></a> +<span class="sourceLineNo">096</span>import org.apache.hadoop.io.Text;<a name="line.96"></a> +<span class="sourceLineNo">097</span>import org.apache.hadoop.mapreduce.Job;<a name="line.97"></a> +<span class="sourceLineNo">098</span>import org.apache.hadoop.mapreduce.Mapper;<a name="line.98"></a> +<span class="sourceLineNo">099</span>import org.apache.hadoop.mapreduce.lib.input.NLineInputFormat;<a name="line.99"></a> +<span class="sourceLineNo">100</span>import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat;<a name="line.100"></a> +<span class="sourceLineNo">101</span>import org.apache.hadoop.mapreduce.lib.reduce.LongSumReducer;<a name="line.101"></a> +<span class="sourceLineNo">102</span>import org.apache.hadoop.util.Tool;<a name="line.102"></a> +<span class="sourceLineNo">103</span>import org.apache.hadoop.util.ToolRunner;<a name="line.103"></a> +<span class="sourceLineNo">104</span>import org.apache.htrace.core.ProbabilitySampler;<a name="line.104"></a> +<span class="sourceLineNo">105</span>import org.apache.htrace.core.Sampler;<a name="line.105"></a> +<span class="sourceLineNo">106</span>import org.apache.htrace.core.TraceScope;<a name="line.106"></a> +<span class="sourceLineNo">107</span>import org.apache.yetus.audience.InterfaceAudience;<a name="line.107"></a> +<span class="sourceLineNo">108</span>import org.slf4j.Logger;<a name="line.108"></a> +<span class="sourceLineNo">109</span>import org.slf4j.LoggerFactory;<a name="line.109"></a> +<span class="sourceLineNo">110</span>import org.apache.hbase.thirdparty.com.google.common.base.MoreObjects;<a name="line.110"></a> +<span class="sourceLineNo">111</span>import org.apache.hbase.thirdparty.com.google.common.util.concurrent.ThreadFactoryBuilder;<a name="line.111"></a> +<span class="sourceLineNo">112</span><a name="line.112"></a> +<span class="sourceLineNo">113</span>/**<a name="line.113"></a> +<span class="sourceLineNo">114</span> * Script used evaluating HBase performance and scalability. Runs a HBase<a name="line.114"></a> +<span class="sourceLineNo">115</span> * client that steps through one of a set of hardcoded tests or 'experiments'<a name="line.115"></a> +<span class="sourceLineNo">116</span> * (e.g. a random reads test, a random writes test, etc.). Pass on the<a name="line.116"></a> +<span class="sourceLineNo">117</span> * command-line which test to run and how many clients are participating in<a name="line.117"></a> +<span class="sourceLineNo">118</span> * this experiment. Run {@code PerformanceEvaluation --help} to obtain usage.<a name="line.118"></a> +<span class="sourceLineNo">119</span> *<a name="line.119"></a> +<span class="sourceLineNo">120</span> * <p>This class sets up and runs the evaluation programs described in<a name="line.120"></a> +<span class="sourceLineNo">121</span> * Section 7, <i>Performance Evaluation</i>, of the <a<a name="line.121"></a> +<span class="sourceLineNo">122</span> * href="http://labs.google.com/papers/bigtable.html">Bigtable</a><a name="line.122"></a> +<span class="sourceLineNo">123</span> * paper, pages 8-10.<a name="line.123"></a> +<span class="sourceLineNo">124</span> *<a name="line.124"></a> +<span class="sourceLineNo">125</span> * <p>By default, runs as a mapreduce job where each mapper runs a single test<a name="line.125"></a> +<span class="sourceLineNo">126</span> * client. Can also run as a non-mapreduce, multithreaded application by<a name="line.126"></a> +<span class="sourceLineNo">127</span> * specifying {@code --nomapred}. Each client does about 1GB of data, unless<a name="line.127"></a> +<span class="sourceLineNo">128</span> * specified otherwise.<a name="line.128"></a> +<span class="sourceLineNo">129</span> */<a name="line.129"></a> +<span class="sourceLineNo">130</span>@InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.TOOLS)<a name="line.130"></a> +<span class="sourceLineNo">131</span>public class PerformanceEvaluation extends Configured implements Tool {<a name="line.131"></a> +<span class="sourceLineNo">132</span> static final String RANDOM_SEEK_SCAN = "randomSeekScan";<a name="line.132"></a> +<span class="sourceLineNo">133</span> static final String RANDOM_READ = "randomRead";<a name="line.133"></a> +<span class="sourceLineNo">134</span> private static final Logger LOG = LoggerFactory.getLogger(PerformanceEvaluation.class.getName());<a name="line.134"></a> +<span class="sourceLineNo">135</span> private static final ObjectMapper MAPPER = new ObjectMapper();<a name="line.135"></a> +<span class="sourceLineNo">136</span> static {<a name="line.136"></a> +<span class="sourceLineNo">137</span> MAPPER.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true);<a name="line.137"></a> +<span class="sourceLineNo">138</span> }<a name="line.138"></a> +<span class="sourceLineNo">139</span><a name="line.139"></a> +<span class="sourceLineNo">140</span> public static final String TABLE_NAME = "TestTable";<a name="line.140"></a> +<span class="sourceLineNo">141</span> public static final byte[] FAMILY_NAME = Bytes.toBytes("info");<a name="line.141"></a> +<span class="sourceLineNo">142</span> public static final byte [] COLUMN_ZERO = Bytes.toBytes("" + 0);<a name="line.142"></a> <span class="sourceLineNo">143</span> public static final int DEFAULT_VALUE_LENGTH = 1000;<a name="line.143"></a> <span class="sourceLineNo">144</span> public static final int ROW_LENGTH = 26;<a name="line.144"></a> <span class="sourceLineNo">145</span><a name="line.145"></a> @@ -1055,1591 +1055,1698 @@ <span class="sourceLineNo">1047</span> private String testName;<a name="line.1047"></a> <span class="sourceLineNo">1048</span> private Histogram latencyHistogram;<a name="line.1048"></a> <span class="sourceLineNo">1049</span> private Histogram valueSizeHistogram;<a name="line.1049"></a> -<span class="sourceLineNo">1050</span> private RandomDistribution.Zipf zipf;<a name="line.1050"></a> -<span class="sourceLineNo">1051</span><a name="line.1051"></a> -<span class="sourceLineNo">1052</span> /**<a name="line.1052"></a> -<span class="sourceLineNo">1053</span> * Note that all subclasses of this class must provide a public constructor<a name="line.1053"></a> -<span class="sourceLineNo">1054</span> * that has the exact same list of arguments.<a name="line.1054"></a> -<span class="sourceLineNo">1055</span> */<a name="line.1055"></a> -<span class="sourceLineNo">1056</span> TestBase(final Configuration conf, final TestOptions options, final Status status) {<a name="line.1056"></a> -<span class="sourceLineNo">1057</span> this.conf = conf;<a name="line.1057"></a> -<span class="sourceLineNo">1058</span> this.receiverHost = this.conf == null? null: SpanReceiverHost.getInstance(conf);<a name="line.1058"></a> -<span class="sourceLineNo">1059</span> this.opts = options;<a name="line.1059"></a> -<span class="sourceLineNo">1060</span> this.status = status;<a name="line.1060"></a> -<span class="sourceLineNo">1061</span> this.testName = this.getClass().getSimpleName();<a name="line.1061"></a> -<span class="sourceLineNo">1062</span> if (options.traceRate >= 1.0) {<a name="line.1062"></a> -<span class="sourceLineNo">1063</span> this.traceSampler = Sampler.ALWAYS;<a name="line.1063"></a> -<span class="sourceLineNo">1064</span> } else if (options.traceRate > 0.0) {<a name="line.1064"></a> -<span class="sourceLineNo">1065</span> conf.setDouble("hbase.sampler.fraction", options.traceRate);<a name="line.1065"></a> -<span class="sourceLineNo">1066</span> this.traceSampler = new ProbabilitySampler(new HBaseHTraceConfiguration(conf));<a name="line.1066"></a> -<span class="sourceLineNo">1067</span> } else {<a name="line.1067"></a> -<span class="sourceLineNo">1068</span> this.traceSampler = Sampler.NEVER;<a name="line.1068"></a> -<span class="sourceLineNo">1069</span> }<a name="line.1069"></a> -<span class="sourceLineNo">1070</span> everyN = (int) (opts.totalRows / (opts.totalRows * opts.sampleRate));<a name="line.1070"></a> -<span class="sourceLineNo">1071</span> if (options.isValueZipf()) {<a name="line.1071"></a> -<span class="sourceLineNo">1072</span> this.zipf = new RandomDistribution.Zipf(this.rand, 1, options.getValueSize(), 1.2);<a name="line.1072"></a> -<span class="sourceLineNo">1073</span> }<a name="line.1073"></a> -<span class="sourceLineNo">1074</span> LOG.info("Sampling 1 every " + everyN + " out of " + opts.perClientRunRows + " total rows.");<a name="line.1074"></a> -<span class="sourceLineNo">1075</span> }<a name="line.1075"></a> -<span class="sourceLineNo">1076</span><a name="line.1076"></a> -<span class="sourceLineNo">1077</span> int getValueLength(final Random r) {<a name="line.1077"></a> -<span class="sourceLineNo">1078</span> if (this.opts.isValueRandom()) {<a name="line.1078"></a> -<span class="sourceLineNo">1079</span> return r.nextInt(opts.valueSize);<a name="line.1079"></a> -<span class="sourceLineNo">1080</span> } else if (this.opts.isValueZipf()) {<a name="line.1080"></a> -<span class="sourceLineNo">1081</span> return Math.abs(this.zipf.nextInt());<a name="line.1081"></a> -<span class="sourceLineNo">1082</span> } else {<a name="line.1082"></a> -<span class="sourceLineNo">1083</span> return opts.valueSize;<a name="line.1083"></a> -<span class="sourceLineNo">1084</span> }<a name="line.1084"></a> -<span class="sourceLineNo">1085</span> }<a name="line.1085"></a> -<span class="sourceLineNo">1086</span><a name="line.1086"></a> -<span class="sourceLineNo">1087</span> void updateValueSize(final Result [] rs) throws IOException {<a name="line.1087"></a> -<span class="sourceLineNo">1088</span> if (rs == null || !isRandomValueSize()) return;<a name="line.1088"></a> -<span class="sourceLineNo">1089</span> for (Result r: rs) updateValueSize(r);<a name="line.1089"></a> -<span class="sourceLineNo">1090</span> }<a name="line.1090"></a> -<span class="sourceLineNo">1091</span><a name="line.1091"></a> -<span class="sourceLineNo">1092</span> void updateValueSize(final Result r) throws IOException {<a name="line.1092"></a> -<span class="sourceLineNo">1093</span> if (r == null || !isRandomValueSize()) return;<a name="line.1093"></a> -<span class="sourceLineNo">1094</span> int size = 0;<a name="line.1094"></a> -<span class="sourceLineNo">1095</span> for (CellScanner scanner = r.cellScanner(); scanner.advance();) {<a name="line.1095"></a> -<span class="sourceLineNo">1096</span> size += scanner.current().getValueLength();<a name="line.1096"></a> -<span class="sourceLineNo">1097</span> }<a name="line.1097"></a> -<span class="sourceLineNo">1098</span> updateValueSize(size);<a name="line.1098"></a> -<span class="sourceLineNo">1099</span> }<a name="line.1099"></a> -<span class="sourceLineNo">1100</span><a name="line.1100"></a> -<span class="sourceLineNo">1101</span> void updateValueSize(final int valueSize) {<a name="line.1101"></a> -<span class="sourceLineNo">1102</span> if (!isRandomValueSize()) return;<a name="line.1102"></a> -<span class="sourceLineNo">1103</span> this.valueSizeHistogram.update(valueSize);<a name="line.1103"></a> -<span class="sourceLineNo">1104</span> }<a name="line.1104"></a> -<span class="sourceLineNo">1105</span><a name="line.1105"></a> -<span class="sourceLineNo">1106</span> String generateStatus(final int sr, final int i, final int lr) {<a name="line.1106"></a> -<span class="sourceLineNo">1107</span> return sr + "/" + i + "/" + lr + ", latency " + getShortLatencyReport() +<a name="line.1107"></a> -<span class="sourceLineNo">1108</span> (!isRandomValueSize()? "": ", value size " + getShortValueSizeReport());<a name="line.1108"></a> -<span class="sourceLineNo">1109</span> }<a name="line.1109"></a> -<span class="sourceLineNo">1110</span><a name="line.1110"></a> -<span class="sourceLineNo">1111</span> boolean isRandomValueSize() {<a name="line.1111"></a> -<span class="sourceLineNo">1112</span> return opts.valueRandom;<a name="line.1112"></a> -<span class="sourceLineNo">1113</span> }<a name="line.1113"></a> -<span class="sourceLineNo">1114</span><a name="line.1114"></a> -<span class="sourceLineNo">1115</span> protected int getReportingPeriod() {<a name="line.1115"></a> -<span class="sourceLineNo">1116</span> return opts.period;<a name="line.1116"></a> -<span class="sourceLineNo">1117</span> }<a name="line.1117"></a> -<span class="sourceLineNo">1118</span><a name="line.1118"></a> -<span class="sourceLineNo">1119</span> /**<a name="line.1119"></a> -<span class="sourceLineNo">1120</span> * Populated by testTakedown. Only implemented by RandomReadTest at the moment.<a name="line.1120"></a> -<span class="sourceLineNo">1121</span> */<a name="line.1121"></a> -<span class="sourceLineNo">1122</span> public Histogram getLatencyHistogram() {<a name="line.1122"></a> -<span class="sourceLineNo">1123</span> return latencyHistogram;<a name="line.1123"></a> -<span class="sourceLineNo">1124</span> }<a name="line.1124"></a> -<span class="sourceLineNo">1125</span><a name="line.1125"></a> -<span class="sourceLineNo">1126</span> void testSetup() throws IOException {<a name="line.1126"></a> -<span class="sourceLineNo">1127</span> createConnection();<a name="line.1127"></a> -<span class="sourceLineNo">1128</span> onStartup();<a name="line.1128"></a> -<span class="sourceLineNo">1129</span> latencyHistogram = YammerHistogramUtils.newHistogram(new UniformReservoir(1024 * 500));<a name="line.1129"></a> -<span class="sourceLineNo">1130</span> valueSizeHistogram = YammerHistogramUtils.newHistogram(new UniformReservoir(1024 * 500));<a name="line.1130"></a> -<span class="sourceLineNo">1131</span> }<a name="line.1131"></a> -<span class="sourceLineNo">1132</span><a name="line.1132"></a> -<span class="sourceLineNo">1133</span> abstract void createConnection() throws IOException;<a name="line.1133"></a> -<span class="sourceLineNo">1134</span><a name="line.1134"></a> -<span class="sourceLineNo">1135</span> abstract void onStartup() throws IOException;<a name="line.1135"></a> -<span class="sourceLineNo">1136</span><a name="line.1136"></a> -<span class="sourceLineNo">1137</span> void testTakedown() throws IOException {<a name="line.1137"></a> -<span class="sourceLineNo">1138</span> onTakedown();<a name="line.1138"></a> -<span class="sourceLineNo">1139</span> // Print all stats for this thread continuously.<a name="line.1139"></a> -<span class="sourceLineNo">1140</span> // Synchronize on Test.class so different threads don't intermingle the<a name="line.1140"></a> -<span class="sourceLineNo">1141</span> // output. We can't use 'this' here because each thread has its own instance of Test class.<a name="line.1141"></a> -<span class="sourceLineNo">1142</span> synchronized (Test.class) {<a name="line.1142"></a> -<span class="sourceLineNo">1143</span> status.setStatus("Test : " + testName + ", Thread : " + Thread.currentThread().getName());<a name="line.1143"></a> -<span class="sourceLineNo">1144</span> status.setStatus("Latency (us) : " + YammerHistogramUtils.getHistogramReport(<a name="line.1144"></a> -<span class="sourceLineNo">1145</span> latencyHistogram));<a name="line.1145"></a> -<span class="sourceLineNo">1146</span> status.setStatus("Num measures (latency) : " + latencyHistogram.getCount());<a name="line.1146"></a> -<span class="sourceLineNo">1147</span> status.setStatus(YammerHistogramUtils.getPrettyHistogramReport(latencyHistogram));<a name="line.1147"></a> -<span class="sourceLineNo">1148</span> status.setStatus("ValueSize (bytes) : "<a name="line.1148"></a> -<span class="sourceLineNo">1149</span> + YammerHistogramUtils.getHistogramReport(valueSizeHistogram));<a name="line.1149"></a> -<span class="sourceLineNo">1150</span> status.setStatus("Num measures (ValueSize): " + valueSizeHistogram.getCount());<a name="line.1150"></a> -<span class="sourceLineNo">1151</span> status.setStatus(YammerHistogramUtils.getPrettyHistogramReport(valueSizeHistogram));<a name="line.1151"></a> -<span class="sourceLineNo">1152</span> }<a name="line.1152"></a> -<span class="sourceLineNo">1153</span> closeConnection();<a name="line.1153"></a> -<span class="sourceLineNo">1154</span> receiverHost.closeReceivers();<a name="line.1154"></a> -<span class="sourceLineNo">1155</span> }<a name="line.1155"></a> -<span class="sourceLineNo">1156</span><a name="line.1156"></a> -<span class="sourceLineNo">1157</span> abstract void onTakedown() throws IOException;<a name="line.1157"></a> -<span class="sourceLineNo">1158</span><a name="line.1158"></a> -<span class="sourceLineNo">1159</span> abstract void closeConnection() throws IOException;<a name="line.1159"></a> -<span class="sourceLineNo">1160</span><a name="line.1160"></a> -<span class="sourceLineNo">1161</span> /*<a name="line.1161"></a> -<span class="sourceLineNo">1162</span> * Run test<a name="line.1162"></a> -<span class="sourceLineNo">1163</span> * @return Elapsed time.<a name="line.1163"></a> -<span class="sourceLineNo">1164</span> * @throws IOException<a name="line.1164"></a> -<span class="sourceLineNo">1165</span> */<a name="line.1165"></a> -<span class="sourceLineNo">1166</span> long test() throws IOException, InterruptedException {<a name="line.1166"></a> -<span class="sourceLineNo">1167</span> testSetup();<a name="line.1167"></a> -<span class="sourceLineNo">1168</span> LOG.info("Timed test starting in thread " + Thread.currentThread().getName());<a name="line.1168"></a> -<span class="sourceLineNo">1169</span> final long startTime = System.nanoTime();<a name="line.1169"></a> -<span class="sourceLineNo">1170</span> try {<a name="line.1170"></a> -<span class="sourceLineNo">1171</span> testTimed();<a name="line.1171"></a> -<span class="sourceLineNo">1172</span> } finally {<a name="line.1172"></a> -<span class="sourceLineNo">1173</span> testTakedown();<a name="line.1173"></a> -<span class="sourceLineNo">1174</span> }<a name="line.1174"></a> -<span class="sourceLineNo">1175</span> return (System.nanoTime() - startTime) / 1000000;<a name="line.1175"></a> -<span class="sourceLineNo">1176</span> }<a name="line.1176"></a> +<span class="sourceLineNo">1050</span> private Histogram rpcCallsHistogram;<a name="line.1050"></a> +<span class="sourceLineNo">1051</span> private Histogram remoteRpcCallsHistogram;<a name="line.1051"></a> +<span class="sourceLineNo">1052</span> private Histogram millisBetweenNextHistogram;<a name="line.1052"></a> +<span class="sourceLineNo">1053</span> private Histogram regionsScannedHistogram;<a name="line.1053"></a> +<span class="sourceLineNo">1054</span> private Histogram bytesInResultsHistogram;<a name="line.1054"></a> +<span class="sourceLineNo">1055</span> private Histogram bytesInRemoteResultsHistogram;<a name="line.1055"></a> +<span class="sourceLineNo">1056</span> private RandomDistribution.Zipf zipf;<a name="line.1056"></a> +<span class="sourceLineNo">1057</span><a name="line.1057"></a> +<span class="sourceLineNo">1058</span> /**<a name="line.1058"></a> +<span class="sourceLineNo">1059</span> * Note that all subclasses of this class must provide a public constructor<a name="line.1059"></a> +<span class="sourceLineNo">1060</span> * that has the exact same list of arguments.<a name="line.1060"></a> +<span class="sourceLineNo">1061</span> */<a name="line.1061"></a> +<span class="sourceLineNo">1062</span> TestBase(final Configuration conf, final TestOptions options, final Status status) {<a name="line.1062"></a> +<span class="sourceLineNo">1063</span> this.conf = conf;<a name="line.1063"></a> +<span class="sourceLineNo">1064</span> this.receiverHost = this.conf == null? null: SpanReceiverHost.getInstance(conf);<a name="line.1064"></a> +<span class="sourceLineNo">1065</span> this.opts = options;<a name="line.1065"></a> +<span class="sourceLineNo">1066</span> this.status = status;<a name="line.1066"></a> +<span class="sourceLineNo">1067</span> this.testName = this.getClass().getSimpleName();<a name="line.1067"></a> +<span class="sourceLineNo">1068</span> if (options.traceRate >= 1.0) {<a name="line.1068"></a> +<span class="sourceLineNo">1069</span> this.traceSampler = Sampler.ALWAYS;<a name="line.1069"></a> +<span class="sourceLineNo">1070</span> } else if (options.traceRate > 0.0) {<a name="line.1070"></a> +<span class="sourceLineNo">1071</span> conf.setDouble("hbase.sampler.fraction", options.traceRate);<a name="line.1071"></a> +<span class="sourceLineNo">1072</span> this.traceSampler = new ProbabilitySampler(new HBaseHTraceConfiguration(conf));<a name="line.1072"></a> +<span class="sourceLineNo">1073</span> } else {<a name="line.1073"></a> +<span class="sourceLineNo">1074</span> this.traceSampler = Sampler.NEVER;<a name="line.1074"></a> +<span class="sourceLineNo">1075</span> }<a name="line.1075"></a> +<span class="sourceLineNo">1076</span> everyN = (int) (opts.totalRows / (opts.totalRows * opts.sampleRate));<a name="line.1076"></a> +<span class="sourceLineNo">1077</span> if (options.isValueZipf()) {<a name="line.1077"></a> +<span class="sourceLineNo">1078</span> this.zipf = new RandomDistribution.Zipf(this.rand, 1, options.getValueSize(), 1.2);<a name="line.1078"></a> +<span class="sourceLineNo">1079</span> }<a name="line.1079"></a> +<span class="sourceLineNo">1080</span> LOG.info("Sampling 1 every " + everyN + " out of " + opts.perClientRunRows + " total rows.");<a name="line.1080"></a> +<span class="sourceLineNo">1081</span> }<a name="line.1081"></a> +<span class="sourceLineNo">1082</span><a name="line.1082"></a> +<span class="sourceLineNo">1083</span> int getValueLength(final Random r) {<a name="line.1083"></a> +<span class="sourceLineNo">1084</span> if (this.opts.isValueRandom()) {<a name="line.1084"></a> +<span class="sourceLineNo">1085</span> return r.nextInt(opts.valueSize);<a name="line.1085"></a> +<span class="sourceLineNo">1086</span> } else if (this.opts.isValueZipf()) {<a name="line.1086"></a> +<span class="sourceLineNo">1087</span> return Math.abs(this.zipf.nextInt());<a name="line.1087"></a> +<span class="sourceLineNo">1088</span> } else {<a name="line.1088"></a> +<span class="sourceLineNo">1089</span> return opts.valueSize;<a name="line.1089"></a> +<span class="sourceLineNo">1090</span> }<a name="line.1090"></a> +<span class="sourceLineNo">1091</span> }<a name="line.1091"></a> +<span class="sourceLineNo">1092</span><a name="line.1092"></a> +<span class="sourceLineNo">1093</span> void updateValueSize(final Result [] rs) throws IOException {<a name="line.1093"></a> +<span class="sourceLineNo">1094</span> if (rs == null || !isRandomValueSize()) return;<a name="line.1094"></a> +<span class="sourceLineNo">1095</span> for (Result r: rs) updateValueSize(r);<a name="line.1095"></a> +<span class="sourceLineNo">1096</span> }<a name="line.1096"></a> +<span class="sourceLineNo">1097</span><a name="line.1097"></a> +<span class="sourceLineNo">1098</span> void updateValueSize(final Result r) throws IOException {<a name="line.1098"></a> +<span class="sourceLineNo">1099</span> if (r == null || !isRandomValueSize()) return;<a name="line.1099"></a> +<span class="sourceLineNo">1100</span> int size = 0;<a name="line.1100"></a> +<span class="sourceLineNo">1101</span> for (CellScanner scanner = r.cellScanner(); scanner.advance();) {<a name="line.1101"></a> +<span class="sourceLineNo">1102</span> size += scanner.current().getValueLength();<a name="line.1102"></a> +<span class="sourceLineNo">1103</span> }<a name="line.1103"></a> +<span class="sourceLineNo">1104</span> updateValueSize(size);<a name="line.1104"></a> +<span class="sourceLineNo">1105</span> }<a name="line.1105"></a> +<span class="sourceLineNo">1106</span><a name="line.1106"></a> +<span class="sourceLineNo">1107</span> void updateValueSize(final int valueSize) {<a name="line.1107"></a> +<span class="sourceLineNo">1108</span> if (!isRandomValueSize()) return;<a name="line.1108"></a> +<span class="sourceLineNo">1109</span> this.valueSizeHistogram.update(valueSize);<a name="line.1109"></a> +<span class="sourceLineNo">1110</span> }<a name="line.1110"></a> +<span class="sourceLineNo">1111</span><a name="line.1111"></a> +<span class="sourceLineNo">1112</span> void updateScanMetrics(final ScanMetrics metrics) {<a name="line.1112"></a> +<span class="sourceLineNo">1113</span> Map<String,Long> metricsMap = metrics.getMetricsMap();<a name="line.1113"></a> +<span class="sourceLineNo">1114</span> Long rpcCalls = metricsMap.get(ScanMetrics.RPC_CALLS_METRIC_NAME);<a name="line.1114"></a> +<span class="sourceLineNo">1115</span> if (rpcCalls != null) {<a name="line.1115"></a> +<span class="sourceLineNo">1116</span> this.rpcCallsHistogram.update(rpcCalls.longValue());<a name="line.1116"></a> +<span class="sourceLineNo">1117</span> }<a name="line.1117"></a> +<span class="sourceLineNo">1118</span> Long remoteRpcCalls = metricsMap.get(ScanMetrics.REMOTE_RPC_CALLS_METRIC_NAME);<a name="line.1118"></a> +<span class="sourceLineNo">1119</span> if (remoteRpcCalls != null) {<a name="line.1119"></a> +<span class="sourceLineNo">1120</span> this.remoteRpcCallsHistogram.update(remoteRpcCalls.longValue());<a name="line.1120"></a> +<span class="sourceLineNo">1121</span> }<a name="line.1121"></a> +<span class="sourceLineNo">1122</span> Long millisBetweenNext = metricsMap.get(ScanMetrics.MILLIS_BETWEEN_NEXTS_METRIC_NAME);<a name="line.1122"></a> +<span class="sourceLineNo">1123</span> if (millisBetweenNext != null) {<a name="line.1123"></a> +<span class="sourceLineNo">1124</span> this.millisBetweenNextHistogram.update(millisBetweenNext.longValue());<a name="line.1124"></a> +<span class="sourceLineNo">1125</span> }<a name="line.1125"></a> +<span class="sourceLineNo">1126</span> Long regionsScanned = metricsMap.get(ScanMetrics.REGIONS_SCANNED_METRIC_NAME);<a name="line.1126"></a> +<span class="sourceLineNo">1127</span> if (regionsScanned != null) {<a name="line.1127"></a> +<span class="sourceLineNo">1128</span> this.regionsScannedHistogram.update(regionsScanned.longValue());<a name="line.1128"></a> +<span class="sourceLineNo">1129</span> }<a name="line.1129"></a> +<span class="sourceLineNo">1130</span> Long bytesInResults = metricsMap.get(ScanMetrics.BYTES_IN_RESULTS_METRIC_NAME);<a name="line.1130"></a> +<span class="sourceLineNo">1131</span> if (bytesInResults != null && bytesInResults.longValue() > 0) {<a name="line.1131"></a> +<span class="sourceLineNo">1132</span> this.bytesInResultsHistogram.update(bytesInResults.longValue());<a name="line.1132"></a> +<span class="sourceLineNo">1133</span> }<a name="line.1133"></a> +<span class="sourceLineNo">1134</span> Long bytesInRemoteResults = metricsMap.get(ScanMetrics.BYTES_IN_REMOTE_RESULTS_METRIC_NAME);<a name="line.1134"></a> +<span class="sourceLineNo">1135</span> if (bytesInRemoteResults != null && bytesInRemoteResults.longValue() > 0) {<a name="line.1135"></a> +<span class="sourceLineNo">1136</span> this.bytesInRemoteResultsHistogram.update(bytesInRemoteResults.longValue());<a name="line.1136"></a> +<span class="sourceLineNo">1137</span> }<a name="line.1137"></a> +<span class="sourceLineNo">1138</span> }<a name="line.1138"></a> +<span class="sourceLineNo">1139</span><a name="line.1139"></a> +<span class="sourceLineNo">1140</span> String generateStatus(final int sr, final int i, final int lr) {<a name="line.1140"></a> +<span class="sourceLineNo">1141</span> return sr + "/" + i + "/" + lr + ", latency " + getShortLatencyReport() +<a name="line.1141"></a> +<span class="sourceLineNo">1142</span> (!isRandomValueSize()? "": ", value size " + getShortValueSizeReport());<a name="line.1142"></a> +<span class="sourceLineNo">1143</span> }<a name="line.1143"></a> +<span class="sourceLineNo">1144</span><a name="line.1144"></a> +<span class="sourceLineNo">1145</span> boolean isRandomValueSize() {<a name="line.1145"></a> +<span class="sourceLineNo">1146</span> return opts.valueRandom;<a name="line.1146"></a> +<span class="sourceLineNo">1147</span> }<a name="line.1147"></a> +<span class="sourceLineNo">1148</span><a name="line.1148"></a> +<span class="sourceLineNo">1149</span> protected int getReportingPeriod() {<a name="line.1149"></a> +<span class="sourceLineNo">1150</span> return opts.period;<a name="line.1150"></a> +<span class="sourceLineNo">1151</span> }<a name="line.1151"></a> +<span class="sourceLineNo">1152</span><a name="line.1152"></a> +<span class="sourceLineNo">1153</span> /**<a name="line.1153"></a> +<span class="sourceLineNo">1154</span> * Populated by testTakedown. Only implemented by RandomReadTest at the moment.<a name="line.1154"></a> +<span class="sourceLineNo">1155</span> */<a name="line.1155"></a> +<span class="sourceLineNo">1156</span> public Histogram getLatencyHistogram() {<a name="line.1156"></a> +<span class="sourceLineNo">1157</span> return latencyHistogram;<a name="line.1157"></a> +<span class="sourceLineNo">1158</span> }<a name="line.1158"></a> +<span class="sourceLineNo">1159</span><a name="line.1159"></a> +<span class="sourceLineNo">1160</span> void testSetup() throws IOException {<a name="line.1160"></a> +<span class="sourceLineNo">1161</span> // test metrics<a name="line.1161"></a> +<span class="sourceLineNo">1162</span> latencyHistogram = YammerHistogramUtils.newHistogram(new UniformReservoir(1024 * 500));<a name="line.1162"></a> +<span class="sourceLineNo">1163</span> valueSizeHistogram = YammerHistogramUtils.newHistogram(new UniformReservoir(1024 * 500));<a name="line.1163"></a> +<span class="sourceLineNo">1164</span> // scan metrics<a name="line.1164"></a> +<span class="sourceLineNo">1165</span> rpcCallsHistogram = YammerHistogramUtils.newHistogram(new UniformReservoir(1024 * 500));<a name="line.1165"></a> +<span class="sourceLineNo">1166</span> remoteRpcCallsHistogram = YammerHistogramUtils.newHistogram(new UniformReservoir(1024 * 500));<a name="line.1166"></a> +<span class="sourceLineNo">1167</span> millisBetweenNextHistogram = YammerHistogramUtils.newHistogram(new UniformReservoir(1024 * 500));<a name="line.1167"></a> +<span class="sourceLineNo">1168</span> regionsScannedHistogram = YammerHistogramUtils.newHistogram(new UniformReservoir(1024 * 500));<a name="line.1168"></a> +<span class="sourceLineNo">1169</span> bytesInResultsHistogram = YammerHistogramUtils.newHistogram(new UniformReservoir(1024 * 500));<a name="line.1169"></a> +<span class="sourceLineNo">1170</span> bytesInRemoteResultsHistogram = YammerHistogramUtils.newHistogram(new UniformReservoir(1024 * 500));<a name="line.1170"></a> +<span class="sourceLineNo">1171</span><a name="line.1171"></a> +<span class="sourceLineNo">1172</span> createConnection();<a name="line.1172"></a> +<span class="sourceLineNo">1173</span> onStartup();<a name="line.1173"></a> +<span class="sourceLineNo">1174</span> }<a name="line.1174"></a> +<span class="sourceLineNo">1175</span><a name="line.1175"></a> +<span class="sourceLineNo">1176</span> abstract void createConnection() throws IOException;<a name="line.1176"></a> <span class="sourceLineNo">1177</span><a name="line.1177"></a> -<span class="sourceLineNo">1178</span> int getStartRow() {<a name="line.1178"></a> -<span class="sourceLineNo">1179</span> return opts.startRow;<a name="line.1179"></a> -<span class="sourceLineNo">1180</span> }<a name="line.1180"></a> -<span class="sourceLineNo">1181</span><a name="line.1181"></a> -<span class="sourceLineNo">1182</span> int getLastRow() {<a name="line.1182"></a> -<span class="sourceLineNo">1183</span> return getStartRow() + opts.perClientRunRows;<a name="line.1183"></a> -<span class="sourceLineNo">1184</span> }<a name="line.1184"></a> -<span class="sourceLineNo">1185</span><a name="line.1185"></a> -<span class="sourceLineNo">1186</span> /**<a name="line.1186"></a> -<span class="sourceLineNo">1187</span> * Provides an extension point for tests that don't want a per row invocation.<a name="line.1187"></a> -<span class="sourceLineNo">1188</span> */<a name="line.1188"></a> -<span class="sourceLineNo">1189</span> void testTimed() throws IOException, InterruptedException {<a name="line.1189"></a> -<span class="sourceLineNo">1190</span> int startRow = getStartRow();<a name="line.1190"></a> -<span class="sourceLineNo">1191</span> int lastRow = getLastRow();<a name="line.1191"></a> -<span class="sourceLineNo">1192</span> TraceUtil.addSampler(traceSampler);<a name="line.1192"></a> -<span class="sourceLineNo">1193</span> // Report on completion of 1/10th of total.<a name="line.1193"></a> -<span class="sourceLineNo">1194</span> for (int ii = 0; ii < opts.cycles; ii++) {<a name="line.1194"></a> -<span class="sourceLineNo">1195</span> if (opts.cycles > 1) LOG.info("Cycle=" + ii + " of " + opts.cycles);<a name="line.1195"></a> -<span class="sourceLineNo">1196</span> for (int i = startRow; i < lastRow; i++) {<a name="line.1196"></a> -<span class="sourceLineNo">1197</span> if (i % everyN != 0) continue;<a name="line.1197"></a> -<span class="sourceLineNo">1198</span> long startTime = System.nanoTime();<a name="line.1198"></a> -<span class="sourceLineNo">1199</span> try (TraceScope scope = TraceUtil.createTrace("test row")){<a name="line.1199"></a> -<span class="sourceLineNo">1200</span> testRow(i);<a name="line.1200"></a> -<span class="sourceLineNo">1201</span> }<a name="line.1201"></a> -<span class="sourceLineNo">1202</span> if ( (i - startRow) > opts.measureAfter) {<a name="line.1202"></a> -<span class="sourceLineNo">1203</span> // If multiget is enabled, say set to 10, testRow() returns immediately first 9 times<a name="line.1203"></a> -<span class="sourceLineNo">1204</span> // and sends the actual get request in the 10th iteration. We should only set latency<a name="line.1204"></a> -<span class="sourceLineNo">1205</span> // when actual request is sent because otherwise it turns out to be 0.<a name="line.1205"></a> -<span class="sourceLineNo">1206</span> if (opts.multiGet == 0 || (i - startRow + 1) % opts.multiGet == 0) {<a name="line.1206"></a> -<span class="sourceLineNo">1207</span> latencyHistogram.update((System.nanoTime() - startTime) / 1000);<a name="line.1207"></a> -<span class="sourceLineNo">1208</span> }<a name="line.1208"></a> -<span class="sourceLineNo">1209</span> if (status != null && i > 0 && (i % getReportingPeriod()) == 0) {<a name="line.1209"></a> -<span class="sourceLineNo">1210</span> status.setStatus(generateStatus(startRow, i, lastRow));<a name="line.1210"></a> -<span class="sourceLineNo">1211</span> }<a name="line.1211"></a> -<span class="sourceLineNo">1212</span> }<a name="line.1212"></a> -<span class="sourceLineNo">1213</span> }<a name="line.1213"></a> -<span class="sourceLineNo">1214</span> }<a name="line.1214"></a> -<span class="sourceLineNo">1215</span> }<a name="line.1215"></a> -<span class="sourceLineNo">1216</span><a name="line.1216"></a> -<span class="sourceLineNo">1217</span> /**<a name="line.1217"></a> -<span class="sourceLineNo">1218</span> * @return Subset of the histograms' calculation.<a name="line.1218"></a> -<span class="sourceLineNo">1219</span> */<a name="line.1219"></a> -<span class="sourceLineNo">1220</span> public String getShortLatencyReport() {<a name="line.1220"></a> -<span class="sourceLineNo">1221</span> return YammerHistogramUtils.getShortHistogramReport(this.latencyHistogram);<a name="line.1221"></a> +<span class="sourceLineNo">1178</span> abstract void onStartup() throws IOException;<a name="line.1178"></a> +<span class="sourceLineNo">1179</span><a name="line.1179"></a> +<span class="sourceLineNo">1180</span> void testTakedown() throws IOException {<a name="line.1180"></a> +<span class="sourceLineNo">1181</span> onTakedown();<a name="line.1181"></a> +<span class="sourceLineNo">1182</span> // Print all stats for this thread continuously.<a name="line.1182"></a> +<span class="sourceLineNo">1183</span> // Synchronize on Test.class so different threads don't intermingle the<a name="line.1183"></a> +<span class="sourceLineNo">1184</span> // output. We can't use 'this' here because each thread has its own instance of Test class.<a name="line.1184"></a> +<span class="sourceLineNo">1185</span> synchronized (Test.class) {<a name="line.1185"></a> +<span class="sourceLineNo">1186</span> status.setStatus("Test : " + testName + ", Thread : " + Thread.currentThread().getName());<a name="line.1186"></a> +<span class="sourceLineNo">1187</span> status.setStatus("Latency (us) : " + YammerHistogramUtils.getHistogramReport(<a name="line.1187"></a> +<span class="sourceLineNo">1188</span> latencyHistogram));<a name="line.1188"></a> +<span class="sourceLineNo">1189</span> status.setStatus("Num measures (latency) : " + latencyHistogram.getCount());<a name="line.1189"></a> +<span class="sourceLineNo">1190</span> status.setStatus(YammerHistogramUtils.getPrettyHistogramReport(latencyHistogram));<a name="line.1190"></a> +<span class="sourceLineNo">1191</span> status.setStatus("ValueSize (bytes) : "<a name="line.1191"></a> +<span class="sourceLineNo">1192</span> + YammerHistogramUtils.getHistogramReport(valueSizeHistogram));<a name="line.1192"></a> +<span class="sourceLineNo">1193</span> status.setStatus("Num measures (ValueSize): " + valueSizeHistogram.getCount());<a name="line.1193"></a> +<span class="sourceLineNo">1194</span> status.setStatus(YammerHistogramUtils.getPrettyHistogramReport(valueSizeHistogram));<a name="line.1194"></a> +<span class="sourceLineNo">1195</span> if (rpcCallsHistogram.getCount() > 0) {<a name="line.1195"></a> +<span class="sourceLineNo">1196</span> status.setStatus("rpcCalls (count): " +<a name="line.1196"></a> +<span class="sourceLineNo">1197</span> YammerHistogramUtils.getHistogramReport(rpcCallsHistogram));<a name="line.1197"></a> +<span class="sourceLineNo">1198</span> }<a name="line.1198"></a> +<span class="sourceLineNo">1199</span> if (remoteRpcCallsHistogram.getCount() > 0) {<a name="line.1199"></a> +<span class="sourceLineNo">1200</span> status.setStatus("remoteRpcCalls (count): " +<a name="line.1200"></a> +<span class="sourceLineNo">1201</span> YammerHistogramUtils.getHistogramReport(remoteRpcCallsHistogram));<a name="line.1201"></a> +<span class="sourceLineNo">1202</span> }<a name="line.1202"></a> +<span class="sourceLineNo">1203</span> if (millisBetweenNextHistogram.getCount() > 0) {<a name="line.1203"></a> +<span class="sourceLineNo">1204</span> status.setStatus("millisBetweenNext (latency): " +<a name="line.1204"></a> +<span class="sourceLineNo">1205</span> YammerHistogramUtils.getHistogramReport(millisBetweenNextHistogram));<a name="line.1205"></a> +<span class="sourceLineNo">1206</span> }<a name="line.1206"></a> +<span class="sourceLineNo">1207</span> if (regionsScannedHistogram.getCount() > 0) {<a name="line.1207"></a> +<span class="sourceLineNo">1208</span> status.setStatus("regionsScanned (count): " +<a name="line.1208"></a> +<span class="sourceLineNo">1209</span> YammerHistogramUtils.getHistogramReport(regionsScannedHistogram));<a name="line.1209"></a> +<span class="sourceLineNo">1210</span> }<a name="line.1210"></a> +<span class="sourceLineNo">1211</span> if (bytesInResultsHistogram.getCount() > 0) {<a name="line.1211"></a> +<span class="sourceLineNo">1212</span> status.setStatus("bytesInResults (size): " +<a name="line.1212"></a> +<span class="sourceLineNo">1213</span> YammerHistogramUtils.getHistogramReport(bytesInResultsHistogram));<a name="line.1213"></a> +<span class="sourceLineNo">1214</span> }<a name="line.1214"></a> +<span class="sourceLineNo">1215</span> if (bytesInRemoteResultsHistogram.getCount() > 0) {<a name="line.1215"></a> +<span class="sourceLineNo">1216</span> status.setStatus("bytesInRemoteResults (size): " +<a name="line.1216"></a> +<span class="sourceLineNo">1217</span> YammerHistogramUtils.getHistogramReport(bytesInRemoteResultsHistogram));<a name="line.1217"></a> +<span class="sourceLineNo">1218</span> }<a name="line.1218"></a> +<span class="sourceLineNo">1219</span> }<a name="line.1219"></a> +<span class="sourceLineNo">1220</span> closeConnection();<a name="line.1220"></a> +<span class="sourceLineNo">1221</span> receiverHost.closeReceivers();<a name="line.1221"></a> <span class="sourceLineNo">1222</span> }<a name="line.1222"></a> <span class="sourceLineNo">1223</span><a name="line.1223"></a> -<span class="sourceLineNo">1224</span> /**<a name="line.1224"></a> -<span class="sourceLineNo">1225</span> * @return Subset of the histograms' calculation.<a name="line.1225"></a> -<span class="sourceLineNo">1226</span> */<a name="line.1226"></a> -<span class="sourceLineNo">1227</span> public String getShortValueSizeReport() {<a name="line.1227"></a> -<span class="sourceLineNo">1228</span> return YammerHistogramUtils.getShortHistogramReport(this.valueSizeHistogram);<a name="line.1228"></a> -<span class="sourceLineNo">1229</span> }<a name="line.1229"></a> -<span class="sourceLineNo">1230</span><a name="line.1230"></a> -<span class="sourceLineNo">1231</span> /*<a name="line.1231"></a> -<span class="sourceLineNo">1232</span> * Test for individual row.<a name="line.1232"></a> -<span class="sourceLineNo">1233</span> * @param i Row index.<a name="line.1233"></a> -<span class="sourceLineNo">1234</span> */<a name="line.1234"></a> -<span class="sourceLineNo">1235</span> abstract void testRow(final int i) throws IOException, InterruptedException;<a name="line.1235"></a> -<span class="sourceLineNo">1236</span> }<a name="line.1236"></a> -<span class="sourceLineNo">1237</span><a name="line.1237"></a> -<span class="sourceLineNo">1238</span> static abstract class Test extends TestBase {<a name="line.1238"></a> -<span class="sourceLineNo">1239</span> protected Connection connection;<a name="line.1239"></a> -<span class="sourceLineNo">1240</span><a name="line.1240"></a> -<span class="sourceLineNo">1241</span> Test(final Connection con, final TestOptions options, final Status status) {<a name="line.1241"></a> -<span class="sourceLineNo">1242</span> super(con == null ? HBaseConfiguration.create() : con.getConfiguration(), options, status);<a name="line.1242"></a> -<span class="sourceLineNo">1243</span> this.connection = con;<a name="line.1243"></a> -<span class="sourceLineNo">1244</span> }<a name="line.1244"></a> -<span class="sourceLineNo">1245</span><a name="line.1245"></a> -<span class="sourceLineNo">1246</span> @Override<a name="line.1246"></a> -<span class="sourceLineNo">1247</span> void createConnection() throws IOException {<a name="line.1247"></a> -<span class="sourceLineNo">1248</span> if (!opts.isOneCon()) {<a name="line.1248"></a> -<span class="sourceLineNo">1249</span> this.connection = ConnectionFactory.createConnection(conf);<a name="line.1249"></a> -<span class="sourceLineNo">1250</span> }<a name="line.1250"></a> +<span class="sourceLineNo">1224</span> abstract void onTakedown() throws IOException;<a name="line.1224"></a> +<span class="sourceLineNo">1225</span><a name="line.1225"></a> +<span class="sourceLineNo">1226</span> abstract void closeConnection() throws IOException;<a name="line.1226"></a> +<span class="sourceLineNo">1227</span><a name="line.1227"></a> +<span class="sourceLineNo">1228</span> /*<a name="line.1228"></a> +<span class="sourceLineNo">1229</span> * Run test<a name="line.1229"></a> +<span class="sourceLineNo">1230</span> * @return Elapsed time.<a name="line.1230"></a> +<span class="sourceLineNo">1231</span> * @throws IOException<a name="line.1231"></a> +<span class="sourceLineNo">1232</span> */<a name="line.1232"></a> +<span class="sourceLineNo">1233</span> long test() throws IOException, InterruptedException {<a name="line.1233"></a> +<span class="sourceLineNo">1234</span> testSetup();<a name="line.1234"></a> +<span class="sourceLineNo">1235</span> LOG.info("Timed test starting in thread " + Thread.currentThread().getName());<a name="line.1235"></a> +<span class="sourceLineNo">1236</span> final long startTime = System.nanoTime();<a name="line.1236"></a> +<span class="sourceLineNo">1237</span> try {<a name="line.1237"></a> +<span class="sourceLineNo">1238</span> testTimed();<a name="line.1238"></a> +<span class="sourceLineNo">1239</span> } finally {<a name="line.1239"></a> +<span class="sourceLineNo">1240</span> testTakedown();<a name="line.1240"></a> +<span class="sourceLineNo">1241</span> }<a name="line.1241"></a> +<span class="sourceLineNo">1242</span> return (System.nanoTime() - startTime) / 1000000;<a name="line.1242"></a> +<span class="sourceLineNo">1243</span> }<a name="line.1243"></a> +<span class="sourceLineNo">1244</span><a name="line.1244"></a> +<span class="sourceLineNo">1245</span> int getStartRow() {<a name="line.1245"></a> +<span class="sourceLineNo">1246</span> return opts.startRow;<a name="line.1246"></a> +<span class="sourceLineNo">1247</span> }<a name="line.1247"></a> +<span class="sourceLineNo">1248</span><a name="line.1248"></a> +<span class="sourceLineNo">1249</span> int getLastRow() {<a name="line.1249"></a> +<span class="sourceLineNo">1250</span> return getStartRow() + opts.perClientRunRows;<a name="line.1250"></a> <span class="sourceLineNo">1251</span> }<a name="line.1251"></a> <span class="sourceLineNo">1252</span><a name="line.1252"></a> -<span class="sourceLineNo">1253</span> @Override<a name="line.1253"></a> -<span class="sourceLineNo">1254</span> void closeConnection() throws IOException {<a name="line.1254"></a> -<span class="sourceLineNo">1255</span> if (!opts.isOneCon()) {<a name="line.1255"></a> -<span class="sourceLineNo">1256</span> this.connection.close();<a name="line.1256"></a> -<span class="sourceLineNo">1257</span> }<a name="line.1257"></a> -<span class="sourceLineNo">1258</span> }<a name="line.1258"></a> -<span class="sourceLineNo">1259</span> }<a name="line.1259"></a> -<span class="sourceLineNo">1260</span><a name="line.1260"></a> -<span class="sourceLineNo">1261</span> static abstract class AsyncTest extends TestBase {<a name="line.1261"></a> -<span class="sourceLineNo">1262</span> protected AsyncConnection connection;<a name="line.1262"></a> -<span class="sourceLineNo">1263</span><a name="line.1263"></a> -<span class="sourceLineNo">1264</span> AsyncTest(final AsyncConnection con, final TestOptions options, final Status status) {<a name="line.1264"></a> -<span class="sourceLineNo">1265</span> super(con == null ? HBaseConfiguration.create() : con.getConfiguration(), options, status);<a name="line.1265"></a> -<span class="sourceLineNo">1266</span> this.connection = con;<a name="line.1266"></a> -<span class="sourceLineNo">1267</span> }<a name="line.1267"></a> -<span class="sourceLineNo">1268</span><a name="line.1268"></a> -<span class="sourceLineNo">1269</span> @Override<a name="line.1269"></a> -<span class="sourceLineNo">1270</span> void createConnection() {<a name="line.1270"></a> -<span class="sourceLineNo">1271</span> if (!opts.isOneCon()) {<a name="line.1271"></a> -<span class="sourceLineNo">1272</span> try {<a name="line.1272"></a> -<span class="sourceLineNo">1273</span> this.connection = ConnectionFactory.createAsyncConnection(conf).get();<a name="line.1273"></a> -<span class="sourceLineNo">1274</span> } catch (InterruptedException | ExecutionException e) {<a name="line.1274"></a> -<span class="sourceLineNo">1275</span> LOG.error("Failed to create async connection", e);<a name="line.1275"></a> -<span class="sourceLineNo">1276</span> }<a name="line.1276"></a> -<span class="sourceLineNo">1277</span> }<a name="line.1277"></a> -<span class="sourceLineNo">1278</span> }<a name="line.1278"></a> -<span class="sourceLineNo">1279</span><a name="line.1279"></a> -<span class="sourceLineNo">1280</span> @Override<a name="line.1280"></a> -<span class="sourceLineNo">1281</span> void closeConnection() throws IOException {<a name="line.1281"></a> -<span class="sourceLineNo">1282</span> if (!opts.isOneCon()) {<a name="line.1282"></a> -<span class="sourceLineNo">1283</span> this.connection.close();<a name="line.1283"></a> -<span class="sourceLineNo">1284</span> }<a name="line.1284"></a> -<span class="sourceLineNo">1285</span> }<a name="line.1285"></a> -<span class="sourceLineNo">1286</span> }<a name="line.1286"></a> -<span class="sourceLineNo">1287</span><a name="line.1287"></a> -<span class="sourceLineNo">1288</span> static abstract class TableTest extends Test {<a name="line.1288"></a> -<span class="sourceLineNo">1289</span> protected Table table;<a name="line.1289"></a> +<span class="sourceLineNo">1253</span> /**<a name="line.1253"></a> +<span class="sourceLineNo">1254</span> * Provides an extension point for tests that don't want a per row invocation.<a name="line.1254"></a> +<span class="sourceLineNo">1255</span> */<a name="line.1255"></a> +<span class="sourceLineNo">1256</span> void testTimed() throws IOException, InterruptedException {<a name="line.1256"></a> +<span class="sourceLineNo">1257</span> int startRow = getStartRow();<a name="line.1257"></a> +<span class="sourceLineNo">1258</span> int lastRow = getLastRow();<a name="line.1258"></a> +<span class="sourceLineNo">1259</span> TraceUtil.addSampler(traceSampler);<a name="line.1259"></a> +<span class="sourceLineNo">1260</span> // Report on completion of 1/10th of total.<a name="line.1260"></a> +<span class="sourceLineNo">1261</span> for (int ii = 0; ii < opts.cycles; ii++) {<a name="line.1261"></a> +<span class="sourceLineNo">1262</span> if (opts.cycles > 1) LOG.info("Cycle=" + ii + " of " + opts.cycles);<a name="line.1262"></a> +<span class="sourceLineNo">1263</span> for (int i = startRow; i < lastRow; i++) {<a name="line.1263"></a> +<span class="sourceLineNo">1264</span> if (i % everyN != 0) continue;<a name="line.1264"></a> +<span class="sourceLineNo">1265</span> long startTime = System.nanoTime();<a name="line.1265"></a> +<span class="sourceLineNo">1266</span> try (TraceScope scope = TraceUtil.createTrace("test row")){<a name="line.1266"></a> +<span class="sourceLineNo">1267</span> testRow(i);<a name="line.1267"></a> +<span class="sourceLineNo">1268</span> }<a name="line.1268"></a> +<span class="sourceLineNo">1269</span> if ( (i - startRow) > opts.measureAfter) {<a name="line.1269"></a> +<span class="sourceLineNo">1270</span> // If multiget is enabled, say set to 10, testRow() returns immediately first 9 times<a name="line.1270"></a> +<span class="sourceLineNo">1271</span> // and sends the actual get request in the 10th iteration. We should only set latency<a name="line.1271"></a> +<span class="sourceLineNo">1272</span> // when actual request is sent because otherwise it turns out to be 0.<a name="line.1272"></a> +<span class="sourceLineNo">1273</span> if (opts.multiGet == 0 || (i - startRow + 1) % opts.multiGet == 0) {<a name="line.1273"></a> +<span class="sourceLineNo">1274</span> latencyHistogram.update((System.nanoTime() - startTime) / 1000);<a name="line.1274"></a> +<span class="sourceLineNo">1275</span> }<a name="line.1275"></a> +<span class="sourceLineNo">1276</span> if (status != null && i > 0 && (i % getReportingPeriod()) == 0) {<a name="line.1276"></a> +<span class="sourceLineNo">1277</span> status.setStatus(generateStatus(startRow, i, lastRow));<a name="line.1277"></a> +<span class="sourceLineNo">1278</span> }<a name="line.1278"></a> +<span class="sourceLineNo">1279</span> }<a name="line.1279"></a> +<span class="sourceLineNo">1280</span> }<a name="line.1280"></a> +<span class="sourceLineNo">1281</span> }<a name="line.1281"></a> +<span class="sourceLineNo">1282</span> }<a name="line.1282"></a> +<span class="sourceLineNo">1283</span><a name="line.1283"></a> +<span class="sourceLineNo">1284</span> /**<a name="line.1284"></a> +<span class="sourceLineNo">1285</span> * @return Subset of the histograms' calculation.<a name="line.1285"></a> +<span class="sourceLineNo">1286</span> */<a name="line.1286"></a> +<span class="sourceLineNo">1287</span> public String getShortLatencyReport() {<a name="line.1287"></a> +<span class="sourceLineNo">1288</span> return YammerHistogramUtils.getShortHistogramReport(this.latencyHistogram);<a name="line.1288"></a> +<span class="sourceLineNo">1289</span> }<a name="line.1289"></a> <span class="sourceLineNo">1290</span><a name="line.1290"></a> -<span class="sourceLineNo">1291</span> TableTest(Connection con, TestOptions options, Status status) {<a name="line.1291"></a> -<span class="sourceLineNo">1292</span> super(con, options, status);<a name="line.1292"></a> -<span class="sourceLineNo">1293</span> }<a name="line.1293"></a> -<span class="sourceLineNo">1294</span><a name="line.1294"></a> -<span class="sourceLineNo">1295</span> @Override<a name="line.1295"></a> -<span class="sourceLineNo">1296</span> void onStartup() throws IOException {<a name="line.1296"></a> -<span class="sourceLineNo">1297</span> this.table = connection.getTable(TableName.valueOf(opts.tableName));<a name="line.1297"></a> -<span class="sourceLineNo">1298</span> }<a name="line.1298"></a> -<span class="sourceLineNo">1299</span><a name="line.1299"></a> -<span class="sourceLineNo">1300</span> @Override<a name="line.1300"></a> -<span class="sourceLineNo">1301</span> void onTakedown() throws IOException {<a name="line.1301"></a> -<span class="sourceLineNo">1302</span> table.close();<a name="line.1302"></a> -<span class="sourceLineNo">1303</span> }<a name="line.1303"></a> -<span class="sourceLineNo">1304</span> }<a name="line.1304"></a> -<span class="sourceLineNo">1305</span><a name="line.1305"></a> -<span class="sourceLineNo">1306</span> static abstract class AsyncTableTest extends AsyncTest {<a name="line.1306"></a> -<span class="sourceLineNo">1307</span> protected AsyncTable<?> table;<a name="line.1307"></a> -<span class="sourceLineNo">1308</span><a name="line.1308"></a> -<span class="sourceLineNo">1309</span> AsyncTableTest(AsyncConnection con, TestOptions options, Status status) {<a name="line.1309"></a> -<span class="sourceLineNo">1310</span> super(con, options, status);<a name="line.1310"></a> +<span class="sourceLineNo">1291</span> /**<a name="line.1291"></a> +<span class="sourceLineNo">1292</span> * @return Subset of the histograms' calculation.<a name="line.1292"></a> +<span class="sourceLineNo">1293</span> */<a name="line.1293"></a> +<span class="sourceLineNo">1294</span> public String getShortValueSizeReport() {<a name="line.1294"></a> +<span class="sourceLineNo">1295</span> return YammerHistogramUtils.getShortHistogramReport(this.valueSizeHistogram);<a name="line.1295"></a> +<span class="sourceLineNo">1296</span> }<a name="line.1296"></a> +<span class="sourceLineNo">1297</span><a name="line.1297"></a> +<span class="sourceLineNo">1298</span> /*<a name="line.1298"></a> +<span class="sourceLineNo">1299</span> * Test for individual row.<a name="line.1299"></a> +<span class="sourceLineNo">1300</span> * @param i Row index.<a name="line.1300"></a> +<span class="sourceLineNo">1301</span> */<a name="line.1301"></a> +<span class="sourceLineNo">1302</span> abstract void testRow(final int i) throws IOException, InterruptedException;<a name="line.1302"></a> +<span class="sourceLineNo">1303</span> }<a name="line.1303"></a> +<span class="sourceLineNo">1304</span><a name="line.1304"></a> +<span class="sourceLineNo">1305</span> static abstract class Test extends TestBase {<a name="line.1305"></a> +<span class="sourceLineNo">1306</span> protected Connection connection;<a name="line.1306"></a> +<span class="sourceLineNo">1307</span><a name="line.1307"></a> +<span class="sourceLineNo">1308</span> Test(final Connection con, final TestOptions options, final Status status) {<a name="line.1308"></a> +<span class="sourceLineNo">1309</span> super(con == null ? HBaseConfiguration.create() : con.getConfiguration(), options, status);<a name="line.1309"></a> +<span class="sourceLineNo">1310</span> this.connection = con;<a name="line.1310"></a> <span class="sourceLineNo">1311</span> }<a name="line.1311"></a> <span class="sourceLineNo">1312</span><a name="line.1312"></a> <span class="sourceLineNo">1313</span> @Override<a name="line.1313"></a> -<span class="sourceLineNo">1314</span> void onStartup() throws IOException {<a name="line.1314"></a> -<span class="sourceLineNo">1315</span> this.table = connection.getTable(TableName.valueOf(opts.tableName));<a name="line.1315"></a> -<span class="sourceLineNo">1316</span> }<a name="line.1316"></a> -<span class="sourceLineNo">1317</span><a name="line.1317"></a> -<span class="sourceLineNo">1318</span> @Override<a name="line.1318"></a> -<span class="sourceLineNo">1319</span> void onTakedown() throws IOException {<a name="line.1319"></a> -<span class="sourceLineNo">1320</span> }<a name="line.1320"></a> -<span class="sourceLineNo">1321</span> }<a name="line.1321"></a> -<span class="sourceLineNo">1322</span><a name="line.1322"></a> -<span class="sourceLineNo">1323</span> static class AsyncRandomReadTest extends AsyncTableTest {<a name="line.1323"></a> -<span class="sourceLineNo">1324</span> private final Consistency consistency;<a name="line.1324"></a> -<span class="sourceLineNo">1325</span> private ArrayList<Get> gets;<a name="line.1325"></a> -<span class="sourceLineNo">1326</span> private Random rd = new Random();<a name="line.1326"></a> +<span class="sourceLineNo">1314</span> void createConnection() throws IOException {<a name="line.1314"></a> +<span class="sourceLineNo">1315</span> if (!opts.isOneCon()) {<a name="line.1315"></a> +<span class="sourceLineNo">1316</span> this.connection = ConnectionFactory.createConnection(conf);<a name="line.1316"></a> +<span class="sourceLineNo">1317</span> }<a name="line.1317"></a> +<span class="sourceLineNo">1318</span> }<a name="line.1318"></a> +<span class="sourceLineNo">1319</span><a name="line.1319"></a> +<span class="sourceLineNo">1320</span> @Override<a name="line.1320"></a> +<span class="sourceLineNo">1321</span> void closeConnection() throws IOException {<a name="line.1321"></a> +<span class="sourceLineNo">1322</span> if (!opts.isOneCon()) {<a name="line.1322"></a> +<span class="sourceLineNo">1323</span> this.connection.close();<a name="line.1323"></a> +<span class="sourceLineNo">1324</span> }<a name="line.1324"></a> +<span class="sourceLineNo">1325</span> }<a name="line.1325"></a> +<span class="sourceLineNo">1326</span> }<a name="line.1326"></a> <span class="sourceLineNo">1327</span><a name="line.1327"></a> -<span class="sourceLineNo">1328</span> AsyncRandomReadTest(AsyncConnection con, TestOptions options, Status status) {<a name="line.1328"></a> -<span class="sourceLineNo">1329</span> super(con, options, status);<a name="line.1329"></a> -<span class="sourceLineNo">1330</span> consistency = options.replicas == DEFAULT_OPTS.replicas ? null : Consistency.TIMELINE;<a name="line.1330"></a> -<span class="sourceLineNo">1331</span> if (opts.multiGet > 0) {<a name="line.1331"></a> -<span class="sourceLineNo">1332</span> LOG.info("MultiGet enabled. Sending GETs in batches of " + opts.multiGet + ".");<a name="line.1332"></a> -<span class="sourceLineNo">1333</span> this.gets = new ArrayList<>(opts.multiGet);<a name="line.1333"></a> -<span class="sourceLineNo">1334</span> }<a name="line.1334"></a> -<span class="sourceLineNo">1335</span> }<a name="line.1335"></a> -<span class="sourceLineNo">1336</span><a name="line.1336"></a> -<span class="sourceLineNo">1337</span> @Override<a name="line.1337"></a> -<span class="sourceLineNo">1338</span> void testRow(final int i) throws IOException, InterruptedException {<a name="line.1338"></a> -<span class="sourceLineNo">1339</span> if (opts.randomSleep > 0) {<a name="line.1339"></a> -<span class="sourceLineNo">1340</span> Thread.sleep(rd.nextInt(opts.randomSleep));<a name="line.1340"></a> -<span class="sourceLineNo">1341</span> }<a name="line.1341"></a> -<span class="sourceLineNo">1342</span> Get get = new Get(getRandomRow(this.rand, opts.totalRows));<a name="line.1342"></a> -<span class="sourceLineNo">1343</span> if (opts.addColumns) {<a name="line.1343"></a> -<span class="sourceLineNo">1344</span> get.addColumn(FAMILY_NAME, QUALIFIER_NAME);<a name="line.1344"></a> -<span class="sourceLineNo">1345</span> } else {<a name="line.1345"></a> -<span class="sourceLineNo">1346</span> get.addFamily(FAMILY_NAME);<a name="line.1346"></a> -<span class="sourceLineNo">1347</span> }<a name="line.1347"></a> -<span class="sourceLineNo">1348</span> if (opts.filterAll) {<a name="line.1348"></a> -<span class="sourceLineNo">1349</span> get.setFilter(new FilterAllFilter());<a name="line.1349"></a> -<span class="sourceLineNo">1350</span> }<a name="line.1350"></a> -<span class="sourceLineNo">1351</span> get.setConsistency(consistency);<a name="line.1351"></a> -<span class="sourceLineNo">1352</span> if (LOG.isTraceEnabled()) LOG.trace(get.toString());<a name="line.1352"></a> -<span class="sourceLineNo">1353</span> try {<a name="line.1353"></a> -<span class="sourceLineNo">1354</span> if (opts.multiGet > 0) {<a name="line.1354"></a> -<span class="sourceLineNo">1355</span> this.gets.add(get);<a name="line.1355"></a> -<span class="sourceLineNo">1356</span> if (this.gets.size() == opts.multiGet) {<a name="line.1356"></a> -<span class="sourceLineNo">1357</span> Result[] rs =<a name="line.1357"></a> -<span class="sourceLineNo">1358</span> this.table.get(this.gets).stream().map(f -> propagate(f::get)).toArray(Result[]::new);<a name="line.1358"></a> -<span class="sourceLineNo">1359</span> updateValueSize(rs);<a name="line.1359"></a> -<span class="sourceLineNo">1360</span> this.gets.clear();<a name="line.1360"></a> -<span class="sourceLineNo">1361</span> }<a name="line.1361"></a> -<span class="sourceLineNo">1362</span> } else {<a name="line.1362"></a> -<span class="sourceLineNo">1363</span> updateValueSize(this.table.get(get).get());<a name="line.1363"></a> -<span class="sourceLineNo">1364</span> }<a name="line.1364"></a> -<span class="sourceLineNo">1365</span> } catch (ExecutionException e) {<a name="line.1365"></a> -<span class="sourceLineNo">1366</span> throw new IOException(e);<a name="line.1366"></a> -<span class="sourceLineNo">1367</span> }<a name="line.1367"></a> -<span class="sourceLineNo">1368</span> }<a name="line.1368"></a> -<span class="sourceLineNo">1369</span><a name="line.1369"></a> -<span class="sourceLineNo">1370</span> public static RuntimeException runtime(Throwable e) {<a name="line.1370"></a> -<span class="sourceLineNo">1371</span> if (e instanceof RuntimeException) {<a name="line.1371"></a> -<span class="sourceLineNo">1372</span> return (RuntimeException) e;<a name="line.1372"></a> -<span class="sourceLineNo">1373</span> }<a name="line.1373"></a> -<span class="sourceLineNo">1374</span> return new RuntimeException(e);<a name="line.1374"></a> -<span class="sourceLineNo">1375</span> }<a name="line.1375"></a> -<span class="sourceLineNo">1376</span><a name="line.1376"></a> -<span class="sourceLineNo">1377</span> public static <V> V propagate(Callable<V> callable) {<a name="line.1377"></a> -<span class="sourceLineNo">1378</span> try {<a name="line.1378"></a> -<span class="sourceLineNo">1379</span> return callable.call();<a name="line.1379"></a> -<span class="sourceLineNo">1380</span> } catch (Exception e) {<a name="line.1380"></a> -<span class="sourceLineNo">1381</span> throw runtime(e);<a name="line.1381"></a> -<span class="sourceLineNo">1382</span> }<a name="line.1382"></a> +<span class="sourceLineNo">1328</span> static abstract class AsyncTest extends TestBase {<a name="line.1328"></a> +<span class="sourceLineNo">1329</span> protected AsyncConnection connection;<a name="line.1329"></a> +<span class="sourceLineNo">1330</span><a name="line.1330"></a> +<span class="sourceLineNo">1331</span> AsyncTest(final AsyncConnection con, final TestOptions options, final Status status) {<a name="line.1331"></a> +<span class="sourceLineNo">1332</span> super(con == null ? HBaseConfiguration.create() : con.getConfiguration(), options, status);<a name="line.1332"></a> +<span class="sourceLineNo">1333</span> this.connection = con;<a name="line.1333"></a> +<span class="sourceLineNo">1334</span> }<a name="line.1334"></a> +<span class="sourceLineNo">1335</span><a name="line.1335"></a> +<span class="sourceLineNo">1336</span> @Override<a name="line.1336"></a> +<span class="sourceLineNo">1337</span> void createConnection() {<a name="line.1337"></a> +<span class="sourceLineNo">1338</span> if (!opts.isOneCon()) {<a name="line.1338"></a> +<span class="sourceLineNo">1339</span> try {<a name="line.1339"></a> +<span class="sourceLineNo">1340</span> this.connection = ConnectionFactory.createAsyncConnection(conf).get();<a name="line.1340"></a> +<span class="sourceLineNo">1341</span> } catch (InterruptedException | ExecutionException e) {<a name="line.1341"></a> +<span class="sourceLineNo">1342</span> LOG.error("Failed to create async connection", e);<a name="line.1342"></a> +<span class="sourceLineNo">1343</span> }<a name="line.1343"></a> +<span class="sourceLineNo">1344</span> }<a name="line.1344"></a> +<span class="sourceLineNo">1345</span> }<a name="line.1345"></a> +<span class="sourceLineNo">1346</span><a name="line.1346"></a> +<span class="sourceLineNo">1347</span> @Override<a name="line.1347"></a> +<span class="sourceLineNo">1348</span> void closeConnection() throws IOException {<a name="line.1348"></a> +<span class="sourceLineNo">1349</span> if (!opts.isOneCon()) {<a name="line.1349"></a> +<span class="sourceLineNo">1350</span> this.connection.close();<a name="line.1350"></a> +<span class="sourceLineNo">1351</span> }<a name="line.1351"></a> +<span class="sourceLineNo">1352</span> }<a name="line.1352"></a> +<span class="sourceLineNo">1353</span> }<a name="line.1353"></a> +<span class="sourceLineNo">1354</span><a name="line.1354"></a> +<span class="sourceLineNo">1355</span> static abstract class TableTest extends Test {<a name="line.1355"></a> +<span class="sourceLineNo">1356</span> protected Table table;<a name="line.1356"></a> +<span class="sourceLineNo">1357</span><a name="line.1357"></a> +<span class="sourceLineNo">1358</span> TableTest(Connection con, TestOptions options, Status status) {<a name="line.1358"></a> +<span class="sourceLineNo">1359</span> super(con, options, status);<a name="line.1359"></a> +<span class="sourceLineNo">1360</span> }<a name="line.1360"></a> +<span class="sourceLineNo">1361</span><a name="line.1361"></a> +<span class="sourceLineNo">1362</span> @Override<a name="line.1362"></a> +<span class="sourceLineNo">1363</span> void onStartup() throws IOException {<a name="line.1363"></a> +<span class="sourceLineNo">1364</span> this.table = connection.getTable(TableName.valueOf(opts.tableName));<a name="line.1364"></a> +<span class="sourceLineNo">1365</span> }<a name="line.1365"></a> +<span class="sourceLineNo">1366</span><a name="line.1366"></a> +<span class="sourceLineNo">1367</span> @Override<a name="line.1367"></a> +<span class="sourceLineNo">1368</span> void onTakedown() throws IOException {<a name="line.1368"></a> +<span class="sourceLineNo">1369</span> table.close();<a name="line.1369"></a> +<span class="sourceLineNo">1370</span> }<a name="line.1370"></a> +<span class="sourceLineNo">1371</span> }<a name="line.1371"></a> +<span class="sourceLineNo">1372</span><a name="line.1372"></a> +<span class="sourceLineNo">1373</span> static abstract class AsyncTableTest extends AsyncTest {<a name="line.1373"></a> +<span class="sourceLineNo">1374</span> protected AsyncTable<?> table;<a name="line.1374"></a> +<span class="sourceLineNo">1375</span><a name="line.1375"></a> +<span class="sourceLineNo">1376</span> AsyncTableTest(AsyncConnection con, TestOptions options, Status status) {<a name="line.1376"></a> +<span class="sourceLineNo">1377</span> super(con, options, status);<a name="line.1377"></a> +<span class="sourceLineNo">1378</span> }<a name="line.1378"></a> +<span class="sourceLineNo">1379</span><a name="line.1379"></a> +<span class="sourceLineNo">1380</span> @Override<a name="line.1380"></a> +<span class="sourceLineNo">1381</span> void onStartup() throws IOException {<a name="line.1381"></a> +<span class="sourceLineNo">1382</span> this.table = connection.getTable(TableName.valueOf(opts.tableName));<a name="line.1382"></a> <span class="sourceLineNo">1383</span> }<a name="line.1383"></a> <span class="sourceLineNo">1384</span><a name="line.1384"></a> <span class="sourceLineNo">1385</span> @Override<a name="line.1385"></a> -<span class="sourceLineNo">1386</span> protected int getReportingPeriod() {<a name="line.1386"></a> -<span class="sourceLineNo">1387</span> int period = opts.perClientRunRows / 10;<a name="line.1387"></a> -<span class="sourceLineNo">1388</span> return period == 0 ? opts.perClientRunRows : period;<a name="line.1388"></a> -<span class="sourceLineNo">1389</span> }<a name="line.1389"></a> -<span class="sourceLineNo">1390</span><a name="line.1390"></a> -<span class="sourceLineNo">1391</span> @Override<a name="line.1391"></a> -<span class="sourceLineNo">1392</span> protected void testTakedown() throws IOException {<a name="line.1392"></a> -<span class="sourceLineNo">1393</span> if (this.gets != null && this.gets.size() > 0) {<a name="line.1393"></a> -<span class="sourceLineNo">1394</span> this.table.get(gets);<a name="line.1394"></a> -<span class="sourceLineNo">1395</span> this.gets.clear();<a name="line.1395"></a> -<span class="sourceLineNo">1396</span> }<a name="line.1396"></a> -<span class="sourceLineNo">1397</span> super.testTakedown();<a name="line.1397"></a> -<span class="sourceLineNo">1398</span> }<a name="line.1398"></a> -<span class="sourceLineNo">1399</span> }<a name="line.1399"></a> -<span class="sourceLineNo">1400</span><a name="line.1400"></a> -<span class="sourceLineNo">1401</span> static class AsyncRandomWriteTest extends AsyncTableTest {<a name="line.1401"></a> -<span class="sourceLineNo">1402</span> AsyncRandomWriteTest(AsyncConnection con, TestOptions options, Status status) {<a name="line.1402"></a> -<span class="sourceLineNo">1403</span> super(con, options, status);<a name="line.1403"></a> -<span class="sourceLineNo">1404</span> }<a name="line.1404"></a> -<span class="sourceLineNo">1405</span><a name="line.1405"></a> -<span class="sourceLineNo">1406</span> @Override<a name="line.1406"></a> -<span class="sourceLineNo">1407</span> void testRow(final int i) throws IOException, InterruptedException {<a name="line.1407"></a> -<span class="sourceLineNo">1408</span> byte[] row = getRandomRow(this.rand, opts.totalRows);<a name="line.1408"></a> -<span class="sourceLineNo">1409</span> Put put = new Put(row);<a name="line.1409"></a> -<span class="sourceLineNo">1410</span> for (int column = 0; column < opts.columns; column++) {<a name="line.1410"></a> -<span class="sourceLineNo">1411</span> byte[] qualifier = column == 0 ? COLUMN_ZERO : Bytes.toBytes("" + column);<a name="line.1411"></a> -<span class="sourceLineNo">1412</span> byte[] value = generateData(this.rand, getValueLength(this.rand));<a name="line.1412"></a> -<span class="sourceLineNo">1413</span> if (opts.useTags) {<a name="line.1413"></a> -<span class="sourceLineNo">1414</span> byte[] tag = generateData(this.rand, TAG_LENGTH);<a name="line.1414"></a> -<span class="sourceLineNo">1415</span> Tag[] tags = new Tag[opts.noOfTags];<a name="line.1415"></a> -<span class="sourceLineNo">1416</span> for (int n = 0; n < opts.noOfTags; n++) {<a name="line.1416"></a> -<span class="sourceLineNo">1417</span> Tag t = new ArrayBackedTag((byte) n, tag);<a name="line.1417"></a> -<span class="sourceLineNo">1418</span> tags[n] = t;<a name="line.1418"></a> -<span class="sourceLineNo">1419</span> }<a name="line.1419"></a> -<span class="sourceLineNo">1420</span> KeyValue kv =<a name="line.1420"></a> -<span class="sourceLineNo">1421</span> new KeyValue(row, FAMILY_NAME, qualifier, HConstants.LATEST_TIMESTAMP, value, tags);<a name="line.1421"></a> -<span class="sourceLineNo">1422</span> put.add(kv);<a name="line.1422"></a> -<span class="sourceLineNo">1423</span> updateValueSize(kv.getValueLength());<a name="line.1423"></a> -<span class="sourceLineNo">1424</span> } else {<a name="line.1424"></a> -<span class="sourceLineNo">1425</span> put.addColumn(FAMILY_NAME, qualifier, value);<a name="line.1425"></a> -<span class="sourceLineNo">1426</span> updateValueSize(value.length);<a name="line.1426"></a> -<span class="sourceLineNo">1427</span> }<a name="line.1427"></a> -<span class="sourceLineNo">1428</span> }<a name="line.1428"></a> -<span class="sourceLineNo">1429</span> put.setDurability(opts.writeToWAL ? Durability.SYNC_WAL : Durability.SKIP_WAL);<a name="line.1429"></a> -<span class="sourceLineNo">1430</span> try {<a name="line.1430"></a> -<span class="sourceLineNo">1431</span> table.put(put).get();<a name="line.1431"></a> -<span class="sourceLineNo">1432</span> } catch (ExecutionException e) {<a name="line.1432"></a> -<span class="sourceLineNo">1433</span> throw new IOException(e);<a name="line.1433"></a> -<span class="sourceLineNo">1434</span> }<a name="line.1434"></a> -<span class="sourceLineNo">1435</span> }<a name="line.1435"></a> -<span class="sourceLineNo">1436</span> }<a name="line.1436"></a> -<span class="sourceLineNo">1437</span><a name="line.1437"></a> -<span class="sourceLineNo">1438</span> static class AsyncScanTest extends AsyncTableTest {<a name="line.1438"></a> -<span class="sourceLineNo">1439</span> private ResultScanner testScanner;<a name="line.1439"></a> -<span class="sourceLineNo">1440</span> private AsyncTable<?> asyncTable;<a name="line.1440"></a> -<span class="sourceLineNo">1441</span><a name="line.1441"></a> -<span class="sourceLineNo">1442</span> AsyncScanTest(AsyncConnection con, TestOptions options, Status status) {<a name="line.1442"></a> -<span class="sourceLineNo">1443</span> super(con, options, status);<a name="line.1443"></a> -<span class="sourceLineNo">1444</span> }<a name="line.1444"></a> -<span class="sourceLineNo">1445</span><a name="line.1445"></a> -<span class="sourceLineNo">1446</span> @Override<a name="line.1446"></a> -<span class="sourceLineNo">1447</span> void onStartup() throws IOException {<a name="line.1447"></a> -<span class="sourceLineNo">1448</span> this.asyncTable =<a name="line.1448"></a> -<span class="sourceLineNo">1449</span> connection.getTable(TableName.valueOf(opts.tableName),<a name="line.1449"></a> -<span class="sourceLineNo">1450</span> Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()));<a name="line.1450"></a> -<span class="sourceLineNo">1451</span> }<a name="line.1451"></a> -<span class="sourceLineNo">1452</span><a name="line.1452"></a> -<span class="sourceLineNo">1453</span> @Override<a name="line.1453"></a> -<span class="sourceLineNo">1454</span> void testTakedown() throws IOException {<a name="
<TRUNCATED>